Astaroth  3.1
Scalable Multi-GPU Stencil Computations
Loading...
Searching...
No Matches
Astaroth - A Scalable Multi-GPU Library for Stencil Computations

Docs | API specification | Astaroth DSL | Contributing | Licence | Repository | Issue Tracker | Wiki

Astaroth is a multi-GPU library designed for high-order stencil computations with a special focus on the requirements of multiphysics applications on modern HPC systems. It provides a multi-GPU and single-GPU APIs, a domain-specific language for expressing stencil codes in a high-level syntax, and an optimizing compiler that translates DSL sources into CUDA/HIP subroutines that exhibit near handtuned performance.

Astaroth is licenced under the terms of the GNU General Public Licence, version 3, or later (see LICENCE.txt). For contributing guidelines, see Contributing.

Astaroth is tested against its test suite after every commit. You can find the success of the latest test suite here. You can the test suite yourself locally by first sourcing Astaroth with . ./sourceme.sh and then ./test/run_all_tests.sh. To run the tests on CPUs pass the flag --cpu to ./test/run_all_tests.sh.

Note: Some tests in the full auto-test require pandas to be loaded (to check the correctness of the timeseries data) and expect to be used with OpenMPI due to using –oversubscribe flag. This is to be improved but on MPICH you can search and replace to get rid of the –oversubscribe flag (at the moment we are looking into the best way to support both OpenMPI and MPICH).

Getting started

  • For a hello world example for physical simulations see samples/advection-example

System Requirements

  • An NVIDIA GPU with support for compute capability 3.0 or higher (Kepler architecture or newer)

Or

  • an AMD GPU that has HIP support

Dependencies

Relative recent versions of

gcc cmake flex bison

and either nvcc (NVIDIA) or hipcc (AMD). The library is built for NVIDIA by default, but AMD support can be enabled by passing -DUSE_HIP=ON to CMake.

Choosing a branch

master is a tested, stable branch. We recommend to use this branch in production

develop is the main development branch.

Building

In the base directory, run

  1. source sourceme.sh
  2. mkdir build
  3. cd build
  4. cmake ..
  5. make -j

or

$ source sourceme.sh
$ cmake -S . -B build
$ cmake --build build --parallel

To install Astaroth in order to use it from other projects run

$ sudo cmake --install build

And link to it using the following CMake code

find_package(Astaroth REQUIRED)
add_executable(sor-test main.cc)
target_link_libraries(sor-test PRIVATE Astaroth::astaroth_core Astaroth::astaroth_utils)

Optional: Documentation can be generated by running doxygen in the base directory. Generated documentation can be found in doc/doxygen. Documentation automatically generated after every commit can be found also from here.

Tip: The library is configured by passing options to CMake with -D[option]=[ON|OFF]. For example, double precision can be enabled by calling cmake -DBUILD_DOUBLE_PRECISION=ON ... See CMakeLists.txt for an up-to-date list of options.

Note: CMake will inform you if there are missing dependencies.

Simple example template

If you need a functioning and documented example of how to run Astaroth in standalone more out of the box,

please see this shock turbulence run example in the directory config/samples/shockturb/. Or for a simpler setup see the hello world setup in samples/advection-example.

Running on clusters (Slurm)

  1. Load the modules required for building: module load gcc/8.3.0 cuda/10.1.168 cmake openmpi/4.0.3-cuda
  1. Build with MPI support: cmake -DMPI_ENABLED=ON .. (see 'Building' above)
  1. Run the code interactively or with a batch job, f.ex. srun --account=<project number> --gres=gpu:v100:4 --mem=24000 -t 00:14:59 -p gputest --ntasks-per-socket=2 -n 4 -N 1 <executable here, f.ex ./mpitest or ./benchmark 256 256 256 or ./ac_mpi_run --run-init-kernel randomize>

Note: Assign one task per GPU when using MPI.

Tip: For more information on running the code on Puhti, see Puhti docs.

MPI

Getting the modules and slurm commands right can be tricky because they vary system by system. See a list of systems and commands that have been tested to work below.

# CSC Puhti (2024-03-15)
module load gcc cuda openmpi/4.1.4-cuda cmake
Currently Loaded Modules:
1) csc-tools (S) 2) StdEnv 3) gcc/11.3.0 4) intel-oneapi-mkl/2022.1.0 5) cuda/11.7.0 6) openmpi/4.1.4-cuda 7) cmake/3.23.1
srun --account=$PROJECT --gres=gpu:v100:4 --mem=24000 -t 00:14:59 -p gputest --ntasks-per-socket=2 --ntasks-per-node=4 -N 2
# CSC Mahti (2023-01-24)
module load gcc/9.4.0 openmpi/4.1.2-cuda cuda cmake
Currently Loaded Modules:
1) csc-tools (S) 3) gcc/9.4.0 5) openmpi/4.1.2-cuda 7) cmake/3.21.4
2) StdEnv 4) openblas/0.3.18-omp 6) cuda/11.5.0
srun --account=$PROJECT --gpus-per-node=4 --mem=24000 -t 00:14:59 -p gpumedium --ntasks-per-node=4 -N 2
# CSC Lumi (2023-01-24)
# NOTE! System is still being installed, modules and settings highly likely to change.
module purge
module load CrayEnv
module load PrgEnv-cray
module load craype-accel-amd-gfx90a
module load rocm
module load buildtools
module load cray-python
Currently Loaded Modules:
1) init-lumi/0.1 (S) 7) CrayEnv (S) 13) PrgEnv-cray/8.3.3
2) ModuleLabel/label (S) 8) cce/14.0.2 14) craype-accel-amd-gfx90a
3) craype-x86-rome 9) craype/2.7.17 15) rocm/5.0.2
4) libfabric/1.15.0.0 10) cray-dsmml/0.2.2 16) buildtools/22.08
5) craype-network-ofi 11) cray-mpich/8.1.18 17) cray-python/3.9.12.1
6) xpmem/2.4.4-2.3_9.1__gff0e1d9.shasta 12) cray-libsci/22.08.1.1
SRUNMPI8="srun --account=$PROJECT -t 00:05:00 -p dev-g --gpus-per-node=8 --ntasks-per-node=8 --nodes=1"
SRUNMPI16="srun --account=$PROJECT -t 00:05:00 -p dev-g --gpus-per-node=8 --ntasks-per-node=8 --nodes=2"
# Aalto Triton (2023-01-24)
git clone git@bitbucket.org:jpekkila/astaroth.git
cd astaroth && checkout develop # Needed for up-to-date AMD support
mkdir build && cd build # Create a build directory
module load gcc bison flex cmake openmpi
srun -p gpu-amd -t 00:05:00 --pty /bin/bash # Currently need to build on the gpu-amd partition, otherwise hipcc is not available
cmake -DBUILD_SHARED_LIBS=ON .. && make -j # Hangs with the hip compiler on Triton if BUILD_SHARED_LIBS=OFF due linker failure (note: BUILD_SHARED_LIBS deprecated on 2025-01-07)
./devicetest # Check that everything works

CMake Options

Option Description Default
2D Compile Astaroth for 2D simulation OFF
BUILD_ACM Whether to build to the Astaroth Communication Module (ACM). OFF
BUILD_ADVECTION_EXAMPLE Builds hello world example OFF
BUILD_MHD_SAMPLES Builds MHD samples. Has no effect if BUILD_SAMPLES=OFF. ON
BUILD_MLLIB_SAMPLES Builds samples that use cuDNN or MIOpen OFF
BUILD_SAMPLES Builds projects in samples subdirectory. ON
BUILD_SHARED_LIBS Build Astaroth as a collection of shared libraries instead of statically built modules OFF
BUILD_STANDALONE Build the standalone_mpi executable to run standard simulation. ON
BUILD_TESTS Builds tests in test subdirectory. Make sure to set DSL_MODULE_DIR and DSL_MODULE_FILE accordingly and build only a specific test taget. OFF
BUILD_UTILS Builds the utility library ON
CPU_BUILD To build CPU-only build OFF
DEBUG_SYNC Whether to sync after all tasks in default ops OFF
DOUBLE_PRECISION Generates double precision code. ON
FFT_ENABLED Whether to enable FFT OFF
INCLUDE_3RD_PARTIES Whether to include 3rd party dependencies OFF
LAGRANGIAN_GRID Use Lagrangian grid instead of Eulerian OFF
MPI_ENABLED Enables additional functions for MPI communciation. OFF
MULTIGPU_ENABLED Enables multi-GPU on a single node. Uses peer-to-peer communication instead of MPI. Affects Legacy & Node layers only. ON
PACKED_DATA_TRANSFERS Enables kernel for packed data transfers OFF
PROFILING_ENABLED Whether to enable profiling and link to the vendor profiling libraries ON
RUNTIME_COMPILATION Compile version of Astaroth compiled at runtime OFF
SINGLEPASS_INTEGRATION Perform integration in a single pass. Improves performance by ~20% but may introduce slightly larger floating-point arithmetic error than the conventional approach OFF
SUPPORT_MAJOR_ARCHITECTURES Compile for all major CUDA architectures supported by the used CUDA SDK ON
SUPPRESS_COMPILER_WARNINGS Suppress default compiler warnings of Astaroth OFF
USE_DISTRIBUTED_IO Use distributed IO (one file per process) instead of collective ON
USE_HIP Use HIP as the underlying GPGPU library instead of CUDA OFF
USE_PERFSTUBS Build with perfstubs OFF
USE_POSIX_IO Uses POSIX I/O less error prone, but increased overheads. ON
USE_VENDORED_PERFSTUBS Use the vendored perfstubs in 3rd_party/perfstubs ON
VERBOSE Enables various status and warning messages OFF

