NUMA++ 0.11.0
Loading...
Searching...
No Matches
lockResourceExample.cpp
1#include <vector>
2
3#include <numapp/memory.hpp>
4
5void Example() {
6 // Create a pool resource that allocates memory from NUMA node 1 with strict
7 // policy, using PageResource.
9 numapp::MemPolicyFlag::Strict);
10
11 auto locked = numapp::LockResource(numapp::LockFlag::PreFault, &resource);
12
13 // Allocate 4 MiB block memory from NUMA node 1, pre-fault it and lock it
14 // into memory.
15 [[maybe_unused]] auto vector =
16 std::pmr::vector<std::uint8_t>(4 * 1024 * 1024, &locked);
17}
Lock memory allocated from upstream memory resource using specified LockFlag.
Definition memory.hpp:406
static MemPolicy MakeBindNode(int node)
Creates a strict policy (using MPOL_BIND) to allocate all memory to the specified node.
Polymorphic memory resource allocating full system pages with specified NUMA policy.
Definition memory.hpp:359
@ PreFault
Locks pages whether they are resident or not.
Definition memory.hpp:126
Contains memory function declarations.