![]() |
(git:b77b4be)
|
#include <assert.h>
#include <omp.h>
#include <stdbool.h>
#include <stddef.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "../offload/offload_library.h"
#include "../offload/offload_runtime.h"
#include "dbm_hyperparams.h"
#include "dbm_mempool.h"
#include "dbm_mpi.h"
Go to the source code of this file.
Data Structures | |
struct | dbm_memchunk |
Private struct for storing a chunk of memory. More... | |
Typedefs | |
typedef struct dbm_memchunk | dbm_memchunk_t |
Private struct for storing a chunk of memory. | |
Functions | |
static void * | actual_malloc (size_t size, bool on_device) |
Private routine for actually allocating system memory. | |
static void | actual_free (const void *memory, bool on_device) |
Private routine for actually freeing system memory. | |
static void * | internal_mempool_malloc (dbm_memchunk_t **available_head, dbm_memchunk_t **allocated_head, size_t size) |
Private routine for allocating host or device memory from the pool. | |
void * | dbm_mempool_host_malloc (size_t size) |
Internal routine for allocating host memory from the pool. | |
void * | dbm_mempool_device_malloc (size_t size) |
Internal routine for allocating device memory from the pool. | |
static void | internal_mempool_free (dbm_memchunk_t **available_head, dbm_memchunk_t **allocated_head, const void *mem) |
Private routine for releasing memory back to the pool. | |
void | dbm_mempool_host_free (const void *memory) |
Internal routine for releasing memory back to the pool. | |
void | dbm_mempool_device_free (const void *memory) |
Internal routine for releasing memory back to the pool. | |
static void | internal_mempool_clear (dbm_memchunk_t **available_head) |
Private routine for freeing all memory in the pool. | |
void | dbm_mempool_clear (void) |
Internal routine for freeing all memory in the pool. | |
void | dbm_mempool_statistics (dbm_memstats_t *memstats) |
Internal routine to query statistics. | |
Variables | |
static dbm_memchunk_t * | mempool_device_available_head = NULL |
Private linked list of memory chunks that are available. | |
static dbm_memchunk_t * | mempool_host_available_head = NULL |
static dbm_memchunk_t * | mempool_device_allocated_head = NULL |
Private linked list of memory chunks that are in use. | |
static dbm_memchunk_t * | mempool_host_allocated_head = NULL |
static dbm_memstats_t | mempool_stats = {0} |
Private statistics. | |
typedef struct dbm_memchunk dbm_memchunk_t |
Private struct for storing a chunk of memory.
|
static |
Private routine for actually allocating system memory.
Definition at line 56 of file dbm_mempool.c.
|
static |
Private routine for actually freeing system memory.
Definition at line 94 of file dbm_mempool.c.
|
static |
Private routine for allocating host or device memory from the pool.
Definition at line 120 of file dbm_mempool.c.
void * dbm_mempool_host_malloc | ( | size_t | size | ) |
Internal routine for allocating host memory from the pool.
Definition at line 187 of file dbm_mempool.c.
void * dbm_mempool_device_malloc | ( | size_t | size | ) |
Internal routine for allocating device memory from the pool.
Definition at line 200 of file dbm_mempool.c.
|
static |
Private routine for releasing memory back to the pool.
Definition at line 218 of file dbm_mempool.c.
void dbm_mempool_host_free | ( | const void * | memory | ) |
Internal routine for releasing memory back to the pool.
Definition at line 246 of file dbm_mempool.c.
void dbm_mempool_device_free | ( | const void * | memory | ) |
Internal routine for releasing memory back to the pool.
Definition at line 259 of file dbm_mempool.c.
|
static |
Private routine for freeing all memory in the pool.
Definition at line 276 of file dbm_mempool.c.
void dbm_mempool_clear | ( | void | ) |
Internal routine for freeing all memory in the pool.
Definition at line 293 of file dbm_mempool.c.
void dbm_mempool_statistics | ( | dbm_memstats_t * | memstats | ) |
Internal routine to query statistics.
Definition at line 309 of file dbm_mempool.c.
|
static |
Private linked list of memory chunks that are available.
Definition at line 36 of file dbm_mempool.c.
|
static |
Definition at line 37 of file dbm_mempool.c.
|
static |
Private linked list of memory chunks that are in use.
Definition at line 43 of file dbm_mempool.c.
|
static |
Definition at line 44 of file dbm_mempool.c.
|
static |
Private statistics.
Definition at line 50 of file dbm_mempool.c.