diff --git a/sycl/doc/extensions/experimental/sycl_ext_oneapi_graph.asciidoc b/sycl/doc/extensions/experimental/sycl_ext_oneapi_graph.asciidoc index 4dab18e3de7f..40b08cf7a6e5 100644 --- a/sycl/doc/extensions/experimental/sycl_ext_oneapi_graph.asciidoc +++ b/sycl/doc/extensions/experimental/sycl_ext_oneapi_graph.asciidoc @@ -1258,6 +1258,29 @@ _Throws:_ Synchronously `exception` with error code `invalid` if the device associated with `syclQueue` <>. +[source,c++] +---- +command_graph(const device& syclDevice, + const property_list& propList = {}); +---- + +_Effects:_ Simplified constructor form where only device `syclDevice` is provided +without explicitly passing a context. The graph uses the platform's default context. +Zero or more properties can be provided to the constructed SYCL `command_graph` +via an instance of `property_list`. All other properties of the queue are +ignored for the purposes of graph creation. See the +<> section for more general information +about how queue properties interact with `command_graph` objects. + +_Constraints:_ This constructor is only available when the `command_graph` state is +`graph_state::modifiable`. + +_Preconditions:_ Valid `command_graph` constructor properties are listed in +Section <>. + +_Throws:_ Synchronously `exception` with error code `invalid` if `syclDevice` + <>. + ===== Member functions of the `command_graph` class [source,c++] diff --git a/sycl/include/sycl/ext/oneapi/experimental/graph/command_graph.hpp b/sycl/include/sycl/ext/oneapi/experimental/graph/command_graph.hpp index 2fd1be9e4106..b21336d608a9 100644 --- a/sycl/include/sycl/ext/oneapi/experimental/graph/command_graph.hpp +++ b/sycl/include/sycl/ext/oneapi/experimental/graph/command_graph.hpp @@ -101,6 +101,13 @@ class command_graph : public detail::modifiable_command_graph { const property_list &PropList = {}) : modifiable_command_graph(SyclQueue, PropList) {} + /// Constructor with default context. + /// @param SyclDevice Device all nodes will be associated with. + /// @param PropList Optional list of properties to pass. + explicit command_graph(const device &SyclDevice, + const property_list &PropList = {}) + : modifiable_command_graph(SyclDevice, PropList) {} + private: /// Constructor used internally by the runtime. /// @param Impl Detail implementation class to construct object with. diff --git a/sycl/include/sycl/ext/oneapi/experimental/graph/modifiable_graph.hpp b/sycl/include/sycl/ext/oneapi/experimental/graph/modifiable_graph.hpp index f84654f1ef31..99808f76575f 100644 --- a/sycl/include/sycl/ext/oneapi/experimental/graph/modifiable_graph.hpp +++ b/sycl/include/sycl/ext/oneapi/experimental/graph/modifiable_graph.hpp @@ -55,6 +55,12 @@ class __SYCL_EXPORT modifiable_command_graph modifiable_command_graph(const queue &SyclQueue, const property_list &PropList = {}); + /// Constructor with default context. + /// @param SyclDevice Device all nodes will be associated with. + /// @param PropList Optional list of properties to pass. + modifiable_command_graph(const device &SyclDevice, + const property_list &PropList = {}); + /// Add an empty node to the graph. /// @param PropList Property list used to pass [0..n] predecessor nodes. /// @return Constructed empty node which has been added to the graph. diff --git a/sycl/source/detail/graph/graph_impl.cpp b/sycl/source/detail/graph/graph_impl.cpp index 70b96eaa8660..5569d73cdfb3 100644 --- a/sycl/source/detail/graph/graph_impl.cpp +++ b/sycl/source/detail/graph/graph_impl.cpp @@ -1806,6 +1806,12 @@ modifiable_command_graph::modifiable_command_graph( : impl(std::make_shared( SyclQueue.get_context(), SyclQueue.get_device(), PropList)) {} +modifiable_command_graph::modifiable_command_graph( + const sycl::device &SyclDevice, const sycl::property_list &PropList) + : impl(std::make_shared( + SyclDevice.get_platform().khr_get_default_context(), SyclDevice, + PropList)) {} + node modifiable_command_graph::addImpl(dynamic_command_group &DynCGF, const std::vector &Deps) { impl->throwIfGraphRecordingQueue("Explicit API \"Add()\" function"); diff --git a/sycl/test-e2e/Graph/Inputs/basic_usm.cpp b/sycl/test-e2e/Graph/Inputs/basic_usm.cpp index 223149827670..828d2648a980 100644 --- a/sycl/test-e2e/Graph/Inputs/basic_usm.cpp +++ b/sycl/test-e2e/Graph/Inputs/basic_usm.cpp @@ -18,7 +18,7 @@ int main() { calculate_reference_data(Iterations, Size, ReferenceA, ReferenceB, ReferenceC); - exp_ext::command_graph Graph{Queue.get_context(), Queue.get_device()}; + exp_ext::command_graph Graph{Queue.get_device()}; T *PtrA = malloc_device(Size, Queue); T *PtrB = malloc_device(Size, Queue); diff --git a/sycl/test/abi/sycl_symbols_linux.dump b/sycl/test/abi/sycl_symbols_linux.dump index e9f65ce66248..ab6d37ae7108 100644 --- a/sycl/test/abi/sycl_symbols_linux.dump +++ b/sycl/test/abi/sycl_symbols_linux.dump @@ -3113,8 +3113,10 @@ _ZN4sycl3_V13ext6oneapi12experimental6detail24modifiable_command_graph7addImplER _ZN4sycl3_V13ext6oneapi12experimental6detail24modifiable_command_graph7addImplESt8functionIFvRNS0_7handlerEEERKSt6vectorINS3_4nodeESaISC_EE _ZN4sycl3_V13ext6oneapi12experimental6detail24modifiable_command_graph9make_edgeERNS3_4nodeES7_ _ZN4sycl3_V13ext6oneapi12experimental6detail24modifiable_command_graphC1ERKNS0_5queueERKNS0_13property_listE +_ZN4sycl3_V13ext6oneapi12experimental6detail24modifiable_command_graphC1ERKNS0_6deviceERKNS0_13property_listE _ZN4sycl3_V13ext6oneapi12experimental6detail24modifiable_command_graphC1ERKNS0_7contextERKNS0_6deviceERKNS0_13property_listE _ZN4sycl3_V13ext6oneapi12experimental6detail24modifiable_command_graphC2ERKNS0_5queueERKNS0_13property_listE +_ZN4sycl3_V13ext6oneapi12experimental6detail24modifiable_command_graphC2ERKNS0_6deviceERKNS0_13property_listE _ZN4sycl3_V13ext6oneapi12experimental6detail24modifiable_command_graphC2ERKNS0_7contextERKNS0_6deviceERKNS0_13property_listE _ZN4sycl3_V13ext6oneapi12experimental6detail27dynamic_local_accessor_base19updateLocalAccessorENS0_5rangeILi3EEE _ZN4sycl3_V13ext6oneapi12experimental6detail27dynamic_local_accessor_baseC1ENS0_5rangeILi3EEEiiRKNS0_13property_listE diff --git a/sycl/test/abi/sycl_symbols_windows.dump b/sycl/test/abi/sycl_symbols_windows.dump index b3453854edec..b91c10147570 100644 --- a/sycl/test/abi/sycl_symbols_windows.dump +++ b/sycl/test/abi/sycl_symbols_windows.dump @@ -466,6 +466,7 @@ ??0modifiable_command_graph@detail@experimental@oneapi@ext@_V1@sycl@@QEAA@$$QEAV0123456@@Z ??0modifiable_command_graph@detail@experimental@oneapi@ext@_V1@sycl@@QEAA@AEBV0123456@@Z ??0modifiable_command_graph@detail@experimental@oneapi@ext@_V1@sycl@@QEAA@AEBVcontext@56@AEBVdevice@56@AEBVproperty_list@56@@Z +??0modifiable_command_graph@detail@experimental@oneapi@ext@_V1@sycl@@QEAA@AEBVdevice@56@AEBVproperty_list@56@@Z ??0modifiable_command_graph@detail@experimental@oneapi@ext@_V1@sycl@@QEAA@AEBVqueue@56@AEBVproperty_list@56@@Z ??0node@experimental@oneapi@ext@_V1@sycl@@AEAA@AEBV?$shared_ptr@Vnode_impl@detail@experimental@oneapi@ext@_V1@sycl@@@std@@@Z ??0node@experimental@oneapi@ext@_V1@sycl@@QEAA@$$QEAV012345@@Z