Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

numa_preferred returns unexpected result #19

Open
angainor opened this issue May 18, 2021 · 3 comments
Open

numa_preferred returns unexpected result #19

angainor opened this issue May 18, 2021 · 3 comments

Comments

@angainor
Copy link
Collaborator

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.

@angainor angainor mentioned this issue May 19, 2021
@boeschf
Copy link
Collaborator

boeschf commented Jun 14, 2021

Good catch. I see in the gist that you use a multi-threaded test. does it work for single-threaded process? I.e. does it has something to do with the way we implement the initialization of libnuma?

@angainor
Copy link
Collaborator Author

@boeschf I think it's the same - in the gist I print

  printf("MAIN preferred %d\n", numa_preferred());

before the threaded section also.

@boeschf
Copy link
Collaborator

boeschf commented Jun 15, 2021

oh yes, my bad

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants