Skip to content

Commit

Permalink
Update sycl_ext_oneapi_graph.asciidoc
Browse files Browse the repository at this point in the history
  • Loading branch information
reble authored Nov 23, 2022
1 parent baeb701 commit 4ecdd3f
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions sycl/doc/extensions/proposed/sycl_ext_oneapi_graph.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -859,14 +859,16 @@ implementation is currently under development.
#include <sycl/ext/oneapi/experimental/graph.hpp>
int main() {
using namespace sycl::ext::oneapi::experimental;
const size_t n = 10;
float alpha = 1.0f;
float beta = 2.0f;
float gamma = 3.0f;
sycl::queue q;
sycl::ext::oneapi::experimental::command_graph g;
command_graph g;
float *x , *y, *z;
Expand Down Expand Up @@ -896,21 +898,21 @@ int main() {
y[i] = 2.0f;
z[i] = 3.0f;
});
}, { sycl::ext::oneapi::experimental::property::node::depends_on(node_x, node_y, node_z)});
}, { property::node::depends_on(node_x, node_y, node_z)});
auto node_a = g.add([&](sycl::handler &h) {
h.parallel_for(sycl::range<1>{n}, [=](sycl::id<1> it) {
const size_t i = it[0];
x[i] = alpha * x[i] + beta * y[i];
});
}, { sycl::ext::oneapi::experimental::property::node::depends_on(node_i)});
}, { property::node::depends_on(node_i)});
auto node_b = g.add([&](sycl::handler &h) {
h.parallel_for(sycl::range<1>{n}, [=](sycl::id<1> it) {
const size_t i = it[0];
z[i] = gamma * z[i] + beta * y[i];
});
}, { sycl::ext::oneapi::experimental::property::node::depends_on(node_i)});
}, { property::node::depends_on(node_i)});
auto node_c = g.add(
[&](sycl::handler &h) {
Expand All @@ -921,10 +923,10 @@ int main() {
sum += x[i] * z[i];
});
},
{ sycl::ext::oneapi::experimental::property::node::depends_on(node_a, node_b)});
{ property::node::depends_on(node_a, node_b)});
auto node_fx = g.add_free(x, {sycl::ext::oneapi::experimental::property::node::depends_on(node_c)});
auto node_fy = g.add_free(y, {sycl::ext::oneapi::experimental::property::node::depends_on(node_b)});
auto node_fx = g.add_free(x, {property::node::depends_on(node_c)});
auto node_fy = g.add_free(y, {property::node::depends_on(node_b)});
auto exec = g.finalize(q.get_context());
Expand Down

0 comments on commit 4ecdd3f

Please sign in to comment.