monolish  0.14.0
MONOlithic LIner equation Solvers for Highly-parallel architecture
fill_view1D.cpp
Go to the documentation of this file.
1 #include "../../../include/common/monolish_dense.hpp"
2 #include "../../../include/common/monolish_logger.hpp"
3 #include "../../../include/common/monolish_matrix.hpp"
4 #include "../../../include/monolish_vml.hpp"
5 #include "../../internal/monolish_internal.hpp"
6 
7 namespace monolish {
8 
9 template <typename T, typename U> void view1D<T, U>::fill(U value) {
10  Logger &logger = Logger::get_instance();
11  logger.util_in(monolish_func);
12  U *val = data();
13  if (get_device_mem_stat() == true) {
14 #if MONOLISH_USE_GPU
15 #pragma omp target teams distribute parallel for
16  for (size_t i = first; i < last; i++) {
17  val[i] = value;
18  }
19 #else
20  throw std::runtime_error(
21  "error USE_GPU is false, but get_device_mem_stat() == true");
22 #endif
23  } else {
24 #pragma omp parallel for
25  for (size_t i = first; i < last; i++) {
26  val[i] = value;
27  }
28  }
29  logger.util_out();
30 }
31 template void view1D<vector<double>, double>::fill(double value);
32 template void view1D<matrix::Dense<double>, double>::fill(double value);
33 template void
34 view1D<matrix::LinearOperator<double>, double>::fill(double value);
35 template void view1D<vector<float>, float>::fill(float value);
36 template void view1D<matrix::Dense<float>, float>::fill(float value);
37 template void view1D<matrix::LinearOperator<float>, float>::fill(float value);
38 
39 } // namespace monolish
monolish_func
#define monolish_func
Definition: monolish_logger.hpp:9
monolish::Logger
logger class (singleton, for developper class)
Definition: monolish_logger.hpp:19
monolish::Logger::util_out
void util_out()
Definition: logger_utils.cpp:123
monolish::view1D::fill
void fill(Float value)
fill vector elements with a scalar value
Definition: fill_view1D.cpp:9
monolish::Logger::util_in
void util_in(const std::string func_name)
Definition: logger_utils.cpp:113
monolish
Definition: monolish_matrix_blas.hpp:9
monolish::view1D
1D view class
Definition: monolish_coo.hpp:26
monolish::Logger::get_instance
static Logger & get_instance()
Definition: monolish_logger.hpp:42