|
Unified Memory Group Allocator
|
#include <cstdlib>#include <memory>#include <mutex>#include <unordered_map>#include <vector>#include "GroupAllocator.h"
Go to the source code of this file.
Classes | |
| struct | groupallocator::Context |
Functions | |
| template<typename T > | |
| void | groupallocator::allocate (T **ptr, size_t s, const Context ctx, int group=-1, bool forceAligned128=false) |
| template<typename T > | |
| void | groupallocator::free (T *p, int group=-1) |
| void | groupallocator::freeall () |
| void | groupallocator::moveToGPU (int group=-1, int gpuID=0, cudaStream_t stream=cudaStreamDefault) |
| void | groupallocator::moveToCPU (int group=-1, cudaStream_t stream=cudaStreamDefault) |
Allocation and deallocation functionality resides here.
| void groupallocator::allocate | ( | T ** | ptr, |
| size_t | s, | ||
| const Context | ctx, | ||
| int | group = -1, |
||
| bool | forceAligned128 = false |
||
| ) |
Allocates memory of type T and sets *ptr to this memory of size s. It allocates in group group. Thread Safe!
| ptr | |
| s | |
| group |
| void groupallocator::free | ( | T * | p, |
| int | group = -1 |
||
| ) |
Free T* p from group
| T |
| p | |
| group |
|
inline |
Cleans up the allocator by freeing everything so there is no memory leak. Thread safe.
|
inline |
Moves data to CPU, thread safe
| group | |
| stream |
|
inline |
Moves data to GPU, thread safe
| group | |
| gpuID | |
| stream |
1.8.17