hip: Set --gcc-toolchain to ensure external HIP installs pick up correct GCC#46573
Merged
RMeli merged 1 commit intospack:developfrom Oct 10, 2024
Merged
Conversation
deb702a to
66e55af
Compare
66e55af to
ea975c6
Compare
Contributor
Author
Contributor
|
Also works for me on LUMI-G with gcc-12.2.0 and rocm-6.0.3 |
Contributor
|
@haampie how about merging this? |
RMeli
approved these changes
Oct 10, 2024
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When using
hipand friends as externals, the install will in many cases not be set up to use a specific compiler/GCC standard library but will simply pick up the first one it finds from some system install directory, and this will often not be the same GCC as the one specified as the compiler in a spec.One problematic case that we bumped into with this is if the system GCC is version 13 and a spack spec uses
%gcc@12, where GCC 12 is installed in some non-standard location. However, when a package depends on HIP compilation through hipcc/HIP's clang would pick up GCC 13 (or libstdc++ from GCC 13). The rest of the code would be compiled with the correct GCC 12. Since GCC is not compatible in this direction (forward?), i.e. an application built with a newer version of libstdc++ can't be linked later to an older version of libstdc++. For searchability, the error you'd get in this case while linking isThis PR attempts to fix this when
hipis external and the compiler is%gcc. It will set in dependent environments:HIPCC_COMPILE_FLAGS_APPENDto include--gcc-toolchainpointing to the prefix of GCC. This is picked up by hipcc. This will be used e.g. by CMake packages that setCMAKE_CXX_COMPILERto hipcc.HIPFLAGSto include the same as above. This is picked up by CMake for the initial value ofCMAKE_HIP_FLAGS. When using HIP as a CMake language (at least in newer versions of CMake) HIP's clang++ will be used for compilation, soHIPCC_COMPILE_FLAGS_APPENDwouldn't work here.As far as I understand if someone sets
CMAKE_HIP_FLAGSexplicitly, this will overrideHIPFLAGS. This is not perfect, but as far as I could tell no package is settingCMAKE_HIP_FLAGSat the moment.I don't know if any of this will help non-CMake packages, but it should not hurt them at least.
llvm-amdgpuwhen built through spack will setGCC_INSTALL_PREFIXduring configuration so the above is only used whenhipis external. I suppose the workaround could also be set inllvm-amdgpubut I feel likehipis the semantically right place for these since that is what packages will usually depend on. The environment variables that are being set are also HIP flags, notllvm-amdgpuflags, and I don't think they'd have any effect if one depends only onllvm-amdgpuand uses clang++ directly from there. I don't know if this is a naive assumption?