Skip to content
This repository was archived by the owner on Mar 28, 2023. It is now read-only.

Commit ce06671

Browse files
authored
[SYCL] Check that the kernel executes before a submitted barrier, in addition to testing if the barrier completes (#160)
1 parent 5ad0692 commit ce06671

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed

SYCL/Basic/barrier_order.cpp

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
// RUN: %clangxx -fsycl -fsycl-targets=%sycl_triple %s -o %t.out
2+
// RUN: %HOST_RUN_PLACEHOLDER %t.out
3+
// RUN: %CPU_RUN_PLACEHOLDER %t.out
4+
// RUN: %GPU_RUN_PLACEHOLDER %t.out
5+
6+
// UNSUPPORTED: cuda
7+
8+
#include <CL/sycl.hpp>
9+
#include <stdlib.h>
10+
11+
int main() {
12+
sycl::device dev{sycl::default_selector{}};
13+
sycl::queue q{dev};
14+
15+
int *x = sycl::malloc_shared<int>(1, q);
16+
int *y = sycl::malloc_shared<int>(1, q);
17+
*x = 0;
18+
*y = 0;
19+
20+
q.single_task<class kernel1>([=] { *x = 1; });
21+
22+
q.submit_barrier();
23+
24+
q.single_task<class kernel2>([=] {
25+
if (*x == 1) {
26+
*y = 2;
27+
}
28+
});
29+
30+
q.wait_and_throw();
31+
32+
int error = (*x != 1 || *y != 2) ? 1 : 0;
33+
std::cout << (error ? "failed\n" : "passed\n");
34+
35+
sycl::free(x, q);
36+
sycl::free(y, q);
37+
38+
return error;
39+
}

0 commit comments

Comments
 (0)