openblas-src
openblas-src copied to clipboard
Disable OpenBLAS threading by default
Rust code assumes that threads can be used without restriction. So, by default, we should disable OpenBLAS threading and enable locking with USE_THREAD=0 USE_LOCKING=1
, since the docs indicate that threading by the application conflicts with threading by OpenBLAS. We can allow the user to enable OpenBLAS threading if desired with an environment variable. (An environment variable is more appropriate than a feature flag, because only the user building the final binary has enough information to know whether enabling OpenBLAS threading is safe for their application.)
I just wanted to mention that we have run into this issue several times, both when using openblas-src, but also when using OpenBLAS with threaded applications outside the Rust ecosystem. The only way to reliably use OpenBLAS reliably in threaded applications is to build it with USE_THREAD=0 USE_LOCKING=1
as @jturner314 suggests, or enabling threading and locking and using one of the environment variables mentioned in the linked FAQ entry (e.g. OPENBLAS_NUM_THREADS=1
).
So, it would be great if the defaults could be changed or at least if USE_LOCKING
and the threading options could be toggled with a feature.
Thank you for the feedback. We have to decide what to make the default. It feels like we want it to be disabled by default to provide as much safety as possible. For experienced users, there will be a feature to enable.