managing hpc software complexity with spack

71
LLNL-PRES-806064 This work was performed under the auspices of the U.S. Department of Energy by Lawrence Livermore National Laboratory under contract DE-AC52-07NA27344. Lawrence Livermore National Security, LLC http://github.com/LLNL/spack Managing HPC Software Complexity with Spack Supercomputing 2016 Half-day Tutorial November 13, 2016 Salt Lake City, UT

Upload: others

Post on 02-Apr-2022

12 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Managing HPC Software Complexity with Spack

LLNL-PRES-806064This work was performed under the auspices of the U.S. Department of Energy by Lawrence Livermore National Laboratory under contract DE-AC52-07NA27344. Lawrence Livermore National Security, LLC

http://github.com/LLNL/spack

ManagingHPCSoftwareComplexitywithSpack

Supercomputing2016Half-dayTutorialNovember13,2016

SaltLakeCity,UT

Page 2: Managing HPC Software Complexity with Spack

LLNL-PRES-8060642http://github.com/LLNL/spack

Materials: Downloadthelatestversionofslidesandhandoutsat:

http://spack.readthedocs.io/

Besuretohavethemostcurrentslidesbeforewebegin!

Resources:

§ Spack GitHubrepository: http://github.com/LLNL/spack

§ Spack Documentation: http://spack.readthedocs.io/

§ Handoutsandadditionaldocumentation:— See“Tutorials”sectionofdocumentationpage.

TutorialMaterials

Page 3: Managing HPC Software Complexity with Spack

LLNL-PRES-8060643http://github.com/LLNL/spack

§ LLNL— ToddGamblin— GregoryBecker— GregLee— MattLegendre

§ EPFL— MassimilianoCulpo

§ CERN— Benedikt Hegner

§ NASA— ElizabethFischer

TutorialPresenters&Contributors

Presenters Contributors

Page 4: Managing HPC Software Complexity with Spack

LLNL-PRES-8060644http://github.com/LLNL/spack

PeoplewhowanttouseordistributesoftwareforHPC!

1. EndUsersofHPCSoftware— InstallandrunHPCapplicationsandtools

2. HPCApplicationTeams— Managethird-partydependencylibraries

3. PackageDevelopers— Peoplewhowanttopackagetheirownsoftwarefordistribution

4. UsersupportteamsatHPCCenters— PeoplewhodeploysoftwareforusersatlargeHPCsites

WhoisthisTutorialfor?

Page 5: Managing HPC Software Complexity with Spack

LLNL-PRES-8060645http://github.com/LLNL/spack

§ NotmuchstandardizationinHPC:everymachine/apphasadifferentsoftwarestack— Thisisdonetogetthebestperformance

§ HPCfrequentlytradesreuseandusabilityforperformance— Reusingapieceofsoftwarefrequentlyrequiresyoutoportittomanynewplatforms

§ ExampleenvironmentforsomeLLNLcodes:

HPCSoftwareComplexityPreventsReuse&ReducesProductivity

48 third party packages 3 MPI versionsmvapich mvapich2 OpenMPI

x 3-ish PlatformsLinux BlueGene Cray

x

Up to 7 compilersIntel GCC XLC Clang

PGI Cray Pathscalex Oh, and 2-3 versions of

each packagex = ~7,500 combinations

Spack lowers barriers to software reuse by automating these builds!

Page 6: Managing HPC Software Complexity with Spack

LLNL-PRES-8060646http://github.com/LLNL/spack

§ Someone’shomedirectory?

§ LLNL?LANL?Sandia?ANL?LBL?TACC?— Environmentsatlarge-scalesitesareverydifferent.

§ WhichMPIimplementation?

§ Whichcompiler?

§ Whichdependencies?

§ Whichversionsofdependencies?— Manyapplicationsrequirespecificdependencyversions.

Whatisthe“production”environmentforHPC?

Real answer: there isn’t a single production environment or a standard way to build.Reusing someone else’s software is HARD.

Page 7: Managing HPC Software Complexity with Spack

LLNL-PRES-8060647http://github.com/LLNL/spack

1. Welcome&Overview 1:30- 1:40

2. Foreveryone:BasicsofBuildingandLinking 1:40- 1:55

3. Foreveryone: Spack Basics(handson) 1:55- 2:40

4. Foreveryone: CoreSpack Concepts 2:40- 3:00

5. -- Break-- 3:00- 3:30

6. Fordevelopers: MakingyourownSpack Packages(handson) 3:30- 4:15

7. ForHPCcenters: DeployingSpack atHPCFacilities(handson) 4:15- 5:00

TutorialOverview

Page 8: Managing HPC Software Complexity with Spack

LLNL-PRES-8060648http://github.com/LLNL/spack

1. Automatetheprocessofbuildinglargesoftwarepackages

2. Automatetestingwithdifferentcompilersandoptions

3. Leveragetheworkofotherswithsharedbuildrecipes1. Don’trepeatthesamebuilds!

4. DistributeyoursoftwaretoagrowingaudienceofHPCusers

Whyuseanewtool?

Page 9: Managing HPC Software Complexity with Spack

LLNL-PRES-8060649http://github.com/LLNL/spack

§ HowtoinstallSpack:

§ Howtoinstallapackage:

§ HDF5anditsdependenciesareinstalledwithintheSpack directory.

§ Unliketypicalpackagemanagers,Spack canalsoinstallmanyvariantsofthesamebuild.— Differentcompilers— DifferentMPIimplementations— Differentbuildoptions

Spack isaflexiblepackagemanagerforHPC

GetSpack!http://github.com/LLNL/spack

$ git clone https://github.com/LLNL/spack.git$ . spack/share/spack/setup-env.sh

$ spack install hdf5

Page 10: Managing HPC Software Complexity with Spack

LLNL-PRES-80606410http://github.com/LLNL/spack

§ 1yearago,LLNLprovidedmostofthecontributionstoSpack

§ Sincelastyear,we’vegonefrom300to1,000packages

§ Over75%oflinesofcodeinpackagesarefromexternalcontributors.— Contributorsaddtothecoreaswell.

§ WearecommittedtosustainingSpack’s opensourceecosystem!

ContributionstoSpack havegrownrapidlyoverthepastyear

Page 11: Managing HPC Software Complexity with Spack

LLNL-PRES-80606411http://github.com/LLNL/spack

§ 20+organizations90+contributorsSharing1,016packages andgrowing

§ Spack canbeacentralrepositoryfortools— Makeiteasyforotherstousethem!— BuildcodethesamewayacrossHPCcenters.

§ Spack isusedinproductionatLLNL— LivermoreComputing— LLNLproductionmulti-physicscodes

§ OtherorganizationsusingSpack:— NERSC usingSpack onCori:Craysupport.— EPFL (Switzerland)contributingcorefeatures.— Fermi,CERN,BNL:highenergyphysicsecosystem.— ANL usingSpack onproductionLinuxclusters.— NASA packaginganIcemodelcode.— ORNL workingwithusonSpack forCORAL.— Kitware:corefeatures,ParaView,UV-CDATsupport

JointheSpack community!

3IBM Brand ElementsIBM Impact 2010 DESIGN GUIDELINES

IBM Brand Elements

IBM Logo

IBM has one of the world’s most recognizable logos. Maintaining its integrity is an essential part of protecting the brand. The 8-bar blue logois more than a signature to our ads or a name on our products andservices. To customers, it is a promise that represents trust, value, quality and advanced technology. In a world of confusing, competitiveads and product claims, the IBM logo is uniquely reassuring, conveyingauthenticity, reliability and quality. The IBM logo is present on every formof IBM communication.

