1- # Either fetches UR from the appropriate repo or sets up variables based on user
2- # preference.
1+ # Builds in-tree UR
32
43# TODO: taken from sycl/plugins/CMakeLists.txt - maybe we should handle this
54# within UR (although it is an obscure warning that the build system here
@@ -9,20 +8,6 @@ if ("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang|IntelLLVM" )
98endif ()
109
1110
12- # Options to override the default behaviour of the FetchContent to include UR
13- # source code.
14- set (SYCL_UR_OVERRIDE_FETCH_CONTENT_REPO
15- "" CACHE STRING "Override the Unified Runtime FetchContent repository" )
16- set (SYCL_UR_OVERRIDE_FETCH_CONTENT_TAG
17- "" CACHE STRING "Override the Unified Runtime FetchContent tag" )
18-
19- # Options to disable use of FetchContent to include Unified Runtime source code
20- # to improve developer workflow.
21- option (SYCL_UR_USE_FETCH_CONTENT
22- "Use FetchContent to acquire the Unified Runtime source code" ON )
23- set (SYCL_UR_SOURCE_DIR
24- "" CACHE PATH "Path to root of Unified Runtime repository" )
25-
2611option (SYCL_UR_BUILD_TESTS "Build tests for UR" OFF )
2712set (UR_BUILD_TESTS "${SYCL_UR_BUILD_TESTS} " CACHE BOOL "" FORCE)
2813# UR tests require the examples to be built
@@ -80,154 +65,26 @@ endif()
8065set (UR_INTREE_SOURCE_DIR "${LLVM_SOURCE_DIR} /../unified-runtime" )
8166cmake_path(NORMAL_PATH UR_INTREE_SOURCE_DIR OUTPUT_VARIABLE UR_INTREE_SOURCE_DIR)
8267
83- if (IS_DIRECTORY "${UR_INTREE_SOURCE_DIR} " )
84- set (UR_INTREE_BINARY_DIR ${LLVM_BINARY_DIR} /unified-runtime)
85- set (UNIFIED_RUNTIME_SOURCE_DIR
86- "${UR_INTREE_SOURCE_DIR} " CACHE PATH
87- "Path to Unified Runtime Headers" FORCE)
88- set (UMF_BUILD_EXAMPLES OFF CACHE INTERNAL "EXAMPLES" )
89- # Due to the use of dependentloadflag and no installer for UMF and hwloc we need
90- # to link statically on windows
91- if (WIN32 )
92- set (UMF_BUILD_SHARED_LIBRARY OFF CACHE INTERNAL "Build UMF shared library" )
93- set (UMF_LINK_HWLOC_STATICALLY ON CACHE INTERNAL "static HWLOC" )
94- endif ()
95- add_subdirectory (${UNIFIED_RUNTIME_SOURCE_DIR} ${UR_INTREE_BINARY_DIR} )
96- elseif (SYCL_UR_USE_FETCH_CONTENT)
97- include (FetchContent)
98-
99- # The fetch_adapter_source function can be used to perform a separate content
100- # fetch for a UR adapter (backend), this allows development of adapters to be decoupled
101- # from each other.
102- #
103- # A separate content fetch will not be performed if:
104- # * The adapter name is not present in the SYCL_ENABLE_BACKENDS variable.
105- # * The repo and tag provided match the values of the
106- # UNIFIED_RUNTIME_REPO/UNIFIED_RUNTIME_TAG variables
107- #
108- # Args:
109- # * name - Must be the directory name of the adapter
110- # * repo - A valid Git URL of a Unified Runtime repo
111- # * tag - A valid Git branch/tag/commit in the Unified Runtime repo
112- function (fetch_adapter_source name repo tag)
113- if (NOT ${name} IN_LIST SYCL_ENABLE_BACKENDS)
114- return ()
115- endif ()
116- if (repo STREQUAL UNIFIED_RUNTIME_REPO AND
117- tag STREQUAL UNIFIED_RUNTIME_TAG)
118- # If the adapter sources are taken from the main checkout, reset the
119- # adapter specific source path.
120- string (TOUPPER ${name} NAME )
121- set (UR_ADAPTER_${NAME} _SOURCE_DIR ""
122- CACHE PATH "Path to external '${name} ' adapter source dir" FORCE)
123- return ()
124- endif ()
125- message (STATUS
126- "Will fetch Unified Runtime ${name} adapter from ${repo} at ${tag} " )
127- set (fetch-name ur-${name} )
128- FetchContent_Declare(${fetch-name }
129- GIT_REPOSITORY ${repo} GIT_TAG ${tag} )
130- # We don't want to add this repo to the build, only fetch its source.
131- FetchContent_Populate(${fetch-name })
132- # Get the path to the source directory
133- string (TOUPPER ${name} NAME )
134- set (source_dir_var UR_ADAPTER_${NAME} _SOURCE_DIR)
135- FetchContent_GetProperties(${fetch-name } SOURCE_DIR UR_ADAPTER_${NAME} _SOURCE_DIR)
136- # Set the variable which informs UR where to get the adapter source from.
137- set (UR_ADAPTER_${NAME} _SOURCE_DIR
138- "${UR_ADAPTER_${NAME} _SOURCE_DIR}/source/adapters/${name} "
139- CACHE PATH "Path to external '${name} ' adapter source dir" FORCE)
140- endfunction ()
141-
142- set (UNIFIED_RUNTIME_REPO "https://github.com/oneapi-src/unified-runtime.git" )
143- include (${CMAKE_CURRENT_SOURCE_DIR} /cmake/modules/UnifiedRuntimeTag.cmake)
144-
145- set (UMF_BUILD_EXAMPLES OFF CACHE INTERNAL "EXAMPLES" )
146- # Due to the use of dependentloadflag and no installer for UMF and hwloc we need
147- # to link statically on windows
148- if (WIN32 )
149- set (UMF_BUILD_SHARED_LIBRARY OFF CACHE INTERNAL "Build UMF shared library" )
150- set (UMF_LINK_HWLOC_STATICALLY ON CACHE INTERNAL "static HWLOC" )
151- endif ()
152-
153- fetch_adapter_source(level_zero
154- ${UNIFIED_RUNTIME_REPO}
155- ${UNIFIED_RUNTIME_TAG}
156- )
157-
158- fetch_adapter_source(opencl
159- ${UNIFIED_RUNTIME_REPO}
160- ${UNIFIED_RUNTIME_TAG}
161- )
162-
163- fetch_adapter_source(cuda
164- ${UNIFIED_RUNTIME_REPO}
165- ${UNIFIED_RUNTIME_TAG}
166- )
167-
168- fetch_adapter_source(hip
169- ${UNIFIED_RUNTIME_REPO}
170- ${UNIFIED_RUNTIME_TAG}
171- )
172-
173- fetch_adapter_source(native_cpu
174- ${UNIFIED_RUNTIME_REPO}
175- ${UNIFIED_RUNTIME_TAG}
176- )
177-
178- if (SYCL_UR_OVERRIDE_FETCH_CONTENT_REPO)
179- set (UNIFIED_RUNTIME_REPO "${SYCL_UR_OVERRIDE_FETCH_CONTENT_REPO} " )
180- endif ()
181- if (SYCL_UR_OVERRIDE_FETCH_CONTENT_TAG)
182- set (UNIFIED_RUNTIME_TAG "${SYCL_UR_OVERRIDE_FETCH_CONTENT_TAG} " )
183- endif ()
184-
185- message (STATUS "Will fetch Unified Runtime from ${UNIFIED_RUNTIME_REPO} " )
186- FetchContent_Declare(unified-runtime
187- GIT_REPOSITORY ${UNIFIED_RUNTIME_REPO}
188- GIT_TAG ${UNIFIED_RUNTIME_TAG}
189- )
68+ if (NOT IS_DIRECTORY "${UR_INTREE_SOURCE_DIR} " )
69+ message (FATAL_ERROR "unified-runtime folder not found at repo root" )
70+ endif ()
19071
191- FetchContent_GetProperties(unified-runtime)
192- FetchContent_MakeAvailable(unified-runtime)
193-
194- set (UNIFIED_RUNTIME_SOURCE_DIR
195- "${unified-runtime_SOURCE_DIR}" CACHE PATH
196- "Path to Unified Runtime Headers" FORCE)
197- elseif (SYCL_UR_SOURCE_DIR)
198- # SYCL_UR_USE_FETCH_CONTENT is OFF and SYCL_UR_SOURCE_DIR has been set,
199- # use the external Unified Runtime source directory.
200- set (UNIFIED_RUNTIME_SOURCE_DIR
201- "${SYCL_UR_SOURCE_DIR} " CACHE PATH
202- "Path to Unified Runtime Headers" FORCE)
203- add_subdirectory (
204- ${UNIFIED_RUNTIME_SOURCE_DIR}
205- ${CMAKE_CURRENT_BINARY_DIR} /unified-runtime)
206- else ()
207- # SYCL_UR_USE_FETCH_CONTENT is OFF and SYCL_UR_SOURCE_DIR has not been
208- # set, check if the fallback local directory exists.
209- if (NOT EXISTS ${CMAKE_CURRENT_SOURCE_DIR} /unified-runtime)
210- message (FATAL_ERROR
211- "SYCL_UR_USE_FETCH_CONTENT is disabled but no alternative Unified \
212- Runtime source directory has been provided, either:
213-
214- * Set -DSYCL_UR_SOURCE_DIR=/path/to/unified-runtime
215- * Clone the UR repo in ${CMAKE_CURRENT_SOURCE_DIR} /unified-runtime" )
216- endif ()
217- # The fallback local directory for the Unified Runtime repository has been
218- # found, use it.
219- set (UNIFIED_RUNTIME_SOURCE_DIR
220- "${CMAKE_CURRENT_SOURCE_DIR} /unified-runtime" CACHE PATH
221- "Path to Unified Runtime Headers" FORCE)
222- add_subdirectory (${UNIFIED_RUNTIME_SOURCE_DIR} )
72+ set (UR_INTREE_BINARY_DIR ${LLVM_BINARY_DIR} /unified-runtime)
73+ set (UNIFIED_RUNTIME_SOURCE_DIR
74+ "${UR_INTREE_SOURCE_DIR} " CACHE PATH
75+ "Path to Unified Runtime Headers" FORCE)
76+ set (UMF_BUILD_EXAMPLES OFF CACHE INTERNAL "EXAMPLES" )
77+ # Due to the use of dependentloadflag and no installer for UMF and hwloc we need
78+ # to link statically on windows
79+ if (WIN32 )
80+ set (UMF_BUILD_SHARED_LIBRARY OFF CACHE INTERNAL "Build UMF shared library" )
81+ set (UMF_LINK_HWLOC_STATICALLY ON CACHE INTERNAL "static HWLOC" )
22382endif ()
83+ add_subdirectory (${UNIFIED_RUNTIME_SOURCE_DIR} ${UR_INTREE_BINARY_DIR} )
22484
22585# Restore original flags
22686set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS_BAK} " )
22787
228- message (STATUS
229- "Using Unified Runtime source directory: ${UNIFIED_RUNTIME_SOURCE_DIR} " )
230-
23188set (UNIFIED_RUNTIME_INCLUDE_DIR "${UNIFIED_RUNTIME_SOURCE_DIR} /include" )
23289set (UNIFIED_RUNTIME_SRC_INCLUDE_DIR "${UNIFIED_RUNTIME_SOURCE_DIR} /source" )
23390set (UNIFIED_RUNTIME_COMMON_INCLUDE_DIR "${UNIFIED_RUNTIME_SOURCE_DIR} /source/common" )
0 commit comments