Conversation
|
Yes, I agree. This seems to currently be the only way to fix this problem when installing blaspp. Is there a compelling reason to choose pthreads over openmp? |
|
The alternative that I had attempted is something like this: But this doesn't work. |
|
No, please don't! This is an issue for downstream parallel libraries like Trilinos that assume they manage the parallelism. Our particle transport codes use MPI and OpenMPI parallelism and make BLAS calls from each process/thread; with parallel BLAS that means extra threads stepping on each other.
|
I picked pthread because openmp might be less portable as a default (looking at you, AppleClang 👀 )
That's right, Spack unfortunately does not support this syntax.
Ah dang it, thanks for the note. What do we do now? 😱 Does someone know if I also found notes like these (We don't set And for Power8: There is more:
|
|
For this one: did you try with the ASP based solver too (if that doesn't work I would consider it a bug)? |
|
Random question: does the ASP solver also recognize conflicts, so he does not need to specify |
|
@ax3l Yep |
|
w/o this PR, a general The result is might be odd: It picks an old openblas instead of switching the thread variant. Probably needs to be seen what is picked in context, e.g. with |
I haven't tried the ASP solver (I assume it is only available for testing through "spack solve"?). What do I need to do to use it? I see that clingo is required, but when I installed and loaded it within spack, I still get some error "Error: module 'clingo' has no attribute 'Control'". |
|
Out of curiosity -- I hadn't heard of blaspp before this but had been hoping that a better API for BLAS existed outside of Trilinos' kind of sketchy Teuchos wrappers. (There are numerous issues with BLAS and LAPACK in mixed-compiler environments, including e.g. the Apple-distributed VecLib, and windows/intel toolchains.) Is Blaspp intended to solve those problems? For the reasons I mentioned above (working with apps that manage parallelism independently from the underlying linear algebra libraries) we wouldn't be able to use BLASpp if it requires BLAS-level multithreading. What is the underlying reason for the conflict with |
@becker33 just told me the way again to try the new solver (config ref): spack install clingo@master,spack
spack load --first clingo@master,spack
# default value config:concretizer:original
spack config add config:concretizer:clingo
@G-Ragghianti and @mgates3 are the perfect people to ask for your questions! It's part of ECP SLATE and early adopters that we are we use the nice C++ API in ECP WarpX :) References for OpenBLAS issues: #20956 and (resolved/hidden) comments in #19311 |
Hi Seth. @mgates3 is the lead on blaspp (and SLATE), so he can give you more details if needed. I believe that a recent openblas update introduced something that isn't thread safe unless you configure it with pthreads or openmp support. The reason blaspp can't automatically request thread support in openblas is that blaspp needs to be able to support other blas implementations though the "blas" virtual dependency. This causes a problem with the current default spack concretizer (see my "depends_on" example above). It may work with the new concretizer. I'm about to test that. |
Thanks @G-Ragghianti . I understand the spack limitations on propagating the |
|
@mgates3 documented the issues here
More notes on virtual variants, see #1712 and #6300. @G-Ragghianti @mgates3 have you had the change to verify the OpenBLAS USE_LOCKING option solves your observed test failures? We can easily add this to |
I haven't tested USE_LOCKING for openblas, but I will soon. I can verify that the clingo concretizer does seem to correctly handle the following simultaneous dependencies: This allows me to use a different blas provider with no complication. |
BlasPP by ECP SLATE will fail to install by default (`spack install blaspp`) because: - the default BLAS installation in Spack is OpenBLAS - BlasPP conflicts with `threads=none` for all recent OpenBLAS releases Luckily, for OpenBLAS itself introduced a threadsafe compile option with 0.3.7+ aka `USE_LOCKING`: ``` 61 # If you want to build a single-threaded OpenBLAS, but expect to call this 62 # from several concurrent threads in some other program, comment this in for 63 # thread safety. (This is done automatically for USE_THREAD=1 , and should not 64 # be necessary when USE_OPENMP=1) 65 # USE_LOCKING = 1 ``` According to my tests, with `spack install --test root blaspp`, this exactly addresses the issues in BlasPP tests. It also seems to be a good option to set by default for OpenBLAS and users that do not need this safety net can always disable it.
|
I would even go more concrete to use (Works well with clingo, does fail with the original dependency solver)
Wuhu, thanks to the great test/check implementation in the Indeed, enabling I updated this PR to reflect the changes in OpenBLAS and BLAS++ and will wait for your and @mgates3's confirmation that this indeed is the solution. I already did 0.3.6
0.3.7
Otherwise this should work because of the
0.3.8
0.3.9
0.3.13 (latest)Probably the most important test, because this is the default user experience with Spack:
Just checking, because yolo:
Any without locking
|
ef4955f to
fe3ccfe
Compare
|
Lot of things happening overnight... 🙂 FYI, to bootstrap @G-Ragghianti config:
concretizer: clingoand ensure Spack can import the |
Friday evenings aren't as they used to be 😅 |
Solve issues with newer OpenBLAS by requiring `+locking` over none-default threading options.
fe3ccfe to
9c4be71
Compare
alalazo
left a comment
There was a problem hiding this comment.
Basically LGTM, just a minor question.
| conflicts('+consistent_fpcsr', when='threads=none', | ||
| msg='FPCSR consistency only applies to multithreading') | ||
|
|
||
| conflicts('threads=pthreads', when='~locking', msg='Pthread support requires +locking') |
There was a problem hiding this comment.
Shouldn't we add also:
conflicts('threads=openmp', when='~locking', msg='OpenMP support requires +locking')There was a problem hiding this comment.
I thought so for a moment, but the OpenBLAS docs on USE_LOCKING read:
This is done automatically for USE_THREAD=1, and should not be necessary when USE_OPENMP=1.
There was a problem hiding this comment.
Sure, not talking about the recipe, just the spec. I think openblas threads=openmp ~locking won't make sense (but we can work on that in a later PR).
There was a problem hiding this comment.
I think if I follow the docs that this is advertised as working, but I would not default to it reading the wording :D
Oddly, this is exactly what we also want in BLAS++: that BLAS++ does the OpenMP parallelism for a batched-BLAS call, and BLAS itself is single threaded. But it seems (at least in some environments) that non-threaded OpenBLAS is not thread safe, so we get failures. Hence the conflict with openblas threads=none. Adding locking without threading would be sufficient for BLAS++. Same applies to SLATE, which is the parent project that BLAS++ was built within, that SLATE handles the parallelism and BLAS should generally be single threaded. |
We can investigate these issues. I thought with Mark |
|
Interesting, I was assuming that openmp and pthreads both meant "use this threading implementation to maximize CPU utilization" rather than "be aware of downstream library's utilization of these threading implementations". For the OpenMP case, it sounds like it's the latter? |
|
Thanks @ax3l ! |
|
Thank you all, too! Epic that we got this solved! :) |
HI Axel. I've found that these cmake failures (unable to detect blas) only occur when using gcc >=10. We will be looking into it. Thanks for finding it. |
|
Thanks @G-Ragghianti! :) |
BlasPP by ECP SLATE will fail to install by default (
spack install blaspp) becausethreads=nonefor all recent OpenBLAS releasesLuckily, for OpenBLAS itself introduced a threadsafe compile option with 0.3.7+ aka
USE_LOCKING:According to my tests, with
spack install --test root blaspp, this exactly addresses the issues in BlasPP tests.It also seems to be a good option to set by default for OpenBLAS and users that do not need this safety net can always disable it.
cc @G-Ragghianti @mgates3
Follow-up to #20956