Repository navigation
Compile HIP sources with the HIP language when the C++ compiler is not Clang - #980
haampie-bot wants to merge 1 commit into
Conversation
|
Azure Pipelines: There may be pipelines that require an authorized user to comment /azp run to run. |
There was a problem hiding this comment.
🟡 Changes recommended
Coverage builds with GCC fail to link because they receive the Clang-only -Xarch_host option, while HIP sources receive no coverage instrumentation.
1 open issue
What changed in this PR
This PR enables ROCm builds with a non-Clang C++ compiler, such as GCC, by compiling GPU-related sources with CMake’s HIP language. Existing hipcc/Clang and CUDA paths are preserved.
Changes:
- Selects HIP compilation and
hip::hostlinking for non-Clang C++ compilers. - Updates libraries and tests to use HIP source properties and CMake-managed GPU architectures.
- Preserves hidden symbol visibility for HIP-compiled Python modules.
| File | Description |
|---|---|
test/mscclpp-test/CMakeLists.txt |
Applies HIP compilation to test sources and shared helpers. |
test/CMakeLists.txt |
Selects HIP compilation for ROCm tests in the new mode. |
src/ext/nccl/CMakeLists.txt |
Uses the selected language and conditional architecture flags. |
src/ext/collectives/CMakeLists.txt |
Adds HIP compilation for collective sources. |
src/core/CMakeLists.txt |
Adds HIP compilation for core library sources. |
python/test/CMakeLists.txt |
Compiles test bindings as HIP with hidden visibility. |
python/csrc/CMakeLists.txt |
Compiles Python bindings as HIP with hidden visibility. |
CMakeLists.txt |
Selects the ROCm compilation mode and runtime dependency. |
Review effort: Balanced
|
@microsoft-github-policy-service agree (written by a human from the bot account) |
…t Clang On ROCm, the HIP sources are compiled as C++ and linked to hip::device, which requires the C++ compiler to be hipcc or Clang. With GCC, every source fails with "g++: error: unrecognized command-line option '--offload-arch=gfx90a'". When the C++ compiler is not Clang, enable CMake's HIP language, compile the sources of the core library, the collectives and NCCL extensions, the Python bindings and the tests as HIP, and link hip::host instead of hip::device. The GPU architectures then come from CMAKE_HIP_ARCHITECTURES, which is already set from MSCCLPP_GPU_ARCHS. Builds with hipcc or Clang as C++ compiler and CUDA builds are unchanged.
4be9260 to
5b9bb1d
Compare
There was a problem hiding this comment.
🔵 Needs a closer look
The GCC/HIP compiler-boundary changes have only build-level validation; GPU execution and cross-module Python conversions still require ROCm runtime testing unavailable in this review environment.
No open issues 🎉
1 resolved since last review
Review effort: Balanced

On ROCm, the HIP sources are compiled as C++ (src/core/CMakeLists.txt#L9, src/ext/nccl/CMakeLists.txt#L8, test/CMakeLists.txt#L15) and linked to
hip::device(CMakeLists.txt#L240), so the C++ compiler has to be hipcc or Clang. With GCC, every source fails with "g++: error: unrecognized command-line option '--offload-arch=gfx90a'". Package managers such as Spack then have to replace their C++ compiler with hipcc for the whole build.The fix is to compile these sources with CMake's HIP language when the C++ compiler is not Clang, and to link
hip::hostinstead ofhip::device. The project already setsCMAKE_HIP_STANDARD,CMAKE_HIP_FLAGSandCMAKE_HIP_ARCHITECTURES(CMakeLists.txt#L235-L238), so the per-target--offload-archoptions are not needed in this mode. Builds with hipcc or Clang as C++ compiler, and CUDA builds, are unchanged.Testing
Tested with ROCm 10.1 and MPICH for gfx90a. With GCC 11 as C++ compiler and amdclang++ as HIP compiler, the default
alltarget builds: the libraries, the Python modules and the tests (with numactl's headers onCPATH). Onmainthat configuration fails with the error above. With hipcc as C++ compiler, the generated compile and link commands are identical tomain. Nothing was run on a GPU, and the CUDA build was not tested.