CMake Transition

We are currently transitioning to support CMake as our primary build system. Until we have transitioned our documentation and functionality completely, please read the following preview section for details.

Progress status: see on GitHub

Introduction to CMake

If you are new to CMake, this short tutorial from the HEP Software foundation is the perfect place to get started with it.

If you just want to use CMake to build the project, jump into sections 1. Introduction, 2. Building with CMake and 9. Finding Packages.

Dependencies

WarpX depends on the following popular third party software. Please see installation instructions below.

Optional dependencies include:

Install Dependencies

macOS/Linux:

spack env create warpx-dev
spack env activate warpx-dev
spack add adios2
spack add ccache
spack add cmake
spack add fftw
spack add hdf5
spack add mpi
spack add pkgconfig  # for fftw
# optional:
# spack add cuda
spack install

(in new terminals, re-activate the environment with spack env activate warpx-dev again)

or macOS/Linux:

brew update
brew install adios2
brew install ccache
brew install cmake
brew install fftw
brew install hdf5-mpi
brew install libomp
brew install pkg-config  # for fftw
brew install open-mpi

Now, cmake --version should be at version 3.14.0 or newer.

Configure your compiler

For example, using a GCC on macOS:

export CC=$(which gcc)
export CXX=$(which g++)

If you also want to select a CUDA compiler:

export CUDACXX=$(which nvcc)
export CUDAHOSTCXX=$(which g++)

Build & Test

From the base of the WarpX source directory, execute:

mkdir -p build
cd build

# find dependencies & configure
cmake ..

# build using up to four threads
make -j 4

# run tests (todo)

You can inspect and modify build options after running cmake .. with either

ccmake .

or by providing arguments to the CMake call: cmake .. -D<OPTION_A>=<VALUE_A> -D<OPTION_B>=<VALUE_B>

CMake Option

Default & Values

Description

CMAKE_BUILD_TYPE

RelWithDebInfo/Release/Debug

Type of build, symbols & optimizations

WarpX_ASCENT

ON/OFF

Ascent in situ visualization

WarpX_COMPUTE

NOACC/OMP/CUDA/DPCPP

On-node, accelerated computing backend

WarpX_DIMS

3/2/RZ

Simulation dimensionality

WarpX_MPI

ON/OFF

Multi-node support (message-passing)

WarpX_MPI_THREAD_MULTIPLE

ON/OFF

MPI thread-multiple support, i.e. for async_io

WarpX_OPENPMD

ON/OFF

openPMD I/O (HDF5, ADIOS)

WarpX_PARSER_DEPTH

24

Maximum parser depth for input file functions

WarpX_PRECISION

double/single

Floating point precision (single/double)

WarpX_PSATD

ON/OFF

Spectral solver

WarpX_QED

ON/OFF

PICSAR QED (requires Boost and PICSAR)

WarpX_amrex_repo

https://github.com/AMReX-Codes/amrex.git

Repository URI to pull and build AMReX from

WarpX_amrex_branch

development

Repository branch for WarpX_amrex_repo

WarpX_amrex_internal

ON/OFF

Needs a pre-installed AMReX library if set to OFF

WarpX_openpmd_internal

ON/OFF

Needs a pre-installed openPMD library if set to OFF

For example, one can also build against a local AMReX git repo. Assuming AMReX’ source is located in $HOME/src/amrex and changes are committed into a branch such as my-amrex-branch then pass to cmake the arguments: -DWarpX_amrex_repo=file://$HOME/src/amrex -DWarpX_amrex_branch=my-amrex-branch.

For developers, WarpX can be configured in further detail with options from AMReX, which are documented in the AMReX manual.

Run

An executable WarpX binary with the current compile-time options encoded in its file name will be created in bin/.

Additionally, a symbolic link named warpx can be found in that directory, which points to the last built WarpX executable.