Skip to content

Commit

Permalink
Add option to use locally installed Unified Runtime (#21)
Browse files Browse the repository at this point in the history
  • Loading branch information
lslusarczyk authored Sep 26, 2024
1 parent 330102c commit f688255
Showing 1 changed file with 14 additions and 10 deletions.
24 changes: 14 additions & 10 deletions source/framework/ur/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,17 @@ if (NOT BUILD_UR)
return()
endif()

if(BENCHMARK_UR_SOURCE_DIR)
add_subdirectory(
${BENCHMARK_UR_SOURCE_DIR}
${CMAKE_CURRENT_BINARY_DIR}/unified-runtime)
find_package(unified-runtime)

if(${unified-runtime_FOUND} AND NOT BENCHMARK_UR_OVERRIDE_FETCH_CONTENT_REPO AND NOT BENCHMARK_UR_OVERRIDE_FETCH_CONTENT_TAG)

message(STATUS "Unified Runtime installation found")

add_library(ur_loader ALIAS unified-runtime::ur_loader)
add_library(ur_headers ALIAS unified-runtime::ur_headers)

else()

include(FetchContent)

set(UMF_DISABLE_HWLOC ON CACHE INTERNAL "")
Expand All @@ -22,31 +28,29 @@ else()
set(UNIFIED_RUNTIME_REPO "https://github.com/oneapi-src/unified-runtime.git")
set(UNIFIED_RUNTIME_TAG main)

message(STATUS
"Will fetch Unified Runtime from ${UNIFIED_RUNTIME_REPO} at ${UNIFIED_RUNTIME_TAG}")

if(BENCHMARK_UR_OVERRIDE_FETCH_CONTENT_REPO)
set(UNIFIED_RUNTIME_REPO "${BENCHMARK_UR_OVERRIDE_FETCH_CONTENT_REPO}")
endif()
if(BENCHMARK_UR_OVERRIDE_FETCH_CONTENT_TAG)
set(UNIFIED_RUNTIME_TAG "${BENCHMARK_UR_OVERRIDE_FETCH_CONTENT_TAG}")
endif()

message(STATUS "Will fetch Unified Runtime from ${UNIFIED_RUNTIME_REPO}")
message(STATUS
"Will fetch Unified Runtime from ${UNIFIED_RUNTIME_REPO} at ${UNIFIED_RUNTIME_TAG}")

FetchContent_Declare(unified-runtime
GIT_REPOSITORY ${UNIFIED_RUNTIME_REPO}
GIT_TAG ${UNIFIED_RUNTIME_TAG}
)

FetchContent_GetProperties(unified-runtime)
FetchContent_MakeAvailable(unified-runtime)

endif()

# Define target
set(API_NAME ur)

set(TARGET_NAME compute_benchmarks_framework_${API_NAME})

add_library(${TARGET_NAME} STATIC ur.cpp ur.h error.h)
target_include_directories(${TARGET_NAME} PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
target_link_libraries(${TARGET_NAME} PUBLIC compute_benchmarks_framework ur_loader ur_headers)
Expand Down

0 comments on commit f688255

Please sign in to comment.