Color of the IBM Logo

IBM has one logo, which may appear only in black, white, or IBM Blue.The logo should appear consistently and without alteration, as shownhere. On a white or light background, use the IBM logo in black or IBMBlue. On a black or dark background, use the IBM logo in white or IBMBlue. The color itself is an important symbol of IBM, and should bespecified for printed documents using Pantone 2718 as a spot colorwhenever possible. Use of this spot color is necessary when setting thelogo in IBM Blue on a colored background.

IBM Blue

PMS 2718CMYK C75 M43 Y0 K0RGB R75 G107 B175WEB 006699

1 white on black or dark background

2 black on white or light background

3 IBM blue on white or light background

4 IBM blue on black or dark background

1 2

3 4

Page 12: Managing HPC Software Complexity with Spack

LLNL-PRES-80606412http://github.com/LLNL/spack

Spack isnotthefirsttooltoautomatebuilds— Inspiredbycopiouspriorwork

1. “Functional”PackageManagers— Nix https://nixos.org/— GNUGuix https://www.gnu.org/s/guix/

2. Build-from-sourcePackageManagers— Homebrew http://brew.sh— MacPorts https://www.macports.org

OthertoolsintheHPCSpace:

§ Easybuild http://hpcugent.github.io/easybuild/— Aninstallation toolforHPC— FocusedonHPCsystemadministrators– differentpackagemodelfromSpack— Reliesonafixedsoftwarestack– hardertotweakrecipesforexperimentation

§ Hashdist https://hashdist.github.io

RelatedWork

Page 13: Managing HPC Software Complexity with Spack

LLNL-PRES-80606413http://github.com/LLNL/spack

Building&LinkingBasics

Page 14: Managing HPC Software Complexity with Spack

LLNL-PRES-80606414http://github.com/LLNL/spack

What’sapackagemanager?

§ Spack isapackagemanager— Doesnot areplaceCmake/Autotools— PackagesbuiltbySpack canhaveany

buildsystemtheywant

§ Spack managesdependencies— Drivespackage-levelbuildsystems— Ensuresconsistentbuilds

§ Determiningmagicconfigurelinestakestime— Spack isacacheofrecipes

• Manages dependencies• Drive package-level build

systems

Package Manager

• Cmake, Autotools• Handle library abstractions• Generate Makefiles, etc.

High Level Build

System

• Make, Ninja• Handles dependencies among commands in a single build

Low Level Build

System

Page 15: Managing HPC Software Complexity with Spack

LLNL-PRES-80606415http://github.com/LLNL/spack

§ Staticlibraries:libfoo.a— .afilesarearchivesof.ofiles(objectfiles)— Linkerincludesneededpartsofastaticlibraryintheoutputexecutable— Noneedtofinddependenciesatruntime– onlyatbuildtime.— Canleadtolargeexecutables— Oftenhardtobuildacompletelystaticexecutableonmodernsystems.

§ Sharedlibraries:libfoo.so (Linux),libfoo.dylib (MacOS)— Morecomplexbuildsemantics,typicallyhandledbythebuildsystem— Mustbefoundbyld.so ordyld (dynamiclinker)andloadedatruntime

• Cancauselotsofheadacheswithmultipleversions— 2mainways:

• LD_LIBRARY_PATH:environmentvariableconfiguredbyuserand/ormodulesystem• RPATH:pathsembeddedinexecutablesandlibraries,sothattheyknowwheretofindtheirowndependencies.

Staticvs.sharedlibraries

Page 16: Managing HPC Software Complexity with Spack

LLNL-PRES-80606416http://github.com/LLNL/spack

§ API:ApplicationProgrammingInterface— Sourcecodefunctionsandsymbolnamesexposedbyalibrary— IfAPIofadependencyisbackwardcompatible,sourcecodeneednotbechangedtouseit— May needtorecompilecodetouseanewversion.

§ ABI:ApplicationBinaryInterface— Callingconventions,registersemantics,exceptionhandling,etc.— Definedbyhowthecompilerbuildsalibrary

• BinariesgeneratedbydifferentcompilersaretypicallyABI-incompatible.— Mayalsoincludethingslikestandardruntimelibrariesandcompilerintrinsicfunctions— Mayalsoincludevaluesofhard-codedsymbols/constantsinheaders.

§ HPCcode,includingMPI,istypicallyAPI-compatiblebutnotABI-compatible.— Causesmanybuildproblems,especiallyfordynamicallyloadedlibraries— OftenneedtorebuildtogetaroundABIproblems— LeadstocombinatorialbuildsofsoftwareatHPCsites.

APIandABICompatibility

Page 17: Managing HPC Software Complexity with Spack

LLNL-PRES-80606417http://github.com/LLNL/spack

1. Make(usuallyGNUMake)— https://www.gnu.org/software/make/

2. GNUAutotools— Automake: https://www.gnu.org/software/automake/— Autoconf: https://www.gnu.org/software/autoconf/— Libtool: https://www.gnu.org/software/libtool/

3. CMake:— https://cmake.org

3majorbuildsystemstobeawareof

Page 18: Managing HPC Software Complexity with Spack

LLNL-PRES-80606418http://github.com/LLNL/spack

§ ManyprojectsopttowritetheirownMakefiles.— Canrangefromsimpletovery

complicated

§ Makedeclaressomestandardvariablesforvariouscompilers— ManyHPCprojectsdon’trespectthem— Nostandardinstallprefixconvention— Makefiles maynothaveinstalltarget

§ AutomatingbuildswithMakeusuallyrequireseditingfiles— Typicaltousesed/awk/someother

regularexpressiontoolonMakefile— Canalsousepatches

MakeandGNUMake

<edit Makefile>make PREFIX=/path/to/prefix

Typical build incantation

None. Typically must edit Makefiles.

Configure options

Environment variablesCC CFLAGS LDFLAGSCXX CXXFLAGS LIBSFC FFLAGS CPPF77 FFLAGS

Page 19: Managing HPC Software Complexity with Spack

LLNL-PRES-80606419http://github.com/LLNL/spack

§ Threepartsofautotools:— autoconf:generatesaportable

configurescripttoinspectbuildhost— automake:high-levelsyntaxfor

generatinglower-levelMakefiles.— libtool:abstractionforsharedlibraries

§ Typicalvariablesaresimilartomake

§ Muchmoreconsistencyamongautotools projects— Wideuseofstandardvariablesand

configureoptions— Standardinstalltarget,staging

conventions.

Autotools

./configure --prefix=/path/to/install_dirmakemake install

Typical build incantation

./configure \--prefix=/path/to/install_dir \--with-package=/path/to/dependency \--enable-foo \--disable-bar

Configure options

Useful environment variablesCC CFLAGS LDFLAGSCXX CXXFLAGS LIBSFC FFLAGS CPPF77 FFLAGS

Environment variables

Page 20: Managing HPC Software Complexity with Spack

LLNL-PRES-80606420http://github.com/LLNL/spack

§ Gainingpopularity

§ Arguablyeasiertouse(fordevelopers)thanautotools

§ Similarstandardoptionstoautotools— differentvariablenames— Moreconfigurationoptions— Abstractsplatform-specific

detailsofsharedlibraries

§ MostCMake projectsshouldbebuilt“outofsouce”— Separatebuilddirectoryfrom

sourcedirectory

CMake

mkdir BUILD && cd BUILDcmake –DCMAKE_INSTALL_PREFIX=/path/to/install_dir ..makemake install

Typical build incantation

cmake \–D CMAKE_INSTALL_PREFIX=/path/to/install_dir \-D ENABLE_FOO=yes \-D ENABLE_BAR=no \..

Configure options

Useful environment variablesCMAKE_C_COMPILER CMAKE_C_FLAGSCMAKE_CXX_COMPILER CMAKE_CXX_FLAGSCMAKE_Fortran_COMPILER CMAKE_Fortran_FLAGSCMAKE_SHARED_LINKER_FLAGS CMAKE_EXE_LINKER_FLAGSCMAKE_STATIC_LINKER_FLAGS

Common –D options

Page 21: Managing HPC Software Complexity with Spack

LLNL-PRES-80606421http://github.com/LLNL/spack

Spack Basics

Page 22: Managing HPC Software Complexity with Spack

LLNL-PRES-80606422http://github.com/LLNL/spack

§ Eachexpressionisaspecforaparticularconfiguration— Eachclauseaddsaconstrainttothespec— Constraintsareoptional– specifyonlywhatyouneed.— Customizeinstallonthecommandline!

§ Specsyntaxisrecursive— Fullcontroloverthecombinatorialbuildspace

Spack providesaspecsyntaxtodescribecustomizedDAGconfigurations

$ 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\” setting compiler flags$ spack install [email protected] os=CNL10 target=haswell setting target for X-compile$ spack install [email protected] ^[email protected] %[email protected] ^ dependency information

Page 23: Managing HPC Software Complexity with Spack

LLNL-PRES-80606423http://github.com/LLNL/spack

`spack list`showswhatpackagesareavailable

$ spack list==> 303 packages.activeharmony cgal fish gtkplus libgd mesa openmpi py-coverage py-pycparser qt tcladept-utils cgm flex harfbuzz libgpg-error metis openspeedshop py-cython py-pyelftools qthreads texinfoapex cityhash fltk hdf libjpeg-turbo Mitos openssl py-dateutil py-pygments R the_silver_searcherarpack cleverleaf flux hdf5 libjson-c mpc otf py-epydoc py-pylint ravel thriftasciidoc cloog fontconfig hwloc libmng mpe2 otf2 py-funcsigs py-pypar readline tkatk cmake freetype hypre libmonitor mpfr pango py-genders py-pyparsing rose tmuxatlas cmocka gasnet icu libNBC mpibash papi py-gnuplot py-pyqt rsync tmuxinatoratop coreutils gcc icu4c libpciaccess mpich paraver py-h5py py-pyside ruby trilinosautoconf cppcheck gdb ImageMagick libpng mpileaks paraview py-ipython py-pytables SAMRAI uncrustifyautomaded cram gdk-pixbuf isl libsodium mrnet parmetis py-libxml2 py-python-daemon samtools util-linux automake cscope geos jdk libtiff mumps parpack py-lockfile py-pytz scalasca valgrindbear cube gflags jemalloc libtool munge patchelf py-mako py-rpy2 scorep vimbib2xhtml curl ghostscript jpeg libunwind muster pcre py-matplotlib py-scientificpython scotch vtkbinutils czmq git judy libuuid mvapich2 pcre2 py-mock py-scikit-learn scr wgetbison damselfly glib julia libxcb nasm pdt py-mpi4py py-scipy silo wxboost dbus glm launchmon libxml2 ncdu petsc py-mx py-setuptools snappy wxpropgridbowtie2 docbook-xml global lcms libxshmfence ncurses pidx py-mysqldb1 py-shiboken sparsehash xcb-protoboxlib doxygen glog leveldb libxslt netcdf pixman py-nose py-sip spindle xerces-c bzip2 dri2proto glpk libarchive llvm netgauge pkg-config py-numexpr py-six spot xzcairo dtcmp gmp libcerf llvm-lld netlib-blas pmgr_collective py-numpy py-sphinx sqlite yasmcallpath dyninst gmsh libcircle lmdb netlib-lapack postgresql py-pandas py-sympy stat zeromqcblas eigen gnuplot libdrm lmod netlib-scalapack ppl py-pbr py-tappy sundials zlibcbtf elfutils gnutls libdwarf lua nettle protobuf py-periodictable py-twisted swig zshcbtf-argonavis elpa gperf libedit lwgrp ninja py-astropy py-pexpect py-urwid szipcbtf-krell expat gperftools libelf lwm2 ompss py-basemap py-pil py-virtualenv tarcbtf-lanl extrae graphlib libevent matio ompt-openmp py-biopython py-pillow py-yapf taskcereal exuberant-ctags graphviz libffi mbedtls opari2 py-blessings py-pmw python taskdcfitsio fftw gsl libgcrypt memaxes openblas py-cffi py-pychecker qhull tau

§ Spack hasover1000packagesnow.

Page 24: Managing HPC Software Complexity with Spack

LLNL-PRES-80606424http://github.com/LLNL/spack

§ Alltheversionscoexist!— Multipleversionsof

samepackageareok.

§ Packagesareinstalledtoautomaticallyfindcorrectdependencies.

§ Binariesworkregardlessofuser’senvironment.

§ Spack alsogeneratesmodulefiles.— Don’thave tousethem.

`spack find`showswhatisinstalled

$ spack find==> 103 installed packages.-- linux-redhat6-x86_64 / [email protected] [email protected] [email protected] [email protected] [email protected] [email protected]@3.9.1 [email protected] [email protected] [email protected] [email protected]@1.0 [email protected] [email protected] [email protected] [email protected]@2.14.0 [email protected] [email protected] [email protected] [email protected]@1.55.0 [email protected] [email protected] [email protected] [email protected]@1.14.0 [email protected] [email protected] [email protected] [email protected]@1.0.2 jpeg@9a [email protected] [email protected] [email protected]@8.1.2 libdwarf@20130729 [email protected] [email protected] [email protected]@8.1.2 [email protected] ocr@2015-02-16 [email protected] [email protected]@2.11.1 [email protected] [email protected] [email protected]@2.5.3 [email protected] [email protected] [email protected]@2.31.2 [email protected] [email protected] [email protected]

-- linux-redhat6-x86_64 / [email protected] [email protected] [email protected] [email protected] libdwarf@20130729 [email protected]@1.0.1 [email protected] [email protected] [email protected] [email protected]

-- linux-redhat6-x86_64 / [email protected] [email protected] [email protected] [email protected]

-- linux-redhat6-x86_64 / [email protected] [email protected] [email protected] libdwarf@20130729 [email protected] [email protected]

-- linux-redhat6-x86_64 / [email protected] [email protected] [email protected] libdwarf@20130729 [email protected]@1.55.0 [email protected] [email protected] [email protected]

Page 25: Managing HPC Software Complexity with Spack

LLNL-PRES-80606425http://github.com/LLNL/spack

Userscanquerythefulldependencyconfigurationofinstalledpackages.

§ Architecture,compiler,versions,andvariantsmaydifferbetweenbuilds.

$ spack find callpath==> 2 installed packages.-- linux-x86_64 / [email protected] ———————— -- linux-x86_64 / [email protected] [email protected] [email protected]

Expand dependencies with spack find -d

$ spack find -dl callpath==> 2 installed packages.-- linux-x86_64 / [email protected] ----------- -- linux-x86_64 / [email protected] -----------xv2clz2 [email protected] udltshs [email protected] ^[email protected] rfsu7fb ^[email protected] ^[email protected] ybet64y ^[email protected] ^[email protected] aa4ar6i ^[email protected] ^[email protected] tmnnge5 ^[email protected] ^[email protected] ybet64y ^[email protected] ^libdwarf@20130729 g2mxrl2 ^libdwarf@20130729cj5p5fk ^[email protected] ynpai3j ^[email protected] ^[email protected] ynpai3j ^[email protected] ^libdwarf@20130729 g2mxrl2 ^libdwarf@20130729cj5p5fk ^[email protected] ynpai3j ^[email protected] ^[email protected] ynpai3j ^[email protected] ^[email protected] aa4ar6i ^[email protected]

$ spack find -dl callpath==> 2 installed packages.-- linux-x86_64 / [email protected] ----------- -- linux-x86_64 / [email protected] -----------xv2clz2 [email protected] udltshs [email protected] ^[email protected] rfsu7fb ^[email protected] ^[email protected] ybet64y ^[email protected] ^[email protected] aa4ar6i ^[email protected] ^[email protected] tmnnge5 ^[email protected] ^[email protected] ybet64y ^[email protected] ^libdwarf@20130729 g2mxrl2 ^libdwarf@20130729cj5p5fk ^[email protected] ynpai3j ^[email protected] ^[email protected] ynpai3j ^[email protected] ^libdwarf@20130729 g2mxrl2 ^libdwarf@20130729cj5p5fk ^[email protected] ynpai3j ^[email protected] ^[email protected] ynpai3j ^[email protected] ^[email protected] aa4ar6i ^[email protected]

Page 26: Managing HPC Software Complexity with Spack

LLNL-PRES-80606426http://github.com/LLNL/spack

Spack managesinstalledcompilers

§ Compilersareautomaticallydetected— AutomaticdetectiondeterminedbyOS— Linux:PATH— Cray:`moduleavail`

§ Compilerscanbemanuallyadded— IncludingSpack-builtcompilers

compilers:- compiler:

modules: []operating_system: ubuntu14paths:cc: /usr/bin/gcc/4.9.3/gcccxx: /usr/bin/gcc/4.9.3/g++f77: /usr/bin/gcc/4.9.3/gfortranfc: /usr/bin/gcc/4.9.3/gfortran

spec: [email protected] compiler:

modules: []operating_system: ubuntu14paths:cc: /usr/bin/clang/6.0/clangcxx: /usr/bin/clang/6.0/clang++f77: nullfc: null

spec: [email protected] - compiler:

...

$ spack compilers==> Available compilers-- gcc [email protected] [email protected]

-- clang [email protected]

compilers.yaml

Page 27: Managing HPC Software Complexity with Spack

LLNL-PRES-80606427http://github.com/LLNL/spack

Hands-onTime

Page 28: Managing HPC Software Complexity with Spack

LLNL-PRES-80606428http://github.com/LLNL/spack

§ Spack installspackagesinownprefix

§ Somepackagesneedtobeinstalledwithindirectorystructureofotherpackages— i.e.,Pythonmodulesinstalledin$prefix/lib/python-<version>/site-packages— Spack supportsthisviaextensions

ExtensionsandPythonSupport

class PyNumpy(Package):"""NumPy is the fundamental package for scientific computing with Python.""”

homepage = "https://numpy.org"url = "https://pypi.python.org/packages/source/n/numpy/numpy-1.9.1.tar.gz” version(‘1.9.1', ' 78842b73560ec378142665e712ae4ad9’)

extends(“python")

def install(self, spec, prefix):setup_py("install“, “--prefix={0}”.format(prefix))

Page 29: Managing HPC Software Complexity with Spack

LLNL-PRES-80606429http://github.com/LLNL/spack

Spack extensions

spack/opt/linux-redhat6-x86_64/

gcc-4.7.2/python-2.7.12-/

python/py-numpy

py-numpy-1.10.4-oaxix36/py-numpy/

...

§ SymboliclinktoSpack installlocation

§ Automaticallyactivateforcorrectversionofdependency— ProvenanceinformationfromDAG— Activatealldependenciesthatareextensionsaswell

spack/opt/linux-redhat6-x86_64/

gcc-4.7.2/python-2.7.12-6y6vvaw/

python/py-numpy-1.10.4-oaxix36/

py-numpy/...

$ spack activate py-numpy @1.10.4

§ Examplesofextensionpackages:— pythonlibrariesareagoodexample— R,Lua,perl— Needtomaintaincombinatorialversioning

Page 30: Managing HPC Software Complexity with Spack

LLNL-PRES-80606430http://github.com/LLNL/spack

Extensionsmustbeactivatedintoextendee

$ spack extensions python==> [email protected]% [email protected] ~tk~ucs4 arch=linux-redhat7-x86_64-i25k4oi==> 118 extensions:…py-autopep8 py-docutils py-mako py-numpy py-py2neo …

==> 3 installed:-- linux-redhat7-x86_64 / [email protected] [email protected] [email protected] [email protected]

==> None activated.

$ spack load python $ python Python 2.7.12 (default, Aug 26 2016, 15:12:42)[GCC 4.9.3] on linux2Type "help", "copyright", "credits" or "license" for more information.>>> import numpyTraceback (most recent call last): File "<stdin>", line 1, in <module> ImportError: No module named numpy>>>

$ spack activate py-numpy==> Activated extension [email protected]% [email protected] +blas+lapackarch=linux-redhat7-x86_64-77im5ny for [email protected] ~tk~ucs4 % [email protected]$ spack extensions python==> [email protected]% [email protected] ~tk~ucs4 arch=linux-redhat7-x86_64-i25k4oi…==> 1 currently activated:-- linux-redhat7-x86_64 / [email protected] -----------------------------

$ python Python 2.7.12 (default, Aug 26 2016, 15:12:42)[GCC 4.9.3] on linux2Type "help", "copyright", "credits" or "license" for more information.>>> import numpy>>> x = numpy.zeros(10)>>>

§ Pythonunawareofnumpy installation

▪ activate symlinks entirenumpy prefixintoPythoninstallation▪ Canalternativelyloadextension

$ spack load python$ spack load py-numpy

Page 31: Managing HPC Software Complexity with Spack

LLNL-PRES-80606431http://github.com/LLNL/spack

Hands-onTime

Page 32: Managing HPC Software Complexity with Spack

LLNL-PRES-80606432http://github.com/LLNL/spack

CoreSpack Concepts

Page 33: Managing HPC Software Complexity with Spack

LLNL-PRES-80606433http://github.com/LLNL/spack

§ Traditionalbinarypackagemanagers— RPM,yum,APT,yast,etc.— Designedtomanageasinglestack.— Installone versionofeachpackageinasingleprefix(/usr).— Seamlessupgradestoastable,welltested stack

§ Portsystems— BSDPorts,portage,Macports,Homebrew,Gentoo,etc.— Minimalsupportforbuildsparameterizedbycompilers,dependencyversions.

§ VirtualMachinesandLinuxContainers(Docker)— Containersallowuserstobuildenvironmentsfordifferentapplications.— Doesnotsolvethebuildproblem(someonehastobuildtheimage)— Performance,security,andupgradeissuespreventwidespreadHPCdeployment.

Mostexistingtoolsdonotsupportcombinatorialversioning

Page 34: Managing HPC Software Complexity with Spack

LLNL-PRES-80606434http://github.com/LLNL/spack

§ Eachuniquedependencygraphisauniqueconfiguration.

§ Eachconfigurationinstalledinauniquedirectory.— Configurationsofthesamepackagecancoexist.

§ Hash ofentiredirectedacyclicgraph(DAG)isappendedtoeachprefix.

§ Installedpackagesautomaticallyfinddependencies— Spack embedsRPATHsinbinaries.— NoneedtousemodulesorsetLD_LIBRARY_PATH— Thingsworkthewayyoubuiltthem

Spack handlescombinatorialsoftwarecomplexity.

spack/opt/linux-x86_64/

gcc-4.7.2/mpileaks-1.1-

0f54bf34cadk/intel-14.1/

hdf5-1.8.15-lkf14aq3nqiz/bgq/

xl-12.1/hdf5-1-8.16-fqb3a15abrwx/

...

mpileaks

mpi

callpath dyninst

libdwarf

libelf

InstallationLayout

DependencyDAG

Hash

Page 35: Managing HPC Software Complexity with Spack

LLNL-PRES-80606435http://github.com/LLNL/spack

mpileaks

mpi

callpath dyninst

libdwarf

libelf

§ Spack ensuresoneconfigurationofeachlibraryperDAG— EnsuresABIconsistency.— UserdoesnotneedtoknowDAGstructure;onlythedependencynames.

§ Spack canensurethatbuildsusethesamecompiler,oryoucanmix— WorkingonensuringABIcompatibilitywhencompilersaremixed.

Spack Specscanconstrainversionsofdependencies

$ spack install mpileaks %[email protected] ^[email protected]

Page 36: Managing HPC Software Complexity with Spack

LLNL-PRES-80606436http://github.com/LLNL/spack

Spack handlesABI-incompatible,versionedinterfaceslikeMPI

$ spack install mpileaks ^[email protected] $ spack install mpileaks ^[email protected]:

$ spack install mpileaks ^mpi@2

mpileaks

mpi

callpath dyninst

libdwarf

libelf

§ mpi isavirtualdependency

§ InstallthesamepackagebuiltwithtwodifferentMPIimplementations:

§ LetSpack chooseMPIimplementation,aslongasitprovidesMPI2interface:

Page 37: Managing HPC Software Complexity with Spack

LLNL-PRES-80606437http://github.com/LLNL/spack

Concretizationfillsinmissingconfigurationdetailswhentheuserisnotexplicit.

mpileaks ^[email protected]+debug ^[email protected] User input: abstract spec with some constraints

Concrete spec is fully constrainedand can be passed to install.

[email protected]%[email protected]=linux-ppc64

[email protected]%[email protected]=linux-ppc64

[email protected]%[email protected]+debug

=linux-ppc64

[email protected]%[email protected]=linux-ppc64

[email protected]%[email protected]=linux-ppc64

libdwarf@20130729%[email protected]=linux-ppc64

Abstract, normalized specwith some dependencies.

mpileaks

mpi

[email protected]+debug

dyninst

[email protected]

libdwarf

Norm

alize

Concretize Store

spec:- mpileaks:

arch: linux-x86_64compiler:name: gccversion: 4.9.2

dependencies:adept-utils: kszrtkpbzac3ss2ixcjkcorlaybnptp4callpath: bah5f4h4d2n47mgycej2mtrnrivvxy77mpich: aa4ar6ifj23yijqmdabeakpejcli72t3

hash: 33hjjhxi7p6gyzn5ptgyes7sghyprujhvariants: {} version: '1.0'

- adept-utils:arch: linux-x86_64compiler:name: gccversion: 4.9.2

dependencies:boost: teesjv7ehpe5ksspjim5dk43a7qnowlqmpich: aa4ar6ifj23yijqmdabeakpejcli72t3

hash: kszrtkpbzac3ss2ixcjkcorlaybnptp4variants: {} version: 1.0.1

- boost:arch: linux-x86_64compiler:name: gccversion: 4.9.2

dependencies: {} hash: teesjv7ehpe5ksspjim5dk43a7qnowlqvariants: {} version: 1.59.0

...

spec.yaml

Detailed provenance is storedwith the installed package

Page 38: Managing HPC Software Complexity with Spack

LLNL-PRES-80606438http://github.com/LLNL/spack

Usespack spectoseetheresultsofconcretization

$ spack spec mpileaksInput spec------------------------------

mpileaks

Normalized------------------------------

mpileaks^adept-utils

^[email protected]:^mpi

^callpath^dyninst

^libdwarf^libelf

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

Page 39: Managing HPC Software Complexity with Spack

LLNL-PRES-80606439http://github.com/LLNL/spack

[email protected]@4.7.3

arch=linux-redhat6-ppc64

[email protected]@4.7.3

arch=linux-redhat6-ppc64+debug

[email protected]@4.7.3

arch=linux-redhat6-ppc64

[email protected]@4.7.3

arch=linux-redhat6-ppc64

[email protected]@4.7.3

arch=linux-redhat6-ppc64

[email protected]@4.7.3

arch=linux-redhat6-ppc64

[email protected]@4.7.3

arch=linux-redhat6-ppc64

[email protected]@4.7.3

arch=linux-redhat6-ppc64

[email protected]@4.7.3

arch=linux-redhat6-ppc64

[email protected]@4.7.3

arch=linux-redhat6-ppc64

libdwarf@[email protected]

arch=linux-redhat6-ppc64

Buildingagainstexternallyinstalledsoftware

[email protected]@4.7.3

arch=linux-redhat6-ppc64

[email protected]@4.7.3

arch=linux-redhat6-ppc64+debug

[email protected]@4.7.3

arch=linux-redhat6-ppc64

[email protected]@4.7.3

arch=linux-redhat6-ppc64

[email protected]@4.7.3

arch=linux-redhat6-ppc64

libdwarf@[email protected]

arch=linux-redhat6-ppc64

/path/to/external/gcc/openmpi-2.0.0

packages:mpi:buildable: False

openmpi:buildable: Falsepaths:[email protected] %[email protected] arch=linux-redhat6-ppc64:/path/to/external/gcc/openmpi-2.0.0

[email protected] %[email protected] arch=linux-redhat6-ppc64:/path/to/external/gcc/openmpi-1.10.3

[email protected] %[email protected] arch=linux-redhat6-ppc64:/path/to/external/intel/openmpi-2.0.0

[email protected] %[email protected] arch=linux-redhat6-ppc64:/path/to/external/intel/openmpi-1.10.3

...

packages.yaml

A user registers external packages with Spack.

If a node in the DAG matches an registered external package, Spack prunes the DAG at that node and replaces the node with a reference to the external package.

mpileaks ^[email protected]+debug ^openmpi ^[email protected]

Page 40: Managing HPC Software Complexity with Spack

LLNL-PRES-80606440http://github.com/LLNL/spack

$ spack repo create /path/to/my_repo$ spack repo add my_repo$ spack repo list==> 2 package repositories.my_repo /path/to/my_repobuiltin spack/var/spack/repos/builtin

§ Somepackagescannotbereleasedpublicly

§ Someusershaveusecasesthatrequirebizarrecustombuilds

§ PackagingissuesshouldnotpreventusersfromupdatingSpack— Solution:separaterepositories— Arepositoryissimplyadirectoryofpackagefiles

Spack packagerepositories

my_repo spack/var/repos/builtin

Proprietary packages

Pathological build cases

“Standard” packages

Page 41: Managing HPC Software Complexity with Spack

LLNL-PRES-80606441http://github.com/LLNL/spack

§ UserCache— Userscreatea

“mirror”oftararchivesforpackages

— Removeinternetdependence

Fetchingsourcecodeforspack

Concretize

spack install mpileaks

Recursively install dependencies

Fetch package source

Build software

Load package from repository

User Cache

Spack Cache

The Internet§ Spack Cache

— Spack automaticallycachestararchivesforpreviouslyinstalledsoftware

§ TheInternet— Spack packagescanfindsourcefilesonline

Page 42: Managing HPC Software Complexity with Spack

LLNL-PRES-80606442http://github.com/LLNL/spack

Addingcompilerflags(forcompilerparameterstudies)

$ spack install ares cflags=\‘-O3 –g –fast –fpack-struct\’

§ ThiswouldinstallARESwiththespecifiedflags— FlagsareinjectedviaSpack’s compilerwrappers.

§ Flagsarepropagatedtodependenciesautomatically— FlagsareincludedintheDAGhash— Eachbuildisconsideredadifferentversion

§ Thisprovidesaneasyharnessfordoingparameterstudiesfortuningcodes— Previouslyworkingwithlargecodeswasverytedious.

§ Supportscflags,cxxflags,fflags,cppflags,ldflags,andldlibs— AddedfromCLIorconfig file

Spack provides hooks that enable tools to work with large codes.

Page 43: Managing HPC Software Complexity with Spack

LLNL-PRES-80606443http://github.com/LLNL/spack

MakingyourownSpack Packages

Page 44: Managing HPC Software Complexity with Spack

LLNL-PRES-80606444http://github.com/LLNL/spack

CreatingyourownSpackPackages

from spack import *

class Zlib(Package):"""A free, general-purpose, legally unencumbered lossless

