@@ -650,16 +650,20 @@ namespace detail {
650
650
template <int >
651
651
class acc_out_of_bounds_kernel {};
652
652
653
- TEMPLATE_TEST_CASE_METHOD_SIG (oob_fixture, " accessor reports out-of-bounds accesses" , " [accessor][oob]" , ((int Dims), Dims), 1 , 2 , 3 ) {
653
+ TEMPLATE_TEST_CASE_METHOD_SIG (oob_fixture, " device accessor reports out-of-bounds accesses" , " [accessor][oob]" , ((int Dims), Dims), 1 , 2 , 3 ) {
654
654
#if !CELERITY_ACCESSOR_BOUNDARY_CHECK
655
655
SKIP (" CELERITY_ACCESSOR_BOUNDARY_CHECK=0" );
656
656
#endif
657
- buffer<int , Dims> buff (test_utils::truncate_range<Dims>({10 , 20 , 30 }));
657
+ buffer<int , Dims> unnamed_buff (test_utils::truncate_range<Dims>({10 , 20 , 30 }));
658
+ buffer<int , Dims> named_buff (test_utils::truncate_range<Dims>({10 , 20 , 30 }));
658
659
const auto accessible_sr = test_utils::truncate_subrange<Dims>({{5 , 10 , 15 }, {1 , 2 , 3 }});
659
660
const auto oob_idx_lo = test_utils::truncate_id<Dims>({1 , 2 , 3 });
660
661
const auto oob_idx_hi = test_utils::truncate_id<Dims>({7 , 13 , 25 });
662
+ const auto buffer_name = " oob" ;
661
663
662
- // we need to be careful about the orderign of the construction and destruction
664
+ celerity::debug::set_buffer_name (named_buff, buffer_name);
665
+
666
+ // we need to be careful about the ordering of the construction and destruction
663
667
// of the Celerity queue and the log capturing utility here
664
668
std::unique_ptr<celerity::test_utils::log_capture> lc;
665
669
{
@@ -668,21 +672,83 @@ namespace detail {
668
672
lc = std::make_unique<celerity::test_utils::log_capture>();
669
673
670
674
q.submit ([&](handler& cgh) {
671
- accessor acc (buff, cgh, celerity::access::fixed (accessible_sr), celerity::write_only, celerity::no_init);
675
+ accessor unnamed_acc (unnamed_buff, cgh, celerity::access::fixed (accessible_sr), celerity::write_only, celerity::no_init);
676
+ accessor named_acc (named_buff, cgh, celerity::access::fixed (accessible_sr), celerity::write_only, celerity::no_init);
677
+
672
678
cgh.parallel_for <acc_out_of_bounds_kernel<Dims>>(range<Dims>(ones), [=](item<Dims>) {
673
- acc[oob_idx_lo] = 0 ;
674
- acc[oob_idx_hi] = 0 ;
679
+ unnamed_acc[oob_idx_lo] = 0 ;
680
+ unnamed_acc[oob_idx_hi] = 0 ;
681
+
682
+ named_acc[oob_idx_lo] = 0 ;
683
+ named_acc[oob_idx_hi] = 0 ;
675
684
});
676
685
});
677
686
q.slow_full_sync ();
678
687
}
679
688
680
- const auto attempted_sr = subrange<3 >{id_cast<3 >(oob_idx_lo), range_cast<3 >(oob_idx_hi - oob_idx_lo + id_cast<Dims>(range<Dims>(ones)))};
681
- const auto error_message = fmt::format (" Out-of-bounds access in kernel 'celerity::detail::acc_out_of_bounds_kernel<{}>' detected: Accessor 0 for "
682
- " buffer 0 attempted to access indices between {} which are outside of mapped subrange {}" ,
683
- Dims, attempted_sr, subrange_cast<3 >(accessible_sr));
684
- CHECK_THAT (lc->get_log (), Catch::Matchers::ContainsSubstring (error_message));
689
+ const auto attempted_sr =
690
+ subrange<3 >{id_cast<3 >(oob_idx_lo), range_cast<3 >(oob_idx_hi - oob_idx_lo + id_cast<Dims>(range<Dims>(ones))) - range_cast<3 >(range<Dims>(zeros))};
691
+ const auto unnamed_error_message =
692
+ fmt::format (" Out-of-bounds access in kernel 'celerity::detail::acc_out_of_bounds_kernel<{}>' detected: Accessor 0 for buffer 0 attempted to "
693
+ " access indices between {} which are outside of mapped subrange {}" ,
694
+ Dims, attempted_sr, subrange_cast<3 >(accessible_sr));
695
+ CHECK_THAT (lc->get_log (), Catch::Matchers::ContainsSubstring (unnamed_error_message));
696
+
697
+ const auto named_error_message =
698
+ fmt::format (" Out-of-bounds access in kernel 'celerity::detail::acc_out_of_bounds_kernel<{}>' detected: Accessor 1 for buffer {} attempted to "
699
+ " access indices between {} which are outside of mapped subrange {}" ,
700
+ Dims, buffer_name, attempted_sr, subrange_cast<3 >(accessible_sr));
701
+ CHECK_THAT (lc->get_log (), Catch::Matchers::ContainsSubstring (named_error_message));
685
702
}
686
703
704
+ TEMPLATE_TEST_CASE_METHOD_SIG (oob_fixture, " host accessor reports out-of-bounds accesses" , " [accessor][oob]" , ((int Dims), Dims), 1 , 2 , 3 ) {
705
+ #if !CELERITY_ACCESSOR_BOUNDARY_CHECK
706
+ SKIP (" CELERITY_ACCESSOR_BOUNDARY_CHECK=0" );
707
+ #endif
708
+ buffer<int , Dims> unnamed_buff (test_utils::truncate_range<Dims>({10 , 20 , 30 }));
709
+ buffer<int , Dims> named_buff (test_utils::truncate_range<Dims>({10 , 20 , 30 }));
710
+ const auto accessible_sr = test_utils::truncate_subrange<Dims>({{5 , 10 , 15 }, {1 , 2 , 3 }});
711
+ const auto oob_idx_lo = test_utils::truncate_id<Dims>({1 , 2 , 3 });
712
+ const auto oob_idx_hi = test_utils::truncate_id<Dims>({7 , 13 , 25 });
713
+ const auto buffer_name = " oob" ;
714
+
715
+ celerity::debug::set_buffer_name (named_buff, buffer_name);
716
+
717
+ // we need to be careful about the ordering of the construction and destruction
718
+ // of the Celerity queue and the log capturing utility here
719
+ std::unique_ptr<celerity::test_utils::log_capture> lc;
720
+ {
721
+ distr_queue q;
722
+
723
+ lc = std::make_unique<celerity::test_utils::log_capture>();
724
+
725
+ q.submit ([&](handler& cgh) {
726
+ accessor unnamed_acc (unnamed_buff, cgh, celerity::access::fixed (accessible_sr), celerity::write_only_host_task, celerity::no_init);
727
+ accessor nambed_acc (named_buff, cgh, celerity::access::fixed (accessible_sr), celerity::write_only_host_task, celerity::no_init);
728
+
729
+ cgh.host_task (range<Dims>(ones), [=](partition<Dims>) {
730
+ unnamed_acc[oob_idx_lo] = 0 ;
731
+ unnamed_acc[oob_idx_hi] = 0 ;
732
+
733
+ nambed_acc[oob_idx_lo] = 0 ;
734
+ nambed_acc[oob_idx_hi] = 0 ;
735
+ });
736
+ });
737
+
738
+ q.slow_full_sync ();
739
+ }
740
+
741
+ const auto attempted_sr =
742
+ subrange<3 >{id_cast<3 >(oob_idx_lo), range_cast<3 >(oob_idx_hi - oob_idx_lo + id_cast<Dims>(range<Dims>(ones))) - range_cast<3 >(range<Dims>(zeros))};
743
+ const auto unnamed_error_message = fmt::format (" Out-of-bounds access in host task detected: Accessor 0 for buffer 0 attempted to "
744
+ " access indices between {} which are outside of mapped subrange {}" ,
745
+ attempted_sr, subrange_cast<3 >(accessible_sr));
746
+ CHECK_THAT (lc->get_log (), Catch::Matchers::ContainsSubstring (unnamed_error_message));
747
+
748
+ const auto named_error_message = fmt::format (" Out-of-bounds access in host task detected: Accessor 1 for buffer {} attempted to "
749
+ " access indices between {} which are outside of mapped subrange {}" ,
750
+ buffer_name, attempted_sr, subrange_cast<3 >(accessible_sr));
751
+ CHECK_THAT (lc->get_log (), Catch::Matchers::ContainsSubstring (named_error_message));
752
+ }
687
753
} // namespace detail
688
754
} // namespace celerity
0 commit comments