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

Class DeviceBlasHandle

XM/include/Utils/memory.h:49–81  ·  view source on GitHub ↗

cublas handle wrapper

Source from the content-addressed store, hash-verified

47
48// cublas handle wrapper
49class DeviceBlasHandle {
50 public:
51 size_s gpu_id;
52 cublasHandle_t cublas_handle;
53
54 DeviceBlasHandle(): gpu_id(0), cublas_handle(NULL) {}
55 DeviceBlasHandle(const size_s gpu_id): gpu_id(gpu_id), cublas_handle(NULL) {}
56
57 inline void set_gpu_id(const size_s gpu_id) {
58 this->gpu_id = gpu_id;
59 return;
60 }
61 inline void activate() {
62 CHECK_CUDA( cudaSetDevice(this->gpu_id) );
63 CHECK_CUBLAS( cublasCreate_v2(&this->cublas_handle) );
64 return;
65 }
66 inline void activate(const DeviceStream& device_stream) {
67 assert(device_stream.gpu_id == this->gpu_id);
68 CHECK_CUDA( cudaSetDevice(this->gpu_id) );
69 CHECK_CUBLAS( cublasCreate_v2(&this->cublas_handle) );
70 CHECK_CUBLAS( cublasSetStream_v2(this->cublas_handle, device_stream.stream) );
71 return;
72 }
73
74 ~DeviceBlasHandle() {
75 if (this->cublas_handle != NULL) {
76 CHECK_CUBLAS( cublasDestroy_v2(this->cublas_handle) );
77 this->cublas_handle = NULL;
78 }
79 // std::cout << "DeviceBlasHandle destructor called!" << std::endl;
80 }
81};
82
83// cusolver (dense) handle wrapper
84class DeviceSolverDnHandle {

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected