Skip to content

Commit d398d4a

Browse files
committed
[UR][HIP] Detect COMGR version in CMake
Signed-off-by: Lukas Sommer <lukas.sommer@codeplay.com>
1 parent 6847c5d commit d398d4a

File tree

3 files changed

+21
-8
lines changed

3 files changed

+21
-8
lines changed

source/adapters/hip/CMakeLists.txt

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,21 @@ if("${UR_HIP_PLATFORM}" STREQUAL "AMD")
101101
)
102102

103103
if(UR_ENABLE_COMGR)
104+
set(UR_COMGR_VERSION5_HEADER "${UR_HIP_INCLUDE_DIR}/amd_comgr/amd_comgr.h")
105+
set(UR_COMGR_VERSION4_HEADER "${UR_HIP_INCLUDE_DIR}/amd_comgr.h")
106+
# The COMGR header changed location between ROCm versions 4 and 5.
107+
# Check for existence in the version 5 location or fallback to version 4
108+
if(NOT EXISTS "${UR_COMGR_VERSION5_HEADER}")
109+
if(NOT EXISTS "${UR_COMGR_VERSION4_HEADER}")
110+
message(FATAL_ERROR "Could not find AMD COMGR header at "
111+
"${UR_COMGR_VERSION5_HEADER} or"
112+
"${UR_COMGR_VERSION4_HEADER}, "
113+
"check ROCm installation")
114+
else()
115+
target_compile_definitions(${TARGET_NAME} PRIVATE UR_COMGR_VERSION4_INCLUDE)
116+
endif()
117+
endif()
118+
104119
add_library(amd_comgr SHARED IMPORTED GLOBAL)
105120
set_target_properties(
106121
amd_comgr PROPERTIES

source/adapters/hip/common.hpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,10 @@
1010
#pragma once
1111

1212
#ifdef SYCL_ENABLE_KERNEL_FUSION
13-
#include <rocm/rocm_version.h>
14-
#if (ROCM_VERSION_MAJOR >= 5)
15-
#include <amd_comgr/amd_comgr.h>
16-
#else
13+
#ifdef UR_COMGR_VERSION4_INCLUDE
1714
#include <amd_comgr.h>
15+
#else
16+
#include <amd_comgr/amd_comgr.h>
1817
#endif
1918
#endif
2019
#include <hip/hip_runtime.h>

source/adapters/hip/program.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,10 @@
1111
#include "program.hpp"
1212

1313
#ifdef SYCL_ENABLE_KERNEL_FUSION
14-
#include <rocm/rocm_version.h>
15-
#if (ROCM_VERSION_MAJOR >= 5)
16-
#include <amd_comgr/amd_comgr.h>
17-
#else
14+
#ifdef UR_COMGR_VERSION4_INCLUDE
1815
#include <amd_comgr.h>
16+
#else
17+
#include <amd_comgr/amd_comgr.h>
1918
#endif
2019
namespace {
2120
template <typename ReleaseType, ReleaseType Release, typename T>

0 commit comments

Comments
 (0)