Skip to content

HIP backend for AMD GPUs; canoP studio on Adastra - #14

Merged
ptrembli merged 1 commit into
mainfrom
feature/hip-backend
Dec 1, 2026
Merged

ptrembli merged 1 commit into
mainfrom
feature/hip-backend

Conversation

@ptrembli

@ptrembli ptrembli commented Dec 1, 2026

Copy link
Copy Markdown
Contributor

Summary

canoP can now be built and run on AMD GPUs with the Kokkos HIP backend (tested on the MI250X of
Adastra, CINES). The shared Kokkos, pykokkos-base and the kernels of the physics are compiled with
hipcc. canoP studio offers HIP as a Kokkos backend and pre-fills the Adastra environment.

Changes

Build

  • cmake/pykokkos.cmake: KALYPSSO_CORE_KOKKOS_BACKEND=HIP builds the shared Kokkos with
    Kokkos_ENABLE_HIP (OpenMP on the host, no relocatable device code). The C++ compiler is hipcc.
    pykokkos-base is built with 8 jobs, as for Cuda.
  • cmake/patches/kalypsso-core-hip-device-code-in-headers.patch (new), applied on top of the Cuda
    patch for HIP:
    • KALYPSSO_CORE_DEVICE_CODE_IN_HEADERS is also defined for HIP without RDC;
    • HIPAsyncTimer.h: the HIP port of CudaAsyncTimer.h, which kalypsso-core lacked (the API is the same);
    • KOKKOS_FUNCTION on the definitions of the operator() of ComputeDataSliceAlongLine. clang
      refuses a host definition of a host-device declaration;
    • the virtual destructors of MeshGhostsExchanger(MultiVar) are no longer defaulted. clang makes
      the defaulted ones device functions that reference a device vtable in another translation unit.
  • cmake/build_or_find_kalypsso_core.cmake: the patches are a series. CMake finds how much of the
    series is already applied and applies the rest. A Cuda build in a tree patched for HIP keeps the
    patches, which do not change Cuda or CPU builds.

Physics

  • physics/jit.py: HIP kernels are compiled directly, without CMake for each kernel, like Cuda.
    They use the compiler that the Kokkos install was built with (Kokkos_CXX_COMPILER). When
    PK_KOKKOS_LIB_PATH is set, pykokkos itself would use g++ for every backend except Cuda.

canoP studio

  • HIP is listed as a Kokkos backend, with the AMD architectures found in the Kokkos sources.
  • The GPU architecture is now kept for each backend (PROFILE_FIELDS), because Cuda and HIP
    architectures differ. Settings saved before this change keep their Cuda architecture.
  • New Slurm GPU request gpus-per-node, in the studio and in the template of new campaigns.
    Adastra refuses --gpus-per-task.
  • On Adastra (found from the host name):
    • pre-filled environments: GCC-CPU-6.0.0 for OpenMP; for HIP, GCC-GPU-6.0.0 plus cray-mpich GTL
      (LDFLAGS) and MPICH_GPU_SUPPORT_ENABLED=1, because canoP gives device buffers to MPI;
    • --constraint=GENOA/MI250/MI300 instead of --partition, which Adastra refuses;
    • gpus-per-node as the default GPU request.

Docs: installation (HIP, Adastra), tutorial, physics guide, AGENTS.md, CHANGELOG.md.

Tests (Adastra)

  • Build of canoP_2d and canoP_3d with ROCm 6.4.3 / hipcc for AMD_GFX90A, on the login node.
  • Blast 2D on 1 MI250X GCD:
    • the 6 kernels of the physics are compiled by hipcc at the first run (15 to 30 s each);
    • mass and energy are conserved to machine precision;
    • all fields match an OpenMP run of the same case (max relative difference about 1e-16).
  • Same case with one more AMR level on 2 GCDs with 2 MPI ranks (GPU-aware cray-mpich, GTL linked):
    it matches the OpenMP run (relative difference below 1e-15).
  • Studio: backend switching and the conversion of older settings tested offline with an isolated
    CANOP_STUDIO_CONFIG; check_i18n.py passes.

Not tested: MI300A (AMD_GFX942_APU), a HIP campaign run from the studio, and Cuda (the Cuda
patch and its code path are unchanged). CI has no GPU, so neither the Cuda nor the HIP builds run
there.

Notes for review

  • Existing campaigns keep their own copy of templates/script.sh, which does not know
    gpus-per-node. Only new campaigns get it.
  • The kalypsso-core changes should eventually go to kalypsso-core itself, as for the Cuda patch.

🤖 Generated with Claude Code

- Shared Kokkos and pykokkos-base built with HIP (hipcc); the kernels of the
  physics compiled with the compiler of that Kokkos (physics/jit.py), directly
  as for Cuda.
- kalypsso-core: a second patch, on top of the Cuda one, for HIP without
  relocatable device code (device code in headers, HIP device timer,
  KOKKOS_FUNCTION definitions, non-defaulted virtual destructors); the CMake
  applies the series as needed.
- canoP studio: HIP backend, GPU architecture kept per backend, Slurm request
  gpus-per-node, pre-filled modules and constraints on Adastra (CINES).
- Docs and changelog.

Tested on Adastra: build with ROCm 6.4.3 for gfx90a; blast 2D on 1 MI250X and
on 2 GCDs with 2 MPI ranks (GPU-aware cray-mpich) matches the OpenMP run to
round-off.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@ptrembli
ptrembli force-pushed the feature/hip-backend branch from a9ad4ec to e432542 Compare December 1, 2026 22:58
@ptrembli
ptrembli merged commit c8ed80b into main Dec 1, 2026
2 checks passed
@ptrembli
ptrembli deleted the feature/hip-backend branch December 1, 2026 23:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant