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

Class DeviceStream

XM/include/Utils/memory.h:20–46  ·  view source on GitHub ↗

cuda stream wrapper

Source from the content-addressed store, hash-verified

18
19// cuda stream wrapper
20class DeviceStream {
21 public:
22 size_s gpu_id;
23 cudaStream_t stream;
24
25 // Initialize using the index of GPU
26 DeviceStream(): gpu_id(0), stream(NULL) {}
27 DeviceStream(const size_s gpu_id): gpu_id(gpu_id), stream(NULL) {}
28
29 inline void set_gpu_id(const size_s gpu_id) {
30 this->gpu_id = gpu_id;
31 return;
32 }
33 inline void activate() {
34 CHECK_CUDA( cudaSetDevice(this->gpu_id) );
35 CHECK_CUDA( cudaStreamCreateWithFlags(&this->stream, cudaStreamNonBlocking) );
36 }
37
38 ~DeviceStream() {
39 CHECK_CUDA( cudaSetDevice(this->gpu_id) );
40 if (this->stream != NULL) {
41 CHECK_CUDA( cudaStreamDestroy(this->stream) );
42 this->stream = NULL;
43 }
44 // std::cout << "DeviceStream destructor called!" << std::endl;
45 }
46};
47
48// cublas handle wrapper
49class DeviceBlasHandle {

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected