Skip to content

Commit 2d9c962

Browse files
authored
get LLVM_MAIN_REVISION macro from compiler header (#3469)
1 parent f67a20b commit 2d9c962

2 files changed

Lines changed: 17 additions & 1 deletion

File tree

CMakeLists.txt

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,22 @@ set(version 1.2.0)
3838
project(composable_kernel VERSION ${version} LANGUAGES CXX HIP)
3939
include(CTest)
4040

41+
# Set the default value of LLVM_MAIN_REVISION to the equivalent of ROCm7.1.1 release
42+
set(LLVM_MAIN_REVISION 524190)
43+
if (CMAKE_CXX_COMPILER MATCHES "/opt/rocm")
44+
message("compiler in default /opt/rocm/ path")
45+
file(READ "/opt/rocm/llvm/include/llvm/Config/llvm-config.h" HEADER_CONTENT)
46+
string(REGEX MATCH "#define LLVM_MAIN_REVISION[ \t]+([0-9]+)" MATCH_RESULT "${HEADER_CONTENT}")
47+
set(LLVM_MAIN_REVISION ${CMAKE_MATCH_1})
48+
elseif (CMAKE_CXX_COMPILER MATCHES "/llvm-project/build")
49+
message("compiler in custom /llvm-project/build/ path")
50+
file(READ "/llvm-project/build/include/llvm/Config/llvm-config.h" HEADER_CONTENT)
51+
string(REGEX MATCH "#define LLVM_MAIN_REVISION[ \t]+([0-9]+)" MATCH_RESULT "${HEADER_CONTENT}")
52+
set(LLVM_MAIN_REVISION ${CMAKE_MATCH_1})
53+
endif()
54+
message("From CMake: LLVM_MAIN_REVISION=${LLVM_MAIN_REVISION}")
55+
add_definitions(-DLLVM_MAIN_REVISION=${LLVM_MAIN_REVISION})
56+
4157
option(ENABLE_CLANG_CPP_CHECKS "Enables clang tidy, cppcheck" ON)
4258
option(MIOPEN_REQ_LIBS_ONLY "Build only the MIOpen required libraries" OFF)
4359
option(CK_EXPERIMENTAL_BUILDER "Enable experimental builder" OFF)

include/ck_tile/core/config.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
#define CK_TILE_DEVICE inline __device__
4040
#define CK_TILE_HOST_DEVICE inline __host__ __device__
4141
#define CK_TILE_DEVICE_EXTERN __device__
42-
#if __clang_major__ < 22
42+
#if LLVM_MAIN_REVISION < 554785
4343
#define CK_TILE_HOST_DEVICE_EXTERN __host__ __device__
4444
#else
4545
#define CK_TILE_HOST_DEVICE_EXTERN

0 commit comments

Comments
 (0)