dense vector wrapper on device: long int type
| 1046 | |
| 1047 | // dense vector wrapper on device: long int type |
| 1048 | class DeviceDnVecLongInt { |
| 1049 | public: |
| 1050 | int gpu_id; |
| 1051 | int size; |
| 1052 | size_t* vals; |
| 1053 | |
| 1054 | DeviceDnVecLongInt(): gpu_id(0), size(0), vals(nullptr) {} |
| 1055 | DeviceDnVecLongInt(const int gpu_id, const int size): gpu_id(gpu_id), size(size), vals(nullptr) { |
| 1056 | this->allocate(this->gpu_id, this->size); |
| 1057 | } |
| 1058 | |
| 1059 | inline void allocate(const int gpu_id, const int size) { |
| 1060 | if (this->vals == nullptr) { |
| 1061 | this->gpu_id = gpu_id; |
| 1062 | this->size = size; |
| 1063 | CHECK_CUDA( cudaSetDevice(this->gpu_id) ); |
| 1064 | CHECK_CUDA( cudaMalloc((void**) &this->vals, sizeof(size_t) * this->size) ); |
| 1065 | } |
| 1066 | return; |
| 1067 | } |
| 1068 | |
| 1069 | ~DeviceDnVecLongInt() { |
| 1070 | CHECK_CUDA( cudaSetDevice(this->gpu_id) ); |
| 1071 | if (this->vals != nullptr) { |
| 1072 | CHECK_CUDA( cudaFree(this->vals) ); |
| 1073 | this->vals = nullptr; |
| 1074 | } |
| 1075 | // std::cout << "DeviceDnVecLongInt destructor called!" << std::endl; |
| 1076 | } |
| 1077 | }; |
| 1078 | |
| 1079 | // sparse vector wrapper on device: double type |
| 1080 | class DeviceSpVecDouble { |
nothing calls this directly
no outgoing calls
no test coverage detected