Skip to content

Commit

Permalink
Merge pull request #1222 from sommerlukas/lukas/comgr-include-rocm4
Browse files Browse the repository at this point in the history
[UR][HIP] Fix include for AMD COMGR
  • Loading branch information
kbenzie committed Jan 4, 2024
1 parent 41a0841 commit 7b5f58b
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 2 deletions.
19 changes: 17 additions & 2 deletions source/adapters/hip/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -98,15 +98,30 @@ if("${UR_HIP_PLATFORM}" STREQUAL "AMD")
)

if(UR_ENABLE_COMGR)
set(UR_COMGR_VERSION5_HEADER "${UR_HIP_INCLUDE_DIR}/amd_comgr/amd_comgr.h")
set(UR_COMGR_VERSION4_HEADER "${UR_HIP_INCLUDE_DIR}/amd_comgr.h")
# The COMGR header changed location between ROCm versions 4 and 5.
# Check for existence in the version 5 location or fallback to version 4
if(NOT EXISTS "${UR_COMGR_VERSION5_HEADER}")
if(NOT EXISTS "${UR_COMGR_VERSION4_HEADER}")
message(FATAL_ERROR "Could not find AMD COMGR header at "
"${UR_COMGR_VERSION5_HEADER} or"
"${UR_COMGR_VERSION4_HEADER}, "
"check ROCm installation")
else()
target_compile_definitions(${TARGET_NAME} PRIVATE UR_COMGR_VERSION4_INCLUDE)
endif()
endif()

add_library(amd_comgr SHARED IMPORTED GLOBAL)
set_target_properties(
amd_comgr PROPERTIES
IMPORTED_LOCATION "${UR_HIP_LIB_DIR}/libamd_comgr.so"
INTERFACE_INCLUDE_DIRECTORIES "${HIP_HEADERS}"
INTERFACE_SYSTEM_INCLUDE_DIRECTORIES "${HIP_HEADERS}"
)
target_link_libraries(pi_hip PUBLIC amd_comgr)
target_compile_definitions(pi_hip PRIVATE SYCL_ENABLE_KERNEL_FUSION)
target_link_libraries(${TARGET_NAME} PUBLIC amd_comgr)
target_compile_definitions(${TARGET_NAME} PRIVATE SYCL_ENABLE_KERNEL_FUSION)
endif(UR_ENABLE_COMGR)

target_link_libraries(${TARGET_NAME} PRIVATE
Expand Down
4 changes: 4 additions & 0 deletions source/adapters/hip/common.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,12 @@
#pragma once

#ifdef SYCL_ENABLE_KERNEL_FUSION
#ifdef UR_COMGR_VERSION4_INCLUDE
#include <amd_comgr.h>
#else
#include <amd_comgr/amd_comgr.h>
#endif
#endif
#include <hip/hip_runtime.h>
#include <ur/ur.hpp>

Expand Down
4 changes: 4 additions & 0 deletions source/adapters/hip/program.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,11 @@
#include "program.hpp"

#ifdef SYCL_ENABLE_KERNEL_FUSION
#ifdef UR_COMGR_VERSION4_INCLUDE
#include <amd_comgr.h>
#else
#include <amd_comgr/amd_comgr.h>
#endif
namespace {
template <typename ReleaseType, ReleaseType Release, typename T>
struct COMgrObjCleanUp {
Expand Down

0 comments on commit 7b5f58b

Please sign in to comment.