On two systems I tested, numa_preferred always returns 0 if not explicitly initialized. That means that even when I start a process explicitly on some processor on NUMA node ~= 0, using the default memory allocation policy (local alloc), numa_preferred will return 0. The memory will be allocated correctly on the local numa node.
https://gist.github.com/angainor/d09c367631880ae99e1acf7f6653128b
I suggest we add the following function to numa_tools:
numa_tools::index_type
numa_tools::local_node() const noexcept
{
return numa_node_of_cpu(sched_getcpu());
}
While this will not return the preferred node, it will return the thread-local node id, which is often what we want.
On two systems I tested,
numa_preferredalways returns 0 if not explicitly initialized. That means that even when I start a process explicitly on some processor on NUMA node ~= 0, using the default memory allocation policy (local alloc),numa_preferredwill return 0. The memory will be allocated correctly on the local numa node.https://gist.github.com/angainor/d09c367631880ae99e1acf7f6653128b
I suggest we add the following function to
numa_tools:While this will not return the preferred node, it will return the thread-local node id, which is often what we want.