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

Class DeviceDnVecLongInt

XM/include/Utils/memory.h:1048–1077  ·  view source on GitHub ↗

dense vector wrapper on device: long int type

Source from the content-addressed store, hash-verified

1046
1047// dense vector wrapper on device: long int type
1048class 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
1080class DeviceSpVecDouble {

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected