cusolver (dense) handle wrapper
| 117 | |
| 118 | // cusolver (dense) handle wrapper |
| 119 | class DeviceSolverSpHandle { |
| 120 | public: |
| 121 | size_s gpu_id; |
| 122 | cusolverSpHandle_t cusolver_sp_handle; |
| 123 | |
| 124 | DeviceSolverSpHandle(): gpu_id(0), cusolver_sp_handle(NULL) {} |
| 125 | DeviceSolverSpHandle(const size_s gpu_id): gpu_id(gpu_id), cusolver_sp_handle(NULL) {} |
| 126 | |
| 127 | inline void set_gpu_id(const size_s gpu_id) { |
| 128 | this->gpu_id = gpu_id; |
| 129 | return; |
| 130 | } |
| 131 | inline void activate() { |
| 132 | CHECK_CUDA( cudaSetDevice(this->gpu_id) ); |
| 133 | CHECK_CUSOLVER( cusolverSpCreate(&this->cusolver_sp_handle) ); |
| 134 | return; |
| 135 | } |
| 136 | inline void activate(const DeviceStream& device_stream) { |
| 137 | assert(device_stream.gpu_id == this->gpu_id); |
| 138 | CHECK_CUDA( cudaSetDevice(this->gpu_id) ); |
| 139 | CHECK_CUSOLVER( cusolverSpCreate(&this->cusolver_sp_handle) ); |
| 140 | CHECK_CUSOLVER( cusolverSpSetStream(this->cusolver_sp_handle, device_stream.stream) ); |
| 141 | return; |
| 142 | } |
| 143 | |
| 144 | ~DeviceSolverSpHandle() { |
| 145 | if (this->cusolver_sp_handle != NULL) { |
| 146 | CHECK_CUSOLVER( cusolverSpDestroy(this->cusolver_sp_handle) ); |
| 147 | this->cusolver_sp_handle = NULL; |
| 148 | } |
| 149 | //std::cout << "DeviceSolverSpHandle destructor called!" << std::endl; |
| 150 | } |
| 151 | }; |
| 152 | |
| 153 | // cusparse handle wrapper |
| 154 | class DeviceSparseHandle { |
nothing calls this directly
no outgoing calls
no test coverage detected