Skip to content

Commit

Permalink
Update usage examples after graph API changes
Browse files Browse the repository at this point in the history
Signed-off-by: Lukas Sommer <lukas.sommer@codeplay.com>
  • Loading branch information
sommerlukas committed Apr 11, 2023
1 parent a306722 commit 1afafe9
Showing 1 changed file with 22 additions and 17 deletions.
39 changes: 22 additions & 17 deletions sycl/doc/extensions/proposed/sycl_ext_oneapi_graph_fusion.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -465,33 +465,38 @@ int main() {

queue q{default_selector_v};

ext::oneapi::experimental::command_graph graph;
ext::oneapi::experimental::command_graph graph{q.get_context(),
q.get_device()};
{
buffer<int> bIn1{in1, range{dataSize}};
buffer<int> bIn2{in2, range{dataSize}};
buffer<int> bIn3{in3, range{dataSize}};
buffer<int> bTmp1{tmp1, range{dataSize}};
// Internalization specified on the buffer
buffer<int> bTmp2{tmp2, range{dataSize},
{sycl::ext::oneapi::experimental::property::promote_private{}}};
buffer<int> bTmp2{
tmp2,
range{dataSize},
{sycl::ext::oneapi::experimental::property::promote_private{}}};
// Internalization specified on the buffer
buffer<int> bTmp3{tmp3, range{dataSize},
{sycl::ext::oneapi::experimental::property::promote_private{}}};
buffer<int> bTmp3{
tmp3,
range{dataSize},
{sycl::ext::oneapi::experimental::property::promote_private{}}};
buffer<int> bOut{out, range{dataSize}};

graph.begin_recording(q);

q.submit([&](handler &cgh) {
auto accIn1 = bIn1.get_access(cgh);
auto accIn2 = bIn2.get_access(cgh);
// Internalization specified on each accessor.
// Internalization specified on each accessor.
auto accTmp1 = bTmp1.get_access(
cgh, sycl::ext::oneapi::experimental::property::promote_private{});
cgh.parallel_for<AddKernel>(dataSize, AddKernel{accIn1, accIn2, accTmp1});
});

q.submit([&](handler &cgh) {
// Internalization specified on each accessor.
// Internalization specified on each accessor.
auto accTmp1 = bTmp1.get_access(
cgh, sycl::ext::oneapi::experimental::property::promote_private{});
auto accIn3 = bIn3.get_access(cgh);
Expand All @@ -501,7 +506,7 @@ int main() {
});

q.submit([&](handler &cgh) {
// Internalization specified on each accessor.
// Internalization specified on each accessor.
auto accTmp1 = bTmp1.get_access(
cgh, sycl::ext::oneapi::experimental::property::promote_private{});
auto accTmp3 = bTmp3.get_access(cgh);
Expand All @@ -520,12 +525,11 @@ int main() {
graph.end_recording();

// Trigger fusion during finalization.
auto exec_graph = graph.finalize(q.get_context(),
{sycl::ext::oneapi::experimental::property::command_graph::perform_fusion});
auto exec_graph =
graph.finalize({sycl::ext::oneapi::experimental::property::
command_graph::perform_fusion});

q.submit([&](handler& cgh) {
cgh.ext_oneapi_graph(exec_graph);
});
q.ext_oneapi_graph(exec_graph);
}
return 0;
}
Expand All @@ -548,7 +552,7 @@ int main() {

queue q{default_selector_v};

sycl_ext::command_graph graph;
sycl_ext::command_graph graph{q.get_context(), q.get_device()};

int *dIn1, dIn2, dIn3, dTmp, dOut;

Expand All @@ -558,7 +562,8 @@ int main() {
dOut = malloc_device<int>(q, dataSize);

// Specify internalization for an USM pointer
dTmp = malloc_device<int>(q, dataSize,
dTmp = malloc_device<int>(
q, dataSize,
{sycl::ext::oneapi::experimental::property::promote_private});

// This explicit memory operation is compatible with fusion, as it can be
Expand Down Expand Up @@ -597,8 +602,7 @@ int main() {
{sycl_ext::property::node::depends_on(kernel2)});

// Trigger fusion during finalization.
auto exec = graph.finalize(q.get_context(),
{sycl::ext::oneapi::experimental::property::
auto exec = graph.finalize({sycl::ext::oneapi::experimental::property::
command_graph::perform_fusion});

// use queue shortcut for graph submission
Expand Down Expand Up @@ -630,4 +634,5 @@ Ewan Crawford, Codeplay +
|Rev|Date|Authors|Changes
|1|2023-02-16|Lukas Sommer|*Initial draft*
|2|2023-03-16|Lukas Sommer|*Remove reference to outdated `add_malloc_device` API*
|3|2023-04-11|Lukas Sommer|*Update usage examples for graph API changes*
|========================================

0 comments on commit 1afafe9

Please sign in to comment.