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

Method allocate

XM/include/Utils/memory.h:977–991  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

975 }
976
977 inline void allocate(const int gpu_id, const int size, bool as_byte = false) {
978 if (this->vals == nullptr) {
979 this->gpu_id = gpu_id;
980 CHECK_CUDA( cudaSetDevice(this->gpu_id) );
981 // as_byte is used to allocate buffer size, which is usually given in terms of bytes
982 if (as_byte) {
983 this->size = (size + sizeof(float) - 1) / sizeof(float);
984 } else {
985 this->size = size;
986 }
987 CHECK_CUDA( cudaMalloc((void**) &this->vals, sizeof(float) * this->size) );
988 CHECK_CUSPARSE( cusparseCreateDnVec(&this->cusparse_descr, this->size, this->vals, CUDA_R_32F) );
989 }
990 return;
991 }
992 inline float get_norm(const DeviceBlasHandle& cublas_H) {
993 float norm;
994 CHECK_CUDA( cudaSetDevice(this->gpu_id) );

Callers 1

DeviceDnVecFloatMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected