Installation
This guide covers how to build and install Cocoa on your system.
Prerequisites
Before building Cocoa, ensure you have the following dependencies installed:
Compilers
Cocoa requires a C++20 compatible compiler. The minimum versions are dictated by Kokkos 5.0 (included with Trilinos 17), which sets stricter requirements than C++20 alone.
Compiler |
Minimum Version |
Notes |
|---|---|---|
GCC |
10.4.0 |
Recommended for CPU and as CUDA host compiler |
Clang (CPU) |
14.0.0 |
For CPU-only builds |
Clang (CUDA host) |
15.0.0 |
When used as nvcc host compiler |
NVIDIA nvcc |
12.2 |
Requires CUDA Toolkit 12.2+ |
Intel icpx (CPU) |
2022.0.0 |
Intel oneAPI DPC++/C++ Compiler |
Intel icpx (SYCL) |
2024.2.1 |
For SYCL backend builds |
ROCm (HIPCC) |
6.2.0 |
For AMD GPU builds |
NVIDIA HPC SDK (NVC++) |
22.3 |
Alternative to nvcc for NVIDIA GPUs |
Note
These requirements are set by Kokkos 5.0. See the Kokkos Requirements documentation for the most up-to-date information.
Build System
CMake 3.23 or later
GNU Make or Ninja build system
Required Libraries
The following libraries must be pre-installed on your system:
Trilinos 17.0 or later (with Kokkos, KokkosKernels, Tpetra, Belos, Ifpack2, Zoltan2 enabled)
NetCDF-C (4.9.3+ recommended; for mesh and output I/O)
HDF5 (development headers required; installed automatically as a NetCDF-C dependency)
Warning
NetCDF-C versions prior to 4.9.3 have a bug (#2674) that causes spurious HDF5 error messages on stderr when reading variables. Ubuntu 24.04 ships NetCDF-C 4.9.2; if using that distribution, build NetCDF-C 4.9.3+ from source.
ParMETIS (for mesh partitioning, required via Zoltan2 for MPI builds)
Note
Trilinos 17.0+ is required because it includes Kokkos 5.0+ which uses APIs that Cocoa depends on.
Automatically Fetched Dependencies
The following dependencies are automatically downloaded and built via CPM during CMake configuration:
yaml-cpp (configuration file parsing)
spdlog (logging)
fmt (string formatting)
Catch2 (unit testing)
Optional Dependencies
CUDA Toolkit (for NVIDIA GPU support, required for Trilinos CUDA build)
ROCm (for AMD GPU support, required for Trilinos HIP build)
MPI (for distributed computing, if Trilinos was built with MPI)
Building from Source
Clone the Repository
git clone https://github.com/cocoaorg/cocoa.git
cd cocoa
Configure with CMake
Basic Build:
mkdir build && cd build
cmake .. \
-DCMAKE_BUILD_TYPE=Release \
-DNETCDF_DIR=/path/to/netcdf-c \
-DTrilinos_DIR=/path/to/trilinos
With custom install prefix:
cmake .. \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INSTALL_PREFIX=/path/to/install \
-DNETCDF_DIR=/path/to/netcdf-c \
-DTrilinos_DIR=/path/to/trilinos
CMake Options
Option |
Description |
Default |
|---|---|---|
|
Hint path for CMake’s |
(auto-detected; required if not in system paths) |
|
Path to the Trilinos CMake config directory (e.g.,
|
(auto-detected; required if not in system paths) |
|
Combined execution space and MPI configuration. Available options
depend on the Trilinos build. Examples: |
|
|
Build type. Options: |
|
|
Installation directory for |
|
|
Build the unit test suite (requires Catch2, fetched automatically). |
|
|
Enable strict compiler warnings, sanitizers, cppcheck, and hardening. Automatically enabled when building as the top-level project. |
|
|
CUDA memory space. |
|
|
Use |
|
|
Enable GRIB2 meteorological forcing (GFS, HRRR, …). Requires an
installed ECMWF ecCodes (found via |
|
|
Path to the ecCodes CMake config directory (e.g.,
|
(auto-detected) |
|
Print elapsed wall-clock time in screen log output. |
|
Floating-Point Precision
Cocoa computes in double precision (FP64). There is no build-time precision option: to reduce GPU memory traffic, a fixed set of bandwidth-sensitive fields is stored as float and promoted to double on read, while all arithmetic stays in double. See Numerical Methods for the list of mixed-precision fields and the rationale.
Stream Compaction
Each step, the wet/dry solver rebuilds compacted lists of the currently wet
elements and nodes – a stream compaction (copy_if over an index range).
The implementation is selected by backend:
CUDA:
cub::DeviceSelect::Ifon the Kokkos execution-space stream, with the algorithm’s temporary storage allocated once at setup and reused every step (no per-stepcudaMalloc/cudaFree). CUB ships with the CUDA Toolkit, so no extra setup is needed.OpenMP/Serial with
cocoa_USE_THRUST=ON:thrust::copy_ifthrough the matching thrust host device system.Otherwise: a fused Kokkos
parallel_scan.
All implementations use the same selection predicate and produce identical results.
cocoa_USE_THRUST is an advanced option that applies only to OpenMP and
Serial backends; CUDA builds always use CUB and ignore it. Enabling it
requires a Thrust installation,
typically via NVIDIA CCCL, with CMake
pointed at it:
cmake .. \
-Dcocoa_BACKEND=OPENMP+MPI \
-Dcocoa_USE_THRUST=ON \
-DCCCL_DIR=/path/to/cccl/lib/cmake/cccl
# or, for a standalone Thrust:
# -DThrust_DIR=/path/to/thrust/lib/cmake/thrust
Cocoa configures the thrust host device system to match the selected backend
(OpenMP or Serial). If cocoa_USE_THRUST=ON is requested but no
Thrust/CCCL installation is found, or the backend is neither OpenMP nor
Serial (and not CUDA, where the option is ignored), configuration fails with
an explanatory error.
Compile
make -j$(nproc)
Install
make install
Verifying the Installation
Run the test suite to verify your installation:
ctest --output-on-failure