14 #include "../offload/offload_library.h"
15 #include "../offload/offload_runtime.h"
25 #if defined(__OFFLOAD) && !defined(__NO_OFFLOAD_DBM)
29 offloadMalloc(&memory, size);
30 assert(memory != NULL);
37 void *memory = malloc(size);
38 assert(memory != NULL);
51 #if defined(__OFFLOAD) && !defined(__NO_OFFLOAD_DBM)
99 #pragma omp critical(dbm_mempool_modify)
104 indirect = &(*indirect)->
next;
111 *indirect = chunk->
next;
162 #pragma omp critical(dbm_mempool_modify)
166 while (*indirect != NULL && (*indirect)->
mem !=
mem) {
167 indirect = &(*indirect)->
next;
170 assert(chunk != NULL && chunk->
mem ==
mem);
173 *indirect = chunk->
next;
186 assert(omp_get_num_threads() == 1);
static void actual_free(void *memory, const bool on_device)
Private routine for actually freeing system memory.
void * dbm_mempool_device_malloc(const size_t size)
Internal routine for allocating device memory from the pool.
void dbm_mempool_clear(void)
Internal routine for freeing all memory in the pool.
void dbm_mempool_free(void *mem)
Internal routine for releasing memory back to the pool.
static void * internal_mempool_malloc(const size_t size, const bool on_device)
Private routine for allocating host or device memory from the pool.
static dbm_memchunk_t * mempool_available_head
Private linked list of memory chunks that are available.
static void * actual_malloc(const size_t size, const bool on_device)
Private routine for actually allocating system memory.
void * dbm_mempool_host_malloc(const size_t size)
Internal routine for allocating host memory from the pool.
static dbm_memchunk_t * mempool_allocated_head
Private linked list of memory chunks that are in use.
subroutine, public offload_activate_chosen_device()
Activates the device selected via offload_set_chosen_device()
Private struct for storing a chunk of memory.
struct dbm_memchunk * next