-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Could you elaborate on the combination of OpenBLAS with multi-threading? #2543
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
This is a bit unspecific as none of the original developers is still available to explain the reasoning behind certain concepts, and very litte documentation was left. What has become clear in the last few years is that the original GotoBLAS was in no way thread-safe, probably owing to the fact that off-the-shelf multicore systems were quite uncommon 10+ years ago. Since then, many issues have been addressed - mostly by rather heavy-handed locking, but there may still be corner cases left to surprise us. |
@martin-frbg Thanks for your reply! This is already very useful. I think more of this should be added to the wiki / docs -- I imagine there will be more contributors helping out with that situation if this is clearer, as there are some people that are really into threading. The thread-contention part makes a lot of sense, that is a common problem. On the topic of thread-safety, a couple of follow-up questions arise (but I understand that you may not be able to answer them fully). One would be "Is it unsafe to use OpenBLAS compiled/run with OpenMP enabled from a managed, threaded language like Haskell or Go, where some code paths lead through C++ wrapper code that itself uses OpenMP, wile other code paths use OpenBLAS directly from the outer language", and it seems that the answer is "It is probably unsafe as we do not quite understand all parts of the code and Another one is: Is my understanding correct that |
I'd add more to the wiki if I were confident about it - unfortunately I have no local access to big |
I'm not sure if you've considered this, but coming up with a coherent design and/or implementing it sounds like it could be an advanced GSoC project, with possible mentoring from yourself and other knowledgeable parties (@xianyi? @wjc404? @brada4? @stevengj?). See also: #2255, #2392. |
Thanks for the suggestion, but I do not see how the added complexity of mentoring a (necessarily inexperienced) GSoC participant would ease the pressure on the extremely small number of current developers at this stage. |
The reality is that there will be no long lazy summer for most. Not a beneficial idea for either side to push named student through missing grunt work in the project. But if there is outside summer project that produces measurably beneficial result in form of a pull request - the result is more than welcome. Say ML-focused tuning as part of other project etc. |
Hi. Thank you all for the comments on this issue so far. I’m still a little confused about the use of USE_THREAD, USE_LOCKING and USE_OPENMP when building OpenBLAS. I’m reading USE_THREAD as “USE_PTHREAD”. So, ... To build with pthread support I should use USE_THREAD=1, USE_OPENMP=0 To build with OpenMP support I should use USE_THREAD=0, USE_OPENMP=1 To build a serial version I should use USE_THREAD=0, USE_OPENMP=0, but with USE_LOCKING=1 for the reason in the previous comments. Is my thinking correct. Best wishes John |
Almost - the OpenMP support sits on top of threads support so USE_THREAD=1 USE_OPENMP=1 |
Great, got it. Thanks for the swift reply. |
OpenBlas's implementation is not thread safe. Thus when used within parallel_for, it produces incorrect output. This has been documented in a few places like here OpenMathLib/OpenBLAS#1441 and OpenMathLib/OpenBLAS#2543. I tried few options to disable openblas's multithreading but none of them seemed to work. It is possible that upstream openblas has fixed this. Will validate this by pulling in latest, but in the meanwhile using eigen_blas to unblock. Differential Revision: [D64334733](https://our.internmc.facebook.com/intern/diff/D64334733/) [ghstack-poisoned]
OpenBlas's implementation is not thread safe. Thus when used within parallel_for, it produces incorrect output. This has been documented in a few places like here OpenMathLib/OpenBLAS#1441 and OpenMathLib/OpenBLAS#2543. I tried few options to disable openblas's multithreading but none of them seemed to work. It is possible that upstream openblas has fixed this. Will validate this by pulling in latest, but in the meanwhile using eigen_blas to unblock. Differential Revision: [D64334733](https://our.internmc.facebook.com/intern/diff/D64334733/) ghstack-source-id: 247927422 Pull Request resolved: #6197
OpenBlas's implementation is not thread safe. Thus when used within parallel_for, it produces incorrect output. This has been documented in a few places like here OpenMathLib/OpenBLAS#1441 and OpenMathLib/OpenBLAS#2543. I tried few options to disable openblas's multithreading but none of them seemed to work. It is possible that upstream openblas has fixed this. Will validate this by pulling in latest, but in the meanwhile using eigen_blas to unblock. Differential Revision: [D64334733](https://our.internmc.facebook.com/intern/diff/D64334733/) [ghstack-poisoned]
Pull Request resolved: #6197 OpenBlas's implementation is not thread safe. Thus when used within parallel_for, it produces incorrect output. This has been documented in a few places like here OpenMathLib/OpenBLAS#1441 and OpenMathLib/OpenBLAS#2543. I tried few options to disable openblas's multithreading but none of them seemed to work. It is possible that upstream openblas has fixed this. Will validate this by pulling in latest, but in the meanwhile using eigen_blas to unblock. ghstack-source-id: 247950073 @exported-using-ghexport Differential Revision: [D64334733](https://our.internmc.facebook.com/intern/diff/D64334733/)
Summary: Pull Request resolved: #6197 OpenBlas's implementation is not thread safe. Thus when used within parallel_for, it produces incorrect output. This has been documented in a few places like here OpenMathLib/OpenBLAS#1441 and OpenMathLib/OpenBLAS#2543. I tried few options to disable openblas's multithreading but none of them seemed to work. It is possible that upstream openblas has fixed this. Will validate this by pulling in latest, but in the meanwhile using eigen_blas to unblock. ghstack-source-id: 247950073 exported-using-ghexport Reviewed By: guangy10, nausicaasnow Differential Revision: D64334733 fbshipit-source-id: a7117233584860c2910f45bfaa8dd8fa41f9f28d
OpenBlas's implementation is not thread safe. Thus when used within parallel_for, it produces incorrect output. This has been documented in a few places like here OpenMathLib/OpenBLAS#1441 and OpenMathLib/OpenBLAS#2543. I tried few options to disable openblas's multithreading but none of them seemed to work. It is possible that upstream openblas has fixed this. Will validate this by pulling in latest, but in the meanwhile using eigen_blas to unblock. Differential Revision: [D64398816](https://our.internmc.facebook.com/intern/diff/D64398816/) [ghstack-poisoned]
OpenBlas's implementation is not thread safe. Thus when used within parallel_for, it produces incorrect output. This has been documented in a few places like here OpenMathLib/OpenBLAS#1441 and OpenMathLib/OpenBLAS#2543. I tried few options to disable openblas's multithreading but none of them seemed to work. It is possible that upstream openblas has fixed this. Will validate this by pulling in latest, but in the meanwhile using eigen_blas to unblock. Differential Revision: [D64398816](https://our.internmc.facebook.com/intern/diff/D64398816/) ghstack-source-id: 248080389 Pull Request resolved: #6229
OpenBlas's implementation is not thread safe. Thus when used within parallel_for, it produces incorrect output. This has been documented in a few places like here OpenMathLib/OpenBLAS#1441 and OpenMathLib/OpenBLAS#2543. I tried few options to disable openblas's multithreading but none of them seemed to work. It is possible that upstream openblas has fixed this. Will validate this by pulling in latest, but in the meanwhile using eigen_blas to unblock. Differential Revision: [D64398816](https://our.internmc.facebook.com/intern/diff/D64398816/) [ghstack-poisoned]
Pull Request resolved: #6229 OpenBlas's implementation is not thread safe. Thus when used within parallel_for, it produces incorrect output. This has been documented in a few places like here OpenMathLib/OpenBLAS#1441 and OpenMathLib/OpenBLAS#2543. I tried few options to disable openblas's multithreading but none of them seemed to work. It is possible that upstream openblas has fixed this. Will validate this by pulling in latest, but in the meanwhile using eigen_blas to unblock. ghstack-source-id: 248095356 @exported-using-ghexport Differential Revision: [D64398816](https://our.internmc.facebook.com/intern/diff/D64398816/)
Summary: Pull Request resolved: #6229 OpenBlas's implementation is not thread safe. Thus when used within parallel_for, it produces incorrect output. This has been documented in a few places like here OpenMathLib/OpenBLAS#1441 and OpenMathLib/OpenBLAS#2543. I tried few options to disable openblas's multithreading but none of them seemed to work. It is possible that upstream openblas has fixed this. Will validate this by pulling in latest, but in the meanwhile using eigen_blas to unblock. ghstack-source-id: 248095356 exported-using-ghexport Reviewed By: cccclai Differential Revision: D64398816 fbshipit-source-id: 46f2d10855007e35e5d6fb925e494f12330978fa
Uh oh!
There was an error while loading. Please reload this page.
https://github.com/xianyi/OpenBLAS/wiki/Faq/4bded95e8dc8aadc70ce65267d1093ca7bdefc4c#multi-threaded says:
That is good to know, but it is very unspecific.
To aid people debugging problems, could you elaborate a bit on that? What does "will conflict" mean exactly here? How do things break? What are the fundamental technical reasons?
Also, many Linux distributions ship OpenBLAS with OpenMP enabled. And then bindings from other, programming languages that have their own built-in threading which is not based on OpenMP (Haskell, Go, etc) use the distribution-provided packages, often without setting
OPENBLAS_NUM_THREADS=1
oropenblas_set_num_threads(1)
.In my understanding, this violates what's stated in https://github.com/xianyi/OpenBLAS/wiki/faq#multi-threaded and is thus unsafe. Can you, as a general guideline, confirm whether languages with built-in threading must address this?
Thanks!
The text was updated successfully, but these errors were encountered: