![]() |
(git:f56c6e3)
|
#include "offload_mempool.h"#include "../mpiwrap/cp_mpi.h"#include "offload_library.h"#include "offload_runtime.h"#include <assert.h>#include <inttypes.h>#include <omp.h>#include <stdbool.h>#include <stdio.h>#include <stdlib.h>#include <string.h>Go to the source code of this file.
Data Structures | |
| struct | offload_memchunk |
| Private struct for storing a chunk of memory. More... | |
| struct | offload_mempool |
| Private struct for storing a memory pool. More... | |
Macros | |
| #define | OFFLOAD_MEMPOOL_PRINT(FN, MSG, OUTPUT_UNIT) ((FN)(MSG, (int)strlen(MSG), OUTPUT_UNIT)) |
| #define | OFFLOAD_MEMPOOL_OMPALLOC 1 |
Typedefs | |
| typedef struct offload_memchunk | offload_memchunk_t |
| Private struct for storing a chunk of memory. | |
| typedef struct offload_mempool | offload_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 (offload_mempool_t *pool, const size_t size, const bool on_device) |
| Private routine for allocating host or device memory from the pool. | |
| void * | offload_mempool_host_malloc (const size_t size) |
| Internal routine for allocating host memory from the pool. | |
| void * | offload_mempool_device_malloc (const size_t size) |
| Internal routine for allocating device memory from the pool. | |
| static void | internal_mempool_free (offload_mempool_t *pool, const void *mem) |
| Private routine for releasing memory back to the pool. | |
| void | offload_mempool_host_free (const void *memory) |
| Internal routine for releasing memory back to the pool. | |
| void | offload_mempool_device_free (const void *memory) |
| Internal routine for releasing memory back to the pool. | |
| static void | internal_mempool_clear (offload_mempool_t *pool, const bool on_device) |
| Private routine for freeing all memory in the pool. | |
| void | offload_mempool_clear (void) |
| Internal routine for freeing all memory in the pool. | |
| static uint64_t | sum_chunks_size (const offload_memchunk_t *head) |
| Private routine for summing alloc sizes of all chunks in given list. | |
| static uint64_t | sum_chunks_used (const offload_memchunk_t *head) |
| Private routine for summing used sizes of all chunks in given list. | |
| void | offload_mempool_stats_get (offload_mempool_stats_t *memstats) |
| Internal routine to query statistics. | |
| void | offload_mempool_stats_print (int fortran_comm, void(*print_func)(const char *, int, int), int output_unit) |
| Print allocation statistics.. | |
Variables | |
| static offload_mempool_t | mempool_host = {0} |
| Private pools for host and device memory. | |
| static offload_mempool_t | mempool_device = {0} |
| static uint64_t | host_malloc_counter = 0 |
| Private some counters for statistics. | |
| static uint64_t | device_malloc_counter = 0 |
| #define OFFLOAD_MEMPOOL_PRINT | ( | FN, | |
| MSG, | |||
| OUTPUT_UNIT | |||
| ) | ((FN)(MSG, (int)strlen(MSG), OUTPUT_UNIT)) |
Definition at line 24 of file offload_mempool.c.
| #define OFFLOAD_MEMPOOL_OMPALLOC 1 |
Definition at line 26 of file offload_mempool.c.
| typedef struct offload_memchunk offload_memchunk_t |
Private struct for storing a chunk of memory.
| typedef struct offload_mempool offload_mempool_t |
Private struct for storing a memory pool.
|
static |
Private routine for actually allocating system memory.
Definition at line 62 of file offload_mempool.c.
|
static |
Private routine for actually freeing system memory.
Definition at line 106 of file offload_mempool.c.
|
static |
Private routine for allocating host or device memory from the pool.
Definition at line 139 of file offload_mempool.c.
| void * offload_mempool_host_malloc | ( | const size_t | size | ) |
Internal routine for allocating host memory from the pool.
Definition at line 205 of file offload_mempool.c.
| void * offload_mempool_device_malloc | ( | const size_t | size | ) |
Internal routine for allocating device memory from the pool.
Definition at line 213 of file offload_mempool.c.
|
static |
Private routine for releasing memory back to the pool.
Definition at line 221 of file offload_mempool.c.
| void offload_mempool_host_free | ( | const void * | memory | ) |
Internal routine for releasing memory back to the pool.
Definition at line 249 of file offload_mempool.c.
| void offload_mempool_device_free | ( | const void * | memory | ) |
Internal routine for releasing memory back to the pool.
Definition at line 257 of file offload_mempool.c.
|
static |
Private routine for freeing all memory in the pool.
Definition at line 265 of file offload_mempool.c.
| void offload_mempool_clear | ( | void | ) |
Internal routine for freeing all memory in the pool.
Definition at line 286 of file offload_mempool.c.
|
static |
Private routine for summing alloc sizes of all chunks in given list.
Definition at line 295 of file offload_mempool.c.
|
static |
Private routine for summing used sizes of all chunks in given list.
Definition at line 308 of file offload_mempool.c.
| void offload_mempool_stats_get | ( | offload_mempool_stats_t * | memstats | ) |
Internal routine to query statistics.
Definition at line 321 of file offload_mempool.c.
| void offload_mempool_stats_print | ( | int | fortran_comm, |
| void(*)(const char *, int, int) | print_func, | ||
| int | output_unit | ||
| ) |
Print allocation statistics..
Print allocation statistics.
Definition at line 343 of file offload_mempool.c.
|
static |
Private pools for host and device memory.
Definition at line 50 of file offload_mempool.c.
|
static |
Definition at line 50 of file offload_mempool.c.
|
static |
Private some counters for statistics.
Definition at line 56 of file offload_mempool.c.
|
static |
Definition at line 56 of file offload_mempool.c.