blas_lapack: add multithreading variant consistent in all implementations. (#5340)

* blas_lapack: add multithreading variant

* elemental: update

* intel-mkl: extend to macOS

* rename multithreading to threads

* intel-mkl: avoid long lines

* intel-mkl: make one install error a conflict

* openblas: fix a minor bug in the test
This commit is contained in:
Denis Davydov
2017-09-23 22:27:42 +02:00
committed by Todd Gamblin
parent bf2f96ce78
commit 7f84de52a0
5 changed files with 67 additions and 22 deletions

View File

@@ -23,6 +23,7 @@
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
##############################################################################
import os
import sys
from spack import *
from spack.environment import EnvironmentModifications
@@ -50,13 +51,22 @@ class IntelMkl(IntelPackage):
variant('shared', default=True, description='Builds shared library')
variant('ilp64', default=False, description='64 bit integers')
variant('openmp', default=False, description='OpenMP multithreading layer')
variant(
'threads', default='none',
description='Multithreading support',
values=('openmp', 'none'),
multi=False
)
provides('blas')
provides('lapack')
provides('scalapack')
provides('mkl')
if sys.platform == 'darwin':
# there is no libmkl_gnu_thread on macOS
conflicts('threads=openmp', when='%gcc')
@property
def license_required(self):
# The Intel libraries are provided without requiring a license as of
@@ -82,12 +92,15 @@ def blas_libs(self):
omp_libs = LibraryList([])
if '+openmp' in spec:
if spec.satisfies('threads=openmp'):
if '%intel' in spec:
mkl_threading = ['libmkl_intel_thread']
omp_threading = ['libiomp5']
omp_root = prefix.compilers_and_libraries.linux.lib.intel64
if sys.platform != 'darwin':
omp_root = prefix.compilers_and_libraries.linux.lib.intel64
else:
omp_root = prefix.lib
omp_libs = find_libraries(
omp_threading, root=omp_root, shared=shared)
elif '%gcc' in spec:
@@ -100,7 +113,10 @@ def blas_libs(self):
# TODO: TBB threading: ['libmkl_tbb_thread', 'libtbb', 'libstdc++']
mkl_root = prefix.compilers_and_libraries.linux.mkl.lib.intel64
if sys.platform != 'darwin':
mkl_root = prefix.compilers_and_libraries.linux.mkl.lib.intel64
else:
mkl_root = prefix.mkl.lib
mkl_libs = find_libraries(
mkl_integer + ['libmkl_core'] + mkl_threading,
@@ -130,7 +146,10 @@ def scalapack_libs(self):
# inspect the root package which asked for Scalapack and check which
# MPI it depends on.
root = self.spec.root
if '^openmpi' in root:
if sys.platform == 'darwin' and '^mpich' in root:
# MKL 2018 supports only MPICH on darwin
libnames.append('libmkl_blacs_mpich')
elif '^openmpi' in root:
libnames.append('libmkl_blacs_openmpi')
elif '^mpich@1' in root:
libnames.append('libmkl_blacs')
@@ -146,7 +165,9 @@ def scalapack_libs(self):
raise InstallError('No MPI found for scalapack')
integer = 'ilp64' if '+ilp64' in self.spec else 'lp64'
mkl_root = self.prefix.compilers_and_libraries.linux.mkl.lib.intel64
mkl_root = self.prefix.mkl.lib if sys.platform == 'darwin' else \
self.prefix.compilers_and_libraries.linux.mkl.lib.intel64
shared = True if '+shared' in self.spec else False
libs = find_libraries(
@@ -159,7 +180,8 @@ def scalapack_libs(self):
def setup_dependent_environment(self, spack_env, run_env, dependent_spec):
# set up MKLROOT for everyone using MKL package
mkl_root = self.prefix.compilers_and_libraries.linux.mkl.lib.intel64
mkl_root = self.prefix.mkl.lib if sys.platform == 'darwin' else \
self.prefix.compilers_and_libraries.linux.mkl.lib.intel64
spack_env.set('MKLROOT', self.prefix)
spack_env.append_path('SPACK_COMPILER_EXTRA_RPATHS', mkl_root)