This repository was archived by the owner on Mar 2, 2026. It is now read-only.
forked from intel/llvm
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
243 lines (211 loc) · 8.36 KB
/
CMakeLists.txt
File metadata and controls
243 lines (211 loc) · 8.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
# PI Unified Runtime plugin library.
#
# Options to override the default behaviour of the FetchContent to include UR
# source code.
set(SYCL_PI_UR_OVERRIDE_FETCH_CONTENT_REPO
"" CACHE STRING "Override the Unified Runtime FetchContent repository")
set(SYCL_PI_UR_OVERRIDE_FETCH_CONTENT_TAG
"" CACHE STRING "Override the Unified Runtime FetchContent tag")
# Options to disable use of FetchContent to include Unified Runtime source code
# to improve developer workflow.
option(SYCL_PI_UR_USE_FETCH_CONTENT
"Use FetchContent to acquire the Unified Runtime source code" ON)
set(SYCL_PI_UR_SOURCE_DIR
"" CACHE PATH "Path to root of Unified Runtime repository")
# Override default to enable building tests from unified-runtime
set(UR_BUILD_TESTS OFF CACHE BOOL "Build unit tests.")
set(UMF_ENABLE_POOL_TRACKING ON)
if("level_zero" IN_LIST SYCL_ENABLE_PLUGINS)
set(UR_BUILD_ADAPTER_L0 ON)
endif()
if("cuda" IN_LIST SYCL_ENABLE_PLUGINS)
set(UR_BUILD_ADAPTER_CUDA ON)
endif()
if("hip" IN_LIST SYCL_ENABLE_PLUGINS)
set(UR_BUILD_ADAPTER_HIP ON)
endif()
if("opencl" IN_LIST SYCL_ENABLE_PLUGINS)
set(UR_BUILD_ADAPTER_OPENCL ON)
set(UR_OPENCL_ICD_LOADER_LIBRARY OpenCL-ICD)
endif()
# TODO: Set UR_BUILD_ADAPTER_NATIVE_CPU once adapter moved
# Disable errors from warnings while building the UR.
# And remember origin flags before doing that.
set(CMAKE_CXX_FLAGS_BAK "${CMAKE_CXX_FLAGS}")
if(WIN32)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /WX-")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /WX-")
# FIXME: Unified runtime build fails with /DUNICODE
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /UUNICODE")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /UUNICODE")
# USE_Z7 forces use of /Z7 instead of /Zi which is broken with sccache
set(USE_Z7 ON)
else()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-error")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-error")
endif()
if(SYCL_PI_UR_USE_FETCH_CONTENT)
include(FetchContent)
set(UNIFIED_RUNTIME_REPO "https://github.com/oneapi-src/unified-runtime.git")
# commit: 7c8617b3710736db642585fe310a64e19e059d2e
# Merge: 20d4f49 9a13af
# Author: Kenneth Benzie (Benie) <k.benzie@codeplay.com>
# Date: Thu Oct 26 10:20:03 2023 +0100
# Merge pull request #965 from Bensuo/ewan/L0_internal_event_fix
# [Command-buffer][L0] Reset sync-point events
set(UNIFIED_RUNTIME_TAG 7c8617b3710736db642585fe310a64e19e059d2e)
if(SYCL_PI_UR_OVERRIDE_FETCH_CONTENT_REPO)
set(UNIFIED_RUNTIME_REPO "${SYCL_PI_UR_OVERRIDE_FETCH_CONTENT_REPO}")
endif()
if(SYCL_PI_UR_OVERRIDE_FETCH_CONTENT_TAG)
set(UNIFIED_RUNTIME_TAG "${SYCL_PI_UR_OVERRIDE_FETCH_CONTENT_TAG}")
endif()
message(STATUS "Will fetch Unified Runtime from ${UNIFIED_RUNTIME_REPO}")
FetchContent_Declare(unified-runtime
GIT_REPOSITORY ${UNIFIED_RUNTIME_REPO}
GIT_TAG ${UNIFIED_RUNTIME_TAG}
)
FetchContent_GetProperties(unified-runtime)
FetchContent_MakeAvailable(unified-runtime)
set(UNIFIED_RUNTIME_SOURCE_DIR
"${unified-runtime_SOURCE_DIR}" CACHE PATH
"Path to Unified Runtime Headers" FORCE)
elseif(SYCL_PI_UR_SOURCE_DIR)
# SYCL_PI_UR_USE_FETCH_CONTENT is OFF and SYCL_PI_UR_SOURCE_DIR has been set,
# use the external Unified Runtime source directory.
set(UNIFIED_RUNTIME_SOURCE_DIR
"${SYCL_PI_UR_SOURCE_DIR}" CACHE PATH
"Path to Unified Runtime Headers" FORCE)
add_subdirectory(
${UNIFIED_RUNTIME_SOURCE_DIR}
${CMAKE_CURRENT_BINARY_DIR}/unified-runtime)
else()
# SYCL_PI_UR_USE_FETCH_CONTENT is OFF and SYCL_PI_UR_SOURCE_DIR has not been
# set, check if the fallback local directory exists.
if(NOT ${CMAKE_CURRENT_SOURCE_DIR}/unified-runtime)
message(FATAL_ERROR
"SYCL_PI_UR_USE_FETCH_CONTENT is disabled but no alternative Unified
Runtime source directory has be proivided, either:
* Set -DSYCL_PI_UR_SOURCE_DIR=/path/to/unified-runtime
* Clone the UR repo in ${CMAKE_CURRENT_SOURCE_DIR}/unified-runtime")
endif()
# The fallback local directory for the Unified Runtime repository has been
# found, use it.
set(UNIFIED_RUNTIME_SOURCE_DIR
"${CMAKE_CURRENT_SOURCE_DIR}/unified-runtime" CACHE PATH
"Path to Unified Runtime Headers" FORCE)
add_subdirectory(${UNIFIED_RUNTIME_SOURCE_DIR})
endif()
# Restore original flags
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS_BAK}")
message(STATUS
"Using Unified Runtime source directory: ${UNIFIED_RUNTIME_SOURCE_DIR}")
set(UNIFIED_RUNTIME_INCLUDE_DIR "${UNIFIED_RUNTIME_SOURCE_DIR}/include")
add_library(UnifiedRuntimeLoader ALIAS ur_loader)
add_library(UnifiedRuntimeCommon ALIAS ur_common)
add_library(UnifiedMallocFramework ALIAS unified_malloc_framework)
add_library(UnifiedRuntime-Headers INTERFACE)
target_include_directories(UnifiedRuntime-Headers
INTERFACE
"${UNIFIED_RUNTIME_INCLUDE_DIR}"
)
find_package(Threads REQUIRED)
set(UNIFIED_RUNTIME_PLUGIN_ARGS
SOURCES
# These are short-term shared with Unified Runtime
# The two plugins define a few things differently so must
# be built separately. This difference is spelled in
# their "ur_bindings.hpp" files.
"ur_bindings.hpp"
"pi2ur.hpp"
"pi2ur.cpp"
# These below belong to Unified Runtime PI Plugin only
"pi_unified_runtime.hpp"
"pi_unified_runtime.cpp"
LIBRARIES
Threads::Threads
UnifiedRuntimeLoader
UnifiedRuntime-Headers
)
# We need for #include <ze_api.h> in common.h
if("level_zero" IN_LIST SYCL_ENABLE_PLUGINS)
list(APPEND UNIFIED_RUNTIME_PLUGIN_ARGS LevelZeroLoader-Headers)
endif()
if("opencl" IN_LIST SYCL_ENABLE_PLUGINS)
list(APPEND UNIFIED_RUNTIME_PLUGIN_ARGS OpenCL-ICD)
endif()
add_sycl_plugin(unified_runtime ${UNIFIED_RUNTIME_PLUGIN_ARGS})
if("native_cpu" IN_LIST SYCL_ENABLE_PLUGINS)
add_sycl_library("ur_adapter_native_cpu" SHARED
SOURCES
"ur/ur.cpp"
"ur/ur.hpp"
"ur/adapters/native_cpu/adapter.cpp"
"ur/adapters/native_cpu/command_buffer.cpp"
"ur/adapters/native_cpu/common.cpp"
"ur/adapters/native_cpu/common.hpp"
"ur/adapters/native_cpu/context.cpp"
"ur/adapters/native_cpu/context.hpp"
"ur/adapters/native_cpu/device.cpp"
"ur/adapters/native_cpu/device.hpp"
"ur/adapters/native_cpu/enqueue.cpp"
"ur/adapters/native_cpu/event.cpp"
"ur/adapters/native_cpu/image.cpp"
"ur/adapters/native_cpu/kernel.cpp"
"ur/adapters/native_cpu/kernel.hpp"
"ur/adapters/native_cpu/memory.cpp"
"ur/adapters/native_cpu/memory.hpp"
"ur/adapters/native_cpu/platform.cpp"
"ur/adapters/native_cpu/platform.hpp"
"ur/adapters/native_cpu/program.cpp"
"ur/adapters/native_cpu/program.hpp"
"ur/adapters/native_cpu/queue.cpp"
"ur/adapters/native_cpu/queue.hpp"
"ur/adapters/native_cpu/sampler.cpp"
"ur/adapters/native_cpu/ur_interface_loader.cpp"
"ur/adapters/native_cpu/usm.cpp"
"ur/adapters/native_cpu/usm_p2p.cpp"
INCLUDE_DIRS
${sycl_inc_dir}
LIBRARIES
UnifiedRuntime-Headers
Threads::Threads
sycl
OpenCL-Headers
)
set_target_properties("ur_adapter_native_cpu" PROPERTIES
VERSION "0.0.0"
SOVERSION "0"
)
endif()
if(TARGET UnifiedRuntimeLoader)
set_target_properties(hello_world PROPERTIES EXCLUDE_FROM_ALL 1 EXCLUDE_FROM_DEFAULT_BUILD 1)
# Install the UR loader.
# TODO: this is piggy-backing on the existing target component level-zero-sycl-dev
# When UR is moved to its separate repo perhaps we should introduce new component,
# e.g. unified-runtime-sycl-dev.
install(TARGETS ur_loader
LIBRARY DESTINATION "lib${LLVM_LIBDIR_SUFFIX}" COMPONENT level-zero-sycl-dev
ARCHIVE DESTINATION "lib${LLVM_LIBDIR_SUFFIX}" COMPONENT level-zero-sycl-dev
RUNTIME DESTINATION "bin" COMPONENT level-zero-sycl-dev
)
endif()
# Install the UR adapters too
if("level_zero" IN_LIST SYCL_ENABLE_PLUGINS)
add_dependencies(sycl-runtime-libraries ur_adapter_level_zero)
# Install the UR adapters too
install(TARGETS ur_adapter_level_zero
LIBRARY DESTINATION "lib${LLVM_LIBDIR_SUFFIX}" COMPONENT level-zero-sycl-dev
ARCHIVE DESTINATION "lib${LLVM_LIBDIR_SUFFIX}" COMPONENT level-zero-sycl-dev
RUNTIME DESTINATION "bin" COMPONENT level-zero-sycl-dev
)
endif()
if("cuda" IN_LIST SYCL_ENABLE_PLUGINS)
add_dependencies(sycl-runtime-libraries ur_adapter_cuda)
endif()
if("hip" IN_LIST SYCL_ENABLE_PLUGINS)
add_dependencies(sycl-runtime-libraries ur_adapter_hip)
endif()
if ("opencl" IN_LIST SYCL_ENABLE_PLUGINS)
add_dependencies(sycl-runtime-libraries ur_adapter_opencl)
endif()