// Overview / API / FAQ / Resources
- Single header (https://raw.githubusercontent.com/qlibs/mem/main/mem) / C++20 module (https://raw.githubusercontent.com/qlibs/mem/main/mem.cppm)
- C++23 standard compliant API
- Verifies itself upon
include/import
(can be disabled with-DNTEST
- see FAQ)
- C++20+ (clang++12+, g++11+) /
Linux
* /numactl
*
import mem;
int main() {
static_assert(mem::allocator_like<std::allocator<int>>);
static_assert(mem::allocator_like<mem::allocator::aligned<int, std::align_val_t(64u)>>);
static_assert(mem::allocator_like<mem::allocator::stack<int, 1024u>>);
static_assert(mem::allocator_like<mem::allocator::transparent_huge_pages<int>>);
static_assert(mem::allocator_like<mem::allocator::huge_pages<int>>);
static_assert(mem::allocator_like<mem::allocator::numa<int>>);
{
std::vector<int, mem::allocator::aligned<int, std::align_val_t(64u)>> v{};
std::vector<int, mem::allocator::stack<int, 1024u>> v{};
// echo 20 > /proc/sys/vm/nr_hugepages
std::vector<int, mem::allocator::huge_pages<int>> v{};
// echo always > /sys/kernel/mm/transparent_hugepage/hugepages-2048kB/enabled
std::vector<int, mem::allocator::transparent_huge_pages<int>> v{};
// -lnuma # requires libnuma-dev
std::vector<int, mem::allocator::numa<int>> v{};
}
}
How to disable running tests at compile-time?
When-DNTEST
is defined static_asserts tests wont be executed upon inclusion. Note: Use with caution as disabling tests means that there are no gurantees upon inclusion that given compiler/env combination works as expected.Similar projects?
std::pmr
std::allocator
Transparent Huge Pages
Huge Pages
Non Uniform Memory Access