-
Notifications
You must be signed in to change notification settings - Fork 81
precondition checks in extents constructors #410
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
89afaea
ef12e3e
11d9a77
8667593
8cb9a2c
24f1bba
738f357
8a5a707
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -481,3 +481,81 @@ TEST(TestExtentsCTADStdArray, test_extents_ctad_std_array) { | |
| } | ||
| */ | ||
| #endif | ||
|
|
||
| #if MDSPAN_HAS_CXX_17 | ||
dalg24 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| TEST(TestExtentsConstructorPreconditions, test_extents_construct_indices) { | ||
| auto test_precondition_indices_not_representable = [] { | ||
| [[maybe_unused]] auto exts = Kokkos::dextents< std::int8_t, 2 >{ 500, 500 }; | ||
dalg24 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| }; | ||
| #if defined(MDSPAN_IMPL_HAS_CUDA) || defined(MDSPAN_IMPL_HAS_HIP) || defined(MDSPAN_IMPL_HAS_SYCL) | ||
| EXPECT_DEATH(test_precondition_indices_not_representable(), ""); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We do not want to ensure that the error message matches some regex?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We can at least for CPU but it won't work with CUDA. So I just decided not to since it doesn't matter a whole lot
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What do you mean it won't work with CUDA?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So for now the CUDA precondition violation handler prints to stdout. #if defined(MDSPAN_IMPL_HAS_CUDA) || defined(MDSPAN_IMPL_HAS_HIP) || defined(MDSPAN_IMPL_HAS_SYCL)
EXPECT_DEATH(test_precondition_indices_not_representable(), "");
#else
EXPECT_DEATH(test_precondition_indices_not_representable(), "extent_is_representable");
#endifWe do this elsewhere. But really the precondition handler doesn't print the best errors anyway
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I updated to test the message on host. On device the message is kinda useless: So I think we should avoid testing device messages for now until we update our precondition violation handler on device (likely a separate PR)
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh, I see, because we call |
||
| #else | ||
| EXPECT_DEATH(test_precondition_indices_not_representable(), "all_values_are_nonnegative_and_representable"); | ||
| #endif | ||
|
|
||
| auto test_precondition_indices_are_negative = [] { | ||
| [[maybe_unused]] auto exts = Kokkos::dextents< int, 2 >{ 500, -500 }; | ||
| }; | ||
| #if defined(MDSPAN_IMPL_HAS_CUDA) || defined(MDSPAN_IMPL_HAS_HIP) || defined(MDSPAN_IMPL_HAS_SYCL) | ||
| EXPECT_DEATH(test_precondition_indices_are_negative(), ""); | ||
| #else | ||
| EXPECT_DEATH(test_precondition_indices_are_negative(), "all_values_are_nonnegative_and_representable"); | ||
| #endif | ||
| } | ||
|
|
||
| TEST(TestExtentsConstructorPreconditions, test_extents_construct_array) { | ||
| auto test_precondition_array_elements_not_representable = [] { | ||
| [[maybe_unused]] auto exts = Kokkos::dextents< std::int8_t, 2 >{ std::array{ 500, 500 } }; | ||
| }; | ||
| #if defined(MDSPAN_IMPL_HAS_CUDA) || defined(MDSPAN_IMPL_HAS_HIP) || defined(MDSPAN_IMPL_HAS_SYCL) | ||
| EXPECT_DEATH(test_precondition_array_elements_not_representable(), ""); | ||
| #else | ||
| EXPECT_DEATH(test_precondition_array_elements_not_representable(), "range_is_nonnegative_and_representable"); | ||
| #endif | ||
|
|
||
| auto test_precondition_array_elements_are_negative = [] { | ||
| [[maybe_unused]] auto exts = Kokkos::dextents< int, 2 >{ std::array{ 500, -500 } }; | ||
| }; | ||
| #if defined(MDSPAN_IMPL_HAS_CUDA) || defined(MDSPAN_IMPL_HAS_HIP) || defined(MDSPAN_IMPL_HAS_SYCL) | ||
| EXPECT_DEATH(test_precondition_array_elements_are_negative(), ""); | ||
| #else | ||
| EXPECT_DEATH(test_precondition_array_elements_are_negative(), "range_is_nonnegative_and_representable"); | ||
| #endif | ||
| } | ||
|
|
||
| #ifdef __cpp_lib_span | ||
| TEST(TestExtentsConstructorPreconditions, test_extents_construct_span) { | ||
| auto test_precondition_span_elements_not_representable = [] { | ||
| auto indices = std::array{ 500, 500 }; | ||
| [[maybe_unused]] auto exts = Kokkos::dextents< std::int8_t, 2 >{ std::span{ indices } }; | ||
| }; | ||
| #if defined(MDSPAN_IMPL_HAS_CUDA) || defined(MDSPAN_IMPL_HAS_HIP) || defined(MDSPAN_IMPL_HAS_SYCL) | ||
| EXPECT_DEATH(test_precondition_span_elements_not_representable(), ""); | ||
| #else | ||
| EXPECT_DEATH(test_precondition_span_elements_not_representable(), "range_is_nonnegative_and_representable"); | ||
| #endif | ||
|
|
||
| auto test_precondition_span_elements_are_negative = [] { | ||
| auto indices = std::array{ 500, -500 }; | ||
| [[maybe_unused]] auto exts = Kokkos::dextents< int, 2 >{ std::span{ indices } }; | ||
| }; | ||
| #if defined(MDSPAN_IMPL_HAS_CUDA) || defined(MDSPAN_IMPL_HAS_HIP) || defined(MDSPAN_IMPL_HAS_SYCL) | ||
| EXPECT_DEATH(test_precondition_span_elements_are_negative(), ""); | ||
| #else | ||
| EXPECT_DEATH(test_precondition_span_elements_are_negative(), "range_is_nonnegative_and_representable"); | ||
| #endif | ||
| } | ||
| #endif | ||
|
|
||
| TEST(TestExtentsConstructorPreconditions, test_extents_construct_other_extents) { | ||
| auto test_precondition_extent_ranks_not_representable = [] { | ||
| auto first = Kokkos::dextents< int, 2 >{ 500, 500 }; | ||
| [[maybe_unused]] auto exts = Kokkos::dextents< std::int8_t, 2 >{ first }; | ||
| }; | ||
| #if defined(MDSPAN_IMPL_HAS_CUDA) || defined(MDSPAN_IMPL_HAS_HIP) || defined(MDSPAN_IMPL_HAS_SYCL) | ||
| EXPECT_DEATH(test_precondition_extent_ranks_not_representable(), ""); | ||
| #else | ||
| EXPECT_DEATH(test_precondition_extent_ranks_not_representable(), "extent_is_representable"); | ||
| #endif | ||
| } | ||
| #endif | ||
Uh oh!
There was an error while loading. Please reload this page.