Setting up Spack

Steps to clone from the Spack community and set the environment for Spack:

    # Setup top level directory SPACK_ROOT
$ export SPACK_ROOT=/path/spack
  
# Install Spack into SPACK_ROOT directory
$ git clone -c feature.manyFiles=true https://github.com/spack/spack.git ${SPACK_ROOT}
$ source ${SPACK_ROOT}/share/spack/setup-env.sh
$ spack --help
  
# Add following lines to your environment to set paths
export SPACK_ROOT=/path/spack
source ${SPACK_ROOT}/share/spack/setup-env.sh

Listing the available compilers

Spack has the ability to build packages with multiple compilers and compiler versions. Spack searches for compilers on your machine automatically the first time it is run. It does this by inspecting your $PATH.

Run spack compilers or spack compiler list to view all the compilers Spack has found on your system:

Spack compilers

    # To list available compilers
$ spack compilers
==> Available compilers
-- aocc rhel8-x86_64 --------------------------------------------
aocc@5.0.0

-- gcc rhel8-x86_64 ---------------------------------------------
gcc@8.5.0

If you do not find a compiler in this list, but you want to use it with Spack, you can run spack compiler find with the path to where the compiler is installed.

Build/Add a Compiler

    # Installing a compiler (aocc)
$ spack install aocc
 
# The compiler can be added to spack in two ways
# Add the installed compiler by providing the path
$ spack cd -i aocc
$ spack compiler add $PWD
 
# Add the installed compiler from the environment
$ spack load aocc
$ spack compiler find

Some Basic Commands

    # Update the spack installation
$ cd ${SPACK_ROOT}
$ git pull
 
# Source spack env
$ source ${SPACK_ROOT}/share/spack/setup-env.sh
 
# Show available compilers
$ spack compilers
 
# Show information about a spack package
$ spack info <package_name>
 
# Show build configuration for a package
$ spack spec <package_name>
 
# Install an application using spack
$ spack install <package_name>
 
# Uninstall an application
$ spack uninstall <package_name>
 
# Show installations for a package
$ spack find <package_name>
 
# List spec of an installed package along with hash values
$ spack find -ldvf <package_name>
 
# Load an installed package
# Use <hash_value> where there are multiple installations
$ spack load <package_name> /<hash_value>
 
# Change the working directory to the location of an installed package
$ spack cd -i <package_name>