![]() |
(git:97501a3)
|
#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... | |
struct | dbm_mempool |
Private struct for storing a memory pool. More... | |
Typedefs | |
typedef struct dbm_memchunk | dbm_memchunk_t |
Private struct for storing a chunk of memory. | |
typedef struct dbm_mempool | dbm_mempool_t |
Private struct for storing a memory pool. | |
Functions | |
static void * | actual_malloc (const size_t size, const bool on_device) |
Private routine for actually allocating system memory. | |
static void | actual_free (void *memory, const bool on_device) |
Private routine for actually freeing system memory. | |
static void * | internal_mempool_malloc (dbm_mempool_t *pool, const size_t size, const bool on_device) |
Private routine for allocating host or device memory from the pool. | |
void * | dbm_mempool_host_malloc (const size_t size) |
Internal routine for allocating host memory from the pool. | |
void * | dbm_mempool_device_malloc (const size_t size) |
Internal routine for allocating device memory from the pool. | |
static void | internal_mempool_free (dbm_mempool_t *pool, 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_mempool_t *pool, const bool on_device) |
Private routine for freeing all memory in the pool. | |
void | dbm_mempool_clear (void) |
Internal routine for freeing all memory in the pool. | |
static uint64_t | sum_chunks_size (const dbm_memchunk_t *head) |
Private routine for summing alloc sizes of all chunks in given list. | |
static uint64_t | sum_chunks_used (const dbm_memchunk_t *head) |
Private routine for summing used sizes of all chunks in given list. | |
void | dbm_mempool_statistics (dbm_memstats_t *memstats) |
Internal routine to query statistics. | |
Variables | |
static dbm_mempool_t | mempool_host = {0} |
Private pools for host and device memory. | |
static dbm_mempool_t | mempool_device = {0} |
static uint64_t | host_malloc_counter = 0 |
Private some counters for statistics. | |
static uint64_t | device_malloc_counter = 0 |
typedef struct dbm_memchunk dbm_memchunk_t |
Private struct for storing a chunk of memory.
typedef struct dbm_mempool dbm_mempool_t |
Private struct for storing a memory pool.
|
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 92 of file dbm_mempool.c.
|
static |
Private routine for allocating host or device memory from the pool.
Definition at line 115 of file dbm_mempool.c.
void * dbm_mempool_host_malloc | ( | const size_t | size | ) |
Internal routine for allocating host memory from the pool.
Definition at line 180 of file dbm_mempool.c.
void * dbm_mempool_device_malloc | ( | const size_t | size | ) |
Internal routine for allocating device memory from the pool.
Definition at line 188 of file dbm_mempool.c.
|
static |
Private routine for releasing memory back to the pool.
Definition at line 196 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 224 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 232 of file dbm_mempool.c.
|
static |
Private routine for freeing all memory in the pool.
Definition at line 240 of file dbm_mempool.c.
void dbm_mempool_clear | ( | void | ) |
Internal routine for freeing all memory in the pool.
Definition at line 260 of file dbm_mempool.c.
|
static |
Private routine for summing alloc sizes of all chunks in given list.
Definition at line 269 of file dbm_mempool.c.
|
static |
Private routine for summing used sizes of all chunks in given list.
Definition at line 281 of file dbm_mempool.c.
void dbm_mempool_statistics | ( | dbm_memstats_t * | memstats | ) |
Internal routine to query statistics.
Definition at line 293 of file dbm_mempool.c.
|
static |
Private pools for host and device memory.
Definition at line 44 of file dbm_mempool.c.
|
static |
Definition at line 44 of file dbm_mempool.c.
|
static |
Private some counters for statistics.
Definition at line 50 of file dbm_mempool.c.
|
static |
Definition at line 50 of file dbm_mempool.c.