OpenBLAS
OpenBLAS copied to clipboard
Release OpenMP resources in blas_thread_shutdown
OpenMP 5.0 gained an omp_pause_resource_all function designed to release the locks before forking the process. The parameters are described in the omp_pause_resource function. Using this function makes it possible for OpenMP builds of OpenBLAS to pass fork safety tests.
An important detail is that there exist OpenMP implementations that only claim OpenMP 4.5 compatibility (i.e. they #define _OPENMP 201511) while they do have the omp_pause_resource_all. We currently don't have a way to use omp_pause_resource_all with such implementations (e.g. GCC 10 on Debian 11).
The first commit adds the omp_pause_resource_all call to blas_thread_shutdown. You may want not to merge this if you'd like blas_thread_shutdown to be safe to call while other OpenMP operations are in progress.
The second commit adds a convoluted way to test fork safety of the resulting build on OpenMP ≥ 5.0 in addition to non-OpenMP builds. I'd be glad to see a better way of testing for OpenMP ≥ 5.0 in a Makefile.
Thanks - I have not had time to review in detail, but perhaps it might be better to put the OpenMP version test in the c_check script rather than getarch
Thanks for your reply!
What do you think about skipping the test using the same mechanism that currently skips it on builds without double precision support? It seems to make for a smaller diff.
I could definitely use c_check if you prefer it for architectural reasons and the omp_pause_resource_all() idea turns out to be sound. (I didn't originally notice that you have a mechanism for checking preprocessor symbols.)