| 1095 | } |
| 1096 | |
| 1097 | inline void allocate(const int gpu_id, const int size, const int nnz) { |
| 1098 | if (this->vals == nullptr) { |
| 1099 | this->gpu_id = gpu_id; |
| 1100 | this->size = size; |
| 1101 | this->nnz = nnz; |
| 1102 | CHECK_CUDA( cudaSetDevice(this->gpu_id) ); |
| 1103 | CHECK_CUDA( cudaMalloc((void**) &this->indices, sizeof(int) * this->nnz) ); |
| 1104 | CHECK_CUDA( cudaMalloc((void**) &this->vals, sizeof(double) * this->nnz) ); |
| 1105 | CHECK_CUSPARSE( cusparseCreateSpVec( |
| 1106 | &this->cusparse_descr, this->size, this->nnz, |
| 1107 | this->indices, this->vals, |
| 1108 | CUSPARSE_INDEX_32I, CUSPARSE_INDEX_BASE_ZERO, CUDA_R_64F |
| 1109 | ) ); |
| 1110 | } |
| 1111 | return; |
| 1112 | } |
| 1113 | |
| 1114 | inline double get_norm(const DeviceBlasHandle& cublas_H) { |
| 1115 | double norm; |