27 #ifndef CUDA_MEMORY_CUH_ 28 #define CUDA_MEMORY_CUH_ 30 #define EXCEPT_MC noexcept 36 #include "util/cuda_util.hpp" 38 extern size_t TotCudaMemoryAllocated;
50 __device__
inline size_t align_number_device(
size_t al,
size_t number)
52 return number + ((number % al) != 0)*(al - number % al);
56 static __device__
unsigned char global_cuda_error_array[256];
95 virtual size_t size()
const;
126 virtual void fill(
unsigned char c);
207 std::cerr <<
"Error: " << __FILE__ <<
" " << __LINE__ <<
" destroying a live object" <<
"\n";
218 void deviceToDevice(
void * ptr,
size_t start,
size_t stop,
size_t offset);
void allocate_host(size_t sz) const
Allocate an host buffer.
CudaMemory(size_t sz)
Constructor.
bool copyFromPointer(const void *ptr)
copy from Pointer to GPU
virtual bool allocate(size_t sz)
allocate memory
virtual void hostToDevice()
Move memory from host to device.
void * toKernel()
return the device memory
virtual void * getPointer()
get a readable pointer with the data
void swap(CudaMemory &mem)
Swap the memory.
size_t ref_cnt
Reference counter.
virtual void decRef()
Decrement the reference counter.
virtual void fill(unsigned char c)
fill the buffer with a byte
virtual void * getDevicePointer()
get a readable pointer with the data
virtual void incRef()
Increment the reference counter.
void deviceToDevice(void *ptr, size_t start, size_t stop, size_t offset)
copy memory from device to device
virtual bool copy(const memory &m)
copy from a General device
virtual bool flush()
flush the memory
size_t sz
Size of the memory.
virtual bool resize(size_t sz)
resize the momory allocated
virtual size_t size() const
the the size of the allocated memory
static constexpr bool isDeviceHostSame()
Return true if the device and the host pointer are the same.
bool copyDeviceToDevice(const CudaMemory &m)
copy from GPU to GPU buffer directly
virtual long int ref()
Return the reference counter.
virtual void deviceToHost()
Move memory from device to host.
bool isInitialized()
Allocated Memory is never initialized.
bool is_hm_sync
Is the host memory synchronized with the GPU memory.
virtual void destroy()
destroy memory