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

Method allocate

XM/include/Utils/memory.h:924–939  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

922 }
923
924 inline void allocate(const int gpu_id, const int size, bool as_byte = false) {
925 if (this->vals == nullptr) {
926 this->gpu_id = gpu_id;
927 this->size = size;
928 CHECK_CUDA( cudaSetDevice(this->gpu_id) );
929 // as_byte is used to allocate buffer size, which is usually given in terms of bytes
930 if (as_byte) {
931 this->size = (size + sizeof(double) - 1) / sizeof(double);
932 } else {
933 this->size = size;
934 }
935 CHECK_CUDA( cudaMalloc((void**) &this->vals, sizeof(double) * this->size) );
936 CHECK_CUSPARSE( cusparseCreateDnVec(&this->cusparse_descr, this->size, this->vals, CUDA_R_64F) );
937 }
938 return;
939 }
940 inline double get_norm(const DeviceBlasHandle& cublas_H) {
941 double norm;
942 CHECK_CUDA( cudaSetDevice(this->gpu_id) );

Callers 1

DeviceDnVecDoubleMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected