← Back to C-Kernel-Engine Docs Doxygen Source Documentation
ckernel_alloc.h
Go to the documentation of this file.
1 #ifndef CKERNEL_ALLOC_H
2 #define CKERNEL_ALLOC_H
3 
4 #include <stddef.h>
5 
6 /**
7  * Allocate a large, contiguous memory region for model weights/activations.
8  *
9  * Implementation strategy:
10  * - Try to allocate 2MB-aligned memory backed by huge pages where possible.
11  * - Fall back to aligned_alloc + madvise(MADV_HUGEPAGE) when explicit
12  * huge pages are not available.
13  *
14  * Returns NULL on failure.
15  */
16 void *ck_huge_alloc(size_t bytes);
17 
18 /**
19  * Free memory allocated by ck_huge_alloc.
20  *
21  * The bytes parameter should be the same size passed to ck_huge_alloc.
22  */
23 void ck_huge_free(void *ptr, size_t bytes);
24 
25 #endif /* CKERNEL_ALLOC_H */
26 
void * ck_huge_alloc(size_t bytes)
Definition: ckernel_alloc.c:67
void ck_huge_free(void *ptr, size_t bytes)