#include <stddef.h>#include <stdint.h>Go to the source code of this file.
Data Structures | |
| struct | ck_bump_alloc_t |
Enumerations | |
| enum | ck_bump_mode_t { CK_BUMP_MODE_UNINITIALIZED = 0 , CK_BUMP_MODE_ANON = 1 , CK_BUMP_MODE_MIXED_FILE_BACKED = 2 } |
Functions | |
| void | ck_bump_alloc_free (ck_bump_alloc_t *alloc) |
| int | ck_bump_alloc_init (ck_bump_alloc_t *alloc, const char *weights_path, size_t total_size, size_t weights_base, size_t activations_base) |
| int | ck_bump_alloc_needs_weight_materialization (const ck_bump_alloc_t *alloc) |
| void * | ck_huge_alloc (size_t bytes) |
| void | ck_huge_free (void *ptr, size_t bytes) |
| enum ck_bump_mode_t |
| Enumerator | |
|---|---|
| CK_BUMP_MODE_UNINITIALIZED | |
| CK_BUMP_MODE_ANON | |
| CK_BUMP_MODE_MIXED_FILE_BACKED | |
Definition at line 26 of file ckernel_alloc.h.
| void ck_bump_alloc_free | ( | ck_bump_alloc_t * | alloc | ) |
Definition at line 313 of file ckernel_alloc.c.
References ck_bump_alloc_t::base, ck_bump_alloc_reset(), CK_BUMP_MODE_ANON, CK_BUMP_MODE_MIXED_FILE_BACKED, ck_huge_free(), ck_bump_alloc_t::mapped_len, ck_bump_alloc_t::mode, and ck_bump_alloc_t::total_size.
| int ck_bump_alloc_init | ( | ck_bump_alloc_t * | alloc, |
| const char * | weights_path, | ||
| size_t | total_size, | ||
| size_t | weights_base, | ||
| size_t | activations_base | ||
| ) |
Definition at line 257 of file ckernel_alloc.c.
References ck_bump_alloc_t::activations_base, align_up_bytes(), ck_bump_alloc_t::base, ck_bump_alloc_reset(), CK_BUMP_MODE_ANON, ck_huge_alloc(), env_flag_enabled(), HUGE_PAGE_SIZE, ck_bump_alloc_t::mapped_len, ck_bump_alloc_t::mode, ck_bump_alloc_t::total_size, and ck_bump_alloc_t::weights_base.
| int ck_bump_alloc_needs_weight_materialization | ( | const ck_bump_alloc_t * | alloc | ) |
Definition at line 331 of file ckernel_alloc.c.
References CK_BUMP_MODE_MIXED_FILE_BACKED, and ck_bump_alloc_t::mode.
| 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 70 of file ckernel_alloc.c.
References align_up_bytes(), align_up_bytes(), align_up_bytes(), align_up_bytes(), HUGE_PAGE_SIZE, record_allocation(), record_allocation(), record_allocation(), and record_allocation().
Referenced by ck_bump_alloc_init().
| 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 104 of file ckernel_alloc.c.
References detach_allocation(), detach_allocation(), detach_allocation(), and detach_allocation().
Referenced by ck_bump_alloc_free().