monolish  0.14.0
MONOlithic LIner equation Solvers for Highly-parallel architecture
IO_view1D.cpp
Go to the documentation of this file.
1 #include "../../../include/monolish_blas.hpp"
2 #include "../../../include/monolish_vml.hpp"
3 #include "../../internal/monolish_internal.hpp"
4 
5 #include <fstream>
6 #include <iomanip>
7 #include <limits>
8 #include <sstream>
9 #include <stdexcept>
10 #include <string>
11 
12 namespace monolish {
13 
14 template <>
15 void view1D<monolish::vector<double>, double>::print_all(bool force_cpu) const {
16  Logger &logger = Logger::get_instance();
17  logger.util_in(monolish_func);
18 
19  double *val = target.data();
20  if (get_device_mem_stat() == true && force_cpu == false) {
21 #if MONOLISH_USE_GPU
22 #pragma omp target
23  for (size_t i = first; i < last; i++) {
24  printf("%f\n", val[i]);
25  }
26 #else
27  throw std::runtime_error(
28  "error USE_GPU is false, but get_device_mem_stat() == true");
29 #endif
30  } else {
31  for (size_t i = first; i < last; i++) {
32  printf("%f\n", val[i]);
33  }
34  }
35  logger.util_out();
36 }
37 
38 template <>
39 void view1D<monolish::matrix::Dense<double>, double>::print_all(
40  bool force_cpu) const {
41  Logger &logger = Logger::get_instance();
42  logger.util_in(monolish_func);
43 
44  double *val = target.val.data();
45  if (get_device_mem_stat() == true && force_cpu == false) {
46 #if MONOLISH_USE_GPU
47 #pragma omp target
48  for (size_t i = first; i < last; i++) {
49  printf("%f\n", val[i]);
50  }
51 #else
52  throw std::runtime_error(
53  "error USE_GPU is false, but get_device_mem_stat() == true");
54 #endif
55  } else {
56  for (size_t i = first; i < last; i++) {
57  printf("%f\n", val[i]);
58  }
59  }
60  logger.util_out();
61 }
62 
63 template <>
64 void view1D<monolish::vector<float>, float>::print_all(bool force_cpu) const {
65  Logger &logger = Logger::get_instance();
66  logger.util_in(monolish_func);
67 
68  float *val = target.data();
69  if (get_device_mem_stat() == true && force_cpu == false) {
70 #if MONOLISH_USE_GPU
71 #pragma omp target
72  for (size_t i = first; i < last; i++) {
73  printf("%f\n", val[i]);
74  }
75 #else
76  throw std::runtime_error(
77  "error USE_GPU is false, but get_device_mem_stat() == true");
78 #endif
79  } else {
80  for (size_t i = first; i < last; i++) {
81  printf("%f\n", val[i]);
82  }
83  }
84  logger.util_out();
85 }
86 
87 template <>
88 void view1D<monolish::matrix::Dense<float>, float>::print_all(
89  bool force_cpu) const {
90  Logger &logger = Logger::get_instance();
91  logger.util_in(monolish_func);
92 
93  float *val = target.val.data();
94  if (get_device_mem_stat() == true && force_cpu == false) {
95 #if MONOLISH_USE_GPU
96 #pragma omp target
97  for (size_t i = first; i < last; i++) {
98  printf("%f\n", val[i]);
99  }
100 #else
101  throw std::runtime_error(
102  "error USE_GPU is false, but get_device_mem_stat() == true");
103 #endif
104  } else {
105  for (size_t i = first; i < last; i++) {
106  printf("%f\n", val[i]);
107  }
108  }
109  logger.util_out();
110 }
111 
112 } // 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::view1D
1D view class
Definition: monolish_coo.hpp:26
monolish::Logger::get_instance
static Logger & get_instance()
Definition: monolish_logger.hpp:42