Skip to content

Commit 66867d4

Browse files
authored
[SYCL][Graph] Adding new graph enqueue function to spec (#15677)
replacing #15385 after offline discussion.
1 parent e7e3b96 commit 66867d4

File tree

6 files changed

+48
-5
lines changed

6 files changed

+48
-5
lines changed

sycl/doc/extensions/experimental/sycl_ext_oneapi_enqueue_functions.asciidoc

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -716,6 +716,34 @@ optimize such partial barriers.
716716
_{endnote}_]
717717
|====
718718

719+
==== Command Graph
720+
721+
The functions in this section are only available if the
722+
link:./sycl_ext_oneapi_graph.asciidoc[
723+
sycl_ext_oneapi_graph] extension is supported.
724+
725+
|====
726+
a|
727+
[frame=all,grid=none]
728+
!====
729+
a!
730+
[source,c++]
731+
----
732+
namespace sycl::ext::oneapi::experimental {
733+
734+
void execute_graph(sycl::queue q, command_graph<graph_state::executable> &g);
735+
736+
void execute_graph(sycl::handler &h, command_graph<graph_state::executable> &g);
737+
738+
}
739+
----
740+
!====
741+
_Constraints_: Device and context associated with queue need to be identical
742+
to device and context provided at command graph creation.
743+
744+
_Effects_: Submits an executable command graph to the `sycl::queue` or `sycl::handler`.
745+
746+
|====
719747

720748
== Issues
721749

sycl/doc/extensions/experimental/sycl_ext_oneapi_graph.asciidoc

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1975,7 +1975,9 @@ Removing this restriction is something we may look at for future revisions of
19751975

19761976
The command submission functions defined in
19771977
link:../experimental/sycl_ext_oneapi_enqueue_functions.asciidoc[sycl_ext_oneapi_enqueue_functions]
1978-
can be used to add nodes to a graph when creating a graph from queue recording.
1978+
can be used adding nodes to a graph when creating a graph from queue recording.
1979+
New methods are also defined that enable submitting an executable graph,
1980+
e.g. directly to a queue without returning an event.
19791981

19801982
== Examples and Usage Guide
19811983

sycl/include/sycl/ext/oneapi/experimental/enqueue_functions.hpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212

1313
#include <sycl/detail/common.hpp>
1414
#include <sycl/event.hpp>
15+
#include <sycl/ext/oneapi/experimental/graph.hpp>
1516
#include <sycl/ext/oneapi/properties/properties.hpp>
1617
#include <sycl/handler.hpp>
1718
#include <sycl/nd_range.hpp>
@@ -383,6 +384,17 @@ inline void partial_barrier(queue Q, const std::vector<event> &Events,
383384
submit(Q, [&](handler &CGH) { partial_barrier(CGH, Events); }, CodeLoc);
384385
}
385386

387+
inline void execute_graph(queue Q, command_graph<graph_state::executable> &G,
388+
const sycl::detail::code_location &CodeLoc =
389+
sycl::detail::code_location::current()) {
390+
Q.ext_oneapi_graph(G, CodeLoc);
391+
}
392+
393+
inline void execute_graph(handler &CGH,
394+
command_graph<graph_state::executable> &G) {
395+
CGH.ext_oneapi_graph(G);
396+
}
397+
386398
} // namespace ext::oneapi::experimental
387399
} // namespace _V1
388400
} // namespace sycl

sycl/test-e2e/Graph/RecordReplay/ext_oneapi_enqueue_functions.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ int main() {
4343

4444
auto GraphExec = Graph.finalize();
4545

46-
InOrderQueue.submit([&](handler &CGH) { CGH.ext_oneapi_graph(GraphExec); });
46+
exp_ext::execute_graph(InOrderQueue, GraphExec);
4747
InOrderQueue.wait_and_throw();
4848

4949
free(PtrA, InOrderQueue);

sycl/test-e2e/Graph/RecordReplay/ext_oneapi_enqueue_functions_submit.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ int main() {
6060

6161
auto GraphExec = Graph.finalize();
6262

63-
Queue.submit([&](handler &CGH) { CGH.ext_oneapi_graph(GraphExec); });
63+
exp_ext::execute_graph(Queue, GraphExec);
6464
Queue.wait_and_throw();
6565
}
6666

sycl/test-e2e/Graph/RecordReplay/ext_oneapi_enqueue_functions_submit_with_event.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,9 @@ int main() {
5252

5353
auto GraphExec = Graph.finalize();
5454

55-
Queue.submit([&](handler &CGH) { CGH.ext_oneapi_graph(GraphExec); });
56-
Queue.wait_and_throw();
55+
exp_ext::submit_with_event(Queue, [&](handler &CGH) {
56+
exp_ext::execute_graph(CGH, GraphExec);
57+
}).wait();
5758

5859
free(PtrA, Queue);
5960
free(PtrB, Queue);

0 commit comments

Comments
 (0)