monolish  0.14.0
MONOlithic LIner equation Solvers for Highly-parallel architecture
copy_dense.cpp
Go to the documentation of this file.
1 #include "../../../include/common/monolish_common.hpp"
2 #include "../../../include/common/monolish_dense.hpp"
3 #include "../../../include/common/monolish_logger.hpp"
4 #include "../../../include/common/monolish_matrix.hpp"
5 #include "../../internal/monolish_internal.hpp"
6 
7 namespace monolish {
8 namespace matrix {
9 
10 template <typename T> void Dense<T>::operator=(const Dense<T> &mat) {
11  Logger &logger = Logger::get_instance();
12  logger.util_in(monolish_func);
13 
14  // err
15  assert(monolish::util::is_same_size(*this, mat));
16  assert(monolish::util::is_same_device_mem_stat(*this, mat));
17 
18  // gpu copy
19  if (mat.get_device_mem_stat()) {
20  internal::vcopy(get_nnz(), mat.val.data(), val.data(), true);
21  } else {
22  internal::vcopy(get_nnz(), mat.val.data(), val.data(), false);
23  }
24 
25  logger.util_out();
26 }
27 
28 template void Dense<double>::operator=(const Dense<double> &mat);
29 template void Dense<float>::operator=(const Dense<float> &mat);
30 
31 template <typename T>
32 void Dense<T>::set_ptr(const size_t M, const size_t N,
33  const std::vector<T> &value) {
34  Logger &logger = Logger::get_instance();
35  logger.util_in(monolish_func);
36  val = value;
37 
38  rowN = M;
39  colN = N;
40  nnz = M * N;
41  logger.util_out();
42 }
43 template void Dense<double>::set_ptr(const size_t M, const size_t N,
44  const std::vector<double> &value);
45 template void Dense<float>::set_ptr(const size_t M, const size_t N,
46  const std::vector<float> &value);
47 
48 } // namespace matrix
49 } // namespace monolish
monolish::util::is_same_size
bool is_same_size(const T &x, const U &y)
compare size of vector or 1Dview (same as is_same_structure())
Definition: monolish_common.hpp:358
monolish_func
#define monolish_func
Definition: monolish_logger.hpp:9
monolish::Logger
logger class (singleton, for developper class)
Definition: monolish_logger.hpp:19
monolish::matrix::Dense::get_device_mem_stat
bool get_device_mem_stat() const
true: sended, false: not send
Definition: monolish_dense.hpp:377
monolish::matrix::Dense::set_ptr
void set_ptr(const size_t M, const size_t N, const std::vector< Float > &value)
Set Dense array from std::vector.
Definition: copy_dense.cpp:32
monolish::matrix::Dense::val
std::vector< Float > val
Dense format value(size M x N)
Definition: monolish_dense.hpp:47
monolish::matrix::Dense
Dense format Matrix.
Definition: monolish_coo.hpp:28
monolish::util::is_same_device_mem_stat
bool is_same_device_mem_stat(const T &arg1, const U &arg2)
compare same device memory status
Definition: monolish_common.hpp:431
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::operator=
void operator=(const Dense< Float > &mat)
matrix copy
Definition: copy_dense.cpp:10
monolish::Logger::get_instance
static Logger & get_instance()
Definition: monolish_logger.hpp:42