NUMA++ 0.11.0
Loading...
Searching...
No Matches
mempolicyExample1.cpp
1#include <iostream>
2#include <numapp/numa.hpp>
4
5int main() {
9 std::cout << "NUMA not available";
10 return -1;
11 }
12
13 auto policy = MemPolicy(MemPolicy::Mode::Bind, Nodemask::MakeFromNodestring("0-1"));
14 // Set default policy for main thread
15 if (auto ec = numapp::thisThread::Apply(policy); ec) {
16 std::cout << "Failed to apply policy: " << ec.message() << std::endl;
17 return 1;
18 }
19 // And apply policy to stack
20 if (auto ec = numapp::thisThread::ApplyStack(policy); ec) {
21 std::cout << "Failed to apply policy: " << ec.message() << std::endl;
22 return 1;
23 }
24}
Class representing a memory policy that can be modified and used to apply to the current thread or a ...
std::error_code Apply(CpuAffinity const &affinity) noexcept
Apply policy to calling thread.
std::error_code ApplyStack(MemPolicy const &policy, MemPolicyFlag flags=MemPolicyFlag::Move|MemPolicyFlag::Strict) noexcept
Convenience function that applies a memory policy to current thread stack memory.
bool NumaAvailable() noexcept
Query whether system has NUMA support.
Definition numa.hpp:34
Contains declarations for numapp::MemPolicy.
Type-safe NUMA node mask.
Definition nodemask.hpp:23