monolish  0.14.0
MONOlithic LIner equation Solvers for Highly-parallel architecture
fill_dense.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 "../../internal/monolish_internal.hpp"
5 
6 namespace monolish {
7 namespace matrix {
8 
9 template <typename T> void Dense<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 #pragma omp target teams distribute parallel for
16  for (size_t i = 0; i < get_nnz(); i++) {
17  vald[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 = 0; i < get_nnz(); i++) {
26  val[i] = value;
27  }
28  }
29  logger.util_out();
30 }
31 template void Dense<double>::fill(double value);
32 template void Dense<float>::fill(float value);
33 
34 } // namespace matrix
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::matrix::Dense::fill
void fill(Float value)
fill matrix elements with a scalar value
Definition: fill_dense.cpp:9
monolish::Logger::get_instance
static Logger & get_instance()
Definition: monolish_logger.hpp:42