.. _install-developers: .. _install-build-cmake: .. _building-cmake: .. _building-cmake-intro: Build from Source ================= `CMake `__ is our primary build system. If you are new to CMake, we recommend starting with `this concise tutorial `__ from the HEP Software Foundation. For those primarily interested in building the project, focus on these key sections: `1. Introduction `__, `2. Building with CMake `__, and `9. Finding Packages `__. .. grid:: 2 :gutter: 2 .. grid-item-card:: :octicon:`alert` Build on HPC :link: install-hpc :link-type: ref Please refer to the :ref:`install-hpc` section. .. grid-item-card:: Install Dependencies :link: install-build-dependencies :link-type: ref Software dependencies of ImpactX. .. grid-item-card:: Build the Code :link: install-build-code :link-type: ref Configuration, compilation and install. .. grid-item-card:: Build Options :link: install-build-options :link-type: ref All build configuration options. .. _install-build-dependencies: Install Dependencies -------------------- To begin, obtain a copy of the ImpactX source code: .. code-block:: bash git clone https://github.com/BLAST-ImpactX/impactx.git $HOME/src/impactx cd $HOME/src/impactx ImpactX relies on :ref:`widely-used third-party software `. Below, you'll find instructions for installing these dependencies using various package managers. To ensure compatibility, pick **one** package manager for your development workflows. .. toctree:: :hidden: dependencies Install with conda-forge ^^^^^^^^^^^^^^^^^^^^^^^^ Conda provides a convenient way to install dependencies across Linux, macOS, and Windows platforms. `conda-forge `__ is a community-led collection of recipes, build infrastructure and distributions for the conda package manager, offering cross-platform compatibility at the user level. .. tip:: We recommend to deactivate that conda self-activates its ``base`` environment. This `avoids interference with the system and other package managers `__. .. code-block:: bash conda config --set auto_activate_base false In order to make sure that the conda configuration uses ``conda-forge`` as the only channel, which will help avoid issues with blocked ``defaults`` or ``anaconda`` repositories, please set the following configurations: .. code-block:: bash conda config --add channels conda-forge conda config --set channel_priority strict .. tab-set:: .. tab-item:: With MPI (only Linux/macOS) .. code-block:: bash conda create -n impactx-cpu-mpich-dev -c conda-forge boost ccache cmake compilers git "openpmd-api=*=mpi_mpich*" packaging pytest pytest-benchmark python python-build numpy pandas quantiphy scipy setuptools yt "fftw=*=mpi_mpich*" pkg-config matplotlib mamba ninja mpich pip virtualenv vir-simd wheel conda activate impactx-cpu-mpich-dev # compile ImpactX with -DImpactX_MPI=ON # for pip, use: export IMPACTX_MPI=ON .. tab-item:: Without MPI .. code-block:: bash conda create -n impactx-cpu-dev -c conda-forge boost ccache cmake compilers git openpmd-api packaging pytest pytest-benchmark python python-build numpy pandas quantiphy scipy setuptools yt fftw pkg-config matplotlib mamba ninja pip virtualenv vir-simd wheel conda activate impactx-cpu-dev # compile ImpactX with -DImpactX_MPI=OFF # for pip, use: export IMPACTX_MPI=OFF For OpenMP support, you will further need: .. tab-set:: .. tab-item:: Linux .. code-block:: bash conda install -c conda-forge libgomp .. tab-item:: macOS or Windows .. code-block:: bash conda install -c conda-forge llvm-openmp For Nvidia CUDA GPU support, you will need to have `a recent CUDA driver installed `__ or you can lower the CUDA version of `the Nvidia cuda package `__ and `conda-forge to match your drivers `__ and then add these packages: .. code-block:: bash conda install -c nvidia -c conda-forge cuda cuda-nvtx-dev cupy For the ImpactX browser/Jupyter dashboard dependencies, install from the ImpactX source directory: .. code-block:: bash python3 -m pip install -r src/python/impactx/dashboard/requirements.txt Install with Spack ^^^^^^^^^^^^^^^^^^ Spack provides another option for installing dependencies on Linux and macOS systems. `Spack `__ is a flexible, user-level package manager designed primarily for Linux, with growing support for macOS and planned future support for Windows. To begin, download a `WarpX Spack desktop development environment `__ configuration (which also works for ImpactX). For most desktop development work, we recommend using the OpenMP environment for CPUs, unless you have a supported GPU device. * **Debian/Ubuntu** Linux: * OpenMP: ``system=ubuntu; compute=openmp`` (CPUs) * CUDA: ``system=ubuntu; compute=cuda`` (Nvidia GPUs) * ROCm: ``system=ubuntu; compute=rocm`` (AMD GPUs) * SYCL: *todo* (Intel GPUs) * **macOS**: first, prepare with ``brew install gpg2; brew install gcc`` * OpenMP: ``system=macos; compute=openmp`` If you already `installed Spack `__, we recommend to activate its `binary caches `__ for faster builds: .. code-block:: bash spack mirror add rolling https://binaries.spack.io/develop spack buildcache keys --install --trust Now install the ImpactX dependencies in a new ImpactX development environment: .. code-block:: bash # download environment file curl -sLO https://raw.githubusercontent.com/BLAST-WarpX/warpx/development/Tools/machines/desktop/spack-${system}-${compute}.yaml # create new development environment spack env create impactx-${compute}-dev spack-${system}-${compute}.yaml spack env activate impactx-${compute}-dev # installation spack install python3 -m pip install jupyter matplotlib numpy openpmd-api openpmd-viewer pandas quantiphy scipy virtualenv yt In new terminal sessions, re-activate the environment with .. code-block:: bash spack env activate impactx-openmp-dev again. Replace ``openmp`` with the equivalent you chose. Compile ImpactX with ``-DImpactX_MPI=ON``. For ``pip``, use ``export IMPACTX_MPI=ON``. Install with Brew ^^^^^^^^^^^^^^^^^ Brew can be used to install dependencies on Linux and macOS. `Homebrew (Brew) `__ is a user-level package manager primarily for `Apple macOS `__, but also supports Linux. .. code-block:: bash brew update brew tap openpmd/openpmd brew install adios2 # for openPMD brew install ccache brew install cmake brew install fftw # for IGF space charge, CSR brew install git brew install hdf5-mpi # for openPMD brew install libomp brew unlink gcc brew link --force libomp brew install pkg-config # for fftw brew install open-mpi brew install openblas brew install openpmd-api # for openPMD Compile ImpactX with ``-DImpactX_MPI=ON``. For ``pip``, use ``export IMPACTX_MPI=ON``. Install with APT ^^^^^^^^^^^^^^^^ The `Advanced Package Tool (APT) `__ is a system-level package manager on Debian-based Linux distributions, including Ubuntu. .. tab-set:: .. tab-item:: With MPI (only Linux/macOS) .. code-block:: bash sudo apt update sudo apt install build-essential ccache cmake g++ git libfftw3-mpi-dev libfftw3-dev libhdf5-openmpi-dev libopenmpi-dev pkg-config python3 python3-dev python3-matplotlib python3-mpi4py python3-numpy python3-pandas python3-pip python3-scipy python3-venv # optional: # for CUDA, either install # https://developer.nvidia.com/cuda-downloads (preferred) # or, if your Debian/Ubuntu is new enough, use the packages # sudo apt install nvidia-cuda-dev libcub-dev # compile ImpactX with -DImpactX_MPI=ON # for pip, use: export IMPACTX_MPI=ON .. tab-item:: Without MPI .. code-block:: bash sudo apt update sudo apt install build-essential ccache cmake g++ git libfftw3-dev libhdf5-dev pkg-config python3 python3-dev python3-matplotlib python3-numpy python3-pandas python3-pip python3-scipy python3-venv # optional: # for CUDA, either install # https://developer.nvidia.com/cuda-downloads (preferred) # or, if your Debian/Ubuntu is new enough, use the packages # sudo apt install nvidia-cuda-dev libcub-dev # compile ImpactX with -DImpactX_MPI=OFF # for pip, use: export IMPACTX_MPI=OFF .. _install-build-code: Build the Code -------------- .. _build-the-executable-with-cmake: Build the Executable with CMake ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ To build ImpactX from the source directory, execute these commands: .. code-block:: bash # Configure the build system # Additional options available, such as: # -DImpactX_PYTHON=ON # -DCMAKE_INSTALL_PREFIX=$HOME/sw/impactx cmake -S . -B build # Compile using four parallel threads cmake --build build -j 4 **That's it!** The ImpactX binary is now available in ``build/bin/`` and is ready to :ref:`run ` with any :ref:`example input file `. You can either run the binary directly from this location or copy it to another directory. For a system-wide installation, use the following command: .. code-block:: bash # for default install paths, you will need administrator rights, e.g. with sudo: cmake --build build --target install You can inspect and modify build options after running ``cmake -S . -B build`` with either .. code-block:: bash ccmake build or by adding arguments with ``-D