cuda stream wrapper
| 18 | |
| 19 | // cuda stream wrapper |
| 20 | class 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 |
| 49 | class DeviceBlasHandle { |
nothing calls this directly
no outgoing calls
no test coverage detected