diff options
Diffstat (limited to 'var/spack/repos/builtin/packages/petsc/package.py')
-rw-r--r-- | var/spack/repos/builtin/packages/petsc/package.py | 152 |
1 files changed, 108 insertions, 44 deletions
diff --git a/var/spack/repos/builtin/packages/petsc/package.py b/var/spack/repos/builtin/packages/petsc/package.py index 838369f4e4..8be5d8cce5 100644 --- a/var/spack/repos/builtin/packages/petsc/package.py +++ b/var/spack/repos/builtin/packages/petsc/package.py @@ -1,27 +1,8 @@ -############################################################################## -# Copyright (c) 2013-2017, Lawrence Livermore National Security, LLC. -# Produced at the Lawrence Livermore National Laboratory. +# Copyright 2013-2018 Lawrence Livermore National Security, LLC and other +# Spack Project Developers. See the top-level COPYRIGHT file for details. # -# This file is part of Spack. -# Created by Todd Gamblin, tgamblin@llnl.gov, All rights reserved. -# LLNL-CODE-647188 -# -# For details, see https://github.com/spack/spack -# Please also see the NOTICE and LICENSE files for our notice and the LGPL. -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU Lesser General Public License (as -# published by the Free Software Foundation) version 2.1, February 1999. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the IMPLIED WARRANTY OF -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the terms and -# conditions of the GNU Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -############################################################################## +# SPDX-License-Identifier: (Apache-2.0 OR MIT) + import os import sys @@ -35,13 +16,24 @@ class Petsc(Package): """ homepage = "http://www.mcs.anl.gov/petsc/index.html" - url = "http://ftp.mcs.anl.gov/pub/petsc/release-snapshots/petsc-3.5.3.tar.gz" + url = "http://ftp.mcs.anl.gov/pub/petsc/release-snapshots/petsc-3.5.3.tar.gz" + git = "https://bitbucket.org/petsc/petsc.git" - maintainers = ['balay', 'barrysmith'] + maintainers = ['balay', 'barrysmith', 'jedbrown'] - version('develop', git='https://bitbucket.org/petsc/petsc.git', tag='master') - version('xsdk-0.2.0', git='https://bitbucket.org/petsc/petsc.git', tag='xsdk-0.2.0') + version('develop', branch='master') + version('xsdk-0.2.0', tag='xsdk-0.2.0') + version('3.10.2', '63ed950653ae9b8d19daea47e24c0338') + version('3.10.1', '2d0d5a9bd8112a4147a2a23f7f62a906') + version('3.10.0', '0240c2ce8c54e47b3531a743ee844d41') + version('3.9.4', 'c98eb67573efb2f91c6f239368259e44') + version('3.9.3', '7b71d705f66f9961cb0e2da3f9da79a1') + version('3.9.2', '8bedc0cd8c8603d54bfd99a6e8f77b3d') + version('3.9.1', 'd3a229a188dbeef9b3f29b9a63622fad') + version('3.9.0', '34b8a81814ca050a96d58e53a2f0ac7a') + version('3.8.4', 'd7767fe2919536aa393eb22841899306') + version('3.8.3', '322cbcf2a0f7b7bad562643b05d66f11') version('3.8.2', '00666e1c4cbfa8dd6eebf91ff8180f79') version('3.8.1', '3ed75c1147800fc156fe1f1e515a68a7') version('3.8.0', '02680f1f78a0d4c5a9de80a366793eb8') @@ -69,7 +61,6 @@ class Petsc(Package): description='Activates support for metis and parmetis') variant('hdf5', default=True, description='Activates support for HDF5 (only parallel)') - variant('boost', default=True, description='Activates support for Boost') variant('hypre', default=True, description='Activates support for Hypre (only parallel)') # Mumps is disabled by default, because it depends on Scalapack @@ -83,6 +74,11 @@ class Petsc(Package): description='Activates support for Trilinos (only parallel)') variant('int64', default=False, description='Compile with 64bit indices') + variant('clanguage', default='C', values=('C', 'C++'), + description='Specify C (recommended) or C++ to compile PETSc', + multi=False) + variant('suite-sparse', default=False, + description='Activates support for SuiteSparse') # 3.8.0 has a build issue with MKL - so list this conflict explicitly conflicts('^intel-mkl', when='@3.8.0') @@ -93,6 +89,7 @@ class Petsc(Package): if sys.platform == "darwin": patch('macos-clang-8.1.0.diff', when='@3.7.5%clang@8.1.0:') + patch('pkg-config-3.7.6-3.8.4.diff', when='@3.7.6:3.8.4') # Virtual dependencies # Git repository needs sowing to build Fortran interface @@ -108,11 +105,13 @@ class Petsc(Package): depends_on('python@2.6:2.8', type='build') # Other dependencies - depends_on('boost', when='@:3.5+boost') - depends_on('metis@5:~int64+real64', when='+metis~int64+double') - depends_on('metis@5:+int64', when='+metis+int64~double') - depends_on('metis@5:~int64+real64', when='+metis~int64+double') - depends_on('metis@5:+int64', when='+metis+int64~double') + depends_on('metis@5:~int64+real64', when='@:3.7.99+metis~int64+double') + depends_on('metis@5:~int64', when='@:3.7.99+metis~int64~double') + depends_on('metis@5:+int64+real64', when='@:3.7.99+metis+int64+double') + depends_on('metis@5:+int64', when='@:3.7.99+metis+int64~double') + # petsc-3.8+ uses default (float) metis with any (petsc) precision + depends_on('metis@5:~int64', when='@3.8:+metis~int64') + depends_on('metis@5:+int64', when='@3.8:+metis+int64') depends_on('hdf5+mpi+hl', when='+hdf5+mpi') depends_on('zlib', when='+hdf5') @@ -121,18 +120,22 @@ class Petsc(Package): # Also PETSc prefer to build it without internal superlu, likely due to # conflict in headers see # https://bitbucket.org/petsc/petsc/src/90564b43f6b05485163c147b464b5d6d28cde3ef/config/BuildSystem/config/packages/hypre.py - depends_on('hypre~internal-superlu~int64', when='+hypre+mpi~complex~int64') + depends_on('hypre@:2.13.99~internal-superlu~int64', when='@:3.8.99+hypre+mpi~complex~int64') + depends_on('hypre@:2.13.99~internal-superlu+int64', when='@:3.8.99+hypre+mpi~complex+int64') + depends_on('hypre@2.14:~internal-superlu~int64', when='@3.9:+hypre+mpi~complex~int64') + depends_on('hypre@2.14:~internal-superlu+int64', when='@3.9+hypre+mpi~complex+int64') depends_on('hypre@xsdk-0.2.0~internal-superlu+int64', when='@xsdk-0.2.0+hypre+mpi~complex+int64') depends_on('hypre@xsdk-0.2.0~internal-superlu~int64', when='@xsdk-0.2.0+hypre+mpi~complex~int64') depends_on('hypre@develop~internal-superlu+int64', when='@develop+hypre+mpi~complex+int64') depends_on('hypre@develop~internal-superlu~int64', when='@develop+hypre+mpi~complex~int64') - depends_on('hypre~internal-superlu+int64', when='+hypre+mpi~complex+int64') depends_on('superlu-dist@:4.3~int64', when='@3.4.4:3.6.4+superlu-dist+mpi~int64') depends_on('superlu-dist@:4.3+int64', when='@3.4.4:3.6.4+superlu-dist+mpi+int64') depends_on('superlu-dist@5.0.0:~int64', when='@3.7:3.7.99+superlu-dist+mpi~int64') depends_on('superlu-dist@5.0.0:+int64', when='@3.7:3.7.99+superlu-dist+mpi+int64') - depends_on('superlu-dist@5.2:5.2.99~int64', when='@3.8:3.8.99+superlu-dist+mpi~int64') - depends_on('superlu-dist@5.2:5.2.99+int64', when='@3.8:3.8.99+superlu-dist+mpi+int64') + depends_on('superlu-dist@5.2:5.2.99~int64', when='@3.8:3.9.99+superlu-dist+mpi~int64') + depends_on('superlu-dist@5.2:5.2.99+int64', when='@3.8:3.9.99+superlu-dist+mpi+int64') + depends_on('superlu-dist@5.4:5.4.99~int64', when='@3.10:3.10.99+superlu-dist+mpi~int64') + depends_on('superlu-dist@5.4:5.4.99+int64', when='@3.10:3.10.99+superlu-dist+mpi+int64') depends_on('superlu-dist@xsdk-0.2.0~int64', when='@xsdk-0.2.0+superlu-dist+mpi~int64') depends_on('superlu-dist@xsdk-0.2.0+int64', when='@xsdk-0.2.0+superlu-dist+mpi+int64') depends_on('superlu-dist@develop~int64', when='@develop+superlu-dist+mpi~int64') @@ -142,6 +145,7 @@ class Petsc(Package): depends_on('trilinos@12.6.2:', when='@3.7.0:+trilinos+mpi') depends_on('trilinos@xsdk-0.2.0', when='@xsdk-0.2.0+trilinos+mpi') depends_on('trilinos@develop', when='@xdevelop+trilinos+mpi') + depends_on('suite-sparse', when='+suite-sparse') def mpi_dependent_options(self): if '~mpi' in self.spec: @@ -169,8 +173,12 @@ class Petsc(Package): compiler_opts = [ '--with-cc=%s' % self.spec['mpi'].mpicc, '--with-cxx=%s' % self.spec['mpi'].mpicxx, - '--with-fc=%s' % self.spec['mpi'].mpifc + '--with-fc=%s' % self.spec['mpi'].mpifc, ] + if self.spec.satisfies('%intel'): + # mpiifort needs some help to automatically link + # all necessary run-time libraries + compiler_opts.append('--FC_LINKER_FLAGS=-lintlc') return compiler_opts def install(self, spec, prefix): @@ -178,7 +186,13 @@ class Petsc(Package): '--with-x=0', '--download-c2html=0', '--download-sowing=0', - '--download-hwloc=0'] + '--download-hwloc=0', + 'CFLAGS=%s' % ' '.join(spec.compiler_flags['cflags']), + 'FFLAGS=%s' % ' '.join(spec.compiler_flags['fflags']), + 'CXXFLAGS=%s' % ' '.join(spec.compiler_flags['cxxflags']), + 'COPTFLAGS=', + 'FOPTFLAGS=', + 'CXXOPTFLAGS='] options.extend(self.mpi_dependent_options()) options.extend([ '--with-precision=%s' % ( @@ -198,9 +212,17 @@ class Petsc(Package): if 'trilinos' in spec: options.append('--with-cxx-dialect=C++11') + if spec.satisfies('^trilinos+boost'): + options.append('--with-boost=1') + + if self.spec.satisfies('clanguage=C++'): + options.append('--with-clanguage=C++') + else: + options.append('--with-clanguage=C') - # Help PETSc pick up Scalapack from MKL: - if 'scalapack' in spec: + # PETSc depends on scalapack when '+mumps+mpi~int64' (see depends()) + # help PETSc pick up Scalapack from MKL + if spec.satisfies('+mumps+mpi~int64'): scalapack = spec['scalapack'].libs options.extend([ '--with-scalapack-lib=%s' % scalapack.joined(), @@ -212,8 +234,8 @@ class Petsc(Package): ]) # Activates library support if needed - for library in ('metis', 'boost', 'hdf5', 'hypre', 'parmetis', - 'mumps', 'trilinos', 'zlib'): + for library in ('metis', 'hdf5', 'hypre', 'parmetis', + 'mumps', 'trilinos'): options.append( '--with-{library}={value}'.format( library=library, value=('1' if library in spec else '0')) @@ -238,8 +260,31 @@ class Petsc(Package): options.append( '--with-superlu_dist=0' ) + # SuiteSparse: configuring using '--with-suitesparse-dir=...' has some + # issues, so specify directly the include path and the libraries. + if '+suite-sparse' in spec: + ss_spec = 'suite-sparse:umfpack,klu,cholmod,btf,ccolamd,colamd,' \ + 'camd,amd,suitesparseconfig' + options.extend([ + '--with-suitesparse-include=%s' % spec[ss_spec].prefix.include, + '--with-suitesparse-lib=%s' % spec[ss_spec].libs.ld_flags, + '--with-suitesparse=1' + ]) + else: + options.append('--with-suitesparse=0') + + # zlib: configuring using '--with-zlib-dir=...' has some issues with + # SuiteSparse so specify directly the include path and the libraries. + if 'zlib' in spec: + options.extend([ + '--with-zlib-include=%s' % spec['zlib'].prefix.include, + '--with-zlib-lib=%s' % spec['zlib'].libs.ld_flags, + '--with-zlib=1' + ]) + else: + options.append('--with-zlib=0') - configure('--prefix=%s' % prefix, *options) + python('configure', '--prefix=%s' % prefix, *options) # PETSc has its own way of doing parallel make. make('MAKE_NP=%s' % make_jobs, parallel=False) @@ -253,6 +298,18 @@ class Petsc(Package): cc('ex50.c', '-I%s' % prefix.include, '-L%s' % prefix.lib, '-lpetsc', '-lm', '-o', 'ex50') run = Executable(join_path(spec['mpi'].prefix.bin, 'mpirun')) + # For Spectrum MPI, if -np is omitted, the default behavior is + # to assign one process per process slot, where the default + # process slot allocation is one per core. On systems with + # many cores, the number of processes can exceed the size of + # the grid specified when the testcase is run and the test case + # fails. Specify a small number of processes to prevent + # failure. + # For more information about Spectrum MPI invocation, see URL + # https://www.ibm.com/support/knowledgecenter/en/SSZTET_10.1.0/smpi02/smpi02_mpirun_options.html + if ('spectrum-mpi' in spec): + run.add_default_arg('-np') + run.add_default_arg('4') run('ex50', '-da_grid_x', '4', '-da_grid_y', '4') if 'superlu-dist' in spec: run('ex50', @@ -288,3 +345,10 @@ class Petsc(Package): # Set up PETSC_DIR for everyone using PETSc package spack_env.set('PETSC_DIR', self.prefix) spack_env.unset('PETSC_ARCH') + + @property + def headers(self): + return find_headers('petsc', self.prefix.include, recursive=False) \ + or None # return None to indicate failure + + # For the 'libs' property - use the default handler. |