|
SpECTRE
2021.08.02
|
This page details the installation procedure for SpECTRE on personal computers. For instructions on installing SpECTRE on clusters please refer to the Installation on Clusters page. Refer to the Versioning and releases page for information on specific versions to install.
If you're new to writing code for SpECTRE and would like to jump right into a working development environment, a good place to start is our Code development quick-start with Docker and Visual Studio Code. If you prefer setting up your development environment differently, read on!
Note: You don't need to install any of these dependencies by hand, or by using yum, apt, or other package managers; it is much easier to instead use Singularity, Docker, or Spack (see the corresponding sections below) to obtain an environment that includes all of these dependencies.
ScotchLB graph partition based load balancer in charm++.A Docker image is available from DockerHub and can be used to build SpECTRE on a personal machine.
Note: The Docker image or the Singularity image (see below) are the recommended ways of using SpECTRE on a personal Linux machine. Because of the wide variety of operating systems available today it is not possible for us to support all configurations. However, using Spack as outlined below is a supported alternative to Docker or Singularity images.
Note: If you have SELinux active on your system you must figure out how to enable sharing files with the host OS. If you receive errors that you do not have permission to access a shared directory it is likely that your system has SELinux enabled. One option is to disable SELinux at the expense of reducing the security of your system.
To build with the docker image:
git clone the SpECTRE repository on GitHub, in which case SPECTRE_ROOT will be <your_current_directory>/spectre. That is, inside SPECTRE_ROOT are docs, src, support, tests etc. You can also download the source and extract them to your desired working directory. Make sure not to leave out hidden files when you cp or mv the source files!sudo in front of this command) Start the docker container (you may need sudo)
-v SPECTRE_ROOT:SPECTRE_ROOT binds the directory SPECTRE_ROOT outside the container to SPECTRE_ROOT inside the container. In this way, files in the SPECTRE_ROOT on your host system (outside the container) become accessible within the container through the directory SPECTRE_ROOT inside the container. If you wonder why the same SPECTRE_ROOT needs to be used for both inside and outside the container, which is why SPECTRE_ROOT is repeated in the command above with seperated by a colon, please see one of the notes below regarding -v flag.--name CONTAINER_NAME is optional, where CONTAINER_NAME is a name of your choice. If you don't name your container, docker will generate an arbitrary name.:delegated to -v, e.g. -v SPECTRE_ROOT:SPECTRE_ROOT:delegated (see https://docs.docker.com/docker-for-mac/osxfs-caching/).-p option, e.g. -p 8000:8000.You will end up in a bash shell in the docker container, as root (you need to be root). Within the container, the files in SPECTRE_ROOT are available and Charm++ is installed in /work/charm_6_10_2. For the following steps, stay inside the docker container as root.
/work/spectre-build-gcc, and cd into it.make unit-tests -jN where N is the number of cores to build on in parallel (e.g. -j4).make list.make test-executables -jN to compile the test executables, and ctest to run the tests.Notes:
/work/charm_6_10_2 and any other changes to the container that you have made. To restart the container, try the following commands (you may need sudo):docker ps -a, to list all containers with their CONTAINER_IDs and CONTAINER_NAMEs,docker start -i CONTAINER_NAME or docker start -i CONTAINER_ID, to restart your container.docker stop CONTAINER_NAME, remove it with docker rm CONTAINER_NAME and then start at step 2 above to run it again.docker exec -it CONTAINER_NAME /bin/bash (or docker exec -it CONTAINER_ID /bin/bash) from a terminal outside the container.-v SPECTRE_ROOT:/my/new/path to map SPECTRE_ROOT outside the container to any path you want inside the container, but do not do this. Compiling inside the container sets up git hooks in SPECTRE_ROOT that contain hardcoded pathnames to SPECTRE_ROOT as seen from inside the container. So if your source paths inside and outside the container are different, commands like git commit run from outside the container will die with No such file or directory.-D BUILD_PYTHON_BINDINGS=ON to the cmake command (see Writing Python Bindings). You can specify the Python version, interpreter and libraries used for compiling and testing the bindings by setting the -D Python_EXECUTABLE to an absolute path such as /usr/bin/python3.Singularity is a container alternative to Docker with better security and nicer integration.
To build SpECTRE with Singularity you must:
$PATHcd to the directory where you want to store the SpECTRE Singularity image, source, and build directories, let's call it WORKDIR. The WORKDIR must be somewhere in your home directory. If this does not work for you, follow the Singularity instructions on setting up additional bind points (version 3.7. For other versions, see the docs). Once inside the WORKDIR, clone SpECTRE into WORKDIR/SPECTRE_ROOT.Run sudo singularity build spectre.img docker://sxscollaboration/spectrebuildenv:latest.
If you get the error message that makesquashfs did not have enough space to create the image you need to set a different SINGULARITY_TMPDIR. This can be done by running: sudo SINGULARITY_TMPDIR=/path/to/new/tmp singularity build spectre.img docker://sxscollaboration/spectrebuildenv:latest. Normally SINGULARITY_TMPDIR is /tmp, but building the image will temporarily need almost 8GB of space.
You can control where Singularity stores the downloaded image files from DockerHub by specifying the SINGULARITY_CACHEDIR environment variable. The default is $HOME/.singularity/. Note that $HOME is /root when running using sudo.
singularity shell spectre.img and you will be dropped into a bash shell.cd into SPECTRE_ROOT and run mkdir build && cd build to set up a build directory.make unit-tests -jN where N is the number of cores to build on in parallel (e.g. -j4).make list.make test-executables -jN to compile the test executables, and ctest to run the tests.Notes:
singularity shell spectre.img in another terminal.SpECTRE's dependencies can be installed with Spack, a package manager tailored for HPC use. Install Spack by cloning it into SPACK_DIR (a directory of your choice), then add SPACK_DIR/bin to your PATH.
For security, it is good practice to make Spack use the system's OpenSSL rather than allow it to install a new copy — see Spack's documentation for instructions. You may need to install the development version of OpenSSL:
sudo apt-get install libssl-devsudo dnf install openssl-develSpack works well with a module environment. We recommend LMod, which is available on many systems:
. /usr/local/Cellar/lmod/YOUR_VERSION_NUMBER/init/sh to your .bash_profile.sudo apt-get install -y lmod and, for Ubuntu 17.04, add . /etc/profile.d/lmod.sh to your .bashrc. For Ubuntu 16.04, the correct path to add is . /usr/share/lmod/lmod/init/bash.yaourt -Sy lmod and add . /etc/profile.d/lmod.sh to your .bashrc,To use modules with Spack, enable Spack's shell support by adding . SPACK_DIR/share/spack/setup-env.sh to your .bash_profile or .bashrc.
Once you have Spack installed and configured with OpenSSL and LMod, you can install the SpECTRE dependencies using
You can also install CMake, OpenBLAS, Boost, and HDF5 from Spack. To load the packages you've installed from Spack run spack load PACKAGE, or (equivalently) use the module load command.
Note: Spack allows very flexible configurations and it is recommended you read the documentation if you require features such as packages installed with different compilers.
Note: On a Mac, you may need to spack install yaml-cpp@develop~shared (note that is a tilde and not a dash in front of shared) in order to force the building of the static libraries in order to avoid dynamic linking errors.
After the dependencies have been installed, Charm++ and SpECTRE can be compiled. Follow these steps:
SPECTRE_ROOT, a directory of your choice.CHARM_DIR, again a directory of your choice.CHARM_DIR, run git checkout v6.10.2 to switch to a supported, stable release of Charm++../build LIBS ARCH OPTIONS. To figure out the correct target architecture and options, you can simply run ./build; the script will then ask you questions to guide you towards the correct settings (see notes below for additional details). Then compile Charm++. The Charm++ build will be located in a new directory, CHARM_DIR/ARCH_OPTS, whose name may (or may not) have some of the options appended to the architecture. In addition to the core charm++ target, you will need to compile either the LIBS target or the everylb target. This is needed so that we can support the more sophisticated load balancers in SpECTRE executables./Library/Developer/CommandLineTools/usr/include/c++/v1/__threading_supportSPECTRE_ROOT, and create a build dir by running mkdir build && cd buildcmake -D CHARM_ROOT=CHARM_DIR/ARCH_OPTS SPECTRE_ROOT then make -jN to compile the code.make test-executables && ctest.Notes:
charm++ and, for a personal machine, the correct target architecture is likely to be multicore-linux-x86_64 (or multicore-darwin-x86_64 on macOS). On an HPC system, the correct Charm++ target architecture depends on the machine's inter-node communication architecture. We will be providing specific instructions for various HPC systems.make list to see all available targets. This list can be refreshed by running CMake again.For any coverage analysis you will need to have LCOV installed on the system. For documentation coverage analysis you will also need to install coverxygen and for test coverage analysis gcov.
If you have these installed (which is already done if you are using the docker container), you can look at code coverage as follows:
-D COVERAGE=ON to cmakemake unit-test-coveragedocs/html/unit-test-coverage.