Standalone Module

Usage: ./ac_run [options]
--help | -h: Prints this help.
--test | -t: Runs autotests.
--benchmark | -b: Runs benchmarks.
--simulate | -s: Runs the simulation.
--render | -r: Runs the real-time renderer.
--config | -c: Uses the config file given after this flag instead of the default.
Usage: ./ac_run_mpi [options]
--help | -h: Prints the input parameters

See analysis/python/ directory of existing data visualization and analysis scripts.

Restarting from distributed snapshots

cmake ~/astaroth -DOPTIMIZE_MEM_ACCESSES=ON -DMPI_ENABLED=ON && cmake --build . --parallel && $SRUN4 ./ac_run_mpi --from-snapshot <snapshot directory>

See also config parameter AC_num_snapshots for more control over how many snapshots are written out.

Interface

Citing and Papers

When you use Astaroth please cite the following papers as appropriate:

JOSS paper, General usage of the code: DOI

Communication optimizations: CUDA-aware MPI, Hierarchical decomposition and kernel fusion, Taskgraph system for overlapping communication and computation.

GPU kernels optimizations for stencil computations.

FAQ

Can I use the code even if I don't make my changes public?

GPL requires only that if you release a binary based on Astaroth to the public, then you should also release the source code for it. In private you can do whatever you want (secret forks, secret collaborations, etc). Astaroth Code source files (.ac, .h) do not belong to the library and therefore are not licenced under GPL. The user who created the files holds copyright over them and can choose to distribute them under any licence.

How do I compile with MPI support?

Ensure that your MPI implementation has been built with CUDA support and invoke CMake with cmake -DMPI_ENABLED=ON -DBUILD_SAMPLES=ON ... Otherwise the build steps are the same. Assign exactly one process per GPU and run with, for example, srun --gres=gpu:v100:<ngpus per node> --ntasks-per-socket=<ngpus per node / NICs per node> -n <total number of gpus> -N <number of nodes> ./mpitest or for mpirun the command mpirun -np <ngpus per node> ./mpitest works (at least on a GPU node).

I have issues with MPI

If your MPI has been setup incorrectly or does not support CUDA-aware communication, you can try running Astaroth without RDMA support with AC_use_cuda_aware_mpi=F in your config file. Note that without CUDA-aware support, communication is routed through CPU memory which gives notably worse performance than communicating directly between GPUs.

I have issues with IBM Power PCs

This may be due to utils library requiring vectorization. You can try replacing -mavx with -maltivec or -mcpu=native in src/utils/CMakeLists.txt. Otherwise, the core library does not use vectorization, so using Astaroth without the utils component should be possible.

How do I contribute?

See Contributing.

Reporting issues and seeking help

This section is to be expanded, but for reporting issues and for seeking help you can make issues on the github mirror of Astaroth. Optionally, you can always contact one of the main developers: touko.nosp@m..pur.nosp@m.o@aal.nosp@m.to.f.nosp@m.i. For issues and bug reports, please describe them in enough detail for them to be reproducible, and best if you have clear description on how to invoke the problem. Sharing the commands of how did you build and run the program are very much appreciated. For seeking help on syntax, APIs, etc. please first check does the documentation already answer your problem.