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

[SYCL] Add test for checking that context is destroyed after expected exception #280

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions SYCL/Regression/context_is_destroyed_after_exception.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
// REQUIRES: gpu

// RUN: %clangxx -fsycl %s -o %t.out
// RUN: env SYCL_PI_TRACE=2 %GPU_RUN_PLACEHOLDER %t.out 2>&1 %GPU_CHECK_PLACEHOLDER

#include <CL/sycl.hpp>

int main() {
const auto GlobalRange = 1;
const auto LocalRange = 2;

sycl::queue myQueue{sycl::gpu_selector{}, [](sycl::exception_list elist) {
for (auto e : elist)
std::rethrow_exception(e);
}};

try {
// Generating an exception caused by the fact that LocalRange size (== 2)
// can't be greater than GlobalRange size (== 1)
myQueue.parallel_for<class TestKernel>(
sycl::nd_range<1>{sycl::range<1>(GlobalRange),
sycl::range<1>(LocalRange)},
[=](sycl::nd_item<1> idx) {});
myQueue.wait_and_throw();
assert(false && "Expected exception was not caught");
} catch (sycl::exception &e) {
}

return 0;
}

// CHECK:---> piContextRelease(