some fixes to blas/lapack usage in packages (#1852)

* atlas: fix unit test

* openblas: remove symlinks; use lapack_libs.ld_flags in the test

* mkl: fix openmp variant of blas/lapack libs

* intel-parallel-studio: fix openmp variant of blas/lapack libs

* netlib-scalapack: fix blas/lapack for multilib case (e.g. mkl)

* arpack-ng: fix blas/lapack for multilib case (e.g. mkl)

* petsc: explicitly specify blas/lapack

* minor

* cantera: fix blas/lapack usage

* ipopt: fix blas/lapack usage

* netlib-lapack: fix external blas usage

* mfem: fix lapack/blas usage

* superlu-mt: fix blas usage

* flake8 fixes
This commit is contained in:
Denis Davydov 2016-09-26 19:37:23 +02:00 committed by Todd Gamblin
parent cb36aadaf6
commit 1e10309ff7
12 changed files with 29 additions and 43 deletions

View File

@ -88,8 +88,8 @@ def install(self, spec, prefix):
options.append('-DCMAKE_INSTALL_NAME_DIR:PATH=%s/lib' % prefix) options.append('-DCMAKE_INSTALL_NAME_DIR:PATH=%s/lib' % prefix)
# Make sure we use Spack's blas/lapack: # Make sure we use Spack's blas/lapack:
lapack_libs = spec['lapack'].lapack_libs.joined() lapack_libs = spec['lapack'].lapack_libs.joined(';')
blas_libs = spec['blas'].blas_libs.joined() blas_libs = spec['blas'].blas_libs.joined(';')
options.extend([ options.extend([
'-DLAPACK_FOUND=true', '-DLAPACK_FOUND=true',

View File

@ -142,7 +142,7 @@ def install_test(self):
'test_cblas_dgemm.output') 'test_cblas_dgemm.output')
include_flags = ["-I%s" % self.spec.prefix.include] include_flags = ["-I%s" % self.spec.prefix.include]
link_flags = self.lapack_libs.ld_flags link_flags = self.lapack_libs.ld_flags.split()
output = compile_c_and_execute(source_file, include_flags, link_flags) output = compile_c_and_execute(source_file, include_flags, link_flags)
compare_output_file(output, blessed_file) compare_output_file(output, blessed_file)

View File

@ -85,8 +85,9 @@ def install(self, spec, prefix):
# BLAS/LAPACK support # BLAS/LAPACK support
if '+lapack' in spec: if '+lapack' in spec:
lapack_blas = spec['lapack'].lapack_libs + spec['blas'].blas_libs
options.extend([ options.extend([
'blas_lapack_libs=lapack,blas', 'blas_lapack_libs={0}'.format(','.join(lapack_blas.names)),
'blas_lapack_dir={0}'.format(spec['lapack'].prefix.lib) 'blas_lapack_dir={0}'.format(spec['lapack'].prefix.lib)
]) ])

View File

@ -64,7 +64,10 @@ def blas_libs(self):
shared = True if '+shared' in self.spec else False shared = True if '+shared' in self.spec else False
suffix = dso_suffix if '+shared' in self.spec else 'a' suffix = dso_suffix if '+shared' in self.spec else 'a'
mkl_integer = ['libmkl_intel_ilp64'] if '+ilp64' in self.spec else ['libmkl_intel_lp64'] # NOQA: ignore=E501 mkl_integer = ['libmkl_intel_ilp64'] if '+ilp64' in self.spec else ['libmkl_intel_lp64'] # NOQA: ignore=E501
mkl_threading = ['libmkl_intel_thread'] if '+openmp' in self.spec else ['libmkl_sequential'] # NOQA: ignore=E501 mkl_threading = ['libmkl_sequential']
if '+openmp' in self.spec:
mkl_threading = ['libmkl_intel_thread', 'libiomp5'] if '%intel' in self.spec else ['libmkl_gnu_thread'] # NOQA: ignore=E501
# TODO: TBB threading: ['libmkl_tbb_thread', 'libtbb', 'libstdc++']
mkl_libs = find_libraries( mkl_libs = find_libraries(
mkl_integer + ['libmkl_core'] + mkl_threading, mkl_integer + ['libmkl_core'] + mkl_threading,
root=join_path(self.prefix.lib, 'intel64'), root=join_path(self.prefix.lib, 'intel64'),

View File

@ -53,9 +53,8 @@ def install(self, spec, prefix):
mumps_flags = "-ldmumps -lmumps_common -lpord -lmpiseq" mumps_flags = "-ldmumps -lmumps_common -lpord -lmpiseq"
mumps_libcmd = "-L%s " % mumps_dir.lib + mumps_flags mumps_libcmd = "-L%s " % mumps_dir.lib + mumps_flags
# By convention, spack links blas & lapack libs to libblas & liblapack blas_lib = spec['blas'].blas_libs.ld_flags
blas_lib = "-L%s" % blas_dir.lib + " -lblas" lapack_lib = spec['lapack'].lapack_libs.ld_flags
lapack_lib = "-L%s" % lapack_dir.lib + " -llapack"
configure_args = [ configure_args = [
"--prefix=%s" % prefix, "--prefix=%s" % prefix,

View File

@ -89,8 +89,7 @@ def install(self, spec, prefix):
options = ['PREFIX=%s' % prefix] options = ['PREFIX=%s' % prefix]
if '+lapack' in spec: if '+lapack' in spec:
lapack_lib = '-L{0} -llapack -L{1} -lblas'.format( lapack_lib = (spec['lapack'].lapack_libs + spec['blas'].blas_libs).ld_flags # NOQA: ignore=E501
spec['lapack'].prefix.lib, spec['blas'].prefix.lib)
options.extend([ options.extend([
'MFEM_USE_LAPACK=YES', 'MFEM_USE_LAPACK=YES',
'LAPACK_OPT=-I%s' % spec['lapack'].prefix.include, 'LAPACK_OPT=-I%s' % spec['lapack'].prefix.include,

View File

@ -39,8 +39,9 @@ def blas_libs(self):
suffix = dso_suffix if '+shared' in self.spec else 'a' suffix = dso_suffix if '+shared' in self.spec else 'a'
mkl_integer = ['libmkl_intel_ilp64'] if '+ilp64' in self.spec else ['libmkl_intel_lp64'] # NOQA: ignore=E501 mkl_integer = ['libmkl_intel_ilp64'] if '+ilp64' in self.spec else ['libmkl_intel_lp64'] # NOQA: ignore=E501
mkl_threading = ['libmkl_sequential'] mkl_threading = ['libmkl_sequential']
if '+openmp' in spec: if '+openmp' in self.spec:
mkl_threading = ['libmkl_intel_thread'] if '%intel' in self.spec else ['libmkl_gnu_thread'] # NOQA: ignore=E501 mkl_threading = ['libmkl_intel_thread', 'libiomp5'] if '%intel' in self.spec else ['libmkl_gnu_thread'] # NOQA: ignore=E501
# TODO: TBB threading: ['libmkl_tbb_thread', 'libtbb', 'libstdc++']
mkl_libs = find_libraries( mkl_libs = find_libraries(
mkl_integer + ['libmkl_core'] + mkl_threading, mkl_integer + ['libmkl_core'] + mkl_threading,
root=join_path(self.prefix.lib, 'intel64'), root=join_path(self.prefix.lib, 'intel64'),

View File

@ -91,12 +91,9 @@ def install_one(self, spec, prefix, shared):
cmake_args.extend(['-DCBLAS=ON']) # always build CBLAS cmake_args.extend(['-DCBLAS=ON']) # always build CBLAS
if '+external-blas' in spec: if '+external-blas' in spec:
# TODO : mechanism to specify the library should be more general,
# TODO : but this allows to have an hook to an external blas
cmake_args.extend([ cmake_args.extend([
'-DUSE_OPTIMIZED_BLAS:BOOL=ON', '-DUSE_OPTIMIZED_BLAS:BOOL=ON',
'-DBLAS_LIBRARIES:PATH=%s' % join_path( '-DBLAS_LIBRARIES:PATH=%s' % spec['blas'].blas_libs.joined(';')
spec['blas'].prefix.lib, 'libblas.a')
]) ])
cmake_args.extend(std_cmake_args) cmake_args.extend(std_cmake_args)

View File

@ -79,8 +79,8 @@ def install(self, spec, prefix):
options.extend([ options.extend([
'-DLAPACK_FOUND=true', '-DLAPACK_FOUND=true',
'-DLAPACK_INCLUDE_DIRS=%s' % spec['lapack'].prefix.include, '-DLAPACK_INCLUDE_DIRS=%s' % spec['lapack'].prefix.include,
'-DLAPACK_LIBRARIES=%s' % (lapack.joined()), '-DLAPACK_LIBRARIES=%s' % (lapack.joined(';')),
'-DBLAS_LIBRARIES=%s' % (blas.joined()) '-DBLAS_LIBRARIES=%s' % (blas.joined(';'))
]) ])
if '+fpic' in spec: if '+fpic' in spec:

View File

@ -111,24 +111,6 @@ def install(self, spec, prefix):
# no quotes around prefix (spack doesn't use a shell) # no quotes around prefix (spack doesn't use a shell)
make('install', "PREFIX=%s" % prefix, *make_defs) make('install', "PREFIX=%s" % prefix, *make_defs)
# TODO : the links below are mainly there because client
# TODO : packages are wrongly written. Check if they can be removed
# Blas virtual package should provide blas.a and libblas.a
with working_dir(prefix.lib):
symlink('libopenblas.a', 'blas.a')
symlink('libopenblas.a', 'libblas.a')
if '+shared' in spec:
symlink('libopenblas.%s' % dso_suffix,
'libblas.%s' % dso_suffix)
# Lapack virtual package should provide liblapack.a
with working_dir(prefix.lib):
symlink('libopenblas.a', 'liblapack.a')
if '+shared' in spec:
symlink('libopenblas.%s' % dso_suffix,
'liblapack.%s' % dso_suffix)
# Openblas may pass its own test but still fail to compile Lapack # Openblas may pass its own test but still fail to compile Lapack
# symbols. To make sure we get working Blas and Lapack, do a small # symbols. To make sure we get working Blas and Lapack, do a small
# test. # test.
@ -141,10 +123,8 @@ def check_install(self, spec):
'test_cblas_dgemm.output') 'test_cblas_dgemm.output')
include_flags = ["-I%s" % join_path(spec.prefix, "include")] include_flags = ["-I%s" % join_path(spec.prefix, "include")]
link_flags = ["-L%s" % join_path(spec.prefix, "lib"), link_flags = self.lapack_libs.ld_flags.split()
"-llapack", link_flags.extend(["-lpthread"])
"-lblas",
"-lpthread"]
if '+openmp' in spec: if '+openmp' in spec:
link_flags.extend([self.compiler.openmp_flag]) link_flags.extend([self.compiler.openmp_flag])

View File

@ -129,9 +129,15 @@ def install(self, spec, prefix):
'--with-scalar-type=%s' % ( '--with-scalar-type=%s' % (
'complex' if '+complex' in spec else 'real'), 'complex' if '+complex' in spec else 'real'),
'--with-shared-libraries=%s' % ('1' if '+shared' in spec else '0'), '--with-shared-libraries=%s' % ('1' if '+shared' in spec else '0'),
'--with-debugging=%s' % ('1' if '+debug' in spec else '0'), '--with-debugging=%s' % ('1' if '+debug' in spec else '0')
'--with-blas-lapack-dir=%s' % spec['lapack'].prefix
]) ])
# Make sure we use exactly the same Blas/Lapack libraries
# across the DAG. To that end list them explicitly
lapack_blas = spec['lapack'].lapack_libs + spec['blas'].blas_libs
options.extend([
'--with-blas-lapack-lib=%s' % lapack_blas.joined()
])
# Activates library support if needed # Activates library support if needed
for library in ('metis', 'boost', 'hdf5', 'hypre', 'parmetis', for library in ('metis', 'boost', 'hdf5', 'hypre', 'parmetis',
'mumps', 'scalapack'): 'mumps', 'scalapack'):

View File

@ -86,7 +86,7 @@ def configure(self, spec):
if '+blas' in spec: if '+blas' in spec:
config.extend([ config.extend([
'BLASDEF = -DUSE_VENDOR_BLAS', 'BLASDEF = -DUSE_VENDOR_BLAS',
'BLASLIB = -L{0} -lblas'.format(spec['blas'].prefix.lib) 'BLASLIB = {0}'.format(spec['blas'].blas_libs.ld_flags)
]) ])
else: else:
config.append('BLASLIB = ../lib/libblas$(PLAT).a') config.append('BLASLIB = ../lib/libblas$(PLAT).a')