trilinos: yak shaving (#25549)

* trilinos: yak shaving

- use flags instead of manually adding cxxflags
- rearrange defines more sensibly
- use conflicts instead of inline package disables
- fix some inapplicable definitions such as OpenMP instantiation
- disable "broken" leaf packages(FEI, Panzer) by default
- rely on upstream libraries 'libs' rather than manual names

* flake8

* Fix executable call

* Address reviewer feedback
This commit is contained in:
Seth R. Johnson 2021-09-08 13:04:35 +01:00 committed by GitHub
parent c33382b607
commit f4e66b306e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -3,7 +3,6 @@
# #
# SPDX-License-Identifier: (Apache-2.0 OR MIT) # SPDX-License-Identifier: (Apache-2.0 OR MIT)
import os
import sys import sys
from spack import * from spack import *
@ -56,153 +55,83 @@ class Trilinos(CMakePackage, CudaPackage):
# ###################### Variants ########################## # ###################### Variants ##########################
# Other
# not everyone has py-numpy activated, keep it disabled by default to avoid
# configure errors
# Build options # Build options
variant('complex', default=False, variant('complex', default=False, description='Enable complex numbers in Trilinos')
description='Enable complex numbers in Trilinos') variant('cuda_rdc', default=False, description='turn on RDC for CUDA build')
variant('explicit_template_instantiation', default=True, variant('cxxstd', default='11', values=['11', '14', '17'], multi=False)
description='Enable explicit template instantiation (ETI)') variant('debug', default=False, description='Enable runtime safety and debug checks')
variant('float', default=False, variant('explicit_template_instantiation', default=True, description='Enable explicit template instantiation (ETI)')
description='Enable single precision (float) numbers in Trilinos') variant('float', default=False, description='Enable single precision (float) numbers in Trilinos')
variant('fortran', default=True, description='Compile with Fortran support')
variant('gotype', default='long', variant('gotype', default='long',
values=('int', 'long', 'long_long', 'all'), values=('int', 'long', 'long_long', 'all'),
multi=False, multi=False,
description='global ordinal type for Tpetra') description='global ordinal type for Tpetra')
variant('fortran', default=True, variant('openmp', default=False, description='Enable OpenMP')
description='Compile with Fortran support') variant('python', default=False, description='Build PyTrilinos wrappers')
variant('python', default=False, variant('shared', default=True, description='Enables the build of shared libraries')
description='Build PyTrilinos wrappers') variant('wrapper', default=False, description="Use nvcc-wrapper for CUDA build")
variant('wrapper', default=False,
description="Use nvcc-wrapper for CUDA build")
variant('cuda_rdc', default=False,
description='turn on RDC for CUDA build')
variant('cxxstd', default='11', values=['11', '14', '17'], multi=False)
variant('openmp', default=False,
description='Enable OpenMP')
variant('shared', default=True,
description='Enables the build of shared libraries')
variant('debug', default=False,
description='Enable runtime safety and debug checks')
# TPLs (alphabet order) # TPLs (alphabet order)
variant('boost', default=False, variant('boost', default=False, description='Compile with Boost')
description='Compile with Boost') variant('adios2', default=False, description='Enable ADIOS2')
variant('adios2', default=False, variant('hdf5', default=False, description='Compile with HDF5')
description='Enable ADIOS2') variant('hypre', default=False, description='Compile with Hypre preconditioner')
variant('hdf5', default=False, variant('mpi', default=True, description='Compile with MPI parallelism')
description='Compile with HDF5') variant('mumps', default=False, description='Compile with support for MUMPS solvers')
variant('hypre', default=False, variant('suite-sparse', default=False, description='Compile with SuiteSparse solvers')
description='Compile with Hypre preconditioner') variant('superlu-dist', default=False, description='Compile with SuperluDist solvers')
variant('mpi', default=True, variant('superlu', default=False, description='Compile with SuperLU solvers')
description='Compile with MPI parallelism') variant('strumpack', default=False, description='Compile with STRUMPACK solvers')
variant('mumps', default=False, variant('zlib', default=False, description='Compile with zlib')
description='Compile with support for MUMPS solvers')
variant('suite-sparse', default=False,
description='Compile with SuiteSparse solvers')
variant('superlu-dist', default=False,
description='Compile with SuperluDist solvers')
variant('superlu', default=False,
description='Compile with SuperLU solvers')
variant('strumpack', default=False,
description='Compile with STRUMPACK solvers')
variant('zlib', default=False,
description='Compile with zlib')
# Package options (alphabet order) # Package options (alphabet order)
variant('amesos', default=True, variant('amesos', default=True, description='Compile with Amesos')
description='Compile with Amesos') variant('amesos2', default=True, description='Compile with Amesos2')
variant('amesos2', default=True, variant('anasazi', default=True, description='Compile with Anasazi')
description='Compile with Amesos2') variant('aztec', default=True, description='Compile with Aztec')
variant('anasazi', default=True, variant('belos', default=True, description='Compile with Belos')
description='Compile with Anasazi') variant('chaco', default=False, description='Compile with Chaco from SEACAS')
variant('aztec', default=True, variant('epetra', default=True, description='Compile with Epetra')
description='Compile with Aztec') variant('epetraext', default=True, description='Compile with EpetraExt')
variant('belos', default=True, variant('exodus', default=False, description='Compile with Exodus from SEACAS')
description='Compile with Belos') variant('ifpack', default=True, description='Compile with Ifpack')
# chaco is disabled by default. As of 12.14.1 libchaco.so variant('ifpack2', default=True, description='Compile with Ifpack2')
# has the global symbol divide (and maybe others) that can variant('intrepid', default=False, description='Enable Intrepid')
# lead to symbol clash. variant('intrepid2', default=False, description='Enable Intrepid2')
variant('chaco', default=False, variant('isorropia', default=False, description='Compile with Isorropia')
description='Compile with Chaco from SEACAS') variant('kokkos', default=True, description='Compile with Kokkos')
variant('epetra', default=True, variant('ml', default=True, description='Compile with ML')
description='Compile with Epetra') variant('minitensor', default=False, description='Compile with MiniTensor')
variant('epetraext', default=True, variant('muelu', default=True, description='Compile with Muelu')
description='Compile with EpetraExt') variant('nox', default=False, description='Compile with NOX')
variant('exodus', default=False, variant('piro', default=False, description='Compile with Piro')
description='Compile with Exodus from SEACAS') variant('phalanx', default=False, description='Compile with Phalanx')
variant('ifpack', default=True, variant('rol', default=False, description='Compile with ROL')
description='Compile with Ifpack') variant('rythmos', default=False, description='Compile with Rythmos')
variant('ifpack2', default=True, variant('sacado', default=True, description='Compile with Sacado')
description='Compile with Ifpack2') variant('stk', default=False, description='Compile with STK')
variant('intrepid', default=False, variant('shards', default=False, description='Compile with Shards')
description='Enable Intrepid') variant('shylu', default=False, description='Compile with ShyLU')
variant('intrepid2', default=False, variant('stokhos', default=False, description='Compile with Stokhos')
description='Enable Intrepid2') variant('stratimikos', default=False, description='Compile with Stratimikos')
variant('isorropia', default=False, variant('teko', default=False, description='Compile with Teko')
description='Compile with Isorropia') variant('tempus', default=False, description='Compile with Tempus')
variant('kokkos', default=True, variant('tpetra', default=True, description='Compile with Tpetra')
description='Compile with Kokkos') variant('trilinoscouplings', default=False, description='Compile with TrilinosCouplings')
variant('ml', default=True, variant('zoltan', default=False, description='Compile with Zoltan')
description='Compile with ML') variant('zoltan2', default=False, description='Compile with Zoltan2')
variant('minitensor', default=False,
description='Compile with MiniTensor')
variant('muelu', default=True,
description='Compile with Muelu')
variant('nox', default=False,
description='Compile with NOX')
variant('piro', default=False,
description='Compile with Piro')
variant('phalanx', default=False,
description='Compile with Phalanx')
variant('rol', default=False,
description='Compile with ROL')
variant('rythmos', default=False,
description='Compile with Rythmos')
variant('sacado', default=True,
description='Compile with Sacado')
variant('stk', default=False,
description='Compile with STK')
variant('shards', default=False,
description='Compile with Shards')
variant('shylu', default=False,
description='Compile with ShyLU')
variant('stokhos', default=False,
description='Compile with Stokhos')
variant('stratimikos', default=False,
description='Compile with Stratimikos')
variant('teko', default=False,
description='Compile with Teko')
variant('tempus', default=False,
description='Compile with Tempus')
variant('tpetra', default=True,
description='Compile with Tpetra')
variant('trilinoscouplings', default=False,
description='Compile with TrilinosCouplings')
variant('zoltan', default=False,
description='Compile with Zoltan')
variant('zoltan2', default=False,
description='Compile with Zoltan2')
# Internal package options (alphabetical order) # Internal package options (alphabetical order)
variant('basker', default=False, variant('basker', default=False, description='Compile with the Basker solver in Amesos2')
description='Compile with the Basker solver in Amesos2') variant('epetraextbtf', default=False, description='Compile with BTF in EpetraExt')
variant('epetraextbtf', default=False, variant('epetraextexperimental', default=False, description='Compile with experimental in EpetraExt')
description='Compile with BTF in EpetraExt') variant('epetraextgraphreorderings', default=False, description='Compile with graph reorderings in EpetraExt')
variant('epetraextexperimental', default=False,
description='Compile with experimental in EpetraExt')
variant('epetraextgraphreorderings', default=False,
description='Compile with graph reorderings in EpetraExt')
# External package options # External package options
variant('dtk', default=False, variant('dtk', default=False, description='Enable DataTransferKit (deprecated)')
description='Enable DataTransferKit (deprecated)') variant('scorec', default=False, description='Enable SCOREC')
variant('scorec', default=False, variant('mesquite', default=False, description='Enable Mesquite (deprecated)')
description='Enable SCOREC')
variant('mesquite', default=False,
description='Enable Mesquite (deprecated)')
resource(name='dtk', resource(name='dtk',
git='https://github.com/ornl-cees/DataTransferKit.git', git='https://github.com/ornl-cees/DataTransferKit.git',
@ -329,13 +258,17 @@ class Trilinos(CMakePackage, CudaPackage):
# Multi-value gotype only applies to trilinos through 12.14 # Multi-value gotype only applies to trilinos through 12.14
conflicts('gotype=all', when='@12.15:') conflicts('gotype=all', when='@12.15:')
# All compilers except for pgi are in conflict: # CUDA without wrapper requires clang
for __compiler in spack.compilers.supported_compilers(): for _compiler in spack.compilers.supported_compilers():
if __compiler != 'clang': if _compiler != 'clang':
conflicts('+cuda', when='~wrapper %{0}'.format(__compiler), conflicts('+cuda', when='~wrapper %' + _compiler,
msg='trilinos~wrapper+cuda can only be built with the ' msg='trilinos~wrapper+cuda can only be built with the '
'Clang compiler') 'Clang compiler')
# stokhos fails on xl/xl_r
conflicts('+stokhos', when='%xl')
conflicts('+stokhos', when='%xl_r')
# ###################### Dependencies ########################## # ###################### Dependencies ##########################
# Explicit dependency variants # Explicit dependency variants
@ -410,9 +343,21 @@ class Trilinos(CMakePackage, CudaPackage):
when='@13.0.0:13.0.1 +teko gotype=long') when='@13.0.0:13.0.1 +teko gotype=long')
def flag_handler(self, name, flags): def flag_handler(self, name, flags):
if self.spec.satisfies('%cce'): is_cce = self.spec.satisfies('%cce')
if name == 'ldflags':
flags.append('-fuse-ld=gold') if name == 'cxxflags':
spec = self.spec
if '+mumps' in spec:
# see https://github.com/trilinos/Trilinos/blob/master/packages/amesos/README-MUMPS
flags.append('-DMUMPS_5_0')
if '+stk platform=darwin' in spec:
flags.append('-DSTK_NO_BOOST_STACKTRACE')
if '+wrapper' in spec:
flags.append('--expt-extended-lambda')
elif name == 'ldflags' and is_cce:
flags.append('-fuse-ld=gold')
if is_cce:
return (None, None, flags) return (None, None, flags)
return (flags, None, None) return (flags, None, None)
@ -442,33 +387,43 @@ def setup_build_environment(self, env):
env.set('CXX', spec["kokkos-nvcc-wrapper"].kokkos_cxx) env.set('CXX', spec["kokkos-nvcc-wrapper"].kokkos_cxx)
def cmake_args(self): def cmake_args(self):
options = []
spec = self.spec spec = self.spec
define = CMakePackage.define define = CMakePackage.define
define_from_variant = self.define_from_variant define_from_variant = self.define_from_variant
def define_trilinos_enable(cmake_var, spec_var=None): def _make_definer(prefix):
if spec_var is None: def define_enable(suffix, value=None):
spec_var = cmake_var.lower() key = prefix + suffix
return define_from_variant('Trilinos_ENABLE_' + cmake_var, spec_var) if value is None:
# Default to lower-case spec
value = suffix.lower()
elif isinstance(value, bool):
# Explicit true/false
return define(key, value)
return define_from_variant(key, value)
return define_enable
def define_tpl_enable(cmake_var, spec_var=None): # Return "Trilinos_ENABLE_XXX" for spec "+xxx" or boolean value
if spec_var is None: define_trilinos_enable = _make_definer("Trilinos_ENABLE_")
spec_var = cmake_var.lower() # Same but for TPLs
return define_from_variant('TPL_ENABLE_' + cmake_var, spec_var) define_tpl_enable = _make_definer("TPL_ENABLE_")
cxx_flags = []
options = []
# #################### Base Settings ####################### # #################### Base Settings #######################
options.extend([ options.extend([
define('Trilinos_VERBOSE_CONFIGURE', False), define('Trilinos_VERBOSE_CONFIGURE', False),
define('Trilinos_ENABLE_TESTS', False),
define('Trilinos_ENABLE_EXAMPLES', False),
define('Trilinos_ENABLE_CXX11', True),
define_from_variant("CMAKE_CXX_STANDARD", "cxxstd"),
define_from_variant('BUILD_SHARED_LIBS', 'shared'), define_from_variant('BUILD_SHARED_LIBS', 'shared'),
define_from_variant("CMAKE_CXX_STANDARD", "cxxstd"),
define_trilinos_enable('TESTS', False),
define_trilinos_enable('EXAMPLES', False),
define_trilinos_enable('CXX11', True),
define_trilinos_enable('DEBUG', 'debug'), define_trilinos_enable('DEBUG', 'debug'),
define_trilinos_enable('Fortran'),
define_trilinos_enable('OpenMP'),
define_trilinos_enable('EXPLICIT_INSTANTIATION',
'explicit_template_instantiation')
# The following can cause problems on systems that don't have # The following can cause problems on systems that don't have
# static libraries available for things like dl and pthreads # static libraries available for things like dl and pthreads
# for example when trying to build static libs # for example when trying to build static libs
@ -476,19 +431,6 @@ def define_tpl_enable(cmake_var, spec_var=None):
# define('Trilinos_LINK_SEARCH_START_STATIC', '+shared' not in spec) # define('Trilinos_LINK_SEARCH_START_STATIC', '+shared' not in spec)
]) ])
# MPI settings
options.append(define_tpl_enable('MPI'))
if '+mpi' in spec:
# Force Trilinos to use the MPI wrappers instead of raw compilers
# this is needed on Apple systems that require full resolution of
# all symbols when linking shared libraries
options.extend([
define('CMAKE_C_COMPILER', spec['mpi'].mpicc),
define('CMAKE_CXX_COMPILER', spec['mpi'].mpicxx),
define('CMAKE_Fortran_COMPILER', spec['mpi'].mpifc),
define('MPI_BASE_DIR', spec['mpi'].prefix),
])
# ################## Trilinos Packages ##################### # ################## Trilinos Packages #####################
options.extend([ options.extend([
@ -499,6 +441,8 @@ def define_tpl_enable(cmake_var, spec_var=None):
define_trilinos_enable('Belos'), define_trilinos_enable('Belos'),
define_trilinos_enable('Epetra'), define_trilinos_enable('Epetra'),
define_trilinos_enable('EpetraExt'), define_trilinos_enable('EpetraExt'),
define_trilinos_enable('FEI', False),
define_trilinos_enable('Gtest', False),
define_trilinos_enable('Ifpack'), define_trilinos_enable('Ifpack'),
define_trilinos_enable('Ifpack2'), define_trilinos_enable('Ifpack2'),
define_trilinos_enable('Intrepid'), define_trilinos_enable('Intrepid'),
@ -510,6 +454,9 @@ def define_tpl_enable(cmake_var, spec_var=None):
define_trilinos_enable('ML'), define_trilinos_enable('ML'),
define_trilinos_enable('MueLu'), define_trilinos_enable('MueLu'),
define_trilinos_enable('NOX'), define_trilinos_enable('NOX'),
define_trilinos_enable('Pamgen', False),
define_trilinos_enable('Panzer', False),
define_trilinos_enable('Pike', False),
define_trilinos_enable('Piro'), define_trilinos_enable('Piro'),
define_trilinos_enable('Phalanx'), define_trilinos_enable('Phalanx'),
define_trilinos_enable('PyTrilinos', 'python'), define_trilinos_enable('PyTrilinos', 'python'),
@ -528,6 +475,7 @@ def define_tpl_enable(cmake_var, spec_var=None):
define_trilinos_enable('TrilinosCouplings'), define_trilinos_enable('TrilinosCouplings'),
define_trilinos_enable('Zoltan'), define_trilinos_enable('Zoltan'),
define_trilinos_enable('Zoltan2'), define_trilinos_enable('Zoltan2'),
define_tpl_enable('Cholmod', False),
define_from_variant('EpetraExt_BUILD_BTF', 'epetraextbtf'), define_from_variant('EpetraExt_BUILD_BTF', 'epetraextbtf'),
define_from_variant('EpetraExt_BUILD_EXPERIMENTAL', define_from_variant('EpetraExt_BUILD_EXPERIMENTAL',
'epetraextexperimental'), 'epetraextexperimental'),
@ -539,35 +487,35 @@ def define_tpl_enable(cmake_var, spec_var=None):
if '+dtk' in spec: if '+dtk' in spec:
options.extend([ options.extend([
define('Trilinos_EXTRA_REPOSITORIES', 'DataTransferKit'), define('Trilinos_EXTRA_REPOSITORIES', 'DataTransferKit'),
define('Trilinos_ENABLE_DataTransferKit', True), define_trilinos_enable('DataTransferKit', True),
]) ])
if '+exodus' in spec: if '+exodus' in spec:
options.extend([ options.extend([
define('Trilinos_ENABLE_SEACAS', True), define_trilinos_enable('SEACAS', True),
define('Trilinos_ENABLE_SEACASExodus', True), define_trilinos_enable('SEACASExodus', True),
define('Trilinos_ENABLE_SEACASIoss', True), define_trilinos_enable('SEACASIoss', True),
define('Trilinos_ENABLE_SEACASEpu', True), define_trilinos_enable('SEACASEpu', True),
define('Trilinos_ENABLE_SEACASExodiff', True), define_trilinos_enable('SEACASExodiff', True),
define('Trilinos_ENABLE_SEACASNemspread', True), define_trilinos_enable('SEACASNemspread', True),
define('Trilinos_ENABLE_SEACASNemslice', True), define_trilinos_enable('SEACASNemslice', True),
]) ])
else: else:
options.extend([ options.extend([
define('Trilinos_ENABLE_SEACASExodus', False), define_trilinos_enable('SEACASExodus', False),
define('Trilinos_ENABLE_SEACASIoss', False), define_trilinos_enable('SEACASIoss', False),
]) ])
if '+chaco' in spec: if '+chaco' in spec:
options.extend([ options.extend([
define('Trilinos_ENABLE_SEACAS', True), define_trilinos_enable('SEACAS', True),
define('Trilinos_ENABLE_SEACASChaco', True), define_trilinos_enable('SEACASChaco', True),
]) ])
else: else:
# don't disable SEACAS, could be needed elsewhere # don't disable SEACAS, could be needed elsewhere
options.extend([ options.extend([
define('Trilinos_ENABLE_SEACASChaco', False), define_trilinos_enable('SEACASChaco', False),
define('Trilinos_ENABLE_SEACASNemslice', False) define_trilinos_enable('SEACASNemslice', False)
]) ])
if '+stratimikos' in spec: if '+stratimikos' in spec:
@ -576,7 +524,7 @@ def define_tpl_enable(cmake_var, spec_var=None):
# Thyra is NOT enabled at this point!" leading to eventual build # Thyra is NOT enabled at this point!" leading to eventual build
# errors if using MueLu because `Xpetra_ENABLE_Thyra` is set to # errors if using MueLu because `Xpetra_ENABLE_Thyra` is set to
# off. # off.
options.append(define('Trilinos_ENABLE_Thyra', True)) options.append(define_trilinos_enable('Thyra', True))
# Add thyra adapters based on package enables # Add thyra adapters based on package enables
options.extend( options.extend(
@ -598,18 +546,19 @@ def define_tpl_enable(cmake_var, spec_var=None):
('Matio', 'matio'), ('Matio', 'matio'),
('METIS', 'metis'), ('METIS', 'metis'),
('Netcdf', 'netcdf-c'), ('Netcdf', 'netcdf-c'),
('SCALAPACK', 'scalapack'),
('SuperLU', 'superlu'), ('SuperLU', 'superlu'),
('SuperLUDist', 'superlu-dist'), ('SuperLUDist', 'superlu-dist'),
('UMFPACK', 'suite-sparse'),
('X11', 'libx11'), ('X11', 'libx11'),
('Zlib', 'zlib'), ('Zlib', 'zlib'),
] ]
if spec.satisfies('@12.12.1:'): if spec.satisfies('@12.12.1:'):
tpl_dep_map.append(('Pnetcdf', 'parallel-netcdf')) tpl_dep_map.append(('Pnetcdf', 'parallel-netcdf'))
if spec.satisfies('@13:'): if spec.satisfies('@13:'):
tpl_dep_map.extend([ tpl_dep_map.append(('HWLOC', 'hwloc'))
('HWLOC', 'hwloc'), if spec.satisfies('@13.0.2:'):
('STRUMPACK', 'strumpack'), tpl_dep_map.append(('STRUMPACK', 'strumpack'))
])
for tpl_name, dep_name in tpl_dep_map: for tpl_name, dep_name in tpl_dep_map:
have_dep = (dep_name in spec) have_dep = (dep_name in spec)
@ -617,41 +566,31 @@ def define_tpl_enable(cmake_var, spec_var=None):
if not have_dep: if not have_dep:
continue continue
depspec = spec[dep_name] depspec = spec[dep_name]
libs = depspec.libs
options.extend([ options.extend([
define(tpl_name + '_INCLUDE_DIRS', depspec.prefix.include), define(tpl_name + '_INCLUDE_DIRS', depspec.prefix.include),
define(tpl_name + '_ROOT', depspec.prefix), define(tpl_name + '_ROOT', depspec.prefix),
define(tpl_name + '_LIBRARY_NAMES', depspec.libs.names), define(tpl_name + '_LIBRARY_NAMES', libs.names),
define(tpl_name + '_LIBRARY_DIRS', depspec.libs.directories), define(tpl_name + '_LIBRARY_DIRS', libs.directories),
]) ])
if '+suite-sparse' in spec: # MPI settings
options.append(define_tpl_enable('MPI'))
if '+mpi' in spec:
# Force Trilinos to use the MPI wrappers instead of raw compilers
# to propagate library link flags for linkers that require fully
# resolved symbols in shared libs (such as macOS and some newer
# Ubuntu)
options.extend([ options.extend([
# FIXME: Trilinos seems to be looking for static libs only, define('CMAKE_C_COMPILER', spec['mpi'].mpicc),
# patch CMake TPL file? define('CMAKE_CXX_COMPILER', spec['mpi'].mpicxx),
define('TPL_ENABLE_Cholmod', False), define('CMAKE_Fortran_COMPILER', spec['mpi'].mpifc),
# define('TPL_ENABLE_Cholmod', True), define('MPI_BASE_DIR', spec['mpi'].prefix),
# define('Cholmod_LIBRARY_DIRS', (
# spec['suite-sparse'].prefix.lib)
# define('Cholmod_INCLUDE_DIRS', (
# spec['suite-sparse'].prefix.include)
define('TPL_ENABLE_UMFPACK', True),
define('UMFPACK_LIBRARY_DIRS',
spec['suite-sparse'].prefix.lib),
define('UMFPACK_INCLUDE_DIRS',
spec['suite-sparse'].prefix.include),
define('UMFPACK_LIBRARY_NAMES', [
'umfpack', 'amd', 'colamd', 'cholmod', 'suitesparseconfig'
]),
])
else:
options.extend([
define('TPL_ENABLE_Cholmod', False),
define('TPL_ENABLE_UMFPACK', False),
]) ])
# ParMETIS dependencies have to be transitive explicitly # ParMETIS dependencies have to be transitive explicitly
have_parmetis = 'parmetis' in spec have_parmetis = 'parmetis' in spec
options.append(define('TPL_ENABLE_ParMETIS', have_parmetis)) options.append(define_tpl_enable('ParMETIS', have_parmetis))
if have_parmetis: if have_parmetis:
options.extend([ options.extend([
define('ParMETIS_LIBRARY_DIRS', [ define('ParMETIS_LIBRARY_DIRS', [
@ -664,33 +603,11 @@ def define_tpl_enable(cmake_var, spec_var=None):
]), ]),
]) ])
options.append(define_tpl_enable('MUMPS'))
options.append(define_tpl_enable('SCALAPACK', 'mumps'))
if '+mumps' in spec:
scalapack = spec['scalapack'].libs
options.extend([
define('MUMPS_LIBRARY_DIRS', spec['mumps'].prefix.lib),
# order is important!
define('MUMPS_LIBRARY_NAMES', [
'dmumps', 'mumps_common', 'pord'
]),
define('SCALAPACK_LIBRARY_NAMES', scalapack.names),
define('SCALAPACK_LIBRARY_DIRS', scalapack.directories),
])
# see
# https://github.com/trilinos/Trilinos/blob/master/packages/amesos/README-MUMPS
cxx_flags.extend([
'-DMUMPS_5_0'
])
if spec.satisfies('^superlu-dist@4.0:'): if spec.satisfies('^superlu-dist@4.0:'):
options.extend([ options.extend([
define('HAVE_SUPERLUDIST_LUSTRUCTINIT_2ARG', True), define('HAVE_SUPERLUDIST_LUSTRUCTINIT_2ARG', True),
]) ])
if '+strumpack' in spec:
options.append(define('Amesos2_ENABLE_STRUMPACK', True))
if spec.satisfies('^parallel-netcdf'): if spec.satisfies('^parallel-netcdf'):
options.extend([ options.extend([
define('TPL_Netcdf_Enables_Netcdf4', True), define('TPL_Netcdf_Enables_Netcdf4', True),
@ -698,66 +615,18 @@ def define_tpl_enable(cmake_var, spec_var=None):
define('PNetCDF_ROOT', spec['parallel-netcdf'].prefix), define('PNetCDF_ROOT', spec['parallel-netcdf'].prefix),
]) ])
if '@13: +kokkos' in spec: # ################# Explicit template instantiation #################
kkmarch = Kokkos.spack_micro_arch_map.get(spec.target.name, None)
if kkmarch:
options.append(define("Kokkos_ARCH_" + kkmarch.upper(), True))
# ################# Miscellaneous Stuff ######################
# CUDA
options.append(define_tpl_enable('CUDA'))
if '+cuda' in spec:
options.extend([
define('Kokkos_ENABLE_CUDA', True),
define('Kokkos_ENABLE_CUDA_UVM', True),
define('Kokkos_ENABLE_CUDA_LAMBDA', True)])
if '+cuda_rdc' in spec:
options.append(define(
'Kokkos_ENABLE_CUDA_RELOCATABLE_DEVICE_CODE',
True))
for iArchCC in spec.variants['cuda_arch'].value:
options.append(define(
"Kokkos_ARCH_" +
Kokkos.spack_cuda_arch_map[iArchCC].upper(),
True))
if '+wrapper' in spec:
cxx_flags.extend(['--expt-extended-lambda'])
# OpenMP
options.append(define_trilinos_enable('OpenMP'))
if '+openmp' in spec:
options.append(define('Kokkos_ENABLE_OpenMP', True))
if '+tpetra' in spec:
options.append(define('Tpetra_INST_OPENMP', True))
# Fortran lib (assumes clang is built with gfortran!)
if '+fortran' in spec and (
spec.satisfies('%gcc') or spec.satisfies('%clang') or
spec.satisfies('%apple-clang')
):
options.append(define('Trilinos_ENABLE_Fortran', True))
if '+mpi' in spec:
libgfortran = os.path.dirname(os.popen(
'%s --print-file-name libgfortran.a' %
spec['mpi'].mpifc).read())
options.append(define(
'Trilinos_EXTRA_LINK_FLAGS',
'-L%s/ -lgfortran' % (libgfortran),
))
# Explicit Template Instantiation (ETI) in Tpetra
options.append(define_from_variant(
'Trilinos_ENABLE_EXPLICIT_INSTANTIATION',
'explicit_template_instantiation'))
complex_s = spec.variants['complex'].value complex_s = spec.variants['complex'].value
float_s = spec.variants['float'].value float_s = spec.variants['float'].value
options.extend([ options.extend([
define('Teuchos_ENABLE_COMPLEX', complex_s), define('Teuchos_ENABLE_COMPLEX', complex_s),
define('Teuchos_ENABLE_FLOAT', float_s), define('Teuchos_ENABLE_FLOAT', float_s),
]) ])
if '+explicit_template_instantiation' in spec and '+tpetra' in spec: if '+tpetra +explicit_template_instantiation' in spec:
options.append(define_from_variant('Tpetra_INST_OPENMP', 'openmp'))
options.extend([ options.extend([
define('Tpetra_INST_DOUBLE', True), define('Tpetra_INST_DOUBLE', True),
define('Tpetra_INST_COMPLEX_DOUBLE', complex_s), define('Tpetra_INST_COMPLEX_DOUBLE', complex_s),
@ -781,17 +650,42 @@ def define_tpl_enable(cmake_var, spec_var=None):
define('Tpetra_INST_INT_LONG_LONG', gotype == 'long_long'), define('Tpetra_INST_INT_LONG_LONG', gotype == 'long_long'),
]) ])
# disable due to compiler / config errors: # ################# Kokkos ######################
if spec.satisfies('%xl') or spec.satisfies('%xl_r'):
options.extend([
define('Trilinos_ENABLE_Pamgen', False),
define('Trilinos_ENABLE_Stokhos', False),
])
if sys.platform == 'darwin': if '+kokkos' in spec:
options.append(define('Trilinos_ENABLE_FEI', False)) arch = Kokkos.spack_micro_arch_map.get(spec.target.name, None)
if '+stk' in spec: if arch:
cxx_flags.extend(['-DSTK_NO_BOOST_STACKTRACE']) options.append(define("Kokkos_ARCH_" + arch.upper(), True))
define_kok_enable = _make_definer("Kokkos_ENABLE_")
options.extend([
define_kok_enable('CUDA'),
define_kok_enable('OPENMP' if spec.version >= Version('13')
else 'OpenMP'),
])
if '+cuda' in spec:
options.extend([
define_kok_enable('CUDA_UVM', True),
define_kok_enable('CUDA_LAMBDA', True),
define_kok_enable('CUDA_RELOCATABLE_DEVICE_CODE', 'cuda_rdc')
])
arch_map = Kokkos.spack_cuda_arch_map
options.extend(
define("Kokkos_ARCH_" + arch_map[arch].upper(), True)
for arch in spec.variants['cuda_arch'].value
)
# ################# System-specific ######################
# Fortran lib (assumes clang is built with gfortran!)
if ('+fortran +mpi' in spec
and spec.compiler.name in ['gcc', 'clang', 'apple-clang']):
mpifc = Executable(spec['mpi'].mpifc)
libgfortran = mpifc('--print-file-name', 'libgfortran.a', output=str)
options.append(define(
'Trilinos_EXTRA_LINK_FLAGS',
'-L%s/ -lgfortran' % (libgfortran),
))
if sys.platform == 'darwin' and macos_version() >= Version('10.12'): if sys.platform == 'darwin' and macos_version() >= Version('10.12'):
# use @rpath on Sierra due to limit of dynamic loader # use @rpath on Sierra due to limit of dynamic loader
@ -799,18 +693,6 @@ def define_tpl_enable(cmake_var, spec_var=None):
else: else:
options.append(define('CMAKE_INSTALL_NAME_DIR', self.prefix.lib)) options.append(define('CMAKE_INSTALL_NAME_DIR', self.prefix.lib))
if spec.satisfies('%intel') and spec.satisfies('@12.6.2'):
# Panzer uses some std:chrono that is not recognized by Intel
# Don't know which (maybe all) Trilinos versions this applies to
# Don't know which (maybe all) Intel versions this applies to
options.append(define('Trilinos_ENABLE_Panzer', False))
# collect CXX flags:
options.append(define('CMAKE_CXX_FLAGS', (' '.join(cxx_flags))))
# disable due to compiler / config errors:
options.append(define('Trilinos_ENABLE_Pike', False))
return options return options
@run_after('install') @run_after('install')
@ -831,8 +713,7 @@ def filter_python(self):
def setup_run_environment(self, env): def setup_run_environment(self, env):
if '+exodus' in self.spec: if '+exodus' in self.spec:
env.prepend_path('PYTHONPATH', env.prepend_path('PYTHONPATH', self.prefix.lib)
self.prefix.lib)
if '+cuda' in self.spec: if '+cuda' in self.spec:
# currently Trilinos doesn't perform the memory fence so # currently Trilinos doesn't perform the memory fence so