QUDA  0.9.0
Functions | Variables
quda::pool Namespace Reference

Functions

void init ()
 Initialize the memory pool allocator. More...
 
void * device_malloc_ (const char *func, const char *file, int line, size_t size)
 Allocate device-memory. If free pre-existing allocation exists reuse this. More...
 
void device_free_ (const char *func, const char *file, int line, void *ptr)
 Virtual free of pinned-memory allocation. More...
 
void * pinned_malloc_ (const char *func, const char *file, int line, size_t size)
 Allocate pinned-memory. If a free pre-existing allocation exists reuse this. More...
 
void pinned_free_ (const char *func, const char *file, int line, void *ptr)
 Virtual free of pinned-memory allocation. More...
 
void flush_device ()
 Free all outstanding device-memory allocations. More...
 
void flush_pinned ()
 Free all outstanding pinned-memory allocations. More...
 

Variables

static std::multimap< size_t, void * > pinnedCache
 
static std::map< void *, size_tpinnedSize
 
static std::multimap< size_t, void * > deviceCache
 
static std::map< void *, size_tdeviceSize
 
static bool pool_init = false
 
static bool device_memory_pool = true
 
static bool pinned_memory_pool = true
 

Function Documentation

◆ device_free_()

void quda::pool::device_free_ ( const char *  func,
const char *  file,
int  line,
void *  ptr 
)

Virtual free of pinned-memory allocation.

Parameters
ptrPointer to be (virtually) freed

Definition at line 520 of file malloc.cpp.

References quda::device_free_(), device_memory_pool, deviceCache, deviceSize, errorQuda, func, and ptr.

Here is the call graph for this function:

◆ device_malloc_()

void * quda::pool::device_malloc_ ( const char *  func,
const char *  file,
int  line,
size_t  size 
)

Allocate device-memory. If free pre-existing allocation exists reuse this.

Parameters
sizeSize of allocation
Returns
Pointer to allocated memory

Definition at line 491 of file malloc.cpp.

References quda::device_free_(), quda::device_malloc_(), device_memory_pool, deviceCache, deviceSize, func, quda::it, and ptr.

Here is the call graph for this function:

◆ flush_device()

void quda::pool::flush_device ( )

Free all outstanding device-memory allocations.

Definition at line 545 of file malloc.cpp.

References device_free, device_memory_pool, deviceCache, quda::it, and ptr.

Referenced by endQuda().

Here is the caller graph for this function:

◆ flush_pinned()

void quda::pool::flush_pinned ( )

Free all outstanding pinned-memory allocations.

Definition at line 533 of file malloc.cpp.

References host_free, quda::it, pinned_memory_pool, pinnedCache, and ptr.

Referenced by endQuda().

Here is the caller graph for this function:

◆ init()

void quda::pool::init ( )

Initialize the memory pool allocator.

Definition at line 424 of file malloc.cpp.

References device_memory_pool, getenv(), pinned_memory_pool, pool_init, strcmp(), and warningQuda.

Referenced by initQudaMemory().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ pinned_free_()

void quda::pool::pinned_free_ ( const char *  func,
const char *  file,
int  line,
void *  ptr 
)

Virtual free of pinned-memory allocation.

Parameters
ptrPointer to be (virtually) freed

Definition at line 478 of file malloc.cpp.

References errorQuda, func, quda::host_free_(), pinned_memory_pool, pinnedCache, pinnedSize, and ptr.

Here is the call graph for this function:

◆ pinned_malloc_()

void * quda::pool::pinned_malloc_ ( const char *  func,
const char *  file,
int  line,
size_t  size 
)

Allocate pinned-memory. If a free pre-existing allocation exists reuse this.

Parameters
sizeSize of allocation
Returns
Pointer to allocated memory

Definition at line 449 of file malloc.cpp.

References func, host_free, quda::it, quda::pinned_malloc_(), pinned_memory_pool, pinnedCache, pinnedSize, and ptr.

Here is the call graph for this function:

Variable Documentation

◆ device_memory_pool

bool quda::pool::device_memory_pool = true
static

whether to use a memory pool allocator for device memory

Definition at line 419 of file malloc.cpp.

Referenced by device_free_(), device_malloc_(), flush_device(), and init().

◆ deviceCache

std::multimap<size_t, void *> quda::pool::deviceCache
static

Cache of inactive device-memory allocations. We cache pinned memory allocations so that fields can reuse these with minimal overhead.

Definition at line 409 of file malloc.cpp.

Referenced by device_free_(), device_malloc_(), and flush_device().

◆ deviceSize

std::map<void *, size_t> quda::pool::deviceSize
static

Sizes of active device-memory allocations. For convenience, we keep track of the sizes of active allocations (i.e., those not in the cache).

Definition at line 414 of file malloc.cpp.

Referenced by device_free_(), and device_malloc_().

◆ pinned_memory_pool

bool quda::pool::pinned_memory_pool = true
static

whether to use a memory pool allocator for pinned memory

Definition at line 422 of file malloc.cpp.

Referenced by flush_pinned(), init(), pinned_free_(), and pinned_malloc_().

◆ pinnedCache

std::multimap<size_t, void *> quda::pool::pinnedCache
static

Cache of inactive pinned-memory allocations. We cache pinned memory allocations so that fields can reuse these with minimal overhead.

Definition at line 399 of file malloc.cpp.

Referenced by flush_pinned(), pinned_free_(), and pinned_malloc_().

◆ pinnedSize

std::map<void *, size_t> quda::pool::pinnedSize
static

Sizes of active pinned-memory allocations. For convenience, we keep track of the sizes of active allocations (i.e., those not in the cache).

Definition at line 404 of file malloc.cpp.

Referenced by pinned_free_(), and pinned_malloc_().

◆ pool_init

bool quda::pool::pool_init = false
static

Definition at line 416 of file malloc.cpp.

Referenced by init().