1 of 10

Intro to Spack

2 of 10

spack

  • https://github.com/spack/spack
  • https://spack.io/
  • Package manager that builds packages from source
  • Sophisticated dependency management
  • Can build many versions of each package

3 of 10

The E3SM-Project/spack fork

  • https://github.com/E3SM-Project/spack
  • develop branch
  • Based on v0.18.1 (latest release)
  • Custom packages, releases, tweaks:
    • trilinos-for-albany
    • albany
    • scorpio
    • tempestextremes
    • …

4 of 10

Environments: Making a yaml file

  • Like conda virtual environments
  • specs: the packages to install
  • concretizer: unify: true
    • All packages have to be mutually compatible
  • packages: details on each package
    • all: packages like compilers, MPI, lapack
  • compilers:
    • Full path to executable (but not on Cray)
    • OS and target (spack can tell you)

spack:

specs:

- gcc

- mpich

- …

concretizer:

unify: true

packages:

all:

compiler: [gcc@11.2.0]

providers:

mpi: [mpich@8.1.15]

…

config:

install_missing_compilers: false

compilers:

- compiler:

spec: gcc@11.2.0

paths:

cc: cc

cxx: CC

f77: ftn

fc: ftn

flags: {}

operating_system: sles15

target: x86_64

modules: []

environment: {}

5 of 10

Environments: Using external modules

  • spec:
    • version number
    • “variant” on (+) or off (~)
    • See package.py (or docs?) for details
  • path prefix
  • module name(s)
  • Use buildable: false

gcc:

externals:

- spec: gcc@11.2.0

prefix: /opt/cray/pe/gcc/11.2.0/

modules:

- gcc/11.2.0

buildable: false

mpich:

externals:

- spec: mpich@8.1.15

prefix: /opt/cray/pe/mpich/8.1.15/ofi/gnu/9.1

modules:

- libfabric/1.15.0.0

- cray-mpich/8.1.15

buildable: false

hdf5:

externals:

- spec: hdf5@1.12.1.1~cxx+fortran+hl~java+mpi+shared

prefix: /opt/cray/pe/hdf5-parallel/1.12.1.1/GNU/9.1

modules:

- cray-hdf5-parallel/1.12.1.1

buildable: false

6 of 10

package.py basics

  • Example: scorpio
  • url: code path for any version
  • version and sha256 or branch
  • variant and whether on or off by default
  • depends_on
    • when: depends on variant
    • type=’link’: will link to this library

from spack import *

​

​

class Scorpio(CMakePackage):

homepage = "https://github.com/E3SM-Project/scorpio"

url = "https://github.com/E3SM-Project/scorpio/archive/refs/tags/scorpio-v1.2.2.tar.gz"

​

maintainers = ['xylar']

​

version('develop', branch='master')

version('1.3.2', sha256='663805fa24e85c88509ecd7893264e3d7d2ff27efb304e0f75dd1f0c450b08a6')

version('1.3.1', sha256='4ee6db92fff562e49c58ca1e147f242dd6c7168b7d10c3ec47b399f0d683ce5b')

​

variant('pnetcdf', default=False, description='enable pnetcdf')

variant('timing', default=False, description='enable GPTL timing')

variant('internal-timing', default=False,

description='gather and print GPL timing stats')

variant('tools', default=False, description='enable SCORPIO tools')

variant('malloc', default=True,

description='use native malloc (instead of bget package)')

​

depends_on('gptl', when='+timing')

depends_on('mpi')

depends_on('netcdf-c +mpi', type='link')

depends_on('netcdf-fortran', type='link')

depends_on('parallel-netcdf', type='link', when='+pnetcdf')

7 of 10

package.py basics (continued)

  • Example: scorpio
  • patches
  • cmake_args(), e.g.:
    • get MPI compilers
    • provide paths to libs
    • translate variants to CMake flags

class Scorpio(CMakePackage):

…

patch('6f1ecba7774293d3db34226b09339b32a28f24a3.patch', when='@1.3.2')

patch('a248097a015b14c7015a3ce23a032f15b5fe7612.patch', when='@1.3.2')

​

def cmake_args(self):

define = self.define

define_from_variant = self.define_from_variant

spec = self.spec

env['CC'] = spec['mpi'].mpicc

env['CXX'] = spec['mpi'].mpicxx

env['FC'] = spec['mpi'].mpifc

src = self.stage.source_path

args = [

define('NetCDF_C_PATH', spec['netcdf-c'].prefix),

define('NetCDF_Fortran_PATH', spec['netcdf-fortran'].prefix),

]

if spec.satisfies('+pnetcdf'):

args.extend([

define('PnetCDF_C_PATH', spec['parallel-netcdf'].prefix),

define('PnetCDF_Fortran_PATH', spec['parallel-netcdf'].prefix),

])

args.extend([

define_from_variant('WITH_PNETCDF', 'pnetcdf'),

define_from_variant('PIO_ENABLE_TIMING', 'timing'),

define_from_variant('PIO_ENABLE_INTERNAL_TIMING',

'internal-timing'),

define_from_variant('PIO_ENABLE_TOOLS ', 'tools'),

define_from_variant('PIO_USE_MALLOC', 'malloc'),

])

return args

8 of 10

mache

  • https://github.com/E3SM-Project/mache
  • Python package
  • Recognizes E3SM supported machines
  • Shared paths, config options, etc.
  • Spack environment yaml templates for supported compilers/MPI

9 of 10

mache: example jinja template

10 of 10

compass

  • https://github.com/MPAS-Dev/compass
  • Python package
  • Test cases for MALI, MPAS-Ocean (soon OMEGA, Albany Land Ice?)
  • Regression tests
  • Initial conditions for E3SM