-
Notifications
You must be signed in to change notification settings - Fork 160
NUMA-awareness fixes #652
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-awareness fixes #652
Conversation
Wew amazing! Great call on renaming Some notes:
|
Btw for speed, I can commit those aforementioned changes myself (and fix the CI - Github Actions is treating the cmake warning as an error) but still suggest giving you full merge credit (i.e. not coauthoring with me) since they're merely stylistic. Let me know if you prefer that and I'll do so! |
No worries @TysonRayJones I’m on it now! |
Re sysconf it’s posix, and NUMA_AWARE is not enabled on Windows. I’m not sure there’s other systems (neither Windows nor unix-based) that this code is supposed to run on? |
I’ve moved |
Love this, thanks @lucjaulmes! |
Just helping collate the CI issues:
|
Hmm I likely didn’t test this enough on tiny sized examples. Pushed a few fixes, letting CIs run again. Regarding Rebasing on latest devel for good measure. |
e53c97b
to
b547470
Compare
In the case libnuma is not found, NUMA_FOUND is (can be?) not defined instead of being set to 0.
I'm intending to make some mostly stylistic and defensive changes but I'm having trouble pulling the PR branch locally - so I'm going to experiment with Codespaces, hence please excuse any commit spam from failed tests! Things I intend to tinker with:
Sorry to appear pedantic - QuEST v4's explosion in complexity has made me extremely attentive to defensive design since I foresee a million new ways for insidious bugs. Ergo changes to very fundamental things (like allocating memory) make me overly scrutinous! |
Feel free to edit the PR as you see fit, of course! |
BAH clicking through the inconspicuous Github desktop prompts has caused that unhelpful merge commit. I wasn't able to pull your changes until I opened the "resolve conflicts" menu which reported "no conflicts" and gave a new option to "continue merge", which caused that merge commit without warning, duplicating a number of commits to Are you able to force undo my merge from your end, or otherwise know the secret git source to pull your changes to my local repo? 🫤 Edit: this should require only forcefully reverting my commit onto your
which keeps your latest commit, discarding my merge. I don't have permission to do this myself (despite being able to make commits to it). That should put me back into the strange situation of not being able to pull your changes with Github desktop, but I'll handle it manually now :^) |
not sure how to do it with github desktop, but with cli you should be able to fetch |
Wew brilliant, sorry for the nuisance there! I'll make those edits tomorrow evening after finishing marking 62 masters QIT assignments 😭 |
Closing this in favour of #658 |
Luc: v3.7 was sensible on NUMA machines “by default” through first-touch initialization. This had been lost in v4 as idnetified by James Richings. Here’s some basic numa-aware allocation, and a little love for general parallel/openmp usage. - If we’re on *nix _and_ we find libnuma, we enable NUMA-aware allocaitons - Add & use cpu_allocNumaArray() and cpu_deallocNumaArray for the state-vector allocations (as the current alloc functions are also used for many smaller regions). Fall-back to normal allocation functions if NUMA-unaware. - Perform zero-initialization in parallel (still with std::fill() but use a parallel region) - Make getCurrentNumThreads() work inside parallel regions (!) - Add getAvailableNumThreads() to get thread count outside parallel regions. Improve this from previous getCurrentNumThreads() to only call the omp function once (rather than once per thread). Luc coded the logic and Tyson added doc and error-handling. PR #658 replaced the original of #652 --------- Co-authored-by: Luc Jaulmes <ljaulmes@ed.ac.uk>
v3.7 was sensible on NUMA machines “by default” through first-touch initialization. This had been lost in v4 as idnetified by James Richings. Here’s some basic numa-aware allocation I use, wrapped in
NUMA_AWARE
guards. And a little love for general parallel/openmp usage.libnuma
, we enable NUMA-aware allocaitonscpu_allocNumaArray()
andcpu_deallocNumaArray
for the state-vector allocations (as the current alloc functions are also used for many smaller regions). Fall-back to normal allocation functions if NUMA-unaware.std::fill()
but use a parallel region)getCurrentNumThreads()
work inside parallel regions (!)getAvailableNumThreads()
to get thread count outside parallel regions. Improve this from previousgetCurrentNumThreads()
to only call the omp function once (rather than once per thread).