summaryrefslogtreecommitdiff
path: root/var
diff options
context:
space:
mode:
authorDavid Gardner <gardner48@llnl.gov>2017-10-13 20:13:10 -0700
committerChristoph Junghans <christoph.junghans@gmail.com>2017-10-13 21:13:10 -0600
commitf885c89fdc2ecf22af7e71468b1e65f48940c3ff (patch)
treee2b5115a1d1a325c58827da83aacb92978f8c380 /var
parent1ba4c1af6367697da62bad0262dacbd47eb4e896 (diff)
downloadspack-f885c89fdc2ecf22af7e71468b1e65f48940c3ff.tar.gz
spack-f885c89fdc2ecf22af7e71468b1e65f48940c3ff.tar.bz2
spack-f885c89fdc2ecf22af7e71468b1e65f48940c3ff.tar.xz
spack-f885c89fdc2ecf22af7e71468b1e65f48940c3ff.zip
Update Sundials package (#5696)
* initial update of sundials package * fix bugs in initial sundials update * add xsdk cmake setup, fix generic math option, add cuda/raja Makefiles to install fixes * Fix lapack install bug, add new conflicts, clean up formatting * Address pull requeset comments and make fomatting style consistent Remove blas variant as blas is only needed when used by an external linear solver. Set related CMake blas variables as needed depending enabled external linear solvers. Add minimum required CMake version. Additional conflicts and dependencies for external libraries based on mpi, indextype, and precision. Fix SuperLU_MT logic to check which threading type SuperLU_MT was configured with. Add maintaiers. Change Sundials solver options to use an array of values. Consistently use % for formatting. * change triple-single quotes to single quotes * Change indextype option to a single int64 option
Diffstat (limited to 'var')
-rw-r--r--var/spack/repos/builtin/packages/sundials/package.py474
1 files changed, 375 insertions, 99 deletions
diff --git a/var/spack/repos/builtin/packages/sundials/package.py b/var/spack/repos/builtin/packages/sundials/package.py
index b3007d191a..63c095ebc7 100644
--- a/var/spack/repos/builtin/packages/sundials/package.py
+++ b/var/spack/repos/builtin/packages/sundials/package.py
@@ -27,48 +27,186 @@ import os
import sys
-class Sundials(Package):
+class Sundials(CMakePackage):
"""SUNDIALS (SUite of Nonlinear and DIfferential/ALgebraic equation
Solvers)"""
- homepage = "http://computation.llnl.gov/casc/sundials/"
- url = "http://computation.llnl.gov/projects/sundials-suite-nonlinear-differential-algebraic-equation-solvers/download/sundials-2.6.2.tar.gz"
+ homepage = "https://computation.llnl.gov/projects/sundials"
+ url = "https://computation.llnl.gov/projects/sundials/download/sundials-2.7.0.tar.gz"
+ maintainers = ['cswoodward', 'gardner48']
- version('2.7.0', 'c304631b9bc82877d7b0e9f4d4fd94d3')
+ # ==========================================================================
+ # Versions
+ # ==========================================================================
+
+ version('3.0.0-beta-2',
+ git='https://github.com/LLNL/sundials.git', tag='v3.0.0-beta-2')
+ version('2.7.0', 'c304631b9bc82877d7b0e9f4d4fd94d3', preferred=True)
version('2.6.2', '3deeb0ede9f514184c6bd83ecab77d95')
+ # ==========================================================================
+ # Variants
+ # ==========================================================================
+
+ # SUNDIALS solvers
+ sun_solvers = ['CVODE', 'CVODES', 'ARKODE', 'IDA', 'IDAS', 'KINSOL']
+
+ for pkg in sun_solvers:
+ variant(pkg, default=True,
+ description='Enable %s solver' % pkg)
+
+ # Real type
+ variant(
+ 'precision',
+ default='double',
+ description='real type precision',
+ values=('single', 'double', 'extended'),
+ multi=False
+ )
+
+ # Index type
+ # NOTE: Default to True until v3.0.0 is final as only 64bit integers are
+ # supported before v3.0.0.
+ variant('int64', default=True,
+ description='Use 64bit integers for indices')
+
+ # Parallelism
variant('mpi', default=True,
- description='Enable MPI parallelism')
- variant('lapack', default=True,
- description='Use external BLAS/LAPACK libraries')
- variant('klu', default=False,
+ description='Enable MPI parallel vector')
+ variant('openmp', default=False,
+ description='Enable OpenMP parallel vector')
+ variant('pthread', default=False,
+ description='Enable Pthreads parallel vector')
+ variant('cuda', default=False,
+ description='Enable CUDA parallel vector')
+ variant('raja', default=False,
+ description='Enable RAJA parallel vector')
+
+ # External libraries
+ variant('lapack', default=False,
+ description='Enable LAPACK direct solvers')
+ variant('klu', default=False,
description='Enable KLU sparse, direct solver')
- variant('superlu', default=False,
+ variant('superlu-mt', default=False,
description='Enable SuperLU_MT sparse, direct solver')
- variant('openmp', default=False,
- description='Enable OpenMP parallelism')
- variant('pthread', default=True,
- description='Enable Pthreads parallelism')
- variant('hypre', default=False,
- description='Enable Hypre parallel vector for MPI parallelism')
-
- depends_on('cmake', type='build')
- depends_on('mpi', when='+mpi')
- depends_on('mpi', when='@2.7:+hypre')
- depends_on('hypre', when='@2.7:+hypre')
- depends_on('blas', when='+lapack')
- depends_on('lapack', when='+lapack')
- depends_on('suite-sparse', when='+klu')
- depends_on('superlu-mt+openmp', when='+superlu+openmp')
- depends_on('superlu-mt+pthread', when='+superlu+pthread')
-
- def install(self, spec, prefix):
+ variant('hypre', default=False,
+ description='Enable Hypre MPI parallel vector')
+ variant('petsc', default=False,
+ description='Enable PETSc MPI parallel vector')
+
+ # Library type
+ variant('shared', default=True,
+ description='Build shared libraries')
+ variant('static', default=True,
+ description='Build static libraries')
+
+ # Fortran interface
+ variant('fcmix', default=False,
+ description='Enable Fortran interface')
+
+ # Examples
+ variant('examples-c', default=True,
+ description='Enable C examples')
+ variant('examples-cxx', default=False,
+ description='Enable C++ examples')
+ variant('examples-f77', default=True,
+ description='Enable Fortran 77 examples')
+ variant('examples-f90', default=False,
+ description='Enable Fortran 90 examples')
+ variant('examples-cuda', default=False,
+ description='Enable CUDA examples')
+ variant('examples-raja', default=False,
+ description='Enable RAJA examples')
+ variant('examples-install', default=True,
+ description='Install examples')
+
+ # Generic (std-c) math libraries (UNIX only)
+ variant('generic-math', default=True,
+ description='Use generic (std-c) math libraries on unix systems')
+
+ # ==========================================================================
+ # Conflicts
+ # ==========================================================================
+
+ # Options added after v2.6.2
+ conflicts('+hypre', when='@:2.6.2')
+ conflicts('+petsc', when='@:2.6.2')
+
+ # Options added after v2.7.0
+ conflicts('+cuda', when='@:2.7.0')
+ conflicts('+raja', when='@:2.7.0')
+ conflicts('~int64', when='@:2.7.0')
+ conflicts('+examples-cuda', when='@:2.7.0')
+ conflicts('+examples-raja', when='@:2.7.0')
+
+ # External libraries incompatible with 64-bit indices
+ conflicts('+lapack', when='@3.0.0-beta-2: +int64')
+ conflicts('+hypre', when='+hypre@:2.6.1a +int64')
+
+ # External libraries incompatible with single precision
+ conflicts('+klu', when='precision=single')
+ conflicts('+hypre', when='+hypre@:2.12.0 precision=single')
+
+ # External libraries incompatible with extended (quad) precision
+ conflicts('+lapack', when='precision=extended')
+ conflicts('+superlu-mt', when='precision=extended')
+ conflicts('+klu', when='precision=extended')
+ conflicts('+hypre', when='+hypre@:2.12.0 precision=extended')
+
+ # External libraries that need to be built with MPI
+ conflicts('+hypre', when='~mpi')
+ conflicts('+petsc', when='~mpi')
+
+ # SuperLU_MT interface requires lapack for external blas (before v3.0.0)
+ conflicts('+superlu-mt', when='@:2.7.0 ~lapack')
+
+ # ==========================================================================
+ # Dependencies
+ # ==========================================================================
+
+ # Build dependencies
+ depends_on('cmake@2.8.1:', type='build')
+
+ # MPI related dependencies
+ depends_on('mpi', when='+mpi')
+ depends_on('mpi', when='+hypre')
+ depends_on('mpi', when='+petsc')
+
+ # Other parallelism dependencies
+ depends_on('cuda', when='+cuda')
+ depends_on('raja', when='+raja')
+
+ # External libraries
+ depends_on('blas', when='+lapack')
+ depends_on('lapack', when='+lapack')
+ depends_on('suite-sparse', when='+klu')
+
+ # Require that external libraries built with the same precision
+ depends_on('petsc~double', when='+petsc precision=single')
+ depends_on('petsc+double', when='+petsc precision=double')
+
+ # Require that external libraries built with the same index type
+ depends_on('hypre~int64', when='+hypre ~int64')
+ depends_on('hypre+int64', when='+hypre +int64')
+ depends_on('petsc~int64', when='+petsc ~int64')
+ depends_on('petsc+int64', when='+petsc +int64')
+
+ # Require that PETSc is built with MPI
+ depends_on('petsc+mpi', when='+petsc')
+
+ # Require that SuperLU_MT built with external blas
+ depends_on('superlu-mt+blas', when='+superlu-mt')
+
+ # ==========================================================================
+ # SUNDIALS Settings
+ # ==========================================================================
+
+ def cmake_args(self):
+ spec = self.spec
def on_off(varstr):
return 'ON' if varstr in self.spec else 'OFF'
- cmake_args = std_cmake_args[:]
-
fortran_flag = self.compiler.pic_flag
if spec.satisfies('%clang platform=darwin'):
mpif77 = Executable(self.spec['mpi'].mpif77)
@@ -76,89 +214,152 @@ class Sundials(Package):
'libgfortran.a', output=str))
fortran_flag += ' ' + libgfortran.ld_flags
- cmake_args.extend([
- '-DBUILD_SHARED_LIBS=ON',
- '-DCMAKE_C_FLAGS={0}'.format(self.compiler.pic_flag),
- '-DCMAKE_Fortran_FLAGS={0}'.format(fortran_flag),
- '-DEXAMPLES_ENABLE=ON',
- '-DEXAMPLES_INSTALL=ON',
- '-DFCMIX_ENABLE=ON',
- '-DMPI_ENABLE=%s' % on_off('+mpi'),
- '-DLAPACK_ENABLE=%s' % on_off('+lapack'),
- '-DKLU_ENABLE=%s' % on_off('+klu'),
- '-DHYPRE_ENABLE=%s' % on_off('+hypre'),
- '-DSUPERLUMT_ENABLE=%s' % on_off('+superlu'),
- '-DOPENMP_ENABLE=%s' % on_off('+openmp'),
- '-DPTHREAD_ENABLE=%s' % on_off('+pthread')
+ # List of CMake arguments
+ # Note: CMAKE_INSTALL_PREFIX and CMAKE_BUILD_TYPE are set automatically
+ args = []
+
+ # SUNDIALS solvers
+ for pkg in self.sun_solvers:
+ args.extend(['-DBUILD_%s=%s' % (pkg, on_off('+' + pkg))])
+
+ # precision
+ args.extend([
+ '-DSUNDIALS_PRECISION=%s' % spec.variants['precision'].value
+ ])
+
+ # index type (after v2.7.0)
+ if not spec.satisfies('@:2.7.0'):
+ if '+int64' in spec:
+ args.extend(['-DSUNDIALS_INDEX_TYPE=int64_t'])
+ else:
+ args.extend(['-DSUNDIALS_INDEX_TYPE=int32_t'])
+
+ # Fortran interface
+ args.extend(['-DFCMIX_ENABLE=%s' % on_off('+fcmix')])
+
+ # library type
+ args.extend([
+ '-DBUILD_SHARED_LIBS=%s' % on_off('+shared'),
+ '-DBUILD_STATIC_LIBS=%s' % on_off('+static')
+ ])
+
+ # generic (std-c) math libraries
+ args.extend([
+ '-DUSE_GENERIC_MATH=%s' % on_off('+generic-math')
+ ])
+
+ # parallelism
+ args.extend([
+ '-DMPI_ENABLE=%s' % on_off('+mpi'),
+ '-DOPENMP_ENABLE=%s' % on_off('+openmp'),
+ '-DPTHREAD_ENABLE=%s' % on_off('+pthread'),
+ '-DCUDA_ENABLE=%s' % on_off('+cuda'),
+ '-DRAJA_ENABLE=%s' % on_off('+raja')
])
# MPI support
if '+mpi' in spec:
- cmake_args.extend([
- '-DMPI_MPICC={0}'.format(spec['mpi'].mpicc),
- '-DMPI_MPIF77={0}'.format(spec['mpi'].mpif77)
- ])
-
- # Building with Hypre
- if '+hypre' in spec and spec.satisfies('@2.7:'):
- cmake_args.extend([
- '-DHYPRE_INCLUDE_DIR={0}'.format(
- spec['hypre'].prefix.include),
- '-DHYPRE_LIBRARY_DIR={0}'.format(
- spec['hypre'].prefix.lib)
- ])
+ args.extend(['-DMPI_MPICC=%s' % spec['mpi'].mpicc])
+ if 'examples-cxx' in spec:
+ args.extend(['-DMPI_MPICXX=%s' % spec['mpi'].mpicxx])
+ if ('+fcmix' in spec) and ('+examples-f77' in spec):
+ args.extend(['-DMPI_MPIF77=%s' % spec['mpi'].mpif77])
+ if ('+fcmix' in spec) and ('+examples-f90' in spec):
+ args.extend(['-DMPI_MPIF90=%s' % spec['mpi'].mpifc])
# Building with LAPACK and BLAS
if '+lapack' in spec:
- cmake_args.extend([
- '-DLAPACK_LIBRARIES={0}'.format(
- (spec['lapack'].libs +
- spec['blas'].libs).joined(';')
- )
+ args.extend([
+ '-DLAPACK_ENABLE=ON',
+ '-DLAPACK_LIBRARIES=%s'
+ % (spec['lapack'].libs + spec['blas'].libs).joined(';')
])
# Building with KLU
if '+klu' in spec:
- cmake_args.extend([
- '-DKLU_INCLUDE_DIR={0}'.format(
- spec['suite-sparse'].prefix.include),
- '-DKLU_LIBRARY_DIR={0}'.format(
- spec['suite-sparse'].prefix.lib)
+ args.extend([
+ '-DKLU_ENABLE=ON',
+ '-DKLU_INCLUDE_DIR=%s' % spec['suite-sparse'].prefix.include,
+ '-DKLU_LIBRARY_DIR=%s' % spec['suite-sparse'].prefix.lib
])
# Building with SuperLU_MT
- if '+superlu' in spec:
- cmake_args.extend([
- '-DSUPERLUMT_INCLUDE_DIR={0}'.format(
- spec['superlu-mt'].prefix.include),
- '-DSUPERLUMT_LIBRARY_DIR={0}'.format(
- spec['superlu-mt'].prefix.lib)
+ if '+superlu-mt' in spec:
+ if not spec.satisfies('@:2.7.0'):
+ args.extend([
+ '-DBLAS_ENABLE=ON',
+ '-DBLAS_LIBRARIES=%s' % spec['blas'].libs
+ ])
+ args.extend([
+ '-DSUPERLUMT_ENABLE=ON',
+ '-DSUPERLUMT_INCLUDE_DIR=%s'
+ % spec['superlu-mt'].prefix.include,
+ '-DSUPERLUMT_LIBRARY_DIR=%s'
+ % spec['superlu-mt'].prefix.lib
])
- if '+openmp' in spec:
- cmake_args.append('-DSUPERLUMT_THREAD_TYPE=OpenMP')
- elif '+pthread' in spec:
- cmake_args.append('-DSUPERLUMT_THREAD_TYPE=Pthread')
+ if spec.satisfies('^superlu-mt+openmp'):
+ args.append('-DSUPERLUMT_THREAD_TYPE=OpenMP')
else:
- msg = 'You must choose either +openmp or +pthread when '
- msg += 'building with SuperLU_MT'
- raise RuntimeError(msg)
+ args.append('-DSUPERLUMT_THREAD_TYPE=Pthread')
- with working_dir('build', create=True):
- cmake('..', *cmake_args)
+ # Building with Hypre
+ if '+hypre' in spec:
+ args.extend([
+ '-DHYPRE_ENABLE=ON',
+ '-DHYPRE_INCLUDE_DIR=%s' % spec['hypre'].prefix.include,
+ '-DHYPRE_LIBRARY_DIR=%s' % spec['hypre'].prefix.lib
+ ])
- make()
- make('install')
+ # Building with PETSc
+ if '+petsc' in spec:
+ args.extend([
+ '-DPETSC_ENABLE=ON',
+ '-DPETSC_INCLUDE_DIR=%s' % spec['petsc'].prefix.include,
+ '-DPETSC_LIBRARY_DIR=%s' % spec['petsc'].prefix.lib
+ ])
- if (sys.platform == 'darwin'):
- fix_darwin_install_name(prefix.lib)
+ # Examples
+ if not spec.satisfies('@:2.7.0'):
+ args.extend([
+ '-DEXAMPLES_ENABLE_C=%s' % on_off('+examples-c'),
+ '-DEXAMPLES_ENABLE_CXX=%s' % on_off('+examples-cxx'),
+ '-DEXAMPLES_ENABLE_F77=%s' % on_off('+examples-f77'),
+ '-DEXAMPLES_ENABLE_F90=%s' % on_off('+examples-f90'),
+ '-DEXAMPLES_ENABLE_CUDA=%s' % on_off('+examples-cuda'),
+ '-DEXAMPLES_ENABLE_RAJA=%s' % on_off('+examples-raja')
+ ])
+ else:
+ args.extend([
+ '-DEXAMPLES_ENABLE=%s' % on_off('+examples-c'),
+ '-DCXX_ENABLE=%s' % on_off('+examples-cxx'),
+ '-DF90_ENABLE=%s' % on_off('+examples-f90')
+ ])
- install('LICENSE', prefix)
+ args.extend([
+ '-DEXAMPLES_INSTALL=%s' % on_off('+examples-install')
+ ])
- self.filter_compilers()
+ return args
+ # ==========================================================================
+ # Post Install Actions
+ # ==========================================================================
+
+ @run_after('install')
+ def post_install(self):
+ """Run after install to fix install name of dynamic libraries
+ on Darwin to have full path and install the LICENSE file."""
+ prefix = self.spec.prefix
+
+ if (sys.platform == 'darwin'):
+ fix_darwin_install_name(prefix.lib)
+
+ install('LICENSE', prefix)
+
+ @run_after('install')
def filter_compilers(self):
- """Run after install to tell the Makefiles to use
- the compilers that Spack built the package with.
+ """Run after install to tell the example program Makefiles
+ to use the compilers that Spack built the package with.
If this isn't done, they'll have CC, CPP, and F77 set to
Spack's generic cc and f77. We want them to be bound to
@@ -168,26 +369,101 @@ class Sundials(Package):
dirname = os.path.join(self.prefix, 'examples')
cc_files = [
- 'arkode/C_serial/Makefile', 'arkode/C_parallel/Makefile',
- 'cvode/serial/Makefile', 'cvode/parallel/Makefile',
- 'cvodes/serial/Makefile', 'cvodes/parallel/Makefile',
- 'ida/serial/Makefile', 'ida/parallel/Makefile',
- 'idas/serial/Makefile', 'idas/parallel/Makefile',
- 'kinsol/serial/Makefile', 'kinsol/parallel/Makefile',
- 'nvector/serial/Makefile', 'nvector/parallel/Makefile',
- 'nvector/pthreads/Makefile'
+ 'arkode/C_openmp/Makefile',
+ 'arkode/C_parallel/Makefile',
+ 'arkode/C_parhyp/Makefile',
+ 'arkode/C_serial/Makefile',
+ 'cvode/C_openmp/Makefile',
+ 'cvode/parallel/Makefile',
+ 'cvode/parhyp/Makefile',
+ 'cvode/serial/Makefile',
+ 'cvodes/C_openmp/Makefile',
+ 'cvodes/parallel/Makefile',
+ 'cvodes/serial/Makefile',
+ 'ida/C_openmp/Makefile',
+ 'ida/parallel/Makefile',
+ 'ida/petsc/Makefile',
+ 'ida/serial/Makefile',
+ 'idas/C_openmp/Makefile',
+ 'idas/parallel/Makefile',
+ 'idas/serial/Makefile',
+ 'kinsol/C_openmp/Makefile',
+ 'kinsol/parallel/Makefile',
+ 'kinsol/serial/Makefile',
+ 'nvector/C_openmp/Makefile',
+ 'nvector/parallel/Makefile',
+ 'nvector/parhyp/Makefile',
+ 'nvector/petsc/Makefile',
+ 'nvector/pthreads/Makefile',
+ 'nvector/serial/Makefile',
+ 'sunlinsol/band/Makefile',
+ 'sunlinsol/dense/Makefile',
+ 'sunlinsol/klu/Makefile',
+ 'sunlinsol/lapackband/Makefile',
+ 'sunlinsol/lapackdense/Makefile',
+ 'sunlinsol/pcg/parallel/Makefile',
+ 'sunlinsol/pcg/serial/Makefile',
+ 'sunlinsol/spbcgs/parallel/Makefile',
+ 'sunlinsol/spbcgs/serial/Makefile',
+ 'sunlinsol/spfgmr/parallel/Makefile',
+ 'sunlinsol/spfgmr/serial/Makefile',
+ 'sunlinsol/spgmr/parallel/Makefile',
+ 'sunlinsol/spgmr/serial/Makefile',
+ 'sunlinsol/sptfqmr/parallel/Makefile',
+ 'sunlinsol/sptfqmr/serial/Makefile',
+ 'sunlinsol/superlumt/Makefile',
+ 'sunmatrix/band/Makefile',
+ 'sunmatrix/dense/Makefile',
+ 'sunmatrix/sparse/Makefile'
+ ]
+
+ cxx_files = [
+ 'arkode/CXX_parallel/Makefile',
+ 'arkode/CXX_serial/Makefile'
+ 'cvode/cuda/Makefile',
+ 'cvode/raja/Makefile',
+ 'nvector/cuda/Makefile',
+ 'nvector/raja/Makefile'
]
f77_files = [
- 'arkode/F77_serial/Makefile', 'cvode/fcmix_serial/Makefile',
- 'ida/fcmix_serial/Makefile', 'ida/fcmix_pthreads/Makefile',
+ 'arkode/F77_parallel/Makefile',
+ 'arkode/F77_serial/Makefile',
+ 'cvode/fcmix_parallel/Makefile',
+ 'cvode/fcmix_serial/Makefile',
+ 'ida/fcmix_openmp/Makefile',
+ 'ida/fcmix_parallel/Makefile',
+ 'ida/fcmix_pthreads/Makefile',
+ 'ida/fcmix_serial/Makefile',
+ 'kinsol/fcmix_parallel/Makefile',
'kinsol/fcmix_serial/Makefile'
]
+ f90_files = [
+ 'arkode/F90_parallel/Makefile',
+ 'arkode/F90_serial/Makefile'
+ ]
+
for filename in cc_files:
filter_file(os.environ['CC'], self.compiler.cc,
os.path.join(dirname, filename), **kwargs)
+ for filename in cc_files:
+ filter_file(r'^CPP\s*=.*', self.compiler.cc,
+ os.path.join(dirname, filename), **kwargs)
+
+ for filename in cxx_files:
+ filter_file(os.environ['CXX'], self.compiler.cxx,
+ os.path.join(dirname, filename), **kwargs)
+
+ for filename in cxx_files:
+ filter_file(r'^CPP\s*=.*', self.compiler.cc,
+ os.path.join(dirname, filename), **kwargs)
+
for filename in f77_files:
filter_file(os.environ['F77'], self.compiler.f77,
os.path.join(dirname, filename), **kwargs)
+
+ for filename in f90_files:
+ filter_file(os.environ['FC'], self.compiler.fc,
+ os.path.join(dirname, filename), **kwargs)