Installation¶
Simulation user Operator developer
Prerequisites¶
To build Onika, you need:
- CMake ≥ 3.26
- A C++20 compiler, e.g. GCC ≥ 11
- MPI (e.g. OpenMPI or MPICH) and OpenMP
- yaml-cpp, version 0.6.3 recommended
- CUDA or HIP (optional), for GPU acceleration
- Python 3 (tested with 3.10 to 3.14) with development headers and
numpy(optional), for the Python bindings
Note
Version 0.6.3 of yaml-cpp is the tested reference. Recent versions of
Onika's CMake also find yaml-cpp ≥ 0.7 (yaml-cpp::yaml-cpp target).
If you hit a problem with a newer version, go back to 0.6.3.
yaml-cpp can be built as a shared library (as below) or as a static
one (-DYAML_BUILD_SHARED_LIBS=OFF -DCMAKE_CXX_FLAGS=-fPIC): both work.
Installing yaml-cpp¶
export CURRENT_HOME=$PWD
git clone --depth 1 --branch yaml-cpp-0.6.3 https://github.com/jbeder/yaml-cpp.git
mkdir ${CURRENT_HOME}/build-yaml-cpp && cd ${CURRENT_HOME}/build-yaml-cpp
cmake ../yaml-cpp/ \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INSTALL_PREFIX=${CURRENT_HOME}/install-yaml-cpp \
-DYAML_BUILD_SHARED_LIBS=ON \
-DYAML_CPP_BUILD_TESTS=OFF
make install -j 4
cd ${CURRENT_HOME}
export PATH_TO_YAML=${CURRENT_HOME}/install-yaml-cpp
Note
The version installed by apt depends on your distribution.
Check it with apt show libyaml-cpp-dev.
Installing Onika¶
export CURRENT_HOME=$PWD
git clone https://github.com/Collab4exaNBody/onika.git
cmake -S ${CURRENT_HOME}/onika -B ${CURRENT_HOME}/build-onika \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INSTALL_PREFIX=${CURRENT_HOME}/install-onika \
-Dyaml-cpp_DIR=${PATH_TO_YAML}/lib/cmake/yaml-cpp
cmake --build ${CURRENT_HOME}/build-onika -j 10 --target install
export CURRENT_HOME=$PWD
git clone https://github.com/Collab4exaNBody/onika.git
cmake -S ${CURRENT_HOME}/onika -B ${CURRENT_HOME}/build-onika \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INSTALL_PREFIX=${CURRENT_HOME}/install-onika \
-Dyaml-cpp_DIR=${PATH_TO_YAML}/lib/cmake/yaml-cpp \
-DONIKA_BUILD_CUDA=ON \
-DCMAKE_CUDA_ARCHITECTURES=86
cmake --build ${CURRENT_HOME}/build-onika -j 10 --target install
Set CMAKE_CUDA_ARCHITECTURES to your GPU (e.g. 80 for A100, 90 for H100).
export CURRENT_HOME=$PWD
git clone https://github.com/Collab4exaNBody/onika.git
cmake -S ${CURRENT_HOME}/onika -B ${CURRENT_HOME}/build-onika \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INSTALL_PREFIX=${CURRENT_HOME}/install-onika \
-Dyaml-cpp_DIR=${PATH_TO_YAML}/lib/cmake/yaml-cpp \
-DONIKA_BUILD_CUDA=ON \
-DONIKA_ENABLE_HIP=ON \
-DCMAKE_HIP_ARCHITECTURES=gfx90a \
-DONIKA_HAS_GPU_ATOMIC_MIN_MAX_DOUBLE=ON
cmake --build ${CURRENT_HOME}/build-onika -j 10 --target install
HIP support uses the same code path as CUDA: ONIKA_BUILD_CUDA
enables GPU support and ONIKA_ENABLE_HIP selects HIP instead of CUDA.
See HIP builds below.
brew install cmake ninja llvm open-mpi yaml-cpp
export BREW=$(brew --prefix)
# Apple clang has no OpenMP: use Homebrew LLVM, also behind the Open MPI wrappers
export OMPI_CC=${BREW}/opt/llvm/bin/clang OMPI_CXX=${BREW}/opt/llvm/bin/clang++
export CURRENT_HOME=$PWD
git clone https://github.com/Collab4exaNBody/onika.git
cmake -S ${CURRENT_HOME}/onika -B ${CURRENT_HOME}/build-onika -G Ninja \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INSTALL_PREFIX=${CURRENT_HOME}/install-onika \
-DCMAKE_C_COMPILER=${OMPI_CC} -DCMAKE_CXX_COMPILER=${OMPI_CXX} \
-DMPI_C_COMPILER=${BREW}/bin/mpicc -DMPI_CXX_COMPILER=${BREW}/bin/mpicxx \
-Dyaml-cpp_DIR=${BREW}/opt/yaml-cpp/lib/cmake/yaml-cpp
cmake --build ${CURRENT_HOME}/build-onika -j 4 --target install
CPU only, Onika main (after 1.1.0). See macOS below.
# Get Spack
git clone --depth=2 --branch=v0.23.0 https://github.com/spack/spack.git
export SPACK_ROOT=$PWD/spack
source ${SPACK_ROOT}/share/spack/setup-env.sh
# Add Onika's Spack repository
git clone https://github.com/Collab4exaNBody/spack-repos.git
spack repo add spack-repos
# Install Onika (add +cuda for GPU support)
spack install onika
spack load onika
CPU architecture flags¶
ONIKA_ARCH_FLAGS (Onika main, after 1.1.0) sets the CPU flags used for Onika and every code built on
it (plugins, exaNBody...). It is empty on x86-64 (no flags added) and
-march=armv8-a on ARM64. Use it to target your CPU, for example
-DONIKA_ARCH_FLAGS="-march=x86-64-v3", "-march=native", or
"-mcpu=neoverse-v2" / "-mcpu=native" on ARM (Graviton, Grace, Apple M).
HIP builds¶
CMAKE_HIP_ARCHITECTURESis the target GPU:gfx90afor MI250,gfx942for MI300. Only the ROCm/HIP toolchain is needed to compile: the machine does not need an AMD GPU.ONIKA_HAS_GPU_ATOMIC_MIN_MAX_DOUBLE=ONuses the native atomic min/max ondouble(see CMake options).- If HIP's
clang++picks an unsuitable GCC installation (errors in standard headers), point it to the right one:-DCMAKE_HIP_FLAGS="--gcc-install-dir=$(dirname $(g++ -print-libgcc-file-name))". - If a configuration failed (missing MPI...), remove the build directory before trying again, so that CMake does not reuse its cache.
-
Projects built on a HIP installation (your plugins, exaNBody...) must also be configured with
-DONIKA_USE_HIP=ON:Without it,
onika_add_plugindoes not compile.cufiles as HIP and CMake stops withCannot determine link language for target "myPlugin-plugin".
macOS¶
Onika main (macOS support was merged after the 1.1.0 release) builds on
macOS for CPU execution (no GPU support), with the "macOS"
commands above. Tested on Apple Silicon with Homebrew. Differences with Linux:
- compiler: Apple clang (
/usr/bin/clang++) has no OpenMP andfind_package(OpenMP)fails with it. Use Homebrew LLVM (brew install llvm, as above) or Homebrew GCC (brew install gcc, then e.g.gcc-16/g++-16instead of the LLVM paths); - MPI: Homebrew's Open MPI wrappers (
mpicc,mpicxx) call Apple clang by default. SetOMPI_CC/OMPI_CXXto the compiler used for Onika, and keep them set when building codes on top of Onika (exaNBody, plugins...); - Onika finds the Homebrew yaml-cpp headers outside system directories by itself;
- plugins keep the
.soextension, as on Linux; --debug-fpe(floating point exception trapping) and--pinethreads(thread pinning) are not available: they are ignored with a warning.
All CMake options are listed in CMake options.
What gets installed¶
<install-prefix>/
├── bin/
│ ├── setup-env.sh environment variables (plugin, config and data paths)
│ ├── onika-exec the Onika application
│ ├── onikarun wrapper: sources setup-env.sh, then runs onika-exec
│ └── trace_convert execution trace converter
├── include/ lib/ headers and libraries, to build your own plugins
├── cmake/ thirdparty/ CMake helpers and bundled third-party headers
├── onika-config.cmake CMake package, for find_package(onika)
├── plugins/ operator plugins (libonikaTools-plugin.so, tutorials, ...)
├── python/ pyonika package (only with -DONIKA_BUILD_PYTHON=ON)
└── data/
├── config/ default input files (main-config.msp, ...)
└── exemples/ example input files (print_loop.msp, concurrent_block_parallel.msp)
Check your installation¶
An empty input file runs the default simulation from main-config.msp, which prints:
Version : 1.0.4
MPI : 1 process
CPU : 12 cores (max 12) : 0-11
OpenMP : 4 threads (v5.0)
SIMD : NEON
SOATL : align=16 , vec=4
██████╗ ███╗ ██╗██╗██╗ ██╗ █████╗ ██╗ ██╗ ██╗ ██████╗
██╔═══██╗████╗ ██║██║██║ ██╔╝██╔══██╗ ██║ ██║███║ ██╔═████╗
██║ ██║██╔██╗ ██║██║█████╔╝ ███████║ ██║ ██║╚██║ ██║██╔██║
██║ ██║██║╚██╗██║██║██╔═██╗ ██╔══██║ ╚██╗ ██╔╝ ██║ ████╔╝██║
╚██████╔╝██║ ╚████║██║██║ ██╗██║ ██║ ╚████╔╝ ██║██╗╚██████╔╝
╚═════╝ ╚═╝ ╚═══╝╚═╝╚═╝ ╚═╝╚═╝ ╚═╝ ╚═══╝ ╚═╝╚═╝ ╚═════╝
=========== vgpu ================
vgpu disabled
=================================
Internal unit system for default conversions
+-------------+-------------------+--------+
| Type | Unit | Symbol |
+-------------+-------------------+--------+
| length | meter | m |
...
Note
The 1.1.0 release (and the 1.0.5 and 1.0.6 tags) print Version : 1.0.4:
the version number in CMakeLists.txt was not updated for these releases.
The first lines describe the machine (cores, threads, SIMD). The numbers depend on your machine.
vgpu disabled means no GPU was used (CPU-only build, or --nogpu).
Next step: Your first run.