Unified Memory Group Allocator
Classes | Functions
Allocator.h File Reference
#include <cstdlib>
#include <memory>
#include <mutex>
#include <unordered_map>
#include <vector>
#include "GroupAllocator.h"
Include dependency graph for Allocator.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)
 

Detailed Description

Allocation and deallocation functionality resides here.

Function Documentation

◆ allocate()

template<typename T >
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!

Parameters
ptr
s
group

◆ free()

template<typename T >
void groupallocator::free ( T *  p,
int  group = -1 
)

Free T* p from group

Template Parameters
T
Parameters
p
group

◆ freeall()

void groupallocator::freeall ( )
inline

Cleans up the allocator by freeing everything so there is no memory leak. Thread safe.

◆ moveToCPU()

void groupallocator::moveToCPU ( int  group = -1,
cudaStream_t  stream = cudaStreamDefault 
)
inline

Moves data to CPU, thread safe

Parameters
group
stream

◆ moveToGPU()

void groupallocator::moveToGPU ( int  group = -1,
int  gpuID = 0,
cudaStream_t  stream = cudaStreamDefault 
)
inline

Moves data to GPU, thread safe

Parameters
group
gpuID
stream