Skip to content

Commit ec71841

Browse files
authored
Merge pull request #71 from reble/julianmi/graph-emulation-macro
Guard SYCL Graph implementation and fallback emulation
2 parents 1efde99 + 9b95a70 commit ec71841

File tree

8 files changed

+58
-54
lines changed

8 files changed

+58
-54
lines changed

README.md

Lines changed: 21 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -1,72 +1,44 @@
1-
# Intel Project for LLVM\* technology
1+
# SYCL Command Graph Extensions
22

3-
This is the Intel staging area for llvm.org contributions and the home for
4-
Intel LLVM-based projects:
3+
This is the collaboration space for the oneAPI vendor Command Graph extension for SYCL2020. It provides an API for defining a graph of operations and their dependencies once and submitting this graph repeatedly for execution.
54

6-
- [oneAPI DPC++ compiler](#oneapi-dpc-compiler)
7-
- [Late-outline OpenMP and OpenMP Offload](#late-outline-openmp-and-openmp-offload)
5+
### Specification
86

9-
## oneAPI DPC++ compiler
7+
A draft of our Command Graph extension proposal can be found here:
8+
[https://github.com/intel/llvm/pull/5626](https://github.com/intel/llvm/pull/5626).
109

11-
[![](https://spec.oneapi.io/oneapi-logo-white-scaled.jpg)](https://www.oneapi.io/)
10+
### Implementation
1211

13-
[![SYCL Post Commit](https://github.com/intel/llvm/actions/workflows/sycl_post_commit.yml/badge.svg?branch=sycl)](https://github.com/intel/llvm/actions/workflows/sycl_post_commit.yml)
14-
[![Generate Doxygen documentation](https://github.com/intel/llvm/actions/workflows/gh_pages.yml/badge.svg?branch=sycl)](https://github.com/intel/llvm/actions/workflows/gh_pages.yml)
12+
Our current prototype implementation can be found here:
13+
[https://github.com/reble/llvm/tree/sycl-graph-develop](https://github.com/reble/llvm/tree/sycl-graph-develop).
1514

16-
The DPC++ is a LLVM-based compiler project that implements compiler and runtime
17-
support for the SYCL\* language. The project is hosted in the
18-
[sycl](/../../tree/sycl) branch and is synced with the tip of the LLVM upstream
19-
main branch on a regular basis (revisions delay is usually not more than 1-2
20-
weeks). DPC++ compiler takes everything from LLVM upstream as is, however some
21-
modules of LLVM might be not included in the default project build
22-
configuration. Additional modules can be enabled by modifying build framework
23-
settings.
15+
Limitations include:
16+
* LevelZero backend support only.
17+
* Accessors and reductions are currently not supported.
2418

25-
The DPC++ goal is to support the latest SYCL\* standard and work on that is in
26-
progress. DPC++ also implements a number of extensions to the SYCL\* standard,
27-
which can be found in the [sycl/doc/extensions](/../sycl/sycl/doc/extensions)
28-
directory.
19+
### Other Material
2920

30-
The main purpose of this project is open source collaboration on the DPC++
31-
compiler implementation in LLVM across a variety of architectures, prototyping
32-
compiler and runtime library solutions, designing future extensions, and
33-
conducting experiments. As the implementation becomes more mature, we try to
34-
upstream as much DPC++ support to LLVM main branch as possible. See
35-
[SYCL upstreaming working group notes](/../../wiki/SYCL-upstreaming-working-group-meeting-notes)
36-
for more details.
21+
This extension was presented at the oneAPI Technical Advisory board (Sept'22 meeting). Slides: [https://github.com/oneapi-src/oneAPI-tab/blob/main/language/presentations/2022-09-28-TAB-SYCL-Graph.pdf](https://github.com/oneapi-src/oneAPI-tab/blob/main/language/presentations/2022-09-28-TAB-SYCL-Graph.pdf).
3722

38-
Note that this project can be used as a technical foundation for some
39-
proprietary compiler products, which may leverage implementations from this open
40-
source project. One of the examples is
41-
[Intel(R) oneAPI DPC++ Compiler](https://www.intel.com/content/www/us/en/developer/tools/oneapi/dpc-compiler.html)
42-
Features parity between this project and downstream projects is not guaranteed.
23+
## Intel Project for LLVM\* technology
4324

44-
Project documentation is available at:
45-
[DPC++ Documentation](https://intel.github.io/llvm-docs/).
25+
We target a contribution through the origin of this fork: [Intel staging area for llvm.org contributions](https://github.com/intel/llvm).
4626

4727
### How to use DPC++
4828

49-
#### Docker containers
50-
51-
See available containers with pre-built/pre-installed DPC++ compiler at:
52-
[Containers](/../sycl/sycl/doc/developer/DockerBKMs.md#sycl-containers-overview)
53-
5429
#### Releases
5530

56-
Daily builds of the sycl branch on Linux are available at
57-
[releases](/../../releases).
58-
A few times a year, we publish [Release Notes](/../sycl/sycl/ReleaseNotes.md) to
59-
highlight all important changes made in the project: features implemented and
60-
issues addressed. The corresponding builds can be found using
61-
[search](https://github.com/intel/llvm/releases?q=oneAPI+DPC%2B%2B+Compiler&expanded=true)
62-
in daily releases. None of the branches in the project are stable or rigorously
63-
tested for production quality control, so the quality of these releases is
64-
expected to be similar to the daily releases.
31+
TDB
6532

6633
#### Build from sources
6734

6835
See [Get Started Guide](/../sycl/sycl/doc/GetStartedGuide.md).
6936

37+
SYCL Graph support is enabled with:
38+
* Configuration script: `configure.py -enable-sycl-graph`.
39+
* CMake: `cmake -DSYCL_ENABLE_GRAPH`.
40+
41+
A fallback emulation mode is used otherwise that enables the graph API but eagerly submits kernels.
7042
### Report a problem
7143

7244
Submit an [issue](/../../issues) or initiate a [discussion](/../../discussions).
@@ -75,10 +47,6 @@ Submit an [issue](/../../issues) or initiate a [discussion](/../../discussions).
7547

7648
See [ContributeToDPCPP](/../sycl/sycl/doc/developer/ContributeToDPCPP.md).
7749

78-
## Late-outline OpenMP\* and OpenMP\* Offload
79-
80-
See [openmp](/../../tree/openmp) branch.
81-
8250
# License
8351

8452
See [LICENSE](/../sycl/sycl/LICENSE.TXT) for details.

buildbot/configure.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@ def do_configure(args):
4444
sycl_enable_xpti_tracing = 'ON'
4545
xpti_enable_werror = 'OFF'
4646

47+
sycl_enable_graph = 'OFF'
48+
4749
# lld is needed on Windows or for the HIP plugin on AMD
4850
if platform.system() == 'Windows' or (args.hip and args.hip_platform == 'AMD'):
4951
llvm_enable_projects += ';lld'
@@ -94,6 +96,9 @@ def do_configure(args):
9496

9597
if args.use_lld:
9698
llvm_enable_lld = 'ON'
99+
100+
if args.enable_sycl_graph:
101+
sycl_enable_graph = 'ON'
97102

98103
# CI Default conditionally appends to options, keep it at the bottom of
99104
# args handling
@@ -147,6 +152,7 @@ def do_configure(args):
147152
"-DLLVM_ENABLE_SPHINX={}".format(llvm_enable_sphinx),
148153
"-DBUILD_SHARED_LIBS={}".format(llvm_build_shared_libs),
149154
"-DSYCL_ENABLE_XPTI_TRACING={}".format(sycl_enable_xpti_tracing),
155+
"-DSYCL_ENABLE_GRAPH={}".format(sycl_enable_graph),
150156
"-DLLVM_ENABLE_LLD={}".format(llvm_enable_lld),
151157
"-DXPTI_ENABLE_WERROR={}".format(xpti_enable_werror),
152158
"-DSYCL_CLANG_EXTRA_FLAGS={}".format(sycl_clang_extra_flags),
@@ -216,6 +222,7 @@ def main():
216222
help="host LLVM target architecture, defaults to X86, multiple targets may be provided as a semi-colon separated string")
217223
parser.add_argument("--enable-esimd-emulator", action='store_true', help="build with ESIMD emulation support")
218224
parser.add_argument("--enable-all-llvm-targets", action='store_true', help="build compiler with all supported targets, it doesn't change runtime build")
225+
parser.add_argument("--enable-sycl-graph", action='store_true', help="build with SYCL Graph support")
219226
parser.add_argument("--no-assertions", action='store_true', help="build without assertions")
220227
parser.add_argument("--docs", action='store_true', help="build Doxygen documentation")
221228
parser.add_argument("--werror", action='store_true', help="Treat warnings as errors")

sycl/CMakeLists.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,13 @@ endif()
6363
# of the SYCL runtime and expect enabling
6464
option(SYCL_ENABLE_XPTI_TRACING "Enable tracing of SYCL constructs" OFF)
6565

66+
# Create a soft option for enabling or disabling the experimental support
67+
# for SYCl Graph
68+
option(SYCL_ENABLE_GRAPH "Enable experimental SYCL Graph support" OFF)
69+
if (SYCL_ENABLE_GRAPH)
70+
set(SYCL_BUILD_SYCL_GRAPH ON)
71+
endif()
72+
6673
if(MSVC)
6774
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
6875
# Skip asynchronous C++ exceptions catching and assume "extern C" functions

sycl/doc/GetStartedGuide.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@ flags can be found by launching the script with `--help`):
124124
* `--enable-esimd-emulator` -> enable ESIMD CPU emulation (see [ESIMD CPU emulation](#build-dpc-toolchain-with-support-for-esimd-cpu))
125125
* `--enable-all-llvm-targets` -> build compiler (but not a runtime) with all
126126
supported targets
127+
* `--enable-sycl-graph` -> build SYCL Graph support
127128
* `--shared-libs` -> Build shared libraries
128129
* `-t` -> Build type (Debug or Release)
129130
* `-o` -> Path to build directory

sycl/include/sycl/feature_test.hpp.in

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,10 @@ __SYCL_INLINE_VER_NAMESPACE(_V1) {
8484
#if SYCL_BUILD_PI_HIP
8585
#define SYCL_EXT_ONEAPI_BACKEND_HIP 1
8686
#endif
87+
#cmakedefine01 SYCL_BUILD_SYCL_GRAPH
88+
#if SYCL_BUILD_SYCL_GRAPH
89+
#define SYCL_EXT_ONEAPI_GRAPH 1
90+
#endif
8791

8892
} // __SYCL_INLINE_VER_NAMESPACE(_V1)
8993
} // namespace sycl

sycl/plugins/level_zero/pi_level_zero.cpp

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
#include <sstream>
2222
#include <string>
2323
#include <sycl/detail/spinlock.hpp>
24+
#include <sycl/feature_test.hpp>
2425
#include <thread>
2526
#include <utility>
2627

@@ -1306,7 +1307,8 @@ pi_result resetCommandLists(pi_queue Queue) {
13061307
pi_result _pi_context::getAvailableCommandList(
13071308
pi_queue Queue, pi_command_list_ptr_t &CommandList, bool UseCopyEngine,
13081309
bool AllowBatching, ze_command_queue_handle_t *ForcedCmdQueue) {
1309-
1310+
1311+
#if SYCL_EXT_ONEAPI_GRAPH
13101312
// This is a hack. TODO: Proper CommandList allocation per Executable Graph.
13111313
if( Queue->Properties & PI_EXT_ONEAPI_QUEUE_LAZY_EXECUTION ) {
13121314
// TODO: Create new Command List.
@@ -1346,6 +1348,7 @@ pi_result _pi_context::getAvailableCommandList(
13461348
}
13471349
return PI_SUCCESS;
13481350
}
1351+
#endif
13491352

13501353
// Immediate commandlists have been pre-allocated and are always available.
13511354
if (Queue->Device->useImmediateCommandLists()) {
@@ -1587,8 +1590,10 @@ pi_result _pi_queue::executeCommandList(pi_command_list_ptr_t CommandList,
15871590
bool OKToBatchCommand) {
15881591
// When executing a Graph, defer execution if this is a command
15891592
// which could be batched (i.e. likely a kernel submission)
1593+
#if SYCL_EXT_ONEAPI_GRAPH
15901594
if (this->Properties & PI_EXT_ONEAPI_QUEUE_LAZY_EXECUTION && OKToBatchCommand)
15911595
return PI_SUCCESS;
1596+
#endif
15921597

15931598
bool UseCopyEngine = CommandList->second.isCopy(this);
15941599

@@ -3830,6 +3835,7 @@ pi_result piQueueFinish(pi_queue Queue) {
38303835
// Flushing cross-queue dependencies is covered by createAndRetainPiZeEventList,
38313836
// so this can be left as a no-op.
38323837
pi_result piQueueFlush(pi_queue Queue) {
3838+
#if SYCL_EXT_ONEAPI_GRAPH
38333839
if( Queue->Properties & PI_EXT_ONEAPI_QUEUE_LAZY_EXECUTION ) {
38343840

38353841
pi_command_list_ptr_t CommandList{};
@@ -3838,6 +3844,9 @@ pi_result piQueueFlush(pi_queue Queue) {
38383844

38393845
Queue->executeCommandList(CommandList, false, false);
38403846
}
3847+
#else
3848+
(void)Queue;
3849+
#endif
38413850
return PI_SUCCESS;
38423851
}
38433852

sycl/source/detail/graph_impl.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#include <detail/queue_impl.hpp>
1111
#include <detail/scheduler/commands.hpp>
1212
#include <sycl/queue.hpp>
13+
#include <sycl/feature_test.hpp>
1314

1415
namespace sycl {
1516
__SYCL_INLINE_VER_NAMESPACE(_V1) {
@@ -35,10 +36,14 @@ void graph_impl::exec_and_wait(
3536
if (!IsSubGraph) {
3637
Queue->setIsGraphSubmitting(true);
3738
}
39+
#if SYCL_EXT_ONEAPI_GRAPH
3840
if (MFirst) {
3941
exec(Queue);
4042
MFirst = false;
4143
}
44+
#else
45+
exec(Queue);
46+
#endif
4247
if (!IsSubGraph) {
4348
Queue->setIsGraphSubmitting(false);
4449
Queue->wait();

sycl/source/detail/queue_impl.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
#include <sycl/context.hpp>
1313
#include <sycl/detail/pi.hpp>
1414
#include <sycl/device.hpp>
15+
#include <sycl/feature_test.hpp>
1516

1617
#include <cstring>
1718
#include <utility>
@@ -278,11 +279,13 @@ void queue_impl::wait(const detail::code_location &CodeLoc) {
278279
TelemetryEvent = instrumentationProlog(CodeLoc, Name, StreamID, IId);
279280
#endif
280281

282+
#if SYCL_EXT_ONEAPI_GRAPH
281283
if (has_property<ext::oneapi::property::queue::lazy_execution>()) {
282284
const detail::plugin &Plugin = getPlugin();
283285
if (Plugin.getBackend() == backend::ext_oneapi_level_zero)
284286
Plugin.call<detail::PiApiKind::piQueueFlush>(getHandleRef());
285287
}
288+
#endif
286289

287290
std::vector<std::weak_ptr<event_impl>> WeakEvents;
288291
std::vector<event> SharedEvents;

0 commit comments

Comments
 (0)