4 * [Using deal.II on Mac OS X and Linux via Spack](#using-dealii-on-mac-os-x-and-linux-via-spack)
5 * [Quick installation on the desktop](#quick-installation-on-the-desktop)
6 * [Installation example on a Centos7 cluster (Emmy cluster of RRZE, Erlangen, Germany)](#installation-example-on-a-centos7-cluster-emmy-cluster-of-rrze-erlangen-germany)
7 * [Enabling CUDA](#enabling-cuda)
8 * [Environment Modules](#environment-modules)
9 * [System provided packages](#system-provided-packages)
10 * [Installing GCC](#installing-gcc)
11 * [Best practices using Spack:](#best-practices-using-spack)
13 * [Extra options:](#extra-options)
14 * [Compiler flags](#compiler-flags)
15 * [Different versions coexisting:](#different-versions-coexisting)
16 * [Filesystem Views:](#filesystem-views)
17 * [Check before build:](#check-before-build)
18 * [Develop using Spack](#develop-using-spack)
19 * [Keep the stage to run unit tests](#keep-the-stage-to-run-unit-tests)
20 * [MKL and Licensed software](#mkl-and-licensed-software)
21 * [Freeze package versions](#freeze-package-versions)
22 * [Known issues using Spack:](#known-issues-using-spack)
24 # Using deal.II on Mac OS X and Linux via Spack
26 The deal.II suite is also available on Spack (https://github.com/LLNL/spack) -- a flexible package manager developed with High-Performance-Computing in mind. It is intended to let you build for many combinations of compiler, architectures, dependency libraries, and build configurations, all with a friendly, intuitive user interface.
28 For a quick overview of Spack's features, we recommend this short presentation https://tgamblin.github.io/files/Gamblin-Spack-SC15-Talk.pdf
29 or the following videos from lead developers:
30 [Massimiliano Culpo - SPACK: A Package Manager for Supercomputers, Linux and MacOS](https://www.youtube.com/watch?v=Qok-nXfIWfg) and
31 [Todd Gamblin (LLNL) - Managing HPC Software Complexity with Spack](https://www.youtube.com/watch?v=Ie1cZTR09kk).
33 [Spack tutorial 101](http://spack.readthedocs.io/en/latest/tutorial.html) is good place to start as well.
35 Note: Spack is in active development and is in alpha state, thereby below we recommend using the specific snapshot of the code (hash), that was tested on macOS / Ubuntu / CentOS7 with deal.II and is being used to run the complete testsuite on `Unbutu18.04` with `openmpi` and `openblas`. See [Continuous section of CDash](https://cdash.kyomu.43-1.org/index.php?project=deal.II).
37 ## Quick installation on the desktop
39 Add the following to `~/.bashrc` (or equivalent)
41 export SPACK_ROOT=/path/to/spack
42 export PATH="$SPACK_ROOT/bin:$PATH"
44 `SPACK_ROOT` is the destination where you want Spack to be installed (i.e. `$HOME/spack`).
49 git clone https://github.com/spack/spack.git .
51 git reset --hard 99f678035a279cf85a32a4fdbd98a117b9c1832f
54 **Make sure C/C++/Fortran compilers are in path** (on Ubuntu you need to `sudo apt-get install gfortran`, on macOS you can compile `gcc` with spack, see [below](#installing-gcc), and you have **curl** (`sudo apt-get install curl`) to download packages. Then install the complete deal.II suite
56 spack install --test=root dealii
58 **DONE**! No extra (preliminary) configuration steps are needed on most Linux distributions. **IMPORTANT:** If you compile deal.II on a cluster, see the next section on how to use externally provided MPI implementation instead.
59 Additional option `--test=root` instructs Spack to run quick tests for `dealii`.
61 Before configuring your project you need to set `DEAL_II_DIR` by
63 export DEAL_II_DIR=$(spack location -i dealii)
65 You may jump ahead and read [best practices using spack](#best-practices-using-spack). Also a good starting point is [Getting Started Guide](http://spack.readthedocs.io/en/latest/getting_started.html).
68 ## Installation example on a Centos7 cluster (Emmy cluster of RRZE, Erlangen, Germany)
69 In order to use Spack on a cluster, there are two options: (1) you are a sysadmin and you know hardware details and can use Spack to properly configure and build MPI providers (e.g. `openmpi`); (2) you are a user and you need to make Spack work with MPI provided on your cluster. Below we consider the latter case.
71 Here is a brief step-by-step instruction to install deal.II on [Emmy cluster](https://www.rrze.fau.de/dienste/arbeiten-rechnen/hpc/systeme/emmy-cluster.shtml#access) of RRZE, Erlangen, Germany:
75 mkdir $WOODYHOME/spack
79 (1a) If you plan on using `GCC/Clang` as a compiler:
81 # Clone standard version of Spack
82 git clone https://github.com/llnl/spack.git $WOODYHOME/spack
83 export PATH=$WOODYHOME/spack/bin:$PATH
85 (1b) If you plan on using `Intel` compilers (this point is expanded upon in step (5)):
87 # Clone modified version of Spack to fit RRZE setup
88 git clone -b pkg/intel_mpi_fix https://github.com/davydden/spack.git .
89 export PATH=$WOODYHOME/spack/bin:$PATH
91 (2) Load `openmpi` and let Spack find GCC compiler which is also loaded as a dependency:
93 module load openmpi/2.0.2-gcc
96 (3) Add `openmpi` as an external package, along with `python` and a few other self explanatory setting for `deal.ii`. That is done by adding the following to `~/.spack/linux/packages.yaml`
108 openmpi@2.0.2%gcc@4.8.5: /apps/OpenMPI/2.0.2-gcc/
113 variants: +optflags~python
115 Those paths are the location where external packages can be found (i.e. `<prefix>` instead of `<prefix>/bin` or `<prefix>/lib`). `providers` section essentially tells Spack which packages to use to satisfy virtual dependencies such as `MPI`, `BLAS`, `LAPACK`, `ScaLAPACK`, etc. Here we also limit version of `suite-sparse` to `5.1.0` as we build with `gcc@4.8.5` whereas `5.2.0` requires at least `gcc@4.9`.
117 (4) Now install deal.II: `spack install dealii`.
119 (5) Here is an alternative setup with Intel compilers. Run `module load intel64/18.0up02` followed by `spack compiler find`. You should get the following new entry in `~/.spack/linux/compilers.yaml`:
126 operating_system: centos7
128 cc: /apps/intel/ComposerXE2018/compilers_and_libraries_2018.2.199/linux/bin/intel64/icc
129 cxx: /apps/intel/ComposerXE2018/compilers_and_libraries_2018.2.199/linux/bin/intel64/icpc
130 f77: /apps/intel/ComposerXE2018/compilers_and_libraries_2018.2.199/linux/bin/intel64/ifort
131 fc: /apps/intel/ComposerXE2018/compilers_and_libraries_2018.2.199/linux/bin/intel64/ifort
135 Edit it to set environment variable (with license) and extra rpaths:
139 INTEL_LICENSE_FILE: 1713@license4
140 extra_rpaths: # take from echo $LIBRARY_PATH
141 - /apps/intel/ComposerXE2018/compilers_and_libraries_2018.2.199/linux/ipp/lib/intel64
142 - /apps/intel/ComposerXE2018/compilers_and_libraries_2018.2.199/linux/compiler/lib/intel64_lin
144 Then add to `~/.spack/linux/packages.yaml` paths to `intel-mpi`, `intel-mkl` as well as `cmake` which currently does not build with `Intel`:
153 scalapack: [intel-mkl]
155 version: [2018.2.199]
157 intel-mpi@2018.2.199%intel@18.0.2: /apps/intel/ComposerXE2018/
160 version: [2018.2.199]
162 intel-mkl@2018.2.199%intel@18.0.2: /apps/intel/ComposerXE2018/
167 cmake@3.6.0%intel@18.0.2: /apps/cmake/3.6.0/
172 variants: +optflags~python
174 Finally install `deal.II`
176 spack install -j 20 dealii%intel~assimp~petsc~slepc+mpi^intel-mpi^intel-mkl
178 Note that `%intel` specified the compiler whereas `^intel-mpi` and `^intel-mkl` specified which implementation of MPI and BLAS/LAPACK we want to use. Here we also disabled few other packages that have issues building with `Intel` compilers.
180 See [this discussion](https://groups.google.com/d/msg/spack/NxyNTAZyMQg/Klu2CHR8GQAJ) on more info about using Intel compilers in Spack.
184 You can build the current development version of `dealii` with CUDA. A possible configuration of `packages.yaml` is
189 variants: +cuda cuda_arch=52
193 where we specified explicitly CUDA architecture as well as version of `cuda` to be used.
195 ## Environment Modules
196 Spack provides some integration with Environment Modules and Dotkit to make it easier to use the packages it installs. For a full description, read http://spack.readthedocs.io/en/latest/getting_started.html#environment-modules
198 To add the support for Environment Modules run
200 spack install environment-modules
202 Get the path to the prefix of `environment-modules` by:
204 spack location --install-dir environment-modules
206 and then add to `~/.bashrc` (or equivalent)
208 MODULES_HOME=/path/to/environment-modules
209 source ${MODULES_HOME}/Modules/init/bash
210 . $SPACK_ROOT/share/spack/setup-env.sh
213 If you install `deal.II` before setting up environment modules,
214 the module files have to be regenerated
224 Now `DEAL_II_DIR` environment variable should be set appropriately and `cmake` executable will be available in path. Keep in mind that `spack load dealii` will also set `LD_LIBRARY_PATH` accordingly, this may or may not be what you need. An alternative is to use `export DEAL_II_DIR=$(spack location -i dealii)`.
226 ## System provided packages
227 Spack is flexible to use both self-compiled and system provided packages.
228 In most cases this is desirable for `MPI`, which is already installed on computational clusters. To configure external packages you need to edit `~/.spack/linux/packages.yaml`. For `openmpi` this could be
234 openmpi@1.8.8%gcc@6.2.0: /opt/openmpi-1.8.8
237 In order to make sure that we use to build packages `1.8.8` version of `openmpi` and not the most recent one (i.e. `2.0.2`), we specified conretization preferences with `version: [1.8.8]`.
239 One can also specify which packages should be used to provide `mpi`, `blas/lapack` , preferred compilers and preferred variants:
243 compiler: [gcc,clang]
252 For more elaborated discussion, see [Configuration Files in Spack](http://spack.readthedocs.io/en/latest/configuration.html).
255 If your system does not provide any Fortran compiler or you want to have the most recent `gcc`,
256 you can install it by
261 Assuming that you configured [Environment Modules](#environment-modules), load `gcc` and let Spack find the newly installed compilers:
266 Now you can install deal.II with `gcc`
268 spack install dealii%gcc
271 If you are on the mac, read the following instructions on [Mixed Toolchains](http://spack.readthedocs.io/en/latest/getting_started.html#mixed-toolchains).
273 On following these instructions, you will be able to install deal.II with clang+gfortran
275 spack install dealii%clang
278 ## Best practices using Spack:
280 Spack is complicated and flexible package manager primarily aimed at High-Performance-Computing.
281 Below are some examples of using Spack to build and develop deal.II:
284 If you are not sure which options a given package has, simply run
288 The output will contain available versions, variants, dependencies and description:
294 C++ software library providing well-documented tools to build finite
295 element codes for a broad variety of PDEs.
297 Homepage: https://www.dealii.org
300 8.5.1 https://github.com/dealii/dealii/releases/download/v8.5.1/dealii-8.5.1.tar.gz
303 develop [git] https://github.com/dealii/dealii.git
304 8.5.1 https://github.com/dealii/dealii/releases/download/v8.5.1/dealii-8.5.1.tar.gz
305 8.5.0 https://github.com/dealii/dealii/releases/download/v8.5.0/dealii-8.5.0.tar.gz
306 8.4.2 https://github.com/dealii/dealii/releases/download/v8.4.2/dealii-8.4.2.tar.gz
307 8.4.1 https://github.com/dealii/dealii/releases/download/v8.4.1/dealii-8.4.1.tar.gz
308 8.4.0 https://github.com/dealii/dealii/releases/download/v8.4.0/dealii-8.4.0.tar.gz
309 8.3.0 https://github.com/dealii/dealii/releases/download/v8.3.0/dealii-8.3.0.tar.gz
310 8.2.1 https://github.com/dealii/dealii/releases/download/v8.2.1/dealii-8.2.1.tar.gz
311 8.1.0 https://github.com/dealii/dealii/releases/download/v8.1.0/dealii-8.1.0.tar.gz
314 Name [Default] Allowed values Description
317 adol-c [off] True, False Compile with Adol-c
318 arpack [on] True, False Compile with Arpack and
319 PArpack (only with MPI)
320 build_type [DebugRelease] Debug, Release, The build type to build
322 doc [off] True, False Compile with documentation
323 gsl [on] True, False Compile with GSL
324 hdf5 [on] True, False Compile with HDF5 (only with
326 int64 [off] True, False Compile with 64 bit indices
328 metis [on] True, False Compile with Metis
329 mpi [on] True, False Compile with MPI
330 nanoflann [off] True, False Compile with Nanoflann
331 netcdf [on] True, False Compile with Netcdf (only with
333 oce [on] True, False Compile with OCE
334 optflags [off] True, False Compile using additional
336 p4est [on] True, False Compile with P4est (only with
338 petsc [on] True, False Compile with Petsc (only with
340 python [on] True, False Compile with Python bindings
341 slepc [on] True, False Compile with Slepc (only with
343 sundials [off] True, False Compile with Sundials
344 trilinos [on] True, False Compile with Trilinos (only
351 adol-c cmake hdf5 muparser oce slepc trilinos
352 arpack-ng doxygen lapack nanoflann p4set suite-sparse zlib
353 blas graphivz metis netcdf petsc sundials
354 boost gsl mpi netcdf-cxx python tbb
357 adol-c doxygen lapack nanoflann p4est suite-sparse zlib
358 arpack-ng graphviz metis netcdf petsc sundials
359 blas graphviz mpi netcdf-cxx python tbb
360 boost hdf5 muparser oce slepc trilinos
369 A lot of `spack` commands have help, for example
372 usage: spack install [-h] [--only {package,dependencies}] [-j JOBS]
373 [--keep-prefix] [--keep-stage] [--restage] [-n] [-v]
374 [--fake] [-f] [--clean | --dirty] [--run-tests]
375 [--log-format {junit}] [--log-file LOG_FILE]
378 build and install packages
380 positional arguments:
381 package spec of the package to install
384 -h, --help show this help message and exit
385 --only {package,dependencies}
386 select the mode of installation. the default is to
387 install the package along with all its dependencies.
388 alternatively one can decide to install only the
389 package or only the dependencies
390 -j JOBS, --jobs JOBS explicitly set number of make jobs. default is #cpus
391 --keep-prefix don't remove the install prefix if installation fails
392 --keep-stage don't remove the build stage if installation succeeds
393 --restage if a partial install is detected, delete prior state
394 -n, --no-checksum do not check packages against checksum
395 -v, --verbose display verbose build output while installing
396 --fake fake install. just remove prefix and create a fake
398 -f, --file install from file. Read specs to install from .yaml
400 --clean clean environment before installing package
401 --dirty do NOT clean environment before installing
402 --run-tests run package level tests during installation
403 --log-format {junit} format to be used for log files
404 --log-file LOG_FILE filename for the log file. if not passed a default
409 One can specify extra options for packages in the deal.II suite. For example if you want to have boost with `python` module, this can be done by
411 spack install dealii@develop+mpi~python ^boost+python
414 If you want to specify blas/lapack/mpi implementations, this can be done similarly
416 spack install dealii@develop+mpi ^mpich
418 To check which packages implement `mpi` run
422 One can also specify which Blas/Lapack implementation to use. For example to build deal.II suite with `atlas` run
424 spack install dealii ^atlas
428 You can specify compiler flags on the command line as
430 spack install dealii cppflags="-march=native -O3"
432 Note that these flags will be inherited by dependencies such as `petsc`, `trilinos`, etc. Same can be done by declaring these flags in `~/.spack/compilers.yaml`:
437 operating_system: centos6
441 f77: /usr/bin/gfortran
442 fc: /usr/bin/gfortran
450 See this [google forum topic](https://groups.google.com/forum/?fromgroups#!topic/dealii/3Yjy8CBIrgU) for discussion on which flags to use. You can also use `spack install dealii+optflags` to enable extra optimization flags in release build.
452 ### Different versions coexisting:
453 One can easily have slightly different versions of deal.II side-by-side, e.g. to compile development version of deal.II with complex-valued PETSc and `gcc` compiler run
455 spack install dealii@develop+mpi+petsc~int64%gcc ^petsc+complex~hypre
457 The good thing is that if you already have deal.ii built with real-valued petsc, then only `petsc`, `slepc` and `deal.ii` itself will be rebuild. Everything else (`trilinos`, `mumps`, `metis`, etc) will be reused.
459 One can use `environment-modules` (see above) to automatically set `DEAL_II_DIR` to the complex version:
461 spack load dealii@develop+mpi+petsc~int64%gcc ^petsc+complex~hypre
464 ### Filesystem Views:
465 If you prefer to have the whole dealii suite (and possible something else) symlinked into a single path (like `/usr/local`), one can use [Filesystem Views](http://spack.readthedocs.io/en/latest/workflows.html#filesystem-views):
467 spack view -v symlink dealii_suite dealii@develop
469 You can also add to this view other packages, i.e.
471 spack view -v symlink dealii_suite the-silver-searcher
475 ### Check before build:
476 It is often convenient to check which version of packages, compilers, variants etc will be used before actually starting installation. That can be done by examining the concretized spec via `spack spec` command, e.g.
478 spack spec dealii@develop+mpi+petsc~int64%gcc ^petsc+complex~hypre
481 The `spec` command has a useful flag `-I` which will show install status of dependencies in the graph.
483 ### Develop using Spack
484 Probably the easiest way to use Spack while contributing patches to the deal.II is the following.
485 Install `deal.II` via Spack, go to its installation prefix and copy-paste the CMake command from `.spack/build.out`, which looks like
487 'cmake' '/path/to/spack/var/spack/stage/dealii-develop-tkowxhk55kpi7facfh3ufipofyolt6h7/dealii' '-DCMAKE_INSTALL_PREFIX:PATH=path/to/spack/opt/spack/darwin-sierra-x86_64/clang-8.1.0-apple/dealii-develop-tkowxhk55kpi7facfh3ufipofyolt6h7' '-DCMAKE_BUILD_TYPE:STRING=DebugRelease' <more options>
489 You would need to adjust the path to the `dea.II` source folder (first path) and should remove the `DCMAKE_INSTALL_PREFIX` as you probably don't want to accidentally override the version installed by Spack.
491 Assuming that your build folder is within the `dealii` sources (tha'ts what `..\/` is for below), you can get this substitution done by
493 $ cat $(spack location -i dealii)/.spack/build.out | grep "==> 'cmake'" | sed -e "s/[^ ]*[^ ]/'..\/'/3" | cut -d " " -f2-
496 Before running `cmake` from the build folder, you may want to run
498 spack env dealii@develop+mpi^openmpi^openblas bash
500 to make sure your environment (paths, variables, etc) is set exactly the same way as when compiling `deal.II` from Spack
501 (adjust the spec `dealii@develop+mpi^openmpi^openblas` to be what you use when you installed `deal.II`).
503 An alternative is to create a [Filesystem view](#filesystem-views) for an already installed library and then compile patched version of deal.II manually by providing path to the view for each dependency.
505 ### Keep the stage to run unit tests
506 By default, the build folder (aka `stage`) for each package is created in a temporary system dependent location.
507 This gets purge by system on next restart.
508 If you want to keep the stage after the installation, you need to do two things:
509 First, make spack use a custom location for stage by adding the following to your `~/.spack/config.yaml`:
513 - $spack/var/spack/stage
515 Second, prescribe an extra argument to `install` command to keep the stage after successful installation:
517 spack install --keep-stage dealii@develop
520 ### MKL and Licensed software
521 Spack supports installation of [licensed software](http://spack.readthedocs.io/en/latest/packaging_guide.html#license) as well as usage of [Licensed compilers](http://spack.readthedocs.io/en/latest/getting_started.html#licensed-compilers). For example in order to install MKL on Linux:
523 1. add `Intel` license file as `license.lic` file to `${SPACK_ROOT}/etc/spack/licenses/intel/`.
524 2. run `spack install dealii ^intel-mkl@11.3.2.210`
526 In order to configure Intel compilers see [this page](http://spack.readthedocs.io/en/latest/getting_started.html#vendor-specific-compiler-configuration).
529 ### Freeze package versions
530 Currently Spack does not try to re-use already installed packages. On another hand, by default
531 the most recent version of a package will be installed. When updating deal.II build (for example to use the new version of `trilinos`), the combination of the two factors may lead to recompilation of many other packages used in the deal.II suite when one of the main build dependency like `cmake` has a new version.
533 To circumvent the problem, the user can specify preferred versions of packages in `~/.spack/packages.yaml`:
545 This settings will be taken into account during conretization process and thus will help to avoid rebuilding most of the deal.II suite when, for example, `openssl` is updated to the new version.
547 ## Known issues using Spack:
549 ### Incompatible CMake versions
551 At the moment there is an incompatibility between deal.II and `cmake` with version 3.10 and greater.
552 To install deal.II using an earlier version of `cmake`, either use the `packages.yaml` file to freeze `cmake` to an earlier version, or specify the version at install time, e.g.
554 spack install dealii^cmake@3.9.4