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

@@ -48,13 +48,19 @@ class Openblas(MakefilePackage):
description='Build shared libraries as well as static libs.'
)
variant('ilp64', default=False, description='64 bit integers')
variant('openmp', default=False, description="Enable OpenMP support.")
variant('pic', default=True, description='Build position independent code')
variant('cpu_target', default='',
description='Set CPU target architecture (leave empty for '
'autodetection; GENERIC, SSE_GENERIC, NEHALEM, ...)')
variant(
'threads', default='none',
description='Multithreading support',
values=('pthreads', 'openmp', 'none'),
multi=False
)
# virtual dependency
provides('blas')
provides('lapack')
@@ -89,7 +95,8 @@ def check_compilers(self):
'OpenBLAS requires both C and Fortran compilers!'
)
# Add support for OpenMP
if (('+openmp' in self.spec) and self.spec.satisfies('%clang')):
if (self.spec.satisfies('threads=openmp') and
self.spec.satisfies('%clang')):
if str(self.spec.compiler.version).endswith('-apple'):
raise InstallError("Apple's clang does not support OpenMP")
if '@:0.2.19' in self.spec:
@@ -134,9 +141,14 @@ def make_defs(self):
# fix missing _dggsvd_ and _sggsvd_
if self.spec.satisfies('@0.2.16'):
make_defs += ['BUILD_LAPACK_DEPRECATED=1']
# Add support for OpenMP
if '+openmp' in self.spec:
make_defs += ['USE_OPENMP=1']
# Add support for multithreading
if self.spec.satisfies('threads=openmp'):
make_defs += ['USE_OPENMP=1', 'USE_THREAD=1']
elif self.spec.satisfies('threads=pthreads'):
make_defs += ['USE_OPENMP=0', 'USE_THREAD=1']
else:
make_defs += ['USE_OPENMP=0', 'USE_THREAD=0']
# 64bit ints
if '+ilp64' in self.spec:
@@ -183,9 +195,10 @@ def check_install(self):
link_flags = spec['openblas'].libs.ld_flags
if self.compiler.name == 'intel':
link_flags += ' -lifcore'
link_flags += ' -lpthread'
if '+openmp' in spec:
link_flags += ' ' + self.compiler.openmp_flag
if self.spec.satisfies('threads=pthreads'):
link_flags += ' -lpthread'
if spec.satisfies('threads=openmp'):
link_flags += ' -lpthread ' + self.compiler.openmp_flag
output = compile_c_and_execute(
source_file, [include_flags], link_flags.split()