Spack sc24 Tutorial Slides
Spack sc24 Tutorial Slides
SC24 Tutorial
November 18, 2024
spack-tutorial.rtfd.io
We also have a chat room on Spack slack.
You can join here:
slack.spack.io
Join the #tutorial channel!
You can ask questions here after the conference is over.
Over 3,400 people can help you on Slack!
Morning Afternoon
Intro 8:30 am Software Stacks 1:30 pm
Basics Packaging
Concepts Break 3:00 pm
Break 10:00 am Developer Workflows 3:30 pm
Environments 10:30 am Mirrors & Binary Caches
Configuration Scripting
Lunch 12:00 pm End 5:00 pm
Just when we’re starting to solve the problem of how to create software using reusable parts, it
founders on the nuts-and-bolts problems outside the software itself.
P. DuBois & T. Epperly. Why Johnny Can’t Build. Scientific Programming. Sep/Oct 2003.
▪ Cons:
— Teams must ensure that components work together
— Integration burden increases with each additional library
— Integration must be repeated with each update to components
— Components must be vetted!
▪ Managing changes over time is becoming intractable Appears to work; subtle errors later
r-condop:
R Genome Data Analysis Tools
179 packages,
527 dependencies
Join #tutorial on Slack: slack.spack.io Materials: spack-tutorial.readthedocs.io 7
LLNL-PRES-806064
ECP’s E4S stack is even larger than these codes
30 12 71
▪ Most modern software uses tons of open source
LLNL-PRES-806064
Outside these boundaries, Materials:
users are
Join #tutorial on Slack: slack.spack.io typically on their own
spack-tutorial.readthedocs.io 10
High Performance Computing (HPC)
violates many of these assumptions
▪ Code is typically distributed as source Some Supercomputers
— With exception of vendor libraries, compilers
▪ Multi-language
— C, C++, Fortran, Python, others
Lawrence Livermore
all in the same ecosystem National Lab
Oak Ridge National Lab
AMD Zen / Radeon AMD Zen / Radeon
• Packages are parameterized, so that users can easily tweak and tune configuration
No installation required: clone and go
$ git clone https://github.com/spack/spack
$ spack install hdf5
3. Package Developers
— People who want to package their own software for distribution
2024
Fall Fall
2018 2021
▪ Intel contributing OneApi support and licenses for our build farm
▪ Fujitsu and RIKEN have contributed a huge number of packages for ARM/a64fx support on Fugaku
Highlights:
1. Language Runtimes: depends_on("c"|"cxx"|"fortran")
2. ABI splicing: Build binaries with mpich, deploy w/mvapich2, etc.
3. Broader variant propagation: ++shared, build_system==Release
4. Query by namespace with spack find namespace=myrepo
5. UI Improvements
• More concise output for spack spec
• Explore concretized environments with spack find -c
• spack -C <env> to use just an environment’s configuration
6. New commands: spack env track/untrack
7. ML binary stacks for Grace-Hopper
github.com/spack/spack
8. Devtools binary stack for macos
Full release notes: https://github.com/spack/spack/releases/tag/v0.23.0
▪ Easybuild
— An installation tool for HPC https://easybuild.io
— Focused on HPC system administrators – different package model from Spack
— Relies on a fixed software stack – harder to tweak recipes for experimentation
LLNL-PRES-806064
Join #tutorial on Slack: slack.spack.io Materials: spack-tutorial.readthedocs.io 25
Core Spack Concepts
LLNL-PRES-806064
Join #tutorial on Slack: slack.spack.io Materials: spack-tutorial.readthedocs.io 26
Most existing tools do not support combinatorial versioning
▪ Port systems
— BSD Ports, portage, Macports, Homebrew, Gentoo, etc.
— Minimal support for builds parameterized by compilers, dependency versions.
LLNL-PRES-806064
Join #tutorial on Slack: slack.spack.io Materials: spack-tutorial.readthedocs.io 27
Spack provides a spec syntax to describe customized package
configurations
$ spack install mpileaks unconstrained
$ spack install [email protected] @ custom version
$ spack install [email protected] %[email protected] % custom compiler
$ spack install [email protected] %[email protected] +threads +/- build option
$ spack install [email protected] cppflags="-O3 –g3" set compiler flags
$ spack install [email protected] target=cascadelake set target microarchitecture
$ spack install [email protected] ^[email protected] %[email protected] ^ dependency constraints
LLNL-PRES-806064
Join #tutorial on Slack: slack.spack.io Materials: spack-tutorial.readthedocs.io 28
Spack packages are parameterized using the spec syntax
Python DSL defines many ways to build
from spack import *
Base package
class Kripke(CMakePackage): (CMake support)
"""Kripke is a simple, scalable, 3D Sn deterministic particle transport mini-app."""
version(‘1.2.3’, sha256='3f7f2eef0d1ba5825780d626741eb0b3f026a096048d7ec4794d2a7dfbe2b8a6’)
version(‘1.2.2’, sha256='eaf9ddf562416974157b34d00c3a1c880fc5296fce2aa2efa039a86e0976f3a3’) Versions
version('1.1’, sha256='232d74072fc7b848fa2adc8a1bc839ae8fb5f96d50224186601f55554a25f64a’)
LLNL-PRES-806064
Join #tutorial on Slack: slack.spack.io Materials: spack-tutorial.readthedocs.io 29
Conditional variants simplify packages
CudaPackage: a mix-in for packages that use CUDA
▪ Spack can ensure that builds use the same compiler, or you can mix
— Working on ensuring ABI compatibility when compilers are mixed.
LLNL-PRES-806064
Join #tutorial on Slack: slack.spack.io Materials: spack-tutorial.readthedocs.io 31
Spack handles ABI-incompatible, versioned interfaces like MPI
▪ Install the same package built with two different MPI implementations:
LLNL-PRES-806064
Join #tutorial on Slack: slack.spack.io Materials: spack-tutorial.readthedocs.io 32
Concretization fills in missing configuration details
when the user is not explicit.
mpileaks ^[email protected]+debug ^[email protected] User input: abstract spec with some constraints
spec.yaml
Normalize
spec:
- mpileaks:
arch: linux-x86_64
compiler:
name: gcc
version: 4.9.2
dependencies:
adept-utils: kszrtkpbzac3ss2ixcjkcorlaybnptp4
callpath: bah5f4h4d2n47mgycej2mtrnrivvxy77
mpich: aa4ar6ifj23yijqmdabeakpejcli72t3
hash: 33hjjhxi7p6gyzn5ptgyes7sghyprujh
variants: {}
version: '1.0'
- adept-utils:
arch: linux-x86_64
compiler:
Concretize Store name: gcc
version: 4.9.2
dependencies:
boost: teesjv7ehpe5ksspjim5dk43a7qnowlq
mpich: aa4ar6ifj23yijqmdabeakpejcli72t3
hash: kszrtkpbzac3ss2ixcjkcorlaybnptp4
variants: {}
version: 1.0.1
- boost:
arch: linux-x86_64
compiler:
name: gcc
version: 4.9.2
dependencies: {}
hash: teesjv7ehpe5ksspjim5dk43a7qnowlq
variants: {}
version: 1.59.0
...
Abstract, normalized spec Concrete spec is fully constrained Detailed provenance is stored
with some dependencies. and can be passed to install. with the installed package
LLNL-PRES-806064
Join #tutorial on Slack: slack.spack.io Materials: spack-tutorial.readthedocs.io 33
Hashing allows us to handle combinatorial complexity
LLNL-PRES-806064
Join #tutorial on Slack: slack.spack.io Materials: spack-tutorial.readthedocs.io 34
An isolated compilation environment allows Spack
to easily swap compilers
Spack ▪ Forked build process isolates environment for each build.
do_install()
Process Uses compiler wrappers to:
— Add include, lib, and RPATH flags
— Ensure that dependencies are found automatically
Install dep1 Install dep2 … Install package
— Load Cray modules (use right compiler/system deps)
LLNL-PRES-806064
Join #tutorial on Slack: slack.spack.io Materials: spack-tutorial.readthedocs.io 35
We can configure Spack to build with external software
mpileaks ^[email protected]+debug
^openmpi ^[email protected]
packages.yaml
packages:
mpi:
buildable: Fal se
paths:
[email protected] %[email protected] arch=linux-rhel6-ppc64:
/path/to/external /gcc/openmpi-2.0.0
[email protected] %gcc@ 4.7.3 arch=linux-rhel6-ppc64:
/path/to/external /gcc/openmpi-1.10.3
...
/path/to/external/gcc/openmpi-2.0.0
LLNL-PRES-806064
Join #tutorial on Slack: slack.spack.io Materials: spack-tutorial.readthedocs.io 36
Spack package repositories allow stacks to be layered
marbl llnl.wci.mapp
blast miranda
Common internal
$ spack repo create /path/to/my_repo packages
leos llnl.wci
LLNL-PRES-806064
Join #tutorial on Slack: slack.spack.io Materials: spack-tutorial.readthedocs.io 37
Spack mirrors Original source
on internet
▪ Spack allows you to define mirrors:
OCI Registry
▪ Directories in the filesystem
▪ On a web server
▪ In an S3 bucket S3 Bucket
LLNL-PRES-806064
Join #tutorial on Slack: slack.spack.io Materials: spack-tutorial.readthedocs.io 38
The concretizer includes information from Dependency solving
packages, configuration, and CLI is NP-hard
Contributors
package.py repository
• new versions
• new dependencies
• new constraints
concretizer
spack yaml default config
developers packages.yaml
admins, yaml local preferences config
users packages.yaml
LLNL-PRES-806064
Join #tutorial on Slack: slack.spack.io Materials: spack-tutorial.readthedocs.io 39
We use logic programming to simplify package solving
1. Resolve metadata
▪ Hash matches are very
sensitive to small changes
2. Create per-node hashes
74mwnxgn6nujehpyyalhwizwojwn5zga
Package ▪ Nix, Spack, Guix, Conan,
??
cache and others reuse this way
6zvh4ueem6f5yrcfugh67k2hrtxbgbcs
3. Query for exact hash match
LLNL-PRES-806064
Join #tutorial on Slack: slack.spack.io Materials: spack-tutorial.readthedocs.io 41
--reuse (now the default) is more aggressive
LLNL-PRES-806064
Join #tutorial on Slack: slack.spack.io Materials: spack-tutorial.readthedocs.io 42
Telling the solver to minimize builds is
surprisingly simple in ASP
1. Allow the solver to choose a hash for any package:
4. Minimize builds!
LLNL-PRES-806064
Join #tutorial on Slack: slack.spack.io Materials: spack-tutorial.readthedocs.io 43
With and without --reuse optimization
Pure hash-based reuse: all misses With reuse: 16 packages were reusable
LLNL-PRES-806064
Join #tutorial on Slack: slack.spack.io Materials: spack-tutorial.readthedocs.io 44
Use `spack spec` to see the results of concretization
$ spack spec mpileaks
Input spec
------------------------------
mpileaks
Concretized
------------------------------
[email protected]%[email protected] arch=darwin-elcapitan-x86_64
^[email protected]%[email protected] arch=darwin-elcapitan-x86_64
^[email protected]%[email protected]+atomic+chrono+date_time~debug+filesystem~graph
~icu_support+iostreams+locale+log+math~mpi+multithreaded+program_options
~python+random +regex+serialization+shared+signals+singlethreaded+system
+test+thread+timer+wave arch=darwin-elcapitan-x86_64
^[email protected]%[email protected] arch=darwin-elcapitan-x86_64
^[email protected]%[email protected] arch=darwin-elcapitan-x86_64
^[email protected]%[email protected]~mxm~pmi~psm~psm2~slurm~sqlite3~thread_multiple~tm~verbs+vt arch=darwin-elcapitan-x86_64
^[email protected]%[email protected] arch=darwin-elcapitan-x86_64
^[email protected]%[email protected] arch=darwin-elcapitan-x86_64
^[email protected]%[email protected] arch=darwin-elcapitan-x86_64
^[email protected]%[email protected]+sigsegv arch=darwin-elcapitan-x86_64
^[email protected]%[email protected] arch=darwin-elcapitan-x86_64
^[email protected]%[email protected] arch=darwin-elcapitan-x86_64
^[email protected]%[email protected]~stat_dysect arch=darwin-elcapitan-x86_64
^libdwarf@20160507%[email protected] arch=darwin-elcapitan-x86_64
^[email protected]%[email protected] arch=darwin-elcapitan-x86_64
LLNL-PRES-806064
Join #tutorial on Slack: slack.spack.io Materials: spack-tutorial.readthedocs.io 45
Spack environments enable users to build customized stacks
from an abstract description
Simple spack.yaml file
Concretize Install
LLNL-PRES-806064
Join #tutorial on Slack: slack.spack.io Materials: spack-tutorial.readthedocs.io 46
Environments,
spack.yaml and spack.lock
LLNL-PRES-806064
Join #tutorial on Slack: slack.spack.io Materials: spack-tutorial.readthedocs.io 47
Hands-on Time: Configuration
LLNL-PRES-806064
Join #tutorial on Slack: slack.spack.io Materials: spack-tutorial.readthedocs.io 48
We’ll resume at:
16:30 CEST
Find the slides and associated scripts here:
spack-tutorial.rtfd.io
slack.spack.io
Join the #tutorial channel!
Hands-on Time:
Stacks
Follow script at spack-tutorial.readthedocs.io
LLNL-PRES-806064
Join #tutorial on Slack: slack.spack.io Materials: spack-tutorial.readthedocs.io 50
Spack packages are parameterized using the spec syntax
Python DSL defines many ways to build
from spack import *
Base package
class Kripke(CMakePackage): (CMake support)
"""Kripke is a simple, scalable, 3D Sn deterministic particle transport mini-app."""
version(‘1.2.3’, sha256='3f7f2eef0d1ba5825780d626741eb0b3f026a096048d7ec4794d2a7dfbe2b8a6’)
version(‘1.2.2’, sha256='eaf9ddf562416974157b34d00c3a1c880fc5296fce2aa2efa039a86e0976f3a3’) Versions
version('1.1’, sha256='232d74072fc7b848fa2adc8a1bc839ae8fb5f96d50224186601f55554a25f64a’)
LLNL-PRES-806064
Join #tutorial on Slack: slack.spack.io Materials: spack-tutorial.readthedocs.io 51
Hands-on Time: Creating Packages
LLNL-PRES-806064
Join #tutorial on Slack: slack.spack.io Materials: spack-tutorial.readthedocs.io 52
Get a VM here →
We’ll resume at:
10:00 PT
Find the slides and associated scripts here:
spack-tutorial.rtfd.io
slack.spack.io
Join the #tutorial channel!
Hands-on Time:
Binary Caches and Mirrors
Follow script at spack-tutorial.readthedocs.io
LLNL-PRES-806064
Join #tutorial on Slack: slack.spack.io Materials: spack-tutorial.readthedocs.io 54
Hands-on Time:
Developer Workflows
Follow script at spack-tutorial.readthedocs.io
LLNL-PRES-806064
Join #tutorial on Slack: slack.spack.io Materials: spack-tutorial.readthedocs.io 55
Hands-on Time:
Scripting
Follow script at spack-tutorial.readthedocs.io
LLNL-PRES-806064
Join #tutorial on Slack: slack.spack.io Materials: spack-tutorial.readthedocs.io 56
More Features
and the Road Ahead
LLNL-PRES-806064
Join #tutorial on Slack: spackpm.herokuapp.com Materials: spack-tutorial.readthedocs.io 57
Environments have enabled us to add build many features to
support developer workflows
Automatically find and configure external packages on the system # ... spack package con tents ...
s elf.r un_test(
'cc’, [
'-I%s' % s elf.pr efix.include,
'-L%s' % s elf.pr efix.lib, '-ls igs egv’,
s moke_tes t_c,
spack test ]
'-o', 'sm oke_test '
package.py spack.yaml configuration Packages know how to run their own test suites s elf.r un_test(
‘s moke_tes t’, [], dat a_dir.join('s moke_tes t.out ’),
pur pos e=‘run built smoke tes t’)
s elf.r un_test('sigs egv1': ['Test pass ed’], pur pos e='check s igs egv1o utput ’)
s elf.r un_test('sigs egv2': ['Test pass ed’], pur pos e='check s igs egv2o utput ’)
package.py
spack ci
Automatically generate parallel build pipelines
(more on this later)
LLNL-PRES-806064
Join #tutorial on Slack: slack.spack.io Materials: spack-tutorial.readthedocs.io 58
Spack environments are the foundation of Spack CI
LLNL-PRES-806064
Join #tutorial on Slack: slack.spack.io Materials: spack-tutorial.readthedocs.io 59
We’ve made a lot of progress on compiler dependencies
LLNL-PRES-806064
Join #tutorial on Slack: slack.spack.io Materials: spack-tutorial.readthedocs.io 60
Compilers can now model their own runtimes
▪ Example:
— Intel compilers now (correctly)
depend on gcc-runtime
LLNL-PRES-806064
Join #tutorial on Slack: slack.spack.io Materials: spack-tutorial.readthedocs.io 61
Packages now declare the languages they depend on
▪ Languages are almost virtuals
— HDF5 package depends on cxx and fortran
— Handled specially internally, until compilers are
nodes
▪ TBD:
— Other runtimes like clang libraries and OpenMP
— Compilers as nodes in the graph
LLNL-PRES-806064
Join #tutorial on Slack: slack.spack.io Materials: spack-tutorial.readthedocs.io 62
We’ve also added libc as a dependency
▪ libc is a virtual
— glibc and musl packages are providers
— (nearly) every graph has libc in it, via
the compiler
— Can be external or built by Spack
LLNL-PRES-806064
Join #tutorial on Slack: slack.spack.io Materials: spack-tutorial.readthedocs.io 63
Libc modeling makes for a much better buildcache
experience
▪ Currently on develop (emacs 100% from binary):
LLNL-PRES-806064
Join #tutorial on Slack: slack.spack.io Materials: spack-tutorial.readthedocs.io 64
We’ve made a lot of progress on compiler dependencies
LLNL-PRES-806064
Join #tutorial on Slack: slack.spack.io Materials: spack-tutorial.readthedocs.io 65
What’s needed for Spack v1.0?
LLNL-PRES-837654
We are looking forward to a 1.0 release in June!
github.com/spack/spack 66
But wait! There’s more!
LLNL-PRES-837654
github.com/spack/spack 70
Hands-on Time:
Modules
Follow script at spack-tutorial.readthedocs.io
LLNL-PRES-806064
Join #tutorial on Slack: slack.spack.io Materials: spack-tutorial.readthedocs.io 71