monolish  0.14.0
MONOlithic LIner equation Solvers for Highly-parallel architecture
fill_vector.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> void vector<T>::fill(T value) {
10  Logger &logger = Logger::get_instance();
11  logger.util_in(monolish_func);
12  if (get_device_mem_stat() == true) {
13 #if MONOLISH_USE_GPU
14  T *vald = val.data();
15  auto N = val.size();
16 #pragma omp target teams distribute parallel for
17  for (size_t i = 0; i < N; i++) {
18  vald[i] = value;
19  }
20 #else
21  throw std::runtime_error(
22  "error USE_GPU is false, but get_device_mem_stat() == true");
23 #endif
24  } else {
25 #pragma omp parallel for
26  for (size_t i = 0; i < val.size(); i++) {
27  val[i] = value;
28  }
29  }
30  logger.util_out();
31 }
32 template void vector<double>::fill(double value);
33 template void vector<float>::fill(float value);
34 
35 } // 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::Logger::util_in
void util_in(const std::string func_name)
Definition: logger_utils.cpp:113
monolish
Definition: monolish_matrix_blas.hpp:9
monolish::vector::fill
void fill(Float value)
fill vector elements with a scalar value
Definition: fill_vector.cpp:9
monolish::Logger::get_instance
static Logger & get_instance()
Definition: monolish_logger.hpp:42