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

Class DeviceSolverDnHandle

XM/include/Utils/memory.h:84–116  ·  view source on GitHub ↗

cusolver (dense) handle wrapper

Source from the content-addressed store, hash-verified

82
83// cusolver (dense) handle wrapper
84class DeviceSolverDnHandle {
85 public:
86 size_s gpu_id;
87 cusolverDnHandle_t cusolver_dn_handle;
88
89 DeviceSolverDnHandle(): gpu_id(0), cusolver_dn_handle(NULL) {}
90 DeviceSolverDnHandle(const size_s gpu_id): gpu_id(gpu_id), cusolver_dn_handle(NULL) {}
91
92 inline void set_gpu_id(const size_s gpu_id) {
93 this->gpu_id = gpu_id;
94 return;
95 }
96 inline void activate() {
97 CHECK_CUDA( cudaSetDevice(this->gpu_id) );
98 CHECK_CUSOLVER( cusolverDnCreate(&this->cusolver_dn_handle) );
99 return;
100 }
101 inline void activate(const DeviceStream& device_stream) {
102 assert(device_stream.gpu_id == this->gpu_id);
103 CHECK_CUDA( cudaSetDevice(this->gpu_id) );
104 CHECK_CUSOLVER( cusolverDnCreate(&this->cusolver_dn_handle) );
105 CHECK_CUSOLVER( cusolverDnSetStream(this->cusolver_dn_handle, device_stream.stream) );
106 return;
107 }
108
109 ~DeviceSolverDnHandle() {
110 if (this->cusolver_dn_handle != NULL) {
111 CHECK_CUSOLVER( cusolverDnDestroy(this->cusolver_dn_handle) );
112 this->cusolver_dn_handle = NULL;
113 }
114 //std::cout << "DeviceSolverDnHandle destructor called!" << std::endl;
115 }
116};
117
118// cusolver (dense) handle wrapper
119class DeviceSolverSpHandle {

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected