◆ MemoryManager() [1/2]
MemoryManager class to keep track of a memory address across devices.
- Parameters
-
size | the size of the memory to allocate/manage |
mem_type | what memory type will this data belong to |
device_id | what device will the data reside on (preferred if mem_type is CUDA_MANAGED) |
◆ MemoryManager() [2/2]
Copy Constructor
- Parameters
-
◆ ~MemoryManager()
Destroys the memory manager object and releases all its data.
◆ copy_from() [1/3]
Copies the data from src memory manager into the pointer here. Asserts that src and this have the same size.
- Parameters
-
src | the memorymanager to copy data from |
- Returns
- the error code (0 - no error, 1 - src ptr not allocated)
◆ copy_from() [2/3]
Copies the data from src memory manager into the pointer here. Asserts that src and this have the same size.
- Parameters
-
src | the memorymanager to copy data from |
- Returns
- the error code (0 - no error, 1 - src ptr not allocated)
◆ copy_from() [3/3]
Copies the data from src memory manager into the pointer here. Asserts that src and this have the same size.
- Parameters
-
src | the memorymanager to copy data from |
- Returns
- the error code (0 - no error, 1 - src ptr not allocated)
◆ copy_from_host()
template<typename T >
magmadnn_error_t magmadnn::MemoryManager< T >::copy_from_host |
( |
T * |
src, |
|
|
unsigned int |
begin_idx, |
|
|
unsigned int |
size |
|
) |
| |
copies memory from a host ptr into this memorymanager. will throw an error if it reaches the end of src allocated mem before this is filled.
- Parameters
-
src | the array to copy into this. |
- Returns
- the error code (0 - good, 1 - not enough memory)
◆ get()
Returns the value at idx. Error if idx is out of range.
- Parameters
-
- Returns
- the value at index idx.
◆ get_host_ptr()
returns a CPU pointer to the data.
- Returns
- cpu pointer
◆ get_memory_type()
Returns the memory type of this memory manager.
- Returns
- memory_t
◆ get_ptr()
Returns a pointer to whatever memory type this is using. For MANAGED memory type it returns the device pointer.
- Returns
- the data ptr
◆ get_size()
Returns the size of this memorymanager
- Returns
- unsigned int the size of this memory manager
◆ operator=()
◆ set()
Sets the value at idx to val. Error if idx is out of range.
- Parameters
-
idx | index to set |
val | value to set at idx |
◆ set_device()
Changes the device this memory manager points to. Note that the memory type is still the same, but the device_id will be different.
- Returns
- an error code (0 - ok)
◆ sync()
If MANAGED or CUDA_MANAGED this ensures that data is the same on all devices. It will wait for any gpu kernels to finish before copying data. If HOST or DEVICE memory this does nothing.
- Parameters
-
gpu_was_modified | If true then data will be copied from gpu to cpu, else if false vice-versa. By default true. |
- Returns
- an error code
The documentation for this class was generated from the following files: