Installing Spack

Spack Dependencies

  • The following requirements must be installed to be able to run Spack:

    1. Python 2 (2.6 or 2.7) or 3 (3.5 - 3.9) to run Spack.

    2. A C/C++ compiler for building.

    3. The make executable for building.

    4. The tar, gzip, unzip, bzip2, xz and optionally zstd executables for extracting source code.

    5. The patch command to apply patches.

    6. The git and curl commands for fetching.

    7. If using the gpg subcommand, gnupg2 is required.

  • These requirements are already available on Discovery, so you don’t need to install any of them.

Installing Spack

  • To install Spack, you simply need to clone its GitHub repository as follows:

    git clone https://github.com/spack/spack
  • The Spack repository will be cloned in a directory called spack and the default branch is develop. To have a stable redundancy resolution, it’s recommended using the most recent release. You can check the most recent release in the GitHub repository of Spack. The most recent release at the time of creating this documentation is v0.17.

  • To check out the most recent release (v0.17), you type:

    cd spack
    git checkout releases/v0.17
  • To keep your current local working branch (currently checked out branch) up to date, you need to use the git pull command periodically. You need to make sure that you are in the Spack directory and then type:

    git pull

    For more details on installing Spack, go to Installing Spack Documentation.

Running Spack

  • To use Spack, you need to add it to your path. You simply need to source the Spack setup script by typing:

    source share/spack/setup-env.sh
  • To check if Spack has been installed successfully, you can use which command as follows:

    which spack
  • The above command will display the location of the executable file of Spack as shown in the following output:

    ~/spack/bin/spack

Configuration Scopes

  • Once Spack has been installed, its configuration will be stored into different directories for different scopes. Spack pulls configuration data from files in several directories. Spack searches for configuration parameters in higher-precedence scopes first. Therefore, settings in a higher-precedence file can override those with the same key in a lower-precedence one. Three different scopes are important for this documentation. The scopes are shown from lowest to highest precedences:

    For more information about configuration scopes, visit Configuration Scopes in Spack.

Default Scope

  • The configuration of this scope is stored in $SPACK_ROOT/etc/spack/defaults. You should generally not modify the settings of this scope. Instead, you should override them in other configuration scopes.

User Scope

  • The configuration of this scope is stored in ~/.spack. The settings of this scope affect all instances of Spack. In other words, configurations apply to any loaded/sourced Spack installation. By default, spack compiler and spack repo commands update the configurations of this directory. For example, when you add a new compiler using spack compiler add command, this will modify the compilers.py stored in ~/.spack/linux. You need to move the compiler.

  • Many cache files are stored in this directory. Those files may cause an error when switching between different Spack installations. To avoid such error you need to remove the cache files using spack clean as follows:

    spack clean --all
  • This command removes:

    1. All temporary build stages.

    2. Cached downloads.

    3. All install failure tracking markers.

    4. Long-lived caches, like the virtual package index.

    5. .pyc, .pyo files.

    6. Software needed to bootstrap Spack.

Site Scope

  • The configurations of this scope is stored in $SPACK_ROOT/etc/spack. The settings of this scope affect only this instance of Spack. Spack’s default configuration settings reside in $SPACK_ROOT/etc/spack/defaults. These are useful for reference, but should never be directly edited. To override these settings, create new configuration files or copy the ones in the default scope in another location, i.e in the site scope, and change it there.

  • Spack provides three environment variables to allow users to override or opt out of configuration locations:

    1. SPACK_USER_CONFIG_PATH: it overrides the path to use for the user (~/.spack) scope.

    2. SPACK_SYSTEM_CONFIG_PATH: it overrides the path to use for the system (/etc/spack) scope.

    3. SPACK_DISABLE_LOCAL_CONFIG: setting this variable to true disables both the system and user configuration directories. Spack will only consider its own defaults and site configuration locations.

    4. S`PACK_USER_CACHE_PATH: it overrides the default path to use for user data (misc_cache, tests, reports, etc.).

  • To disable both the system and user configuration directories, you type:

    export SPACK_DISABLE_LOCAL_CONFIG=true
  • Spack will only consider its own site configuration scope because it has higher precedence than the default scope. Also, you make sure now that any update on the settings will affect the settings of the site scope $SPACK_ROOT/etc/spack

Setting up Compilers

Setting up the Micro-architecture

  • Discovery has many different micro-architecture versions and even different brands. It’s important to update the packages.yaml stored in $SPACK_ROOT/etc/spack/defaults/ by setting the target to be x86_64. Therefore, that you can run on any node in the Discovery cluster and not just the specific micro-architecture. To update packages.yaml, you need first to copy the file from the default scope directory $SPACK_ROOT/etc/spack/defaults to the site scope $SPACK_ROOT/etc/spack:

    cp $SPACK_ROOT/etc/spack/defaults/packages.yaml $SPACK_ROOT/etc/spack
  • Then edit the copied file as follows:

    vim $SPACK_ROOT/etc/spackpackages.yaml
  • Now you add target: [x86_64] to the file as follows:

    packages:
      all:
        target: [x86_64]
        compiler: [gcc, intel, pgi, clang, xl, nag, fj, aocc]
        providers:
          D: [ldc]
    ...