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

Commit 8a560bb

Browse files
[SYCL] Add test for checking that context is destroyed after expected exception (#280)
This patch adds new regression test for checking that memory leak in SYCL context is gone after throwing some expected exception
1 parent 95dc2fa commit 8a560bb

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
// REQUIRES: gpu
2+
3+
// RUN: %clangxx -fsycl %s -o %t.out
4+
// RUN: env SYCL_PI_TRACE=2 %GPU_RUN_PLACEHOLDER %t.out 2>&1 %GPU_CHECK_PLACEHOLDER
5+
6+
#include <CL/sycl.hpp>
7+
8+
int main() {
9+
const auto GlobalRange = 1;
10+
const auto LocalRange = 2;
11+
12+
sycl::queue myQueue{sycl::gpu_selector{}, [](sycl::exception_list elist) {
13+
for (auto e : elist)
14+
std::rethrow_exception(e);
15+
}};
16+
17+
try {
18+
// Generating an exception caused by the fact that LocalRange size (== 2)
19+
// can't be greater than GlobalRange size (== 1)
20+
myQueue.parallel_for<class TestKernel>(
21+
sycl::nd_range<1>{sycl::range<1>(GlobalRange),
22+
sycl::range<1>(LocalRange)},
23+
[=](sycl::nd_item<1> idx) {});
24+
myQueue.wait_and_throw();
25+
assert(false && "Expected exception was not caught");
26+
} catch (sycl::exception &e) {
27+
}
28+
29+
return 0;
30+
}
31+
32+
// CHECK:---> piContextRelease(

0 commit comments

Comments
 (0)