fix[cartesian]: MacOS & OpenMP: skip the multithreading#2491
fix[cartesian]: MacOS & OpenMP: skip the multithreading#2491FlorianDeconinck wants to merge 3 commits intoGridTools:mainfrom
Conversation
|
Adding @tehrengruber as reviewer to check with PMAP people if they are running with openmp on mac for development. |
There was a problem hiding this comment.
I'd also suggest to add minimal tests (e.g. we run daily CI on MacOS hardware) to catch obvious errors like deactivating OpenMP on the wrong platform.
Also, we might wanna allow OpenMP on MacOS systems if used in combination with GCC (like we do - without issues - on the daily CI).
| # would require brew, we cancel it altogether. A slightly narrower configuration | ||
| # would run a test on the compiler for OpenMP directives support | ||
| self.options.uses_openmp = True | ||
| if platform.system() != "Darwin": |
There was a problem hiding this comment.
This condition is "the wrong way around" and deactivates OpenMP support except on MacOS devices.
| # Dev NOTE: MacOS is not issue, apple-clang is. But because a proper OpenMP | ||
| # would require brew, we cancel it altogether. A slightly narrower configuration | ||
| # would run a test on the compiler for OpenMP directives support | ||
| self.options.uses_openmp = True |
There was a problem hiding this comment.
Do we need to set the default? Isn't this covered by changes in src/gt4py/cartesian/definitions.py?
| warnings.warn( | ||
| "Multithreading is deactivated under MacOS due to apple-clang " | ||
| "not handling OpenMP by default.", | ||
| category=UserWarning, | ||
| stacklevel=2, | ||
| ) |
There was a problem hiding this comment.
Warning here is very verbose because it will warn for every stencil built, e.g. in the current test log we see a bunch of these warning messages (because the condition is wrong - see above).
I suggest to test this once (I'd probably put in in src/gt4py/cartesian/config.py) and only warn once there. It also seems to be more consistent with build_settings setup there rather than make this a (per-stencil configurable) BuildOption because this won't change per-stencil.
|
My bad - this was supposed to be a draft. Thanks for the review, I'll be back on it today |
Description
This PR deactivate OpenMP when detecting MacOS (
Darwin) as the OS.The reason are simple
apple-clangdon't ship withopenmpby default and the way to acquire it is requiresbrewor other workaround we won't expect out of our users.In detail the PR:
omp_get_max_threadsfrom codegen on the glue code of stencil DaCe backends when all the computes are sequential (non MacOS related),StencilBuilderto centralize deactivation of OpenMP and turn it off when detectingDarwin(+ warning),openmpflags from the command line based on the above option.Requirements