Conversation
This PR gets a GCC built python to use MKL for blas/lapack. This is not perfect and I have put comments for TODO items. The changes to intel-parallel-studio are to get the correct library path for blas. I was using that to attempt to use it but there were a couple of other issues. The changes to the mkl package are to get the proper paths in the environment module, similar to what was done previously for the intel-parallel-studio package. For py-numpy itself, the section title for the defaults changed from DEFAULTS to ALL with numpy-1.10 so that is configured accordingly. Also, for MKL to be used there must be a section called, '[mkl]'. Finally, the mkl_rt library is needed, especially when built with GCC. As such, that library is made explicit in the [mkl] section of the config file.
| env.prepend_path('LD_LIBRARY_PATH', | ||
| join_path(self.prefix, 'lib', 'intel64')) | ||
| env.prepend_path('LIBRARY_PATH', | ||
| join_path(self.prefix, 'lib', 'intel64')) |
There was a problem hiding this comment.
So you remove, and then prepend, and then prepend a second time?
There was a problem hiding this comment.
Oops, looks like duplicates sneaked in there. I will remove those.
There was a problem hiding this comment.
Also, for MKL to be used there must be a section called, '[mkl]'.
i think it can, but it does NOT have to.
Finally, the mkl_rt library is needed, especially when built with GCC.
from my experience on Ubuntu16 with GCC@5.4 i never had any needs to use mkl_rt anywhere when building trilinos, petsc, mumps, superlu_dist, hypre and a number of other linear algebra packages.
I must admit i never tried building py-numpy with MKL, but I would be surprised if it does not work.
|
|
||
| def setup_environment(self, spack_env, env): | ||
| # Remove paths that were guessed but are incorrect for this package. | ||
| env.remove_path('LIBRARY_PATH', |
There was a problem hiding this comment.
AFAIK Spack does not use LD_LIBRARY_PATH or alike anywhere, everything is RPATH'ed, why do you need all those changes?
There was a problem hiding this comment.
in other words, if for any packages in Spack you need to set LD_LIBRARY_PATH to have something working, then something is wrong.
| mkl_libs = find_libraries( | ||
| mkl_integer + ['libmkl_core'] + mkl_threading, | ||
| root=join_path(self.prefix.lib, 'intel64'), | ||
| root=join_path(self.prefix, 'mkl', 'lib', 'intel64'), |
There was a problem hiding this comment.
that looked like a bug, it's probably better have it in a separate commit.
There was a problem hiding this comment.
maybe in a separate PR which can be quickly merged. Then you will rebase this one to get rid of this change.
There was a problem hiding this comment.
I'm fine with this change being in this PR. You can't really test this PR without it I imagine.
There was a problem hiding this comment.
you surely can't. I am just saying to make things fast one could submit this change as a stand-alone PR, but still keep it here. Once a stand alone PR is merged, one can re-base this one on develop.
But i don't really insist on this, just explain my rationale.
| # mkl that package will not work here with a non-Intel | ||
| # compiler due to header collision. | ||
| f.write('[mkl]\n') | ||
| f.write('libraries=mkl_rt\n') |
There was a problem hiding this comment.
i am not in favour of this change. join(lapackblas.names) depends on whole lot of variants (32/64 bits, threaded/serial, and alike). Once you use mkl_rt here it is now up to environment variable. In other words you introduce a way to use different BLAS/LAPACK in DAG.
What was wrong exactly with 'join(lapackblas.names)? At the end of the day we give the complete library lists there and it is bound to work. At least it does in a number of other packages without a need to use mkl_rt anywhere.
There was a problem hiding this comment.
can you please try keeping f.write('libraries=%s\n' % ','.join(lapackblas.names)) unconditionally while using f.write('[mkl]\n') for MKL if py-numpy really want it this way?
|
p.s. if |
|
Okay; I guess I should have split this in multiple PRs. Regarding LD_LIBRARY_PATH, that is needed for the environment module not for the build. Regarding the other comments, yes, the [mkl] section is needed in the numpy site.cfg, unless the config is removed it would fall back to MKLROOT. It seemed better to have the section in the config rather than rely on the environment variable. Using mkl_rt is needed for numpy as far as I can tell. Intel states this as well here: https://software.intel.com/en-us/articles/numpyscipy-with-intel-mkl
Using mkl_rt can be directed by environment variables at run time but it does not depend on them. I think that addresses the bulk of the comments. I am not really sure how to proceed here given the comments. |
still don't understand why. Everything is built with RPATH's in Spack, so
I am not saying it does not build with So please try using
it's not about that. The whole point of NOT using it is to provide consistent BLAS/LAPACK everwhere in the DAG. That is done through the extra class which holds libraries and have methods like
Please try p.s. edited based on @adamjstewart answer below. |
|
FYI, from SciPy org (emphasize is mine):
"shown above" is |
Python packages (like |
that explains a lot, thanks |
|
@davydden Note the caveat that GCC requires mkl_rt, not the intel compiler, which is what your link refers to. Also, I did try to make it work with the standard blas_libs before agreeing with Intel that GCC requires mkl_rt. Anyway, I will close this PR as clearly I have missed the mark. |
but why? As I said above i had no problems building with MKL (without
what was the problem? |
|
for the record, Intel's link advisor with Select compiler: Gnu C/C++ says so i see no reason why GCC would need |
This PR gets a GCC built python to use MKL for blas/lapack. This is not perfect and I
have put comments for TODO items.
The changes to intel-parallel-studio are to get the correct library path for blas. I was
using that to attempt to use it but there were a couple of other issues. The changes to
the mkl package are to get the proper paths in the environment module, similar to what
was done previously for the intel-parallel-studio package.
For py-numpy itself, the section title for the defaults changed from DEFAULTS to ALL with
numpy-1.10 so that is configured accordingly. Also, for MKL to be used there must be a
section called, '[mkl]'. Finally, the mkl_rt library is needed, especially when built
with GCC. As such, that library is made explicit in the [mkl] section of the config file.