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

Commit ae5c5e8

Browse files
[SYCL] test errc for placeholder accessor fail (#890)
Update test to check for correct errc when attempting to use an unassociated placeholder accessor. Test for PR intel/llvm#5737 Signed-off-by: Chris Perkins [email protected]
1 parent 0108419 commit ae5c5e8

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

SYCL/Basic/accessor/accessor.cpp

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -556,6 +556,40 @@ int main() {
556556
return 1;
557557
}
558558
}
559+
560+
// placeholder accessor exception // SYCL2020 4.7.6.9
561+
{
562+
sycl::queue q;
563+
// host device executes kernels via a different method and there
564+
// is no good way to throw an exception at this time.
565+
if (!q.is_host()) {
566+
sycl::range<1> r(4);
567+
sycl::buffer<int, 1> b(r);
568+
try {
569+
sycl::accessor<int, 1, sycl::access::mode::read_write,
570+
sycl::access::target::device,
571+
sycl::access::placeholder::true_t>
572+
acc(b);
573+
574+
q.submit([&](sycl::handler &cgh) {
575+
// we do NOT call .require(acc) without which we should throw a
576+
// synchronous exception with errc::kernel_argument
577+
cgh.parallel_for<class ph>(
578+
r, [=](sycl::id<1> index) { acc[index] = 0; });
579+
});
580+
q.wait_and_throw();
581+
assert(false && "we should not be here, missing exception");
582+
} catch (sycl::exception &e) {
583+
std::cout << "exception received: " << e.what() << std::endl;
584+
assert(e.code() == sycl::errc::kernel_argument &&
585+
"incorrect error code");
586+
} catch (...) {
587+
std::cout << "some other exception" << std::endl;
588+
return 1;
589+
}
590+
}
591+
}
592+
559593
{
560594
try {
561595
int data = -1;

0 commit comments

Comments
 (0)