| 361 | } |
| 362 | |
| 363 | inline void allocate() { |
| 364 | |
| 365 | // std::cout << "allocate with size: " << this->total_size<<std::endl; |
| 366 | CHECK_CUDA(cudaSetDevice(this->gpu_id)); |
| 367 | CHECK_CUDA(cudaMalloc((void**)&this->vals, sizeof(T) * total_size)); |
| 368 | CHECK_CUDA(cudaMemset(this->vals, 0, sizeof(T) * total_size)); |
| 369 | if(num_dims == 1){ |
| 370 | CHECK_CUSPARSE(cusparseCreateDnVec(&this->cusparse_descr, total_size, this->vals, CudaTypeMapper<T>::value)); |
| 371 | } |
| 372 | else if(num_dims == 2){ |
| 373 | CHECK_CUSPARSE(cusparseCreateDnMat(&this->cusparse_descr_mat, dimensions[0],dimensions[1],dimensions[0], this->vals, CudaTypeMapper<T>::value, CUSPARSE_ORDER_COL)); |
| 374 | } |
| 375 | |
| 376 | |
| 377 | } |
| 378 | |
| 379 | void setValueAt(size_s index, T value) { |
| 380 | setValueKernel<<<1, 1>>>(vals, index, value); |
no outgoing calls
no test coverage detected