Skip to content

Commit 737e745

Browse files
Merge branch 'sycl' into refactorcache
2 parents 2a51c3a + bfc783f commit 737e745

24 files changed

+288
-457
lines changed

sycl/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ if(MSVC)
8383
endif()
8484

8585
include(FetchEmhash)
86-
include(FetchUnifiedRuntime)
86+
include(BuildUnifiedRuntime)
8787

8888
# The change in SYCL_MAJOR_VERSION must be accompanied with the same update in
8989
# llvm/clang/lib/Driver/CMakeLists.txt.

sycl/cmake/modules/FetchUnifiedRuntime.cmake renamed to sycl/cmake/modules/BuildUnifiedRuntime.cmake

Lines changed: 15 additions & 158 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
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" )
98
endif()
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-
2611
option(SYCL_UR_BUILD_TESTS "Build tests for UR" OFF)
2712
set(UR_BUILD_TESTS "${SYCL_UR_BUILD_TESTS}" CACHE BOOL "" FORCE)
2813
# UR tests require the examples to be built
@@ -80,154 +65,26 @@ endif()
8065
set(UR_INTREE_SOURCE_DIR "${LLVM_SOURCE_DIR}/../unified-runtime")
8166
cmake_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")
22382
endif()
83+
add_subdirectory(${UNIFIED_RUNTIME_SOURCE_DIR} ${UR_INTREE_BINARY_DIR})
22484

22585
# Restore original flags
22686
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS_BAK}")
22787

228-
message(STATUS
229-
"Using Unified Runtime source directory: ${UNIFIED_RUNTIME_SOURCE_DIR}")
230-
23188
set(UNIFIED_RUNTIME_INCLUDE_DIR "${UNIFIED_RUNTIME_SOURCE_DIR}/include")
23289
set(UNIFIED_RUNTIME_SRC_INCLUDE_DIR "${UNIFIED_RUNTIME_SOURCE_DIR}/source")
23390
set(UNIFIED_RUNTIME_COMMON_INCLUDE_DIR "${UNIFIED_RUNTIME_SOURCE_DIR}/source/common")

sycl/cmake/modules/UnifiedRuntimeTag.cmake

Lines changed: 0 additions & 7 deletions
This file was deleted.

sycl/doc/GetStartedGuide.md

