Release OpenMP resources in blas_thread_shutdown #4080
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
OpenMP 5.0 gained an
omp_pause_resource_all
function designed to release the locks beforefork
ing the process. The parameters are described in theomp_pause_resource
function. Using this function makes it possible for OpenMP builds of OpenBLAS to passfork
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 theomp_pause_resource_all
. We currently don't have a way to useomp_pause_resource_all
with such implementations (e.g. GCC 10 on Debian 11).The first commit adds the
omp_pause_resource_all
call toblas_thread_shutdown
. You may want not to merge this if you'd likeblas_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.