![]() |
Deepity
Ultra-fast, SIMD-accelerated Predictive Coding
|
Functions | |
| void * | AlignedAllocPortable (size_t alignment, size_t size) |
Allocates a block of memory aligned to alignment bytes, using whichever aligned-allocation API is actually reliable on the current platform (see the comment above for why this can't just be std::aligned_alloc everywhere). | |
| void | AlignedFreePortable (void *ptr) |
| Frees a block previously returned by AlignedAllocPortable(). | |
| void * | HugePageAllocPortable (size_t size, bool &succeeded) |
Attempts to allocate size bytes backed by huge pages. This is genuinely opt-in and best-effort: on Linux, requests Transparent Huge Pages via madvise(MADV_HUGEPAGE) on a normal anonymous mmap – this is a HINT to the kernel, not a guarantee, and requires zero system-level configuration (unlike explicit hugetlbfs, which needs pages pre-reserved via /proc/sys/vm/nr_hugepages). On Windows, requests MEM_LARGE_PAGES via VirtualAlloc, which requires the process to hold SeLockMemoryPrivilege – NOT granted by default, so this will typically fail unless explicitly configured by an administrator. | |
| void | HugePageFreePortable (void *ptr, size_t size) |
| Frees a block previously returned by HugePageAllocPortable() with succeeded=true. | |
|
inline |
Allocates a block of memory aligned to alignment bytes, using whichever aligned-allocation API is actually reliable on the current platform (see the comment above for why this can't just be std::aligned_alloc everywhere).
| alignment | Required alignment, in bytes. Must be a valid alignment for the platform's underlying allocator (e.g. a power of two). |
| size | Number of bytes to allocate. |
|
inline |
Frees a block previously returned by AlignedAllocPortable().
| ptr | Pointer to free; must have been returned by AlignedAllocPortable(), not by plain malloc()/new or any other allocator. |
|
inline |
Attempts to allocate size bytes backed by huge pages. This is genuinely opt-in and best-effort: on Linux, requests Transparent Huge Pages via madvise(MADV_HUGEPAGE) on a normal anonymous mmap – this is a HINT to the kernel, not a guarantee, and requires zero system-level configuration (unlike explicit hugetlbfs, which needs pages pre-reserved via /proc/sys/vm/nr_hugepages). On Windows, requests MEM_LARGE_PAGES via VirtualAlloc, which requires the process to hold SeLockMemoryPrivilege – NOT granted by default, so this will typically fail unless explicitly configured by an administrator.
| size | Number of bytes to allocate. | |
| [out] | succeeded | Set to true if huge-page-backed memory was actually obtained, false otherwise. Never throws on failure – callers should fall back to AlignedAllocPortable() when this is false. |
|
inline |
Frees a block previously returned by HugePageAllocPortable() with succeeded=true.
| ptr | Pointer to free. |
| size | The exact size originally passed to HugePageAllocPortable() – required on POSIX systems, where munmap() needs to know the mapping's length. |