Lines changed: 0 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ and a wide range of compute accelerators such as GPU and FPGA.
1414
* [Build DPC++ toolchain with support for HIP NVIDIA](#build-dpc-toolchain-with-support-for-hip-nvidia)
1515
* [Build DPC++ toolchain with support for ARM processors](#build-dpc-toolchain-with-support-for-arm-processors)
1616
* [Build DPC++ toolchain with additional features enabled that require runtime/JIT compilation](#build-dpc-toolchain-with-additional-features-enabled-that-require-runtimejit-compilation)
17-
* [Build DPC++ toolchain with a custom Unified Runtime](#build-dpc-toolchain-with-a-custom-unified-runtime)
1817
* [Build DPC++ toolchain with device image compression support](#build-dpc-toolchain-with-device-image-compression-support)
1918
* [Build Doxygen documentation](#build-doxygen-documentation)
2019
* [Deployment](#deployment)
@@ -369,36 +368,6 @@ After CMake cache is generated, build the documentation with `doxygen-sycl`
369368
target. It will be put to `$DPCPP_HOME/llvm/build/tools/sycl/doc/html`
370369
directory.
371370

372-
### Build DPC++ toolchain with a custom Unified Runtime
373-
374-
DPC++ uses the [Unified Runtime](https://github.com/oneapi-src/unified-runtime)
375-
under the hood to provide implementations of various SYCL backends. By default
376-
the source code for the Unified Runtime will be acquired using CMake's
377-
[FetchCotent](https://cmake.org/cmake/help/latest/module/FetchContent.html). The
378-
specific repository URL and revision tag used can be found in the file
379-
`sycl/cmake/modules/FetchUnifiedRuntime.cmake` searching for the variables
380-
`UNIFIED_RUNTIME_REPO` and `UNIFIED_RUNTIME_TAG`.
381-
382-
In order to enable developers, a number of CMake variables are available to
383-
control which revision of Unified Runtime should be used when building DPC++:
384-
385-
* `SYCL_UR_OVERRIDE_FETCH_CONTENT_REPO` is a variable which can be used to
386-
override the `UNIFIED_RUNTIME_REPO` variable used by `FetchContent` to attain
387-
the Unified Runtime source code.
388-
* `SYCL_UR_OVERRIDE_FETCH_CONTENT_TAG` is a variable which can be used to
389-
override the `UNIFIED_RUNTIME_TAG` variable used by `FetchContent` to attain
390-
the Unified Runtime source code.
391-
* `SYCL_UR_USE_FETCH_CONTENT` is an option to control if CMake should use
392-
`FetchContent` to pull in the Unified Runtime repository, it defaults to `ON`.
393-
When set to `OFF`, `FetchContent` will not be used, instead:
394-
* The path specified by variable `SYCL_UR_SOURCE_DIR` will be used with
395-
`add_directory()`. This can be used to point at an adjacent directory
396-
containing a clone of the Unified Runtime repository.
397-
* The path `sycl/unified-runtime` will be used, if it
398-
exists. This can be used as-if an in-tree build.
399-
* `SYCL_UR_SOURCE_DIR` is a variable used to specify the path to the Unified
400-
Runtime repository when `SYCL_UR_USE_FETCH_CONTENT` is set of `OFF`.
401-
402371
### Build DPC++ libclc with a custom toolchain
403372

404373
libclc is an implementation of the OpenCL required libraries, as described in

sycl/source/detail/buffer_impl.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,6 @@
1818
namespace sycl {
1919
inline namespace _V1 {
2020
namespace detail {
21-
#ifdef XPTI_ENABLE_INSTRUMENTATION
22-
uint8_t GBufferStreamID;
23-
#endif
2421
void *buffer_impl::allocateMem(context_impl *Context, bool InitFromUserData,
2522
void *HostPtr,
2623
ur_event_handle_t &OutEventToWait) {

sycl/source/detail/event_impl.cpp

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
#include <chrono>
2020

2121
#ifdef XPTI_ENABLE_INSTRUMENTATION
22-
#include "xpti/xpti_trace_framework.hpp"
2322
#include <atomic>
2423
#include <detail/xpti_registry.hpp>
2524
#include <sstream>
@@ -28,10 +27,6 @@
2827
namespace sycl {
2928
inline namespace _V1 {
3029
namespace detail {
31-
#ifdef XPTI_ENABLE_INSTRUMENTATION
32-
extern xpti::trace_event_data_t *GSYCLGraphEvent;
33-
#endif
34-
3530
// If we do not yet have a context, use the default one.
3631
void event_impl::initContextIfNeeded() {
3732
if (MContext || !MIsDefaultConstructed)
@@ -293,8 +288,7 @@ void event_impl::wait(bool *Success) {
293288
void *TelemetryEvent = nullptr;
294289
uint64_t IId = 0;
295290
std::string Name;
296-
xpti::stream_id_t StreamID = xptiRegisterStream(SYCL_STREAM_NAME);
297-
TelemetryEvent = instrumentationProlog(Name, StreamID, IId);
291+
TelemetryEvent = instrumentationProlog(Name, GSYCLStreamID, IId);
298292
#endif
299293

300294
auto EventHandle = getHandle();
@@ -306,7 +300,7 @@ void event_impl::wait(bool *Success) {
306300
detail::Scheduler::getInstance().waitForEvent(*this, Success);
307301

308302
#ifdef XPTI_ENABLE_INSTRUMENTATION
309-
instrumentationEpilog(TelemetryEvent, Name, StreamID, IId);
303+
instrumentationEpilog(TelemetryEvent, Name, GSYCLStreamID, IId);
310304
#endif
311305
}
312306

sycl/source/detail/global_handler.cpp

Lines changed: 8 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -77,46 +77,28 @@ std::atomic_uint ObjectUsageCounter::MCounter{0};
7777
GlobalHandler::GlobalHandler() = default;
7878
GlobalHandler::~GlobalHandler() = default;
7979

80-
void GlobalHandler::InitXPTI() {
81-
#ifdef XPTI_ENABLE_INSTRUMENTATION
82-
// Let subscribers know a new stream is being initialized
83-
getXPTIRegistry().initializeStream(SYCL_STREAM_NAME, GMajVer, GMinVer,
84-
GVerStr);
85-
xpti::payload_t SYCLPayload("SYCL Runtime Exceptions");
86-
uint64_t SYCLInstanceNo;
87-
GSYCLCallEvent = xptiMakeEvent("SYCL Try-catch Exceptions", &SYCLPayload,
88-
xpti::trace_algorithm_event, xpti_at::active,
89-
&SYCLInstanceNo);
90-
#endif
91-
}
92-
9380
void GlobalHandler::TraceEventXPTI(const char *Message) {
9481
if (!Message)
9582
return;
9683
#ifdef XPTI_ENABLE_INSTRUMENTATION
97-
static std::once_flag InitXPTIFlag;
84+
// This section is used to emit XPTI trace events when exceptions occur
9885
if (xptiTraceEnabled()) {
99-
std::call_once(InitXPTIFlag, [&]() { InitXPTI(); });
86+
GlobalHandler::instance().getXPTIRegistry().initializeFrameworkOnce();
10087

10188
// We have to handle the cases where: (1) we may have just the code location
10289
// set and not UID and (2) UID set
10390
detail::tls_code_loc_t Tls;
10491
auto CodeLocation = Tls.query();
10592

106-
// Creating a tracepoint will convert a CodeLocation to UID, if not set
107-
xpti::framework::tracepoint_t TP(
93+
// Creating a tracepoint using the stashed code location and notifying the
94+
// subscriber with the diagnostic message
95+
xpti::framework::tracepoint_scope_t TP(
10896
CodeLocation.fileName(), CodeLocation.functionName(),
10997
CodeLocation.lineNumber(), CodeLocation.columnNumber(), nullptr);
11098

111-
// The call to notify will have the signature of:
112-
// (1) the stream defined in .stream()
113-
// (2) The trace type equal to what is set by .trace_type()
114-
// (3) Parent event set to NULL
115-
// (4) Current event set to one created from CodeLocation and UID
116-
// (5) An instance ID that records the number of times this code location
117-
// has been seen (6) The message generated by the exception handler
118-
TP.stream(SYCL_STREAM_NAME)
119-
.trace_type(xpti::trace_point_type_t::diagnostics)
99+
TP.stream(detail::GSYCLStreamID)
100+
.traceType(xpti::trace_point_type_t::diagnostics)
101+
.parentEvent(GSYCLCallEvent)
120102
.notify(static_cast<const void *>(Message));
121103
}
122104

sycl/source/detail/global_handler.hpp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -90,17 +90,12 @@ class GlobalHandler {
9090
void drainThreadPool();
9191
void prepareSchedulerToRelease(bool Blocking);
9292

93-
void InitXPTI();
9493
void TraceEventXPTI(const char *Message);
9594

9695
// For testing purposes only
9796
void attachScheduler(Scheduler *Scheduler);
9897

9998
private:
100-
#ifdef XPTI_ENABLE_INSTRUMENTATION
101-
void *GSYCLCallEvent = nullptr;
102-
#endif
103-
10499
bool OkToDefer = true;
105100

106101
friend void shutdown_early(bool);

0 commit comments

Comments
 (0)