This example is intended for use on Summit with RHEL 8 as the OS.
This guide meant as an example for a user to setup a Spack environment for application development using the OLCF provided files as a template.
spack.yaml files are templates for a user to use as an example.
This not intended as a guide for a new Spack user. Please see the Spack 101 tutorial if you need assistance starting out with Spack.
The provided Spack environment files are intended to assist OLCF users in setup their development environment at the OLCF. The base environment file includes the compilers and packages that are installed at the system level.
Traditionally, the user environment is modified by module files. For example, a user would add use
module load cmake/3.18.2 to
load CMake version 3.18.2 into their environment. Using a Spack environment, a user can add an OLCF provided package
and build against it using Spack without having to load the module file separately.
The information presented here is a subset of what can be found at the Spack documentation site.
- Spack environment - A set of Spack specs for the purpose of building, rebuilding and deploying in a coherent fashion.
- External Packages - An externally-installed package used by Spack, rather than building its own package.
Clone the OLCF User Environment repo and the Spack repo, start a new Spack instance, and create and activate a new Spack environment:
## From a Summit login > git clone https://github.com/olcf/spack-environments.git > cd spack-environments > git clone https://github.com/spack/spack.git > source spack/share/spack/setup-env.sh > spack env create my_env linux-rhel8-ppc64le/summit/spack.yaml > spack env activate my_env
Now a user can add and install their dependencies with Spack and proceed with developing their application.
Chained Spack Instances¶
The Summit Spack environment includes this configuration addition:
upstreams: olcf: install_tree: /sw/summit/spack-envs/base/opt
This allows the user’s newly created instance to use any package installed into the above directory as if it was installed by the user.
NOTE ABOUT UPSTREAM SPACK INSTALLATIONS
This other instance of Spack has no knowledge of the local Spack instance and may not have the same permissions or ownership as the local Spack instance. This has the following consequences:
- Upstream Spack instances are not locked. Therefore it is up to users to make sure that the local instance is not using an upstream instance when it is being modified.
- Users should not uninstall packages from the upstream instance. Since the upstream instance doesn’t know about the local instance, it cannot prevent the uninstallation of packages which the local instance depends on.
See here for more information regarding chained Spack instances.
Add Dependencies to the environment¶
Adding OLCF Installed Dependencies as External Packages¶
If an OLCF installed package is available, these can be added via the included
spack.yaml file by adding to the
section. For this example, CMake was found on Summit by finding a modulefile for the installed CMake package.
By marking the CMake package as
buildable: false it will force Spack to use the externally installed CMake with the
listed modulefile. If this is not indicated, Spack may build its own version of the package.
packages: # EXAMPLE cmake: version: [3.18.2] buildable: false externals: - spec: email@example.com modules: - cmake/3.18.2
Adding User-Defined Dependencies to the environment¶
These can be added to the
spack.yaml by adding to the
specs section. A dependency that is not already installed
will be built via Spack once the environment is concretized and installed.
specs: - firstname.lastname@example.org ## example from above - my_apps_dependency1@version%compiler ## other explicitly defined specs - my_apps_dependency2@version%compiler
Installing the Environment¶
When in the Spack environment, any packages that are added to the environment file can be installed via:
> spack concretize -f > spack install
Alternatively, a user may install a package manually by:
> spack install <my_app_dependencies@version%compiler>
For more information regarding Spack and its usage, please see the Spack documentation.
For an extensive tutorial concerning Spack, go to the Spack 101 tutorial.
For more information concerning external packages, please see here.