NUMA++ 0.12.0
Loading...
Searching...
No Matches
lockResourceExample.cpp
Go to the documentation of this file.
1/**
2 * @file
3 * @copyright
4 * SPDX-FileCopyrightText: 2025-2025 European Southern Observatory (ESO)
5 *
6 * SPDX-License-Identifier: LGPL-3.0-only
7 */
8#include <vector>
9
10#include <numapp/memory.hpp>
11
12void Example() {
13 // Create a pool resource that allocates memory from NUMA node 1 with strict
14 // policy, using PageResource.
16 numapp::MemPolicyFlag::Strict);
17
18 auto locked = numapp::LockResource(numapp::LockFlag::PreFault, &resource);
19
20 // Allocate 4 MiB block memory from NUMA node 1, pre-fault it and lock it
21 // into memory.
22 [[maybe_unused]] auto vector =
23 std::pmr::vector<std::uint8_t>(4 * 1024 * 1024, &locked);
24}
Lock memory allocated from upstream memory resource using specified LockFlag.
Definition memory.hpp:408
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:361
@ PreFault
Locks pages whether they are resident or not.
Definition memory.hpp:128
Contains memory function declarations.