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

Class DeviceSolverSpHandle

XM/include/Utils/memory.h:119–151  ·  view source on GitHub ↗

cusolver (dense) handle wrapper

Source from the content-addressed store, hash-verified

117
118// cusolver (dense) handle wrapper
119class 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
154class DeviceSparseHandle {

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected