From e8be15f3084076568e5a77688b4f117ff36f8b2a Mon Sep 17 00:00:00 2001 From: Lukas Sommer Date: Wed, 3 Jan 2024 16:32:47 +0000 Subject: [PATCH 1/3] [UR][HIP] Fix include for AMD COMGR --- source/adapters/hip/CMakeLists.txt | 4 ++-- source/adapters/hip/common.hpp | 4 ++++ source/adapters/hip/program.cpp | 4 ++++ 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/source/adapters/hip/CMakeLists.txt b/source/adapters/hip/CMakeLists.txt index 1ed9d52c2b..b7e06f0c63 100644 --- a/source/adapters/hip/CMakeLists.txt +++ b/source/adapters/hip/CMakeLists.txt @@ -108,8 +108,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..6459b947b9 100644 --- a/source/adapters/hip/common.hpp +++ b/source/adapters/hip/common.hpp @@ -10,7 +10,11 @@ #pragma once #ifdef SYCL_ENABLE_KERNEL_FUSION +#if (ROCM_VERSION_MAJOR >= 5) #include +#else +#include +#endif #endif #include #include diff --git a/source/adapters/hip/program.cpp b/source/adapters/hip/program.cpp index 4d0351eb5b..8b8a8407d1 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 +#if (ROCM_VERSION_MAJOR >= 5) #include +#else +#include +#endif namespace { template struct COMgrObjCleanUp { From 6847c5d644583102725e286f3429534e70fe1f10 Mon Sep 17 00:00:00 2001 From: Lukas Sommer Date: Wed, 3 Jan 2024 18:28:03 +0000 Subject: [PATCH 2/3] [UR][HIP] Include ROCm version header Signed-off-by: Lukas Sommer --- source/adapters/hip/common.hpp | 1 + source/adapters/hip/program.cpp | 1 + 2 files changed, 2 insertions(+) diff --git a/source/adapters/hip/common.hpp b/source/adapters/hip/common.hpp index 6459b947b9..12575e6cae 100644 --- a/source/adapters/hip/common.hpp +++ b/source/adapters/hip/common.hpp @@ -10,6 +10,7 @@ #pragma once #ifdef SYCL_ENABLE_KERNEL_FUSION +#include #if (ROCM_VERSION_MAJOR >= 5) #include #else diff --git a/source/adapters/hip/program.cpp b/source/adapters/hip/program.cpp index 8b8a8407d1..9d807d4bb2 100644 --- a/source/adapters/hip/program.cpp +++ b/source/adapters/hip/program.cpp @@ -11,6 +11,7 @@ #include "program.hpp" #ifdef SYCL_ENABLE_KERNEL_FUSION +#include #if (ROCM_VERSION_MAJOR >= 5) #include #else From d398d4aec1f9c2397433dc5a4619d5c30269c622 Mon Sep 17 00:00:00 2001 From: Lukas Sommer Date: Thu, 4 Jan 2024 09:40:49 +0000 Subject: [PATCH 3/3] [UR][HIP] Detect COMGR version in CMake Signed-off-by: Lukas Sommer --- source/adapters/hip/CMakeLists.txt | 15 +++++++++++++++ source/adapters/hip/common.hpp | 7 +++---- source/adapters/hip/program.cpp | 7 +++---- 3 files changed, 21 insertions(+), 8 deletions(-) diff --git a/source/adapters/hip/CMakeLists.txt b/source/adapters/hip/CMakeLists.txt index b7e06f0c63..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 diff --git a/source/adapters/hip/common.hpp b/source/adapters/hip/common.hpp index 12575e6cae..be332c280b 100644 --- a/source/adapters/hip/common.hpp +++ b/source/adapters/hip/common.hpp @@ -10,11 +10,10 @@ #pragma once #ifdef SYCL_ENABLE_KERNEL_FUSION -#include -#if (ROCM_VERSION_MAJOR >= 5) -#include -#else +#ifdef UR_COMGR_VERSION4_INCLUDE #include +#else +#include #endif #endif #include diff --git a/source/adapters/hip/program.cpp b/source/adapters/hip/program.cpp index 9d807d4bb2..9aa64151e0 100644 --- a/source/adapters/hip/program.cpp +++ b/source/adapters/hip/program.cpp @@ -11,11 +11,10 @@ #include "program.hpp" #ifdef SYCL_ENABLE_KERNEL_FUSION -#include -#if (ROCM_VERSION_MAJOR >= 5) -#include -#else +#ifdef UR_COMGR_VERSION4_INCLUDE #include +#else +#include #endif namespace { template