@@ -653,7 +653,7 @@ int main() {
653
653
}
654
654
}
655
655
656
- // placeholder accessor exception // SYCL2020 4.7.6.9
656
+ // placeholder accessor exception (1) // SYCL2020 4.7.6.9
657
657
{
658
658
sycl::queue q;
659
659
// host device executes kernels via a different method and there
@@ -669,16 +669,88 @@ int main() {
669
669
q.submit ([&](sycl::handler &cgh) {
670
670
// we do NOT call .require(acc) without which we should throw a
671
671
// synchronous exception with errc::kernel_argument
672
- cgh.parallel_for <class ph >(r,
673
- [=](sycl::id<1 > index) { acc[index] = 0 ; });
672
+ cgh.parallel_for <class ph1 >(r,
673
+ [=](sycl::id<1 > index) { acc[index] = 0 ; });
674
674
});
675
675
q.wait_and_throw ();
676
676
assert (false && " we should not be here, missing exception" );
677
677
} catch (sycl::exception &e) {
678
678
std::cout << " exception received: " << e.what () << std::endl;
679
679
assert (e.code () == sycl::errc::kernel_argument && " incorrect error code" );
680
680
} catch (...) {
681
- std::cout << " some other exception" << std::endl;
681
+ std::cout << " Some other exception (line " << __LINE__ << " )"
682
+ << std::endl;
683
+ return 1 ;
684
+ }
685
+ }
686
+
687
+ // placeholder accessor exception (2) // SYCL2020 4.7.6.9
688
+ {
689
+ sycl::queue q;
690
+ // host device executes kernels via a different method and there
691
+ // is no good way to throw an exception at this time.
692
+ sycl::range<1 > r (4 );
693
+ sycl::buffer<int , 1 > b (r);
694
+ try {
695
+ using AccT = sycl::accessor<int , 1 , sycl::access::mode::read_write,
696
+ sycl::access::target::device,
697
+ sycl::access::placeholder::true_t >;
698
+ AccT acc (b);
699
+
700
+ q.submit ([&](sycl::handler &cgh) {
701
+ // we do NOT call .require(acc) without which we should throw a
702
+ // synchronous exception with errc::kernel_argument
703
+ // The difference with the previous test is that the use of acc
704
+ // is usually optimized away for this particular scenario, but the
705
+ // exception should be thrown because of passing it, not because of
706
+ // using it
707
+ cgh.single_task <class ph2 >([=] { int x = acc[0 ]; });
708
+ });
709
+ q.wait_and_throw ();
710
+ assert (false && " we should not be here, missing exception" );
711
+ } catch (sycl::exception &e) {
712
+ std::cout << " exception received: " << e.what () << std::endl;
713
+ assert (e.code () == sycl::errc::kernel_argument && " incorrect error code" );
714
+ } catch (...) {
715
+ std::cout << " Some other exception (line " << __LINE__ << " )"
716
+ << std::endl;
717
+ return 1 ;
718
+ }
719
+ }
720
+
721
+ // placeholder accessor exception (3) // SYCL2020 4.7.6.9
722
+ {
723
+ sycl::queue q;
724
+ // host device executes kernels via a different method and there
725
+ // is no good way to throw an exception at this time.
726
+ sycl::range<1 > r (4 );
727
+ sycl::buffer<int , 1 > b (r);
728
+ try {
729
+ using AccT = sycl::accessor<int , 1 , sycl::access::mode::read_write,
730
+ sycl::access::target::device,
731
+ sycl::access::placeholder::true_t >;
732
+ AccT acc (b);
733
+
734
+ q.submit ([&](sycl::handler &cgh) {
735
+ AccT acc2 (b, cgh);
736
+ // we do NOT call .require(acc) without which we should throw a
737
+ // synchronous exception with errc::kernel_argument
738
+ // The particularity of this test is that it passes to a command
739
+ // one bound accessor and one unbound accessor. In the past, this
740
+ // has led to throw the wrong exception.
741
+ cgh.single_task <class ph3 >([=] {
742
+ volatile int x = acc[0 ];
743
+ volatile int y = acc2[0 ];
744
+ });
745
+ });
746
+ q.wait_and_throw ();
747
+ assert (false && " we should not be here, missing exception" );
748
+ } catch (sycl::exception &e) {
749
+ std::cout << " exception received: " << e.what () << std::endl;
750
+ assert (e.code () == sycl::errc::kernel_argument && " incorrect error code" );
751
+ } catch (...) {
752
+ std::cout << " Some other exception (line " << __LINE__ << " )"
753
+ << std::endl;
682
754
return 1 ;
683
755
}
684
756
}
0 commit comments