From 8c41b1aa41d9bda6a0ed27efd8f41e6d8a051efe Mon Sep 17 00:00:00 2001 From: Mark Hoemmen Date: Tue, 28 Jun 2022 16:24:18 -0700 Subject: [PATCH] Fix nvc++ test build error Building tests/tests_contiguous_layouts.cpp fails with nvc++ 22.5-0. This commit fixes that. Fixes #148. --- tests/test_contiguous_layouts.cpp | 92 ++++++++++++++++++++++++------- 1 file changed, 73 insertions(+), 19 deletions(-) diff --git a/tests/test_contiguous_layouts.cpp b/tests/test_contiguous_layouts.cpp index 03ad2c51..f09b7996 100644 --- a/tests/test_contiguous_layouts.cpp +++ b/tests/test_contiguous_layouts.cpp @@ -173,10 +173,12 @@ using test_layout_conversion = std::integer_sequence, std::integral_constant>; +// We separate layout_conversion_test_types into multiple type lists +// in order to avoid an nvc++ compiler error (recursion too deep). -using layout_conversion_test_types = +// Left <=> Left conversion +using layout_conversion_test_types_left_to_left = ::testing::Types< - // Left <=> Left conversion test_layout_conversion, stdex::extents, true, 5> ,test_layout_conversion, stdex::extents, true> ,test_layout_conversion, stdex::extents, false, 5> @@ -189,9 +191,12 @@ using layout_conversion_test_types = ,test_layout_conversion, stdex::extents, false, 5, 10, 15, 20, 25> ,test_layout_conversion, stdex::extents, true, 5, 10, 15, 20, 25> ,test_layout_conversion, stdex::extents, true, 5, 10, 15, 20, 25> + >; - // Right <=> Right conversion - ,test_layout_conversion, stdex::extents, true, 5> +// Right <=> Right conversion +using layout_conversion_test_types_right_to_right = + ::testing::Types< + test_layout_conversion, stdex::extents, true, 5> ,test_layout_conversion, stdex::extents, true> ,test_layout_conversion, stdex::extents, false, 5> ,test_layout_conversion, stdex::extents, true, 5,10> @@ -203,9 +208,12 @@ using layout_conversion_test_types = ,test_layout_conversion, stdex::extents, false, 5, 10, 15, 20, 25> ,test_layout_conversion, stdex::extents, true, 5, 10, 15, 20, 25> ,test_layout_conversion, stdex::extents, true, 5, 10, 15, 20, 25> + >; - // Stride <=> Stride conversion - ,test_layout_conversion, stdex::extents, true, 5> +// Stride <=> Stride conversion +using layout_conversion_test_types_stride_to_stride = + ::testing::Types< + test_layout_conversion, stdex::extents, true, 5> ,test_layout_conversion, stdex::extents, true> ,test_layout_conversion, stdex::extents, false, 5> ,test_layout_conversion, stdex::extents, true, 5,10> @@ -217,9 +225,12 @@ using layout_conversion_test_types = ,test_layout_conversion, stdex::extents, false, 5, 10, 15, 20, 25> ,test_layout_conversion, stdex::extents, true, 5, 10, 15, 20, 25> ,test_layout_conversion, stdex::extents, true, 5, 10, 15, 20, 25> + >; - // Right => Stride conversion - ,test_layout_conversion, stdex::extents, true, 5> +// Right => Stride conversion +using layout_conversion_test_types_right_to_stride = + ::testing::Types< + test_layout_conversion, stdex::extents, true, 5> ,test_layout_conversion, stdex::extents, true> ,test_layout_conversion, stdex::extents, false, 5> ,test_layout_conversion, stdex::extents, true, 5,10> @@ -231,9 +242,12 @@ using layout_conversion_test_types = ,test_layout_conversion, stdex::extents, false, 5, 10, 15, 20, 25> ,test_layout_conversion, stdex::extents, true, 5, 10, 15, 20, 25> ,test_layout_conversion, stdex::extents, true, 5, 10, 15, 20, 25> + >; - // Left => Stride conversion - ,test_layout_conversion, stdex::extents, true, 5> +// Left => Stride conversion +using layout_conversion_test_types_left_to_stride = + ::testing::Types< + test_layout_conversion, stdex::extents, true, 5> ,test_layout_conversion, stdex::extents, true> ,test_layout_conversion, stdex::extents, false, 5> ,test_layout_conversion, stdex::extents, true, 5,10> @@ -245,9 +259,12 @@ using layout_conversion_test_types = ,test_layout_conversion, stdex::extents, false, 5, 10, 15, 20, 25> ,test_layout_conversion, stdex::extents, true, 5, 10, 15, 20, 25> ,test_layout_conversion, stdex::extents, true, 5, 10, 15, 20, 25> + >; - // Stride => Left conversion - ,test_layout_conversion, stdex::extents, false, 5> +// Stride => Left conversion +using layout_conversion_test_types_stride_to_left = + ::testing::Types< + test_layout_conversion, stdex::extents, false, 5> ,test_layout_conversion, stdex::extents, true> ,test_layout_conversion, stdex::extents, false, 5> ,test_layout_conversion, stdex::extents, false, 5,10> @@ -259,9 +276,12 @@ using layout_conversion_test_types = ,test_layout_conversion, stdex::extents, false, 5, 10, 15, 20, 25> ,test_layout_conversion, stdex::extents, false, 5, 10, 15, 20, 25> ,test_layout_conversion, stdex::extents, false, 5, 10, 15, 20, 25> + >; - // Stride => Right conversion - ,test_layout_conversion, stdex::extents, false, 5> +// Stride => Right conversion +using layout_conversion_test_types_stride_to_right = + ::testing::Types< + test_layout_conversion, stdex::extents, false, 5> ,test_layout_conversion, stdex::extents, true> ,test_layout_conversion, stdex::extents, false, 5> ,test_layout_conversion, stdex::extents, false, 5,10> @@ -273,15 +293,17 @@ using layout_conversion_test_types = ,test_layout_conversion, stdex::extents, false, 5, 10, 15, 20, 25> ,test_layout_conversion, stdex::extents, false, 5, 10, 15, 20, 25> ,test_layout_conversion, stdex::extents, false, 5, 10, 15, 20, 25> + >; - // Left <=> Right conversion - ,test_layout_conversion, stdex::extents, true, 5> +// Left <=> Right conversion +using layout_conversion_test_types_left_to_right = + ::testing::Types< + test_layout_conversion, stdex::extents, true, 5> ,test_layout_conversion, stdex::extents, false, 5> ,test_layout_conversion, stdex::extents, true, 5> ,test_layout_conversion, stdex::extents, false, 5> ,test_layout_conversion, stdex::extents, true> ,test_layout_conversion, stdex::extents, true> - >; template struct TestLayoutConversion; @@ -335,7 +357,39 @@ struct TestLayoutConversion< } }; -TYPED_TEST_SUITE(TestLayoutConversion, layout_conversion_test_types); +// We can't reuse TestLayoutConversion directly for multiple suites, +// because this results in duplicate test names. +// However, creating an alias for each suite works around this. + +TYPED_TEST_SUITE(TestLayoutConversion, layout_conversion_test_types_left_to_left); + +template +using TestLayoutConversion_R2R = TestLayoutConversion; +TYPED_TEST_SUITE(TestLayoutConversion_R2R, layout_conversion_test_types_right_to_right); + +template +using TestLayoutConversion_S2S = TestLayoutConversion; +TYPED_TEST_SUITE(TestLayoutConversion_S2S, layout_conversion_test_types_stride_to_stride); + +template +using TestLayoutConversion_R2S = TestLayoutConversion; +TYPED_TEST_SUITE(TestLayoutConversion_R2S, layout_conversion_test_types_right_to_stride); + +template +using TestLayoutConversion_L2S = TestLayoutConversion; +TYPED_TEST_SUITE(TestLayoutConversion_L2S, layout_conversion_test_types_left_to_stride); + +template +using TestLayoutConversion_S2L = TestLayoutConversion; +TYPED_TEST_SUITE(TestLayoutConversion_S2L, layout_conversion_test_types_stride_to_left); + +template +using TestLayoutConversion_S2R = TestLayoutConversion; +TYPED_TEST_SUITE(TestLayoutConversion_S2R, layout_conversion_test_types_stride_to_right); + +template +using TestLayoutConversion_L2R = TestLayoutConversion; +TYPED_TEST_SUITE(TestLayoutConversion_L2R, layout_conversion_test_types_left_to_right); TYPED_TEST(TestLayoutConversion, implicit_conversion) { typename TestFixture::map_2_t map2 = this->create_map2(this->exts2); @@ -365,7 +419,7 @@ TYPED_TEST(TestLayoutConversion, implicit_conversion) { #endif map1 = typename TestFixture::map_1_t(map2); - for(size_t r=0; rexts1.rank(); r++) { + for(size_t r=0; r != this->exts1.rank(); ++r) { ASSERT_EQ(map1.extents().extent(r), map2.extents().extent(r)); ASSERT_EQ(map1.stride(r), map2.stride(r)); }