20#ifndef VOTCA_XTP_CUDAMATRIX_H
21#define VOTCA_XTP_CUDAMATRIX_H
28#error Cuda not enabled
54 std::string transpose = M::transposed() ?
"T" :
"";
56 return std::string(transpose +
"(" + std::to_string(mat.rows()) +
"x" +
57 std::to_string(mat.cols()) +
")");
67 assert((rowoffset +
rows) <= mat.rows() &&
68 "block has to fit in matrix, rows exceeded");
69 assert((coloffset +
cols) <= mat.cols() &&
70 "block has to fit in matrix, cols exceeded");
71 start_ = coloffset *
ld() + rowoffset;
79 static constexpr bool transposed() {
return M::transposed(); }
98 static constexpr bool transposed() {
return !M::transposed(); }
114 "reshape cannot change the size of the matrix only the shape");
147 if (m.rows() !=
ld_ || m.cols() !=
cols_) {
148 throw std::runtime_error(
"Shape mismatch of cpu (" +
149 std::to_string(m.rows()) +
"x" +
150 std::to_string(m.cols()) +
") and gpu matrix" +
154 int(m.rows()),
int(m.cols()),
sizeof(
double), m.data(),
155 int(m.colStride()), this->data(),
int(this->rows()),
stream_));
173 operator Eigen::MatrixXd()
const;
189 [](
double *x) {
checkCuda(cudaFree(x)); }};
static constexpr bool transposed()
CudaMatrixBlock(const M &mat, Index rowoffset, Index coloffset, Index rows, Index cols)
CudaMatrixTranspose(const M &mat)
static constexpr bool transposed()
CudaMatrixBlock< CudaMatrix > block(Index rowoffset, Index coloffset, Index rows, Index cols) const
void reshape(Index rows, Index cols)
std::unique_ptr< double, void(*)(double *)> Unique_ptr_to_GPU_data
size_t size_matrix() const
Unique_ptr_to_GPU_data data_
static constexpr bool transposed()
friend std::ostream & operator<<(std::ostream &out, const CudaMatrix &m)
CudaMatrixTranspose< CudaMatrix > transpose() const
void copy_to_gpu(const T &m)
CudaMatrixBlock< CudaMatrix > col(Index col) const
void throw_if_not_enough_memory_in_gpu(size_t requested_memory) const
CudaMatrixBlock< CudaMatrix > row(Index row) const
CudaMatrixBlock< CudaMatrix > middleCols(Index coloffset, Index cols) const
CudaMatrixBlock< CudaMatrix > middleRows(Index rowoffset, Index rows) const
CudaMatrix(const T &matrix, const cudaStream_t &stream)
Unique_ptr_to_GPU_data alloc_matrix_in_gpu(size_t size_arr) const
void checkCublas(cublasStatus_t result)
std::string cudaGetErrorEnum(cublasStatus_t error)
Index count_available_gpus()
std::string OutputDimension(const M &mat)
void checkCuda(cudaError_t result)
base class for all analysis tools