-
Notifications
You must be signed in to change notification settings - Fork 12
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
Switching the threading component to C++20's atomic synchronization? #24
Comments
That makes sense to me, |
Thanks! You are certainly right, any approach with (partial) busy waiting will require more power and is likely only useful in a scenario where each thread is guaranteed to have a dedicated core on which it runs (e.g. large non-interactive scientific calculations run on a batch system).
Using this I managed to reduce the time spent for executing an empty parallel region from roughly 30 microseconds to 1.6 microseconds on the 16 hardware threads of my laptop. |
There is one problematic thing with the change: for some reason, the CI runs on MacOS become extremely slow and are cancelled before the tests can finish. I watched the run, and I'm fairly certain that there are no deadlocks; but still the whole test script slows down to a crawl (see, e.g. https://github.com/mreineck/ducc/actions/runs/7931217750). I have no idea what's causing this and whether it's a property of the testing environment... |
As part of an experiment I recently switched from
ducc
'slatch
class to C++20'sstd::latch
, and to my surprise I noticed a significant speedup when benchmarking the overhead when submitting work items to the thread pool.Looking at the source code it sees that
std::latch
(at least the one fromlibstdc++
) uses atomic synchronization (see, e.g. https://developers.redhat.com/articles/2022/12/06/implementing-c20-atomic-waiting-libstdc#). I wonder if it might be useful to switch the rest ofducc
's multithreading component to this mechanism as well.What's your opinion, @peterbell10 ?
The text was updated successfully, but these errors were encountered: