Skip to content

Commit 258fc72

Browse files
author
Hugh Delaney
authored
[SYCL][Graphs] Fix whole graph update raw arg test (#16377)
Update is only allowed if the kernel object that the graph is being updated with is the same as the kernel that the graph was created with. Calling `ext_oneapi_get_kernel` is creating a new SYCL kernel object for each invocation, since the implementation doesn't cache kernels for kernel bundles. The user should not assume the caching of kernels, so must use the same kernel objects each time for update.
1 parent 1fba00d commit 258fc72

File tree

1 file changed

+16
-15
lines changed

1 file changed

+16
-15
lines changed

sycl/test-e2e/Graph/Inputs/whole_update_raw_arg.cpp

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,17 @@
44

55
void SubmitKernelNode(
66
exp_ext::command_graph<exp_ext::graph_state::modifiable> Graph, queue Queue,
7-
int32_t *Ptr, exp_ext::raw_kernel_arg &RawArg) {
7+
int32_t *Ptr, exp_ext::raw_kernel_arg &RawArg, kernel Kernel) {
8+
9+
add_node(Graph, Queue, [&](handler &cgh) {
10+
cgh.set_arg(0, RawArg);
11+
cgh.set_arg(1, Ptr);
12+
cgh.parallel_for(sycl::range<1>{Size}, Kernel);
13+
});
14+
}
15+
16+
int main() {
17+
queue Queue{};
818

919
auto constexpr CLSource = R"===(
1020
__kernel void RawArgKernel(int scalar, __global int *out) {
@@ -17,18 +27,9 @@ __kernel void RawArgKernel(int scalar, __global int *out) {
1727
sycl::ext::oneapi::experimental::create_kernel_bundle_from_source(
1828
Queue.get_context(),
1929
sycl::ext::oneapi::experimental::source_language::opencl, CLSource);
20-
auto ExecKB = sycl::ext::oneapi::experimental::build(SourceKB);
21-
22-
add_node(Graph, Queue, [&](handler &cgh) {
23-
cgh.set_arg(0, RawArg);
24-
cgh.set_arg(1, Ptr);
25-
cgh.parallel_for(sycl::range<1>{Size},
26-
ExecKB.ext_oneapi_get_kernel("RawArgKernel"));
27-
});
28-
}
29-
30-
int main() {
31-
queue Queue{};
30+
auto Kernel =
31+
sycl::ext::oneapi::experimental::build(SourceKB).ext_oneapi_get_kernel(
32+
"RawArgKernel");
3233

3334
exp_ext::command_graph GraphA{Queue};
3435

@@ -40,7 +41,7 @@ int main() {
4041
sycl::ext::oneapi::experimental::raw_kernel_arg RawScalarA(&ScalarA,
4142
sizeof(int32_t));
4243

43-
SubmitKernelNode(GraphA, Queue, PtrA, RawScalarA);
44+
SubmitKernelNode(GraphA, Queue, PtrA, RawScalarA, Kernel);
4445
auto ExecGraphA = GraphA.finalize(exp_ext::property::graph::updatable{});
4546

4647
// PtrA should be filled with values based on ScalarA
@@ -62,7 +63,7 @@ int main() {
6263
sizeof(int32_t));
6364

6465
// Swap ScalarB and PtrB to be the new inputs/outputs
65-
SubmitKernelNode(GraphB, Queue, PtrB, RawScalarB);
66+
SubmitKernelNode(GraphB, Queue, PtrB, RawScalarB, Kernel);
6667
ExecGraphA.update(GraphB);
6768
Queue.ext_oneapi_graph(ExecGraphA).wait();
6869

0 commit comments

Comments
 (0)