diff --git a/source/adapters/hip/CMakeLists.txt b/source/adapters/hip/CMakeLists.txt index 1ed9d52c2b..e95dcded41 100644 --- a/source/adapters/hip/CMakeLists.txt +++ b/source/adapters/hip/CMakeLists.txt @@ -101,6 +101,21 @@ 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 @@ -108,8 +123,8 @@ if("${UR_HIP_PLATFORM}" STREQUAL "AMD") 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 diff --git a/source/adapters/hip/common.hpp b/source/adapters/hip/common.hpp index d7eea780a5..be332c280b 100644 --- a/source/adapters/hip/common.hpp +++ b/source/adapters/hip/common.hpp @@ -10,8 +10,12 @@ #pragma once #ifdef SYCL_ENABLE_KERNEL_FUSION +#ifdef UR_COMGR_VERSION4_INCLUDE +#include +#else #include #endif +#endif #include #include diff --git a/source/adapters/hip/program.cpp b/source/adapters/hip/program.cpp index 4d0351eb5b..9aa64151e0 100644 --- a/source/adapters/hip/program.cpp +++ b/source/adapters/hip/program.cpp @@ -11,7 +11,11 @@ #include "program.hpp" #ifdef SYCL_ENABLE_KERNEL_FUSION +#ifdef UR_COMGR_VERSION4_INCLUDE +#include +#else #include +#endif namespace { template struct COMgrObjCleanUp {