data-compression library."""

homepage = "http://zlib.net"url = "http://zlib.net/zlib-1.2.8.tar.gz"

version('1.2.8', '44d667c142d7cda120332623eab69f40')

depends_on(‘cmake’, type=‘build’)

def install(self, spec, prefix):configure('--prefix={0}'.format(prefix))

make()make('install')

▪ Packageisarecipeforbuilding

▪ EachpackageisaPythonclass— Downloadinformation— Versions/Checksums— Buildoptions— Dependencies— Buildinstructions

▪ Packagecollectionsarerepos— Spackhasa“builtin”repoin

$REPO/var/spack/repos/builtin

$REPO/packages/zlib/package.py

Page 45: Managing HPC Software Complexity with Spack

LLNL-PRES-80606445http://github.com/LLNL/spack

PackagesareParameterized

def install(self, spec, prefix):config_opts=[‘--prefix=‘+prefix]

if '~shared' in self.spec:config_opts.append('--disable-shared')

else:config_opts.append('--enable-shared')

configure(config_opts)make()make('install')

▪ Eachpackagehasoneclass— e.g.,zlibforIntelcompilerandzlibforGCC

compilerarebuiltwiththesamerecipe.

▪ Canquerywhat’sbeingbuilt.

▪ Compilerwrappershandlemanydetailsautomatically.— Spackfeedscompilerwrappersto(cc,c++,f90,

…)toautoconf,cmake,gmake,…— Wrappersselectcompilers,dependencies,and

optionsunderthehood.

package.py

Page 46: Managing HPC Software Complexity with Spack

LLNL-PRES-80606446http://github.com/LLNL/spack

Spackbuildseachpackageinitsowncompilationenvironment

SpackProcess

Setupenvironment

CC = spack/env/spack-cc SPACK_CC = /opt/ic-15.1/bin/iccCXX = spack/env/spack-c++ SPACK_CXX = /opt/ic-15.1/bin/icpcF77 = spack/env/spack-f77 SPACK_F77 = /opt/ic-15.1/bin/ifortFC = spack/env/spack-f90 SPACK_FC = /opt/ic-15.1/bin/ifort

PKG_CONFIG_PATH = ... PATH = spack/env:$PATHCMAKE_PREFIX_PATH = ...LIBRARY_PATH = ...

do_install()

Install dep1 Install dep2 Install package…

BuildProcess

Fork

install() configure make makeinstall

-I /dep1-prefix/include-L /dep1-prefix/lib-Wl,-rpath=/dep1-prefix/lib

Compilerwrappers(spack-cc, spack-c++, spack-f77, spack-f90)

icc icpc ifort

▪ Forkedbuildprocessisolatesenvironmentforeachbuild.Usescompilerwrappersto:— Addinclude,lib,andRPATHflags— Ensurethatdependenciesarefoundautomatically— LoadCraymodules(userightcompiler/systemdeps)

Page 47: Managing HPC Software Complexity with Spack

LLNL-PRES-80606447http://github.com/LLNL/spack

WritingPackages- VersionsandURLs

class Mvapich2(Package):homepage = "http://mvapich.cse.ohio-state.edu/"url = "http://mvapich.cse.ohio-state.edu/download/mvapich/mv2/mvapich2-2.2rc2.tar.gz"

version('2.2rc2', 'f9082ffc3b853ad1b908cf7f169aa878')version('2.2b', '5651e8b7a72d7c77ca68da48f3a5d108')version('2.2a', 'b8ceb4fc5f5a97add9b3ff1b9cbe39d2')version('2.1', '0095ceecb19bbb7fb262131cb9c2cdd6')version('2.0', '9fbb68a4111a8b6338e476dc657388b4')

▪ Packagedownloadsarehashedwithmd5— orSHA-1,SHA-256,SHA-512

▪ DownloadURLscanbeautomaticallyextrapolatedfromURL.— ExtraoptionscanbeprovidedifSpackcan’textrapolateURLs

▪ OptionscanalsobeprovidedtofetchfromVCSrepositories

$REPO/packages/mvapich/package.py

Page 48: Managing HPC Software Complexity with Spack

LLNL-PRES-80606448http://github.com/LLNL/spack

WritingPackages– VariantsandDependencies

class Petsc(Package):variant('mpi', default=True, description='Activates MPI support')variant('complex', default=False, description='Build with complex numbers')variant('hdf5', default=True, description='Activates support for HDF5 (only parallel)')

depends_on('blas')depends_on('[email protected]:2.7')depends_on('mpi', when='+mpi')

▪ Variantsarenamed,havedefaultvaluesandhelptext

▪ Otherpackagescanbedependencies— whenclauseprovidesconditionaldependencies— Candependonspecificversionsorothervariants

$REPO/packages/petsc/package.py

Page 49: Managing HPC Software Complexity with Spack

LLNL-PRES-80606449http://github.com/LLNL/spack

WritingPackages– BuildRecipes

def install(self, spec, prefix):with working_dir("build", create=True):

cmake("..", *std_cmake_args)make()make("install")

@when('@:8.1')def install(self, spec, prefix):

configure("--prefix=" + prefix)make()make("install")

▪ Functionswrapcommonops— cmake,configure,patch,make,…— Executable andwhichfornewwrappers.

▪ Commandsexecutedincleanenvironment

▪ FullPythonfunctionality— Patchupsourcecode— Makefilesanddirectories— Calculateflags— …

$REPO/packages/dyninst/package.py

Page 50: Managing HPC Software Complexity with Spack

LLNL-PRES-80606450http://github.com/LLNL/spack

CreateNewPackageswithspack create

class Zlib(Package):# FIXME: Add a proper url for your package's homepage here. homepage = "http://www.example.com"url = "http://zlib.net/zlib-1.2.8.tar.gz"version('1.2.8', '44d667c142d7cda120332623eab69f40')

def install(self, spec, prefix):# FIXME: Modify the cmake line to suit your build system here.

▪ Spackcreate<url>willcreateaskeletonforapackage— SpackreasonsaboutURL,hash,version,buildrecipe.

▪ Spackedit<package>forsubsequentchanges

$ spack create http://zlib.net/zlib-1.2.8.tar.gz

$REPO/packages/zlib/package.py

Page 51: Managing HPC Software Complexity with Spack

LLNL-PRES-80606451http://github.com/LLNL/spack

Hands-onTime

Page 52: Managing HPC Software Complexity with Spack

LLNL-PRES-80606452http://github.com/LLNL/spack

DeployingSpackatHPCSiteswithModules

Page 53: Managing HPC Software Complexity with Spack

LLNL-PRES-80606453http://github.com/LLNL/spack

§ Purposeofmodulefiles— modifydynamicallyuser’senv— managemultipleversionsof

samelibrary/application

— minimaluserinterface§ Stateoftheart

— differentfileformats— differentlayouts

— differenttools§ Spacksupportformodulefiles

— TCL/Non-hierarchicallayout

— Lua/Hierarchicallayout

TCLNon-hierarchical

LuaHierarchical

Generatorname tcl lmod

Defaultfolder share/spack/modules share/spack/lmod

Compatibletools Env.modulesLMod

LMod

Whataremodulefiles?

Page 54: Managing HPC Software Complexity with Spack

LLNL-PRES-80606454http://github.com/LLNL/spack

Howdomodulefileslooklike?

$ module av

--- share/spack/modules/linux-Ubuntu14-x86_64 ---autoconf-2.69-gcc-4.8-eud4m3wghostscript-9.18-gcc-4.8-5n627qplua-luaposix-33.4.0-gcc-4.8-s7lrtogautoconf-2.69-gcc-6.1.0-wo3aehoghostscript-9.18-gcc-6.1.0-fsencrwlibpciaccess-0.13.4-clang-3.8.0-oqbf3i7m4-1.4.17-clang-3.8.0-gstiyktpkg-config-0.29.1-gcc-4.8-6zuabcpautomake-1.15-gcc-4.8-z42qh3rgmp-6.1.1-gcc-4.8-xsezhyplibpciaccess-0.13.4-gcc-4.8-62psbr2m4-1.4.17-gcc-4.8-drmfctm...

#%Module1.0## Module file created by spack ...#### <full-spec>##module-whatis "autoconf @2.69"

proc ModulesHelp { } {puts stderr " Autoconf -- system configuration part of autotools"}

prepend-path PATH "<full-prefix>/autoconf-2.69-eud4m3weu6hfeu4o22xiwavnrarxjluo/bin"prepend-path MANPATH ...prepend-path CMAKE_PREFIX_PATH ...

Page 55: Managing HPC Software Complexity with Spack

LLNL-PRES-80606455http://github.com/LLNL/spack

Lifecycleofmodulefileswithinspack

def do_install(self, **kwargs):

# Check if the package is already installed

if self.installed:

return

# Recurse to install dependencies

for x in self.dependencies():

x.do_install(**kwargs)

# Run pre-install hooks

self.pre_install_hooks()

# Real installation happens here

self.install(self, self.spec, self.prefix)

# Module files generation happens here

self.post_install_hooks()

def do_uninstall(self, **kwargs):

# Run pre-uninstall hooks

self.pre_uninstall_hooks()

# "Uninstall" package

self.remove_prefix()

# Deletion of module files

# happens here

self.post_install_hooks()

Page 56: Managing HPC Software Complexity with Spack

LLNL-PRES-80606456http://github.com/LLNL/spack

PackagefileAPI:packagerelatedcontentcustomization

def setup_dependent_environment(

self, spack_env, run_env, extension_spec

):

"""Set up the compile and runtime environments

