openblas: do not use OpenMP with Clang#806
Conversation
| # Note: Apple's Clang 7.3.0 does not support OpenMP. | ||
| # For now, disable OpenMP if we compile with clang. | ||
| if ('+openmp' in spec) and (self.compiler.name != 'clang'): | ||
| make_defs += ['USE_OPENMP=1'] |
There was a problem hiding this comment.
@davydden Please provide at least a warning : clang is not only Apple's Clang and it would be annoying if a spec like
openblas+openmp%clang
build without complaints discarding the openmp support. Have you considered just changing the default value for openmp and exit with failure if openblas+openmp%clang is built on OSX?
There was a problem hiding this comment.
how do I output warnings in Spack packages?
There was a problem hiding this comment.
print does not print to the terminal, there must be a command to display a warning, but i never used it.
ff81249 to
b0c3a89
Compare
| # Note: Apple's Clang 7.3.0 does not support OpenMP. | ||
| # For now, disable OpenMP if we compile with clang on OSX. | ||
| if (sys.platform == 'darwin') and (self.compiler.name == 'clang'): | ||
| print "Warning: +openmp is ignored on OSX when building with Clang." |
There was a problem hiding this comment.
this does not output warning to the terminal. How do I do that?
that is another option, to do via |
b0c3a89 to
b4c841b
Compare
|
@alalazo i updated PR as you suggested. But I would wait for a feedback from other guys. |
| # Note: Apple's Clang 7.3.0 does not support OpenMP. | ||
| # For now, raise an error if we compile with clang on OSX. | ||
| # TODO: one could still have a self-compiled clang-omp on OSX... | ||
| if (sys.platform == 'darwin') and (self.compiler.name == 'clang'): |
There was a problem hiding this comment.
Please don't do this; OpenMP works fine e.g. with the MacPorts clang since version 3.7. (Current is 3.8.)
There was a problem hiding this comment.
@eschnett do you mind suggesting the alternative code to make it pick-up Apple's native Clang?
There was a problem hiding this comment.
Do you want to pick up Apple's clang, or do you want to check whether the compiler supports OpenMP? The latter is more difficult, but the "right thing" to do. Using version numbers will always be iffy.
I would check the version number. Do you have an example of a broken version number? You could simply disallow versions >=7, with an appropriate comment, and open an issue with Spack to handle this in a cleaner way.
There was a problem hiding this comment.
i agree that a check whether the compiler supports OpenMP is the right thing to do, but it is on the different scale.
For now, it would be fine to make it work on native Clang. I will update the PR so that it hopefully does not break the usage of OpenMP with a non-native Clang.
b4c841b to
ccbc4fb
Compare
|
i updated the PR, @eschnett : could you please check that it does not break the usage of MacPorts clang which does support OpenMP? (i don't have Macports myself). |
1db989b to
e781716
Compare
|
@davydden I'll check. Note that anybody can test this, as the current condition does not depend on whether one uses OS X or not. Testing with clang on Linux would answer the question as well. Having said this, I don't think the test is right. This test will disallow all versions of clang up to and including |
|
@eschnett i updated the test to |
|
Funny, I just see this: ifeq ($(C_COMPILER), CLANG)
$(error OpenBLAS: Clang didn't support OpenMP yet.)
CCOMMON_OPT += -fopenmp
endifThat is, OpenBlas (!) hardcodes that OpenMP cannot be used with a compiler called clang. (This is OpenBLAS 0.2.17.) Given this, we should do the same in our package -- any compiler called That also means that the current check in |
|
so are you suggesting to change from to with an appropriate comment that Openblas hardcoded that OpenMP cannot be used with any clang? |
|
@davydden Yes, exactly. |
|
Also, OpenBLAS 0.2.18 has been released. Let me check whether it handles things differently -- if so, we will need your more complex condition after all. |
|
ok... |
|
No change with OpenBLAS 0.2.18; it still checks for |
|
Might as well add 0.2.18 as part of this PR then. I agree that the easiest thing to do is probably just to remove the variant altogether and always build with OpenMP unless the compiler is |
|
@eschnett @adamjstewart i updated the PR to do OpenMP always unless we use clang. |
|
@davydden |
|
@alalazo: ok, i see. I will put back the variant... |
|
Great. I guess let's keep it as a variant then? Would everyone like to vote on defaulting to True or False? |
|
@davydden @adamjstewart Any default value for the variant would do for me. |
c609975 to
b4cb956
Compare
|
@adamjstewart @alalazo @eschnett : updated the PR with a variant. |
|
Looks good to me! |
| # What is worse, Openblas (as of 0.2.18) hardcoded that OpenMP cannot | ||
| # be used with any (!) compiler named clang, bummer. | ||
| if spec.satisfies('%clang'): | ||
| raise InstallError('OpenMP is not currently supported by Openblas with Clang! Install without +openmp') |
There was a problem hiding this comment.
It'd say instead OpenBLAS does not support OpenMP with clang instead.
Yes, looks good.
will do. |
|
@davydden Thank you very much |
258bc43 to
2dd9f5a
Compare
|
@alalazo i move this commit to another PR. This one is clean again and should be ready to merge. |
2dd9f5a to
8c0e1f8
Compare
|
@tgamblin this is ready to merge 👍 😄 |
8c0e1f8 to
26029ef
Compare
…o false by default
26029ef to
72b9175
Compare
|
Changing the default seems reasonable. I'm coming to this late, but why have spack print an error rather than just let the package fail? Either way, the result is the same, but this way there will be more work to do in spack if and when they fix their clang+openmp handling right? |
|
@trws: Openblas takes like 45 minutes to build. I would rather have Spack fail instantly than have Openblas fail much later. But what we could do is call |
|
Is that functionality going in like that @adamjstewart? I'm all good with checking whether the compiler supports OpenMP and bailing early (really that's what their build system should do...), but encoding it the way they did just based on the compiler name feels wrong is all. |
|
@adamjstewart Maybe I remember it the wrong way, but the clang+OpenMP combination fails immediatly... |
It will when #882 gets merged :) @alalazo: That's good. I guess either one would be fine, but calling |
|
I'll probably comment on #882, but having it be based on flags rather than capabilities feels odd. Build systems shouldn't count on spack to supply the right flag for a compiler like that, either way though checking functionality is a good thing. |
That would rule out Apple's clang (after #882 is merged), which does not support
correct. But I think it's still better to make it fail before with some reasonable message. Otherwise it fails to configure (hopefully during configure and not compilation) and then the user needs to dig into logs to see what's wrong. |
|
Ah, you're right. In that case, I'm good with the way things are now. |
|
It does, for now, but they will eventually regain their sanity and fix their build system. I'd rather not have to have someone come back in and special-case this again because of it. |
|
@trws so you suggest to keep |
|
Either that, or do an actual check for whether it does or does not support OpenMP, yes. |
by it you mean |
|
I think Spack should contain logic to help people navigate broken build systems. If If all it takes is a single |
|
i agree with @eschnett and would suggest to keep it the way it is now with a code comment which explains the problem and a readable error message for a user. |
fixes #799 .
@adamjstewart @gartung ping.