monolish  0.14.2
MONOlithic LIner equation Solvers for Highly-parallel architecture
IO_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 #include <cassert>
7 #include <fstream>
8 #include <iomanip>
9 #include <limits>
10 #include <sstream>
11 #include <stdexcept>
12 #include <string>
13 
14 namespace monolish {
15 namespace matrix {
16 
17 template <typename T> void Dense<T>::print_all(bool force_cpu) const {
18  Logger &logger = Logger::get_instance();
19  logger.util_in(monolish_func);
20 
21  if (get_device_mem_stat() == true && force_cpu == false) {
22 #if MONOLISH_USE_NVIDIA_GPU
23  const T *vald = val.data();
24 #pragma omp target
25  for (size_t i = 0; i < get_row(); i++) {
26  for (size_t j = 0; j < get_col(); j++) {
27  printf("%lu %lu %f\n", i + 1, j + 1, vald[i * get_col() + j]);
28  }
29  }
30 #else
31  throw std::runtime_error(
32  "error USE_GPU is false, but get_device_mem_stat() == true");
33 #endif
34  } else {
35  for (size_t i = 0; i < get_row(); i++) {
36  for (size_t j = 0; j < get_col(); j++) {
37  std::cout << i + 1 << " " << j + 1 << " " << val[i * get_col() + j]
38  << std::endl;
39  }
40  }
41  }
42 
43  logger.util_out();
44 }
45 template void Dense<double>::print_all(bool force_cpu) const;
46 template void Dense<float>::print_all(bool force_cpu) const;
47 
48 } // namespace matrix
49 } // 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:10
monolish::matrix::Dense::print_all
void print_all(bool force_cpu=false) const
print all elements to standard I/O
Definition: IO_dense.cpp:17
monolish::Logger::get_instance
static Logger & get_instance()
Definition: monolish_logger.hpp:42