Skip to content

Commit

Permalink
[UR][HIP] Detect COMGR version in CMake
Browse files Browse the repository at this point in the history
Signed-off-by: Lukas Sommer <lukas.sommer@codeplay.com>
  • Loading branch information
sommerlukas committed Jan 4, 2024
1 parent 6847c5d commit d398d4a
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 8 deletions.
15 changes: 15 additions & 0 deletions source/adapters/hip/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 3 additions & 4 deletions source/adapters/hip/common.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,10 @@
#pragma once

#ifdef SYCL_ENABLE_KERNEL_FUSION
#include <rocm/rocm_version.h>
#if (ROCM_VERSION_MAJOR >= 5)
#include <amd_comgr/amd_comgr.h>
#else
#ifdef UR_COMGR_VERSION4_INCLUDE
#include <amd_comgr.h>
#else
#include <amd_comgr/amd_comgr.h>
#endif
#endif
#include <hip/hip_runtime.h>
Expand Down
7 changes: 3 additions & 4 deletions source/adapters/hip/program.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,10 @@
#include "program.hpp"

#ifdef SYCL_ENABLE_KERNEL_FUSION
#include <rocm/rocm_version.h>
#if (ROCM_VERSION_MAJOR >= 5)
#include <amd_comgr/amd_comgr.h>
#else
#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>
Expand Down

0 comments on commit d398d4a

Please sign in to comment.