#include "ckernel_alloc.h"#include <errno.h>#include <pthread.h>#include <stdio.h>#include <stdlib.h>#include <string.h>#include <sys/mman.h>#include <sys/types.h>#include <unistd.h>Go to the source code of this file.
Macros | |
| #define | _GNU_SOURCE |
| #define | HUGE_PAGE_SIZE (2UL * 1024UL * 1024UL) |
Functions | |
| static size_t | align_up_bytes (size_t n, size_t align) |
| void * | ck_huge_alloc (size_t bytes) |
| void | ck_huge_free (void *ptr, size_t bytes) |
| static ck_huge_alloc_entry_t * | detach_allocation (void *ptr) |
| static int | record_allocation (void *ptr, size_t len, int was_mmap) |
Variables | |
| static ck_huge_alloc_entry_t * | g_alloc_list = NULL |
| static pthread_mutex_t | g_alloc_mutex = PTHREAD_MUTEX_INITIALIZER |
| #define _GNU_SOURCE |
Definition at line 1 of file ckernel_alloc_v6.5.c.
| #define HUGE_PAGE_SIZE (2UL * 1024UL * 1024UL) |
Definition at line 15 of file ckernel_alloc_v6.5.c.
|
static |
Definition at line 28 of file ckernel_alloc_v6.5.c.
Referenced by ck_huge_alloc().
| void* ck_huge_alloc | ( | size_t | bytes | ) |
Allocate a large, contiguous memory region for model weights/activations.
Implementation strategy:
Returns NULL on failure.
Definition at line 67 of file ckernel_alloc_v6.5.c.
References align_up_bytes(), HUGE_PAGE_SIZE, and record_allocation().
| void ck_huge_free | ( | void * | ptr, |
| size_t | bytes | ||
| ) |
Free memory allocated by ck_huge_alloc.
The bytes parameter should be the same size passed to ck_huge_alloc.
Definition at line 101 of file ckernel_alloc_v6.5.c.
References detach_allocation().
|
static |
Definition at line 50 of file ckernel_alloc_v6.5.c.
References g_alloc_list, and g_alloc_mutex.
Referenced by ck_huge_free().
|
static |
Definition at line 34 of file ckernel_alloc_v6.5.c.
References g_alloc_list, and g_alloc_mutex.
Referenced by ck_huge_alloc().
|
static |
Definition at line 26 of file ckernel_alloc_v6.5.c.
Referenced by detach_allocation(), and record_allocation().
|
static |
Definition at line 25 of file ckernel_alloc_v6.5.c.
Referenced by detach_allocation(), and record_allocation().