[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

The well of confusion that is HIP_COMPILER



Hi Étienne,

On 2022-07-02 09:05, Étienne Mollier wrote:
Hi Cory,

Cordell Bloor, on 2022-07-02:
[1]: It's usable, but has sharp edges. The changes to HIP_COMPILER need to
be removed from 0005-clang-14.patch; changing HIP_CXX_COMPILER should be
sufficient. We also might want to patch --hip-version=<version> directly
into the HIPCFLAGS / HIPCXXFLAGS in hipcc until we can figure out how to get
that info to clang properly.
I agree there is room for improvement.  At the time of writing
that patch, clang-14 was not the default and it was the only way
I found to enable use of this particular version.  If I only
have clang-14 and corresponding toolset installed, then I don't
have the unversionned compiler commands, i.e. clang, clang++,
and llc, so the checks would fail if left unchanged.

I'm afraid you are mistaken. It's terribly confusing (and completely undocumented), but HIP_COMPILER is not used to store the name of the executable for compiling HIP programs. It is an enumeration that specifies the *type* of compiler being used. The actual executable name is stored in HIP_CXX_COMPILER [1].

I don't think this makes a lot of sense, so I will try to start a conversation to see if the logic in HIP can be improved, but here's my understanding of how it works now:

HIP_COMPILER can have three values: "hcc", "clang" or "nvcc". The values "hcc" and "clang" always imply that the HIP platform is AMD, while the value of "nvcc" implies that the HIP platform is NVIDIA.

Frankly, this is bizarre. It seems to imply that if you are compiling for NVIDIA using clang, the value of HIP_COMPILER will be "nvcc". It's perhaps also worth noting that the hcc value is irrelevant these days. I would be very surprised if anything can still be built with hcc, as it was completely replaced by clang roughly two years ago.

In any case, I've attached a patch for rocm-hipamd that will allow you to drop cram-clang-14.patch from rocrand.

Sincerely,
Cory Bloor

[1]: https://github.com/ROCmSoftwarePlatform/rocRAND/pull/274
--- a/debian/patches/0005-clang-14.patch
+++ b/debian/patches/0005-clang-14.patch
@@ -4,28 +4,8 @@ Forwarded: not-needed
 Last-Update: 2022-05-08
 ---
 This patch header follows DEP-3: http://dep.debian.net/deps/dep3/
---- rocm-hipamd.orig/CMakeLists.txt
-+++ rocm-hipamd/CMakeLists.txt
-@@ -217,7 +217,7 @@
-     set(HIP_COMPILER "nvcc" CACHE STRING "HIP Compiler")
- elseif(HIP_PLATFORM STREQUAL "amd")
-     set(HIP_RUNTIME "rocclr" CACHE STRING "HIP Runtime")
--    set(HIP_COMPILER "clang" CACHE STRING "HIP Compiler")
-+    set(HIP_COMPILER "clang-14" CACHE STRING "HIP Compiler")
- else()
-     message(FATAL_ERROR "Unexpected HIP_PLATFORM: " ${HIP_PLATFORM})
- endif()
 --- rocm-hipamd.orig/hip-config.cmake.in
 +++ rocm-hipamd/hip-config.cmake.in
-@@ -122,7 +122,7 @@
-   endif()
- endif()
- 
--if(HIP_COMPILER STREQUAL "clang")
-+if(HIP_COMPILER STREQUAL "clang-14")
-   if(WIN32)
-     file(TO_CMAKE_PATH "$ENV{HIP_PATH}" HIP_CLANG_ROOT)
-   else()
 @@ -131,7 +131,7 @@
    if(NOT HIP_CXX_COMPILER)
      set(HIP_CXX_COMPILER ${CMAKE_CXX_COMPILER})
@@ -44,12 +24,8 @@ This patch header follows DEP-3: http://dep.debian.net/deps/dep3/
      get_filename_component(HIP_CLANG_ROOT "${HIP_CXX_COMPILER}" DIRECTORY)
      get_filename_component(HIP_CLANG_ROOT "${HIP_CLANG_ROOT}" DIRECTORY)
    endif()
-@@ -221,10 +221,10 @@
-   endif()
- endif()
- 
--if(HIP_COMPILER STREQUAL "clang")
-+if(HIP_COMPILER STREQUAL "clang-14")
+@@ -218,7 +218,7 @@
+ if(HIP_COMPILER STREQUAL "clang")
    get_property(compilePropIsSet TARGET hip::device PROPERTY INTERFACE_COMPILE_OPTIONS SET)
  
 -  if (NOT compilePropIsSet AND HIP_CXX_COMPILER MATCHES ".*clang\\+\\+")

Reply to: