Skip to content

Commit c311fe8

Browse files
authored
Merge pull request #1222 from sommerlukas/lukas/comgr-include-rocm4
[UR][HIP] Fix include for AMD COMGR
2 parents eee75a2 + d398d4a commit c311fe8

File tree

3 files changed

+25
-2
lines changed

3 files changed

+25
-2
lines changed

source/adapters/hip/CMakeLists.txt

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,15 +101,30 @@ 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
107122
IMPORTED_LOCATION "${UR_HIP_LIB_DIR}/libamd_comgr.so"
108123
INTERFACE_INCLUDE_DIRECTORIES "${HIP_HEADERS}"
109124
INTERFACE_SYSTEM_INCLUDE_DIRECTORIES "${HIP_HEADERS}"
110125
)
111-
target_link_libraries(pi_hip PUBLIC amd_comgr)
112-
target_compile_definitions(pi_hip PRIVATE SYCL_ENABLE_KERNEL_FUSION)
126+
target_link_libraries(${TARGET_NAME} PUBLIC amd_comgr)
127+
target_compile_definitions(${TARGET_NAME} PRIVATE SYCL_ENABLE_KERNEL_FUSION)
113128
endif(UR_ENABLE_COMGR)
114129

115130
target_link_libraries(${TARGET_NAME} PRIVATE

source/adapters/hip/common.hpp

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

1212
#ifdef SYCL_ENABLE_KERNEL_FUSION
13+
#ifdef UR_COMGR_VERSION4_INCLUDE
14+
#include <amd_comgr.h>
15+
#else
1316
#include <amd_comgr/amd_comgr.h>
1417
#endif
18+
#endif
1519
#include <hip/hip_runtime.h>
1620
#include <ur/ur.hpp>
1721

source/adapters/hip/program.cpp

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

1313
#ifdef SYCL_ENABLE_KERNEL_FUSION
14+
#ifdef UR_COMGR_VERSION4_INCLUDE
15+
#include <amd_comgr.h>
16+
#else
1417
#include <amd_comgr/amd_comgr.h>
18+
#endif
1519
namespace {
1620
template <typename ReleaseType, ReleaseType Release, typename T>
1721
struct COMgrObjCleanUp {

0 commit comments

Comments
 (0)