Ensure that blas_thread_init has been called in openblas_set_num_threads #1837
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.
Not doing so can lead to bugs if the process happens to have been forked at some point. For example:
This leads to segfaults because currently
openblas_set_num_threads
assumesblas_thread_init()
has already been called andblas_server_avail == 1
. But after a fork, due to thepthread_atfork
handler which callsblas_thread_shutdown
, this is no longer the case. But then when you get intoexec_blas_async
it does callblas_thread_init()
even though there are already threads running, creating a likelihood that one or more of those threads segfault.