-
Notifications
You must be signed in to change notification settings - Fork 80
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
Enforce nthreads = 1 for single threaded lib #431
Conversation
I'm looking at this now too, and another option would be to use the same approach as the one in Lines 269 to 271 in 9744d14
I don't have any argument for why one would be better than the other, but could be good to be consistent! Edited to confirm that this does seem to fix flatironinstitute/jax-finufft#73. |
Do you mean these lines https://github.com/lu1and10/finufft/blob/9744d14b07b2d25bb9e5326d549bb1d7971a7f88/src/spreadinterp.cpp#L269-L271 |
the change here does not cap nthreads to omp_get_max_threads if omp is enabled, this is the same as the original code Line 596 in 9744d14
It only cap nthreads to 1 if omp is not enabled. @dfm suggests we could be consistent with spreader as in Lines 269 to 271 in 9744d14
|
My vote is for consistency. Always cap threads at the requested thread count. If it's single a single threaded build: |
I see, let's see what @ahbarnett 's thought about whether to use omp_get_max_threads or user requested threads count to cap nthreads. The warning could be better, English is not my native.... Concise and pretty warning message is appreciated. |
Thanks for parsing the logic here. I agree we should cap to omp_get_max_threads() and that being set to 1 indicates single-thread mode without invoking #ifdefs. So I like Dan's idea of following what I did in spreadinterp, but adding the warning. I'm going to try and push to your PR, Libin. |
Thanks @ahbarnett, not sure you can push to my fork, added you to the fork collaborator, maybe we should use the official finufft repo creating a new branch for PR later on. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was good and respected the "unlimited thread override" the user could do. But based on Libin + Dan + Robert suggestions, I changed it to always limit to maxnthr given by OMP ( = 1 if single-threaded build, as per defs.h header), matching spreadinterp, and preventing JAX crashes.
Happy for Libin etc to pull in, assuming CI good. Thanks! |
I forgot to update CHANGELOG and docs. Will do it in master. We should always do this for changes to behavior (what if a user relied on setting nthr > get_max_omp_threads() ?) |
… ifndef _OPENMP hard nthr=1 override; warnings at the finufft level only; binsort controlled by spopts.sort_threads matching docs
Enforce nthreads = 1 for single threaded lib, to improve the case that single threaded finufft lib running with nthreads != 1 gives inf/nan error flatironinstitute/jax-finufft#73 and #430.