Skip to content

Commit 7616785

Browse files
authored
[UR] Support fetch adapter source individually (#12907)
This patch and its counterpart in oneapi-src/unified-runtime#1410 add CMake support for fetching an individual Unified Runtime adapter's source code from a different repo/tag combination using the new `fetch_adapter_source()` CMake function. Only the source is cloned, it is not added to the build directly. Instead, the path to the adapter source is passed into Unified Runtime clone described by the `UNIFIED_RUNTIME_REPO` and `UNIFIED_RUNTIME_TAG` CMake variables. This clone is the source of truth for the Unified Runtime API and drives the build of the external adapter source. Using `fetch_adapter_source()` is optional.
1 parent 82bfffe commit 7616785

File tree

1 file changed

+31
-6
lines changed

1 file changed

+31
-6
lines changed

sycl/plugins/unified_runtime/CMakeLists.txt

Lines changed: 31 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -56,14 +56,39 @@ endif()
5656
if(SYCL_PI_UR_USE_FETCH_CONTENT)
5757
include(FetchContent)
5858

59+
# The fetch_adapter_source function can be used to perform a separate content
60+
# fetch for a UR adapter, this allows development of adapters to be decoupled
61+
# from each other.
62+
#
63+
# Args:
64+
# * name - Must be the directory name of the adapter
65+
# * repo - A valid Git URL of a Unified Runtime repo
66+
# * tag - A valid Git branch/tag/commit in the Unified Runtime repo
67+
function(fetch_adapter_source name repo tag)
68+
message(STATUS "Will fetch Unified Runtime ${name} adapter from ${repo} at ${tag}")
69+
set(fetch-name unified-runtime-${name})
70+
FetchContent_Declare(${fetch-name}
71+
GIT_REPOSITORY ${repo} GIT_TAG ${tag})
72+
# We don't want to add this repo to the build, only fetch its source.
73+
FetchContent_Populate(${fetch-name})
74+
# Get the path to the source directory
75+
string(TOUPPER ${name} NAME)
76+
set(source_dir_var UR_ADAPTER_${NAME}_SOURCE_DIR)
77+
FetchContent_GetProperties(${fetch-name} SOURCE_DIR UR_ADAPTER_${NAME}_SOURCE_DIR)
78+
# Set the variable which informs UR where to get the adapter source from.
79+
set(UR_ADAPTER_${NAME}_SOURCE_DIR
80+
"${UR_ADAPTER_${NAME}_SOURCE_DIR}/source/adapters/${name}"
81+
CACHE PATH "Path to external '${name}' adapter source dir" FORCE)
82+
endfunction()
83+
5984
set(UNIFIED_RUNTIME_REPO "https://github.com/oneapi-src/unified-runtime.git")
60-
# commit 09be0881b727fadb1c04b38c00d2562d7dc6875f
61-
# Merge: bb589ca8 e9f855d4
85+
# commit 6513abc404979fa109d64500bf899e632d511291
86+
# Merge: 09be0881 6d586094
6287
# Author: Kenneth Benzie (Benie) <[email protected]>
63-
# Date: Thu Mar 14 22:10:28 2024 +0000
64-
# Merge pull request #1429 from nrspruit/l0_p2p_device_query
65-
# [L0] Support for urUsmP2PPeerAccessGetInfoExp to query p2p access info
66-
set(UNIFIED_RUNTIME_TAG 09be0881b727fadb1c04b38c00d2562d7dc6875f)
88+
# Date: Thu Mar 14 22:38:53 2024 +0000
89+
# Merge pull request #1410 from kbenzie/benie/cmake-external-adapter-source-dirs
90+
# [CMake] Support external adapter source dirs
91+
set(UNIFIED_RUNTIME_TAG 6513abc404979fa109d64500bf899e632d511291)
6792

6893
if(SYCL_PI_UR_OVERRIDE_FETCH_CONTENT_REPO)
6994
set(UNIFIED_RUNTIME_REPO "${SYCL_PI_UR_OVERRIDE_FETCH_CONTENT_REPO}")

0 commit comments

Comments
 (0)