MCPcopy Create free account
hub / github.com/ComputationalRobotics/XM-code / DeviceSparseHandle

Class DeviceSparseHandle

XM/include/Utils/memory.h:154–186  ·  view source on GitHub ↗

cusparse handle wrapper

Source from the content-addressed store, hash-verified

152
153// cusparse handle wrapper
154class DeviceSparseHandle {
155 public:
156 size_s gpu_id;
157 cusparseHandle_t cusparse_handle;
158
159 DeviceSparseHandle(): gpu_id(0), cusparse_handle(NULL) {}
160 DeviceSparseHandle(const size_s gpu_id): gpu_id(gpu_id), cusparse_handle(NULL) {}
161
162 inline void set_gpu_id(const size_s gpu_id) {
163 this->gpu_id = gpu_id;
164 return;
165 }
166 inline void activate() {
167 CHECK_CUDA( cudaSetDevice(this->gpu_id) );
168 CHECK_CUSPARSE( cusparseCreate(&this->cusparse_handle) );
169 return;
170 }
171 inline void activate(const DeviceStream& device_stream) {
172 assert(device_stream.gpu_id == this->gpu_id);
173 CHECK_CUDA( cudaSetDevice(this->gpu_id) );
174 CHECK_CUSPARSE( cusparseCreate(&this->cusparse_handle) );
175 CHECK_CUSPARSE( cusparseSetStream(this->cusparse_handle, device_stream.stream) );
176 return;
177 }
178
179 ~DeviceSparseHandle() {
180 if (this->cusparse_handle != NULL) {
181 CHECK_CUSPARSE( cusparseDestroy(this->cusparse_handle) );
182 this->cusparse_handle = NULL;
183 }
184 // std::cout << "DeviceSparseHandle destructor called!" << std::endl;
185 }
186};
187
188template <typename T>
189class HostDnTen {

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected