22
22
/* SOFTWARE. */
23
23
/* *********************************************************************************/
24
24
25
- #include < cuda/matrix_csr .hpp>
25
+ #include < cuda/cuda_matrix .hpp>
26
26
#include < core/error.hpp>
27
27
#include < utils/timer.hpp>
28
28
#include < algorithm>
29
29
30
30
namespace cubool {
31
31
32
- MatrixCsr::MatrixCsr (size_t nrows, size_t ncols, Instance &instance) : mInstance (instance) {
32
+ CudaMatrix::CudaMatrix (size_t nrows, size_t ncols, CudaInstance &instance) : mInstance (instance) {
33
33
mNrows = nrows;
34
34
mNcols = ncols;
35
35
}
36
36
37
- void MatrixCsr ::setElement (index i, index j) {
37
+ void CudaMatrix ::setElement (index i, index j) {
38
38
RAISE_ERROR (NotImplemented, " This function is not supported for this matrix class" );
39
39
}
40
40
41
- void MatrixCsr ::clone (const MatrixBase &otherBase) {
42
- auto other = dynamic_cast <const MatrixCsr *>(&otherBase);
41
+ void CudaMatrix ::clone (const MatrixBase &otherBase) {
42
+ auto other = dynamic_cast <const CudaMatrix *>(&otherBase);
43
43
44
44
CHECK_RAISE_ERROR (other != nullptr , InvalidArgument, " Passed matrix does not belong to csr matrix class" );
45
45
CHECK_RAISE_ERROR (other != this , InvalidArgument, " Matrices must differ" );
@@ -58,14 +58,14 @@ namespace cubool {
58
58
this ->mMatrixImpl = other->mMatrixImpl ;
59
59
}
60
60
61
- void MatrixCsr ::resizeStorageToDim () const {
61
+ void CudaMatrix ::resizeStorageToDim () const {
62
62
if (mMatrixImpl .is_zero_dim ()) {
63
63
// If actual storage was not allocated, allocate one for an empty matrix
64
64
mMatrixImpl = std::move (MatrixImplType (mNrows , mNcols ));
65
65
}
66
66
}
67
67
68
- void MatrixCsr ::clearAndResizeStorageToDim () const {
68
+ void CudaMatrix ::clearAndResizeStorageToDim () const {
69
69
if (mMatrixImpl .m_vals > 0 ) {
70
70
// Release only if have some nnz values
71
71
mMatrixImpl .zero_dim ();
@@ -75,27 +75,27 @@ namespace cubool {
75
75
this ->resizeStorageToDim ();
76
76
}
77
77
78
- index MatrixCsr ::getNrows () const {
78
+ index CudaMatrix ::getNrows () const {
79
79
return mNrows ;
80
80
}
81
81
82
- index MatrixCsr ::getNcols () const {
82
+ index CudaMatrix ::getNcols () const {
83
83
return mNcols ;
84
84
}
85
85
86
- index MatrixCsr ::getNvals () const {
86
+ index CudaMatrix ::getNvals () const {
87
87
return mMatrixImpl .m_vals ;
88
88
}
89
89
90
- bool MatrixCsr ::isStorageEmpty () const {
90
+ bool CudaMatrix ::isStorageEmpty () const {
91
91
return mMatrixImpl .is_zero_dim ();
92
92
}
93
93
94
- bool MatrixCsr ::isMatrixEmpty () const {
94
+ bool CudaMatrix ::isMatrixEmpty () const {
95
95
return mMatrixImpl .m_vals == 0 ;
96
96
}
97
97
98
- void MatrixCsr ::transferToDevice (const std::vector<index> &rowOffsets, const std::vector<index> &colIndices) const {
98
+ void CudaMatrix ::transferToDevice (const std::vector<index> &rowOffsets, const std::vector<index> &colIndices) const {
99
99
// Create device buffers and copy data from the cpu side
100
100
thrust::device_vector<index , DeviceAlloc<index >> rowsDeviceVec (rowOffsets.size ());
101
101
thrust::device_vector<index , DeviceAlloc<index >> colsDeviceVec (colIndices.size ());
@@ -107,7 +107,7 @@ namespace cubool {
107
107
mMatrixImpl = std::move (MatrixImplType (std::move (colsDeviceVec), std::move (rowsDeviceVec), getNrows (), getNcols (), colIndices.size ()));
108
108
}
109
109
110
- void MatrixCsr ::transferFromDevice (std::vector<index> &rowOffsets, std::vector<index> &colIndices) const {
110
+ void CudaMatrix ::transferFromDevice (std::vector<index> &rowOffsets, std::vector<index> &colIndices) const {
111
111
rowOffsets.resize (mMatrixImpl .m_row_index .size ());
112
112
colIndices.resize (mMatrixImpl .m_col_index .size ());
113
113
0 commit comments