| 1229 | } |
| 1230 | |
| 1231 | inline void allocate(const int gpu_id, const int row_size, const int col_size, const int nnz) { |
| 1232 | if (this->vals == nullptr) { |
| 1233 | this->gpu_id = gpu_id; |
| 1234 | this->row_size = row_size; |
| 1235 | this->col_size = col_size; |
| 1236 | this->nnz = nnz; |
| 1237 | CHECK_CUDA( cudaSetDevice(this->gpu_id) ); |
| 1238 | CHECK_CUDA( cudaSetDevice(this->gpu_id) ); |
| 1239 | CHECK_CUDA( cudaMalloc((void**) &this->row_ptrs, sizeof(int) * (this->row_size + 1)) ); |
| 1240 | if (nnz > 0) { |
| 1241 | CHECK_CUDA( cudaMalloc((void**) &this->col_ids, sizeof(int) * this->nnz) ); |
| 1242 | CHECK_CUDA( cudaMalloc((void**) &this->vals, sizeof(double) * this->nnz) ); |
| 1243 | } else { |
| 1244 | this->col_ids = nullptr; |
| 1245 | this->vals = nullptr; |
| 1246 | } |
| 1247 | CHECK_CUSPARSE( cusparseCreateCsr( |
| 1248 | &this->cusparse_descr, this->row_size, this->col_size, this->nnz, |
| 1249 | this->row_ptrs, this->col_ids, this->vals, |
| 1250 | CUSPARSE_INDEX_32I, CUSPARSE_INDEX_32I, CUSPARSE_INDEX_BASE_ZERO, CUDA_R_64F |
| 1251 | ) ); |
| 1252 | } |
| 1253 | return; |
| 1254 | } |
| 1255 | |
| 1256 | inline double get_norm(const DeviceBlasHandle& cublas_H) { |
| 1257 | double norm; |
no outgoing calls
no test coverage detected