Skip to content

Commit eb38e6c

Browse files
committed
Update usage examples after graph API changes
Signed-off-by: Lukas Sommer <lukas.sommer@codeplay.com>
1 parent 11a4e03 commit eb38e6c

File tree

1 file changed

+22
-17
lines changed

1 file changed

+22
-17
lines changed

sycl/doc/extensions/proposed/sycl_ext_oneapi_graph_fusion.asciidoc

Lines changed: 22 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -465,33 +465,38 @@ int main() {
465465

466466
queue q{default_selector_v};
467467

468-
ext::oneapi::experimental::command_graph graph;
468+
ext::oneapi::experimental::command_graph graph{q.get_context(),
469+
q.get_device()};
469470
{
470471
buffer<int> bIn1{in1, range{dataSize}};
471472
buffer<int> bIn2{in2, range{dataSize}};
472473
buffer<int> bIn3{in3, range{dataSize}};
473474
buffer<int> bTmp1{tmp1, range{dataSize}};
474475
// Internalization specified on the buffer
475-
buffer<int> bTmp2{tmp2, range{dataSize},
476-
{sycl::ext::oneapi::experimental::property::promote_private{}}};
476+
buffer<int> bTmp2{
477+
tmp2,
478+
range{dataSize},
479+
{sycl::ext::oneapi::experimental::property::promote_private{}}};
477480
// Internalization specified on the buffer
478-
buffer<int> bTmp3{tmp3, range{dataSize},
479-
{sycl::ext::oneapi::experimental::property::promote_private{}}};
481+
buffer<int> bTmp3{
482+
tmp3,
483+
range{dataSize},
484+
{sycl::ext::oneapi::experimental::property::promote_private{}}};
480485
buffer<int> bOut{out, range{dataSize}};
481486

482487
graph.begin_recording(q);
483488

484489
q.submit([&](handler &cgh) {
485490
auto accIn1 = bIn1.get_access(cgh);
486491
auto accIn2 = bIn2.get_access(cgh);
487-
// Internalization specified on each accessor.
492+
// Internalization specified on each accessor.
488493
auto accTmp1 = bTmp1.get_access(
489494
cgh, sycl::ext::oneapi::experimental::property::promote_private{});
490495
cgh.parallel_for<AddKernel>(dataSize, AddKernel{accIn1, accIn2, accTmp1});
491496
});
492497

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

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

522527
// Trigger fusion during finalization.
523-
auto exec_graph = graph.finalize(q.get_context(),
524-
{sycl::ext::oneapi::experimental::property::command_graph::perform_fusion});
528+
auto exec_graph =
529+
graph.finalize({sycl::ext::oneapi::experimental::property::
530+
command_graph::perform_fusion});
525531

526-
q.submit([&](handler& cgh) {
527-
cgh.ext_oneapi_graph(exec_graph);
528-
});
532+
q.ext_oneapi_graph(exec_graph);
529533
}
530534
return 0;
531535
}
@@ -548,7 +552,7 @@ int main() {
548552

549553
queue q{default_selector_v};
550554

551-
sycl_ext::command_graph graph;
555+
sycl_ext::command_graph graph{q.get_context(), q.get_device()};
552556

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

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

560564
// Specify internalization for an USM pointer
561-
dTmp = malloc_device<int>(q, dataSize,
565+
dTmp = malloc_device<int>(
566+
q, dataSize,
562567
{sycl::ext::oneapi::experimental::property::promote_private});
563568

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

599604
// Trigger fusion during finalization.
600-
auto exec = graph.finalize(q.get_context(),
601-
{sycl::ext::oneapi::experimental::property::
605+
auto exec = graph.finalize({sycl::ext::oneapi::experimental::property::
602606
command_graph::perform_fusion});
603607

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

0 commit comments

Comments
 (0)