Skip to content

CMake: check that the HIP headers compile as CUDA at configure time - #254

Open
Thenewmanator15 wants to merge 1 commit into
thliebig:masterfrom
Thenewmanator15:hip-header-check
Open

Thenewmanator15 wants to merge 1 commit into
thliebig:masterfrom
Thenewmanator15:hip-header-check

Conversation

@Thenewmanator15

Copy link
Copy Markdown

AI use: the change and this text were generated with Claude Code; I have read and tested them.

With OPENEMS_HIP_AS_CUDA=ON, CMake only looks for hip/hip_runtime.h. Building the GPU engine on Ubuntu 26.04
(WSL2, RTX 5070 Ti), configure reported "HIP GPU backend enabled" each time and the build then failed in the .hip
sources, for three different reasons:

  • Ubuntu's libamdhip64-dev (7.1) has no hip/nvidia_detail
  • a minimal CUDA install (cuda-nvcc, cuda-cudart-dev) has no cuda_profiler_api.h
  • the HIP 7.1 NVIDIA headers do not compile with CUDA 13 (cudaGraphEdgeData signatures); 7.2.4 does

This PR test-compiles #include <hip/hip_runtime.h> with the CUDA compiler at configure time. If that fails, the
backend is switched off with a warning naming these causes, as is done for the other missing parts.

Tested (configure only) with CUDA 13.3.73, GCC 15.2, CMake 4.2:

HIP headers result
Ubuntu libamdhip64-dev 7.1.0 (no nvidia_detail) warning, backend off
the same + nvidia_detail of hipother rocm-7.1.0 warning, backend off
hip-dev 7.2.4 of repo.radeon.com backend on

Not tested: Windows, and a missing cuda_profiler_api.h on its own (same code path).

Also seen, not changed here: CUDA 12.9 does not work with GCC 15 even with -allow-unsupported-compiler, so on a
current distribution CUDA 13 with HIP 7.2 headers is the working pair; and CMake 4.2 prints a CMP0167 (FindBoost)
dev warning.

With the 7.2.4 headers the backend builds and runs: 5420 MC/s against 131 MC/s for the v0.37.0 default engine
(Windows build, 12 threads) on the same machine, 3.5 M cells with PML and lumped ports; S11 of the two runs agrees
to 2e-6.

🤖 Generated with Claude Code

With OPENEMS_HIP_AS_CUDA only hip/hip_runtime.h was looked for, so a setup
with unusable headers reported the backend as enabled and failed in the build.
Now a test compile decides; if it fails, openEMS is built without the backend,
with a warning that names the usual causes.

Generated-by: Claude Code
Signed-off-by: Mathew Newman <3686761+Thenewmanator15@users.noreply.github.com>
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