Skip to content

Commit e0ccfda

Browse files
reblemmichel11
andauthored
[SYCL][Graph] Adding new constructor with default context (#20044)
This patch adds a new `command_graph` constructor with user provided device only and using default context. --------- Co-authored-by: Matthew Michel <[email protected]>
1 parent 3906cea commit e0ccfda

File tree

7 files changed

+46
-1
lines changed

7 files changed

+46
-1
lines changed

sycl/doc/extensions/experimental/sycl_ext_oneapi_graph.asciidoc

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1258,6 +1258,29 @@ _Throws:_ Synchronously `exception` with error code `invalid` if the device
12581258
associated with
12591259
`syclQueue` <<device-info-query, reports this extension as unsupported>>.
12601260

1261+
[source,c++]
1262+
----
1263+
command_graph(const device& syclDevice,
1264+
const property_list& propList = {});
1265+
----
1266+
1267+
_Effects:_ Simplified constructor form where only device `syclDevice` is provided
1268+
without explicitly passing a context. The graph uses the platform's default context.
1269+
Zero or more properties can be provided to the constructed SYCL `command_graph`
1270+
via an instance of `property_list`. All other properties of the queue are
1271+
ignored for the purposes of graph creation. See the
1272+
<<Queue Properties, Queue Properties>> section for more general information
1273+
about how queue properties interact with `command_graph` objects.
1274+
1275+
_Constraints:_ This constructor is only available when the `command_graph` state is
1276+
`graph_state::modifiable`.
1277+
1278+
_Preconditions:_ Valid `command_graph` constructor properties are listed in
1279+
Section <<graph-properties, Graph Properties>>.
1280+
1281+
_Throws:_ Synchronously `exception` with error code `invalid` if `syclDevice`
1282+
<<device-info-query, reports this extension as unsupported>>.
1283+
12611284
===== Member functions of the `command_graph` class
12621285

12631286
[source,c++]

sycl/include/sycl/ext/oneapi/experimental/graph/command_graph.hpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,13 @@ class command_graph : public detail::modifiable_command_graph {
101101
const property_list &PropList = {})
102102
: modifiable_command_graph(SyclQueue, PropList) {}
103103

104+
/// Constructor with default context.
105+
/// @param SyclDevice Device all nodes will be associated with.
106+
/// @param PropList Optional list of properties to pass.
107+
explicit command_graph(const device &SyclDevice,
108+
const property_list &PropList = {})
109+
: modifiable_command_graph(SyclDevice, PropList) {}
110+
104111
private:
105112
/// Constructor used internally by the runtime.
106113
/// @param Impl Detail implementation class to construct object with.

sycl/include/sycl/ext/oneapi/experimental/graph/modifiable_graph.hpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,12 @@ class __SYCL_EXPORT modifiable_command_graph
5555
modifiable_command_graph(const queue &SyclQueue,
5656
const property_list &PropList = {});
5757

58+
/// Constructor with default context.
59+
/// @param SyclDevice Device all nodes will be associated with.
60+
/// @param PropList Optional list of properties to pass.
61+
modifiable_command_graph(const device &SyclDevice,
62+
const property_list &PropList = {});
63+
5864
/// Add an empty node to the graph.
5965
/// @param PropList Property list used to pass [0..n] predecessor nodes.
6066
/// @return Constructed empty node which has been added to the graph.

sycl/source/detail/graph/graph_impl.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1806,6 +1806,12 @@ modifiable_command_graph::modifiable_command_graph(
18061806
: impl(std::make_shared<detail::graph_impl>(
18071807
SyclQueue.get_context(), SyclQueue.get_device(), PropList)) {}
18081808

1809+
modifiable_command_graph::modifiable_command_graph(
1810+
const sycl::device &SyclDevice, const sycl::property_list &PropList)
1811+
: impl(std::make_shared<detail::graph_impl>(
1812+
SyclDevice.get_platform().khr_get_default_context(), SyclDevice,
1813+
PropList)) {}
1814+
18091815
node modifiable_command_graph::addImpl(dynamic_command_group &DynCGF,
18101816
const std::vector<node> &Deps) {
18111817
impl->throwIfGraphRecordingQueue("Explicit API \"Add()\" function");

sycl/test-e2e/Graph/Inputs/basic_usm.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ int main() {
1818
calculate_reference_data(Iterations, Size, ReferenceA, ReferenceB,
1919
ReferenceC);
2020

21-
exp_ext::command_graph Graph{Queue.get_context(), Queue.get_device()};
21+
exp_ext::command_graph Graph{Queue.get_device()};
2222

2323
T *PtrA = malloc_device<T>(Size, Queue);
2424
T *PtrB = malloc_device<T>(Size, Queue);

sycl/test/abi/sycl_symbols_linux.dump

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3113,8 +3113,10 @@ _ZN4sycl3_V13ext6oneapi12experimental6detail24modifiable_command_graph7addImplER
31133113
_ZN4sycl3_V13ext6oneapi12experimental6detail24modifiable_command_graph7addImplESt8functionIFvRNS0_7handlerEEERKSt6vectorINS3_4nodeESaISC_EE
31143114
_ZN4sycl3_V13ext6oneapi12experimental6detail24modifiable_command_graph9make_edgeERNS3_4nodeES7_
31153115
_ZN4sycl3_V13ext6oneapi12experimental6detail24modifiable_command_graphC1ERKNS0_5queueERKNS0_13property_listE
3116+
_ZN4sycl3_V13ext6oneapi12experimental6detail24modifiable_command_graphC1ERKNS0_6deviceERKNS0_13property_listE
31163117
_ZN4sycl3_V13ext6oneapi12experimental6detail24modifiable_command_graphC1ERKNS0_7contextERKNS0_6deviceERKNS0_13property_listE
31173118
_ZN4sycl3_V13ext6oneapi12experimental6detail24modifiable_command_graphC2ERKNS0_5queueERKNS0_13property_listE
3119+
_ZN4sycl3_V13ext6oneapi12experimental6detail24modifiable_command_graphC2ERKNS0_6deviceERKNS0_13property_listE
31183120
_ZN4sycl3_V13ext6oneapi12experimental6detail24modifiable_command_graphC2ERKNS0_7contextERKNS0_6deviceERKNS0_13property_listE
31193121
_ZN4sycl3_V13ext6oneapi12experimental6detail27dynamic_local_accessor_base19updateLocalAccessorENS0_5rangeILi3EEE
31203122
_ZN4sycl3_V13ext6oneapi12experimental6detail27dynamic_local_accessor_baseC1ENS0_5rangeILi3EEEiiRKNS0_13property_listE

sycl/test/abi/sycl_symbols_windows.dump

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -466,6 +466,7 @@
466466
??0modifiable_command_graph@detail@experimental@oneapi@ext@_V1@sycl@@QEAA@$$QEAV0123456@@Z
467467
??0modifiable_command_graph@detail@experimental@oneapi@ext@_V1@sycl@@QEAA@AEBV0123456@@Z
468468
??0modifiable_command_graph@detail@experimental@oneapi@ext@_V1@sycl@@QEAA@AEBVcontext@56@AEBVdevice@56@AEBVproperty_list@56@@Z
469+
??0modifiable_command_graph@detail@experimental@oneapi@ext@_V1@sycl@@QEAA@AEBVdevice@56@AEBVproperty_list@56@@Z
469470
??0modifiable_command_graph@detail@experimental@oneapi@ext@_V1@sycl@@QEAA@AEBVqueue@56@AEBVproperty_list@56@@Z
470471
??0node@experimental@oneapi@ext@_V1@sycl@@AEAA@AEBV?$shared_ptr@Vnode_impl@detail@experimental@oneapi@ext@_V1@sycl@@@std@@@Z
471472
??0node@experimental@oneapi@ext@_V1@sycl@@QEAA@$$QEAV012345@@Z

0 commit comments

Comments
 (0)