Add hip-lang cmake module#2183
Add hip-lang cmake module#2183robertmaynard wants to merge 1 commit intoROCm:developfrom robertmaynard:add_hip_lang_cmake_module
Conversation
hip-lang-config.cmake.in
Outdated
|
|
||
| # Approved by CMake to use this name. This is used so that HIP can | ||
| # change the name of the target and not require any modifications in CMake | ||
| set(_CMAKE_HIP_DEVICE_RUNTIME_TARGET "hip::device") |
There was a problem hiding this comment.
What does this exactly do? CMake will rename the target, is that so users can use hip::device from find_package(hip) as well? Dont we need hip-config.cmake to restrict the flags to CXX?
There was a problem hiding this comment.
What does this exactly do?
The design point is to allow a level of flexibility between the two projects. By reading a a variable it allows the HIP package to elvove over time ( do a refactor ), and not break CMake backwards compat
is that so users can use
hip::devicefromfind_package(hip)as well.
See my comments below on de-duping the config files.
Dont we need hip-config.cmake to restrict the flags to CXX?
Yes you will, but I don't know what HIP backwards compatibility rules are, and didn't want to presume that I could break existing users that rely on the current flag injection to make C files act as HIP.
|
This does duplicate a lot from hip-config.cmake. I wonder if its possible to reuse that file and maybe have another config variable for language(ie |
I agree we should find a way to share logic between the two, but I think we should do that after we figure out how to handle the currently sharing of I would prefer to remove this shared dependency as it allows for clear separation of requirements between the HIP language, and users that want to include C++ components of the ROCM toolkit. I don't know if the better approach is to export Edit: I will revise the pull request to make |
I dont think
Sounds good. There is the flexibility to rename the target.
Is there a way to change the language generator expression from HIP to CXX for |
Currently the rules specified in
In short, no :) The enabling of the
Unforunately this kind of rule doesn't work in CMake. What that currently states is that if they language |
|
I have updated the pull request to have separate targets for |
Ah then we will probably need two different targets and then set them up using different config variables or make a function to set up these targets.
The other backends are deprecated anyways, so I think this is fine. |
|
@gargrahul Can you merge this? |
|
@robertmaynard Can please rebase this patch against the develop branch instead of the 3.9.x release branch? |
Will do. |
|
👉 View analysis in DeepCode’s Dashboard | Configure the bot |
|
@mangupta Rebased on top of develop. |
|
@robertmaynard We need the information for internal discussion. |
Here is the reasoning for the new CMake module: #2158 This is missing some of the context of the subtly of finding compilers, CMake compiler verification and what we need to have |
|
Here is a little more background on this change. This document here goes over our current cmake support in HIP. Currently, our cmake support for hip only supports device compilation if the CXX compiler is set to clang. This is acceptable for our own rocm libraries and many projects as clang is a fully capable C++ compiler. However, some users want to use a different compiler for host and device compilation, as they may want to pick a compiler that provides better CPU optimizations(such as AOCC or ICC). So Robert is working on adding HIP as a seperate language so a different compiler can be set for CPU and GPU code. This requires a different cmake target as there are some small difference. First, Secondly, for HIP as a language, cmake will add the So users will have two ways to compile hip gpu device code. The first by setting the CXX compiler to our device compiler and then linking with |
|
@robertmaynard Looks like your PR depends on /usr/local/share/cmake-3.19/Modules/CMakeTestHIPCompiler.cmake for HIP Language. |
The associated changes to CMake aren't part of an offical release. You will need to build the following fork of CMake to test these changes: https://gitlab.kitware.com/robertmaynard/cmake/-/tree/add_hip_language Note: I force push to this fork at will :) |
|
Thus if the PR is merged, we still need install CMakeTestHIPCompiler.cmake for the PR to work . |
This PR wont break current cmake support. Of course, to use HIP as a seperate compiled language will require a version of cmake that supports it(such as a future version of cmake or robert's fork). CMake will install this file on the versions that support HIP as a lanugage, so I dont see this as being a problem. |
TomSang
left a comment
There was a problem hiding this comment.
Looks good to me but need rebase.
The original codes are too old.
What would you like to me to rebase on? It is currently based on the |
Codes on Dec 7th are still not the latest. I don't know when the latest will come to github. Now Hcc runtime and compiler have been removed in the latest codes, so you just need remove Hcc-related codes in the PR. |
This provides the required information for CMake to bootstrap HIP language and runtime support. In particular this file is consumed by CMake during HIP compiler detection to determine the required flags needed for compilation and linking. Initial design was discussed in #2158
|
I think this PR can be merged. I will do some small change in the future. |
Going forward, one of the things to look out for is leakage of the |
This sounds important. We link everywhere to hip::amdhip64. Guidance on compliance needs to be handled. |
Currently the only target that uses Going forward a couple of soultions would be:
|
|
Could anybody in KitWare add copyright header in hip-lang-config.cmake.in ? |
@TomSang what copyright do you need? I looked at the other cmake files and did not see any copyright information. Can you point to a sample cmake file with the required copyright? Thanks. |
@pfultz2