Skip to content

Commit aafd749

Browse files
committed
[SYCL][Graph] Adding new constructor with default context
1 parent fcd35c0 commit aafd749

File tree

4 files changed

+20
-1
lines changed

4 files changed

+20
-1
lines changed

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);

0 commit comments

Comments
 (0)