for packages that depends on this one.

"""

...

if extension_spec.package.extends(self.spec):

run_env.prepend_path(

'LUA_PATH',

';'.join(lua_patterns),

separator=';'

)

def setup_environment(

self, spack_env, run_env

):

"""Set up the compile and runtime environments

for a package.

"""

...

ld_library_path = join_path(

self.prefix, 'rlib', 'R', 'lib'

)

run_env.prepend_path(

'LIBRARY_PATH', ld_library_path

)

Page 57: Managing HPC Software Complexity with Spack

LLNL-PRES-80606457http://github.com/LLNL/spack

“modules.yaml”:siterelatedcustomizations

modules:

# Module generation needs to be activated

# Every module type will have its own section

enable :

- tcl

- lmod

# Configurations common to all module types

prefix_inspections:

bin:

- PATH

tcl:

# TCL specific section

lmod:

# LMOD specific section

Enable generation of tcl and lmod module files

Options that are common to all types of module

files

Options that are specific to tcl and lmod

respectively

Page 58: Managing HPC Software Complexity with Spack

LLNL-PRES-80606458http://github.com/LLNL/spack

Inspectionofpackage’sinstallationprefix

modules:

prefix_inspections:

bin:

- PATH

man:

- MANPATH

share/man:

- MANPATH

lib:

- LIBRARY_PATH

- LD_LIBRARY_PATH

...

$ ls -l ${PREFIX_ROOT}/autoconf-2.69-eud4m3weu6h

total 8

drwxrwxr-x 2 mculpo mculpo 4096 ago 17 08:35 bin

drwxrwxr-x 6 mculpo mculpo 4096 ago 17 08:35 share

prepend-path PATH "$PREFIX_ROOT/autoconf-2.69-

eud4m3weu6h/bin"

prepend-path MANPATH "$PREFIX_ROOT/autoconf-2.69-

eud4m3weu6h/share/man"

prepend-path CMAKE_PREFIX_PATH

"$PREFIX_ROOT/autoconf-2.69-eud4m3weu6h"

Page 59: Managing HPC Software Complexity with Spack

LLNL-PRES-80606459http://github.com/LLNL/spack

Applyaruletoasetofpackages:“anonymousspecs”

modules:

tcl:

all:

# Modifications that affect all packages

# (always evaluated first)

intel:

# Modifications that affect all 'intel'

# packages

'^openmpi':

# Modifications that affect all the packages

# that depends on 'openmpi'

'%[email protected]':

# Modifications that affect all the packages

# that are compiled with '[email protected]'

anonymousspecs▪ specspossiblywithoutrootpackage

▪ usedforconstraint-matchingpurposesWherearetheyusedasaselectionmechanism?▪ modulefilesuffixes▪ prereq/autoloaddependencies▪ loadexternalmodules▪ conflicts▪ customenvironmentmodifications

Page 60: Managing HPC Software Complexity with Spack

LLNL-PRES-80606460http://github.com/LLNL/spack

Refreshorremovemodulefiles:`spackmodule`command

$ spack module refresh -m tcl hdf5

==> You are about to regenerate tcl module files for:

-- linux-Ubuntu14-x86_64 / [email protected] --

narq2au [email protected]

2qxlg4m [email protected]

-- linux-Ubuntu14-x86_64 / [email protected] --

o52kh5m [email protected]

==> Do you want to proceed ? [y/n]

y

==> Regenerating tcl module files

spack module rm -m tcl hdf5

==> You are about to remove tcl module files the

following specs:

-- linux-Ubuntu14-x86_64 / [email protected] --

narq2au [email protected]

2qxlg4m [email protected]

-- linux-Ubuntu14-x86_64 / [email protected] --

o52kh5m [email protected]

==> Do you want to proceed ? [y/n]

y

Page 61: Managing HPC Software Complexity with Spack

LLNL-PRES-80606461http://github.com/LLNL/spack

Filterunwantedmodificationstotheenvironment

modules:

enable:

- tcl

tcl:

all:

filter:

# Exclude changes to any of these variables

# in all packages, may be more selective

environment_blacklist:

- CPATH

- LIBRARY_PATH

all:

▪ selectsallpackagesfilter:▪ reservedtogatherfilteringdirectives

▪ rightnowsupportsonlywhatisshownenvironment_blacklist:▪ takesalistofenvvariables

▪ thatwon’tbemodifiedinmodulefiles

Page 62: Managing HPC Software Complexity with Spack

LLNL-PRES-80606462http://github.com/LLNL/spack

Preventmodulefilesfrombeinggenerated

modules:

enable:

- 'tcl'

tcl:

whitelist:

- 'gcc'

- 'llvm'

- 'intel'

blacklist:

- '%[email protected]'

- 'py-numpy'

- 'py-scipy'

- 'py-matplotlib'

- 'py-pip'

==> WHITELIST :

[email protected]%[email protected]+all_targets+clang+...

arch=linux-Ubuntu14-x86_64-gpwe4lu

[matches : llvm ]

==> WRITE :

[email protected]%[email protected]+all_targets+clang+...

arch=linux-Ubuntu14-x86_64-gpwe4lu

[.../llvm-3.8.0-gcc-6.1.0-gpwe4lu]

==> BLACKLIST :

[email protected]%[email protected] arch=linux-Ubuntu14-x86_64-

sth2wun

[matches : %[email protected] ]

Whitelisted entries

take precedence over

blacklisted ones

Blacklist modules

using anonymous specs

Page 63: Managing HPC Software Complexity with Spack

LLNL-PRES-80606463http://github.com/LLNL/spack

Changethenamingofmodulefiles:controlthehashlength

modules:

enable:

- tcl

- lmod

tcl:

hash_length : 7 # Default value

modules:

enable:

- tcl

- lmod

tcl:

hash_length : 0

--- /modules/linux-Ubuntu14-x86_64 ---

autoconf-2.69-gcc-4.8-eud4m3w

ghostscript-9.18-gcc-4.8-5n627qp

libedit-3.1-gcc-6.1.0-hzefu25

lua-luaposix-33.4.0-gcc-4.8-s7lrtog

...

--- /modules/linux-Ubuntu14-x86_64 ---

autoconf-2.69-gcc-4.8

ghostscript-9.18-gcc-4.8

libedit-3.1-gcc-6.1.0

lua-luaposix-33.4.0-gcc-4.8

...

Page 64: Managing HPC Software Complexity with Spack

LLNL-PRES-80606464http://github.com/LLNL/spack

Changethenamingofmodulefiles:addcustomsuffixes

modules:

tcl:

all:

suffixes:

# Add '-openmp' suffix if satisfies +openmp

'+openmp': openmp

# ... or if it satisfies ^fftw+openmp

'^fftw+openmp': openmp

# Add 'openblas' if depends on openblas

'^openblas': openblas

netlib-scalapack:

suffixes:

'^openmpi': openmpi

'^mpich': mpich

suffixes:▪ key:anonymousspec▪ value:suffixtobeadded(ifkeymatches)

▪ concatenatemultiplematches

Page 65: Managing HPC Software Complexity with Spack

LLNL-PRES-80606465http://github.com/LLNL/spack

Changethenamingofmodulefiles:setthenamingscheme

--- /modules/linux-Ubuntu14-x86_64 ---

autoconf/2.69-gcc-4.8-eud4m3w

ghostscript/9.18-gcc-4.8-5n627qp

libedit/3.1-gcc-6.1.0-hzefu25

...

modules:

tcl:

# In this directive you can use

# either literals or tokens that

# are understood by `Spec.format`

naming_scheme: '${PACKAGE}/${VERSION}-

${COMPILERNAME}-${COMPILERVER}'

all:

# The same applies to the

# list of conflicts

conflict:

- '${PACKAGE}'

naming_scheme:▪ setsthelayoutformodulefiles

▪ TCL/Non-hierarchicalmodulesonlyconflict:▪ setsaconflictdirectiveinthemodulefile▪ behaviorvariesdependingonthetool

Page 66: Managing HPC Software Complexity with Spack

LLNL-PRES-80606466http://github.com/LLNL/spack

Addcustomenvironmentmodifications

modules:

tcl:

all:

environment:

set: # Variable pointing to package prefix

'${PACKAGE}_ROOT': '${PREFIX}'

intel: # Customize intel package

environment:

set:

'CC': icc

...

prepend_path:

'PATH': '<paths-to-be-prepended>'

...

environment:▪ gathersalldirectivesforenvmodifications▪ key-value:set,prepend_path,append_path▪ keyonly:unset▪ tokensfrom`Spec.format`acceptedinsub-

directives

Page 67: Managing HPC Software Complexity with Spack

LLNL-PRES-80606467http://github.com/LLNL/spack

Autoloadingdependenciesinmodulefiles

modules:

tcl:

all:

# Add code to load dependencies

# automatically. Either 'direct'

# or 'all' are allowed values.

autoload: 'direct'

# Load "literal" modules

load:

- 'intel'

...

if ![ is-loaded openmpi-2.0.0-gcc-4.8-r2nqvn ]

puts stderr "Autoloading openmpi-2.0.0-gcc-4.8-r2nqvn"

module load openmpi-2.0.0-gcc-4.8-r2nqvn

}

if ![ is-loaded intel ] {

puts stderr "Autoloading intel"

module load intel

}

conflict hdf5

conflict foo

Page 68: Managing HPC Software Complexity with Spack

LLNL-PRES-80606468http://github.com/LLNL/spack

Lua- Hierarchicalmodulefiles:Core/Compiler/MPIhierarchy

modules:

# Double colon is intentional:

# it overrides the same keyword

# when merging configuration files

# at different scopes

enable::

- lmod

lmod:

# Specify which compilers are to be

# considered Core compilers in the

# hierarchy

core_compilers:

- '[email protected]'

core_compilers:▪ acceptsalistofcompilers▪ anything‘%[email protected]’generatesamodulein

theCorepartofthehierarchy▪ usuallyonlyutilitiesandcompilersinCore

# Unuse the default TCL / Non-hierarchical modules

$ module unuse ${SPACK_ROOT}/share/spack/modules/<arch>

# Use the Core part of the Hierarchy

$ module use ${SPACK_ROOT}/share/spack/lmod/<arch>/Core

Page 69: Managing HPC Software Complexity with Spack

LLNL-PRES-80606469http://github.com/LLNL/spack

Extendthehierarchytoothervirtualproviders[experimental]

modules:

enable::

- lmod

lmod:

core_compilers:

- '[email protected]'

# Any virtual package in principle

# can be used. It will be treated

# as MPI in the usual hierarchy

hierarchical_scheme:

- lapack

hierarchical_scheme:▪ acceptsalistofvirtualpackages▪ addedatthesamelevelasMPI▪ handlesmultiplevirtualdependencies

Page 70: Managing HPC Software Complexity with Spack

LLNL-PRES-80606470http://github.com/LLNL/spack

§ ContributingpackagestoSpack issimple— Makepackagesonyourownsystem— SendapullrequesttoSpack toletothersusethem— GitHubguidetopullrequests:

https://help.github.com/articles/creating-a-pull-request/— SeecontributorguideintheSpack repository— Spack islicensedunderLGPLv2.1

§ Wewantmorethanjustpackages— Newfeatures— Newdocumentation— Anycontributioncanhelpthecommunity

§ Spack hasahelpfulonlinecommunity— TypicallyhappytorespondtoGitHubissues— ActivemailinglistonGoogleGroups:

https://groups.google.com/d/forum/spack

§ Wehopetomakedistributing&usingHPCsoftwareeasy.

JointheSpack community!

http://github.com/LLNL/spack

Page 71: Managing HPC Software Complexity with Spack