From 1331aba96ce1d5d3b701749a570f7fbc5e8f3431 Mon Sep 17 00:00:00 2001 From: Wu Yongwei Date: Sat, 11 Feb 2023 20:37:47 +0800 Subject: [PATCH 1/4] Remove macro _MDSPAN_USE_ALIAS_TEMPLATE_ARGUMENT_DEDUCTION As it is no longer used. --- include/experimental/__p0009_bits/config.hpp | 9 --------- 1 file changed, 9 deletions(-) diff --git a/include/experimental/__p0009_bits/config.hpp b/include/experimental/__p0009_bits/config.hpp index 1b17a72a..41fcea93 100644 --- a/include/experimental/__p0009_bits/config.hpp +++ b/include/experimental/__p0009_bits/config.hpp @@ -206,15 +206,6 @@ static_assert(_MDSPAN_CPLUSPLUS >= MDSPAN_CXX_STD_14, "mdspan requires C++14 or # endif #endif -#ifndef _MDSPAN_USE_ALIAS_TEMPLATE_ARGUMENT_DEDUCTION -// GCC 10's CTAD seems sufficiently broken to prevent its use. -# if (defined(_MDSPAN_COMPILER_CLANG) || !defined(__GNUC__) || __GNUC__ >= 11) \ - && ((defined(__cpp_deduction_guides) && __cpp_deduction_guides >= 201907) \ - || (!defined(__cpp_deduction_guides) && MDSPAN_HAS_CXX_20)) -# define _MDSPAN_USE_ALIAS_TEMPLATE_ARGUMENT_DEDUCTION 1 -# endif -#endif - #ifndef _MDSPAN_USE_STANDARD_TRAIT_ALIASES # if (defined(__cpp_lib_transformation_trait_aliases) && __cpp_lib_transformation_trait_aliases >= 201304) \ || (!defined(__cpp_lib_transformation_trait_aliases) && MDSPAN_HAS_CXX_14) From 02e7dc85bac601d00756bace19a49879676ac151 Mon Sep 17 00:00:00 2001 From: Wu Yongwei Date: Sat, 11 Feb 2023 21:04:25 +0800 Subject: [PATCH 2/4] Remove the special GCC version check The current code works with GCC 7 and later. --- include/experimental/__p0009_bits/config.hpp | 6 ++---- tests/test_layout_stride.cpp | 1 - 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/include/experimental/__p0009_bits/config.hpp b/include/experimental/__p0009_bits/config.hpp index 41fcea93..68750e9b 100644 --- a/include/experimental/__p0009_bits/config.hpp +++ b/include/experimental/__p0009_bits/config.hpp @@ -198,10 +198,8 @@ static_assert(_MDSPAN_CPLUSPLUS >= MDSPAN_CXX_STD_14, "mdspan requires C++14 or #endif #ifndef _MDSPAN_USE_CLASS_TEMPLATE_ARGUMENT_DEDUCTION -// GCC 10's CTAD seems sufficiently broken to prevent its use. -# if (defined(_MDSPAN_COMPILER_CLANG) || !defined(__GNUC__) || __GNUC__ >= 11) \ - && ((defined(__cpp_deduction_guides) && __cpp_deduction_guides >= 201703) \ - || (!defined(__cpp_deduction_guides) && MDSPAN_HAS_CXX_17)) +# if (defined(__cpp_deduction_guides) && __cpp_deduction_guides >= 201703) \ + || (!defined(__cpp_deduction_guides) && MDSPAN_HAS_CXX_17) # define _MDSPAN_USE_CLASS_TEMPLATE_ARGUMENT_DEDUCTION 1 # endif #endif diff --git a/tests/test_layout_stride.cpp b/tests/test_layout_stride.cpp index 6b645d42..7d7d88e8 100644 --- a/tests/test_layout_stride.cpp +++ b/tests/test_layout_stride.cpp @@ -152,7 +152,6 @@ TYPED_TEST(TestLayoutEquality, equality_op) { ASSERT_EQ(this->map1 == this->map2, this->equal); } -// This fails on GCC 9.2 and others #if defined(_MDSPAN_USE_CLASS_TEMPLATE_ARGUMENT_DEDUCTION) TEST(TestLayoutStrideCTAD, test_ctad) { // This is not possible wiht the array constructor we actually provide From cd48886fd33e1f84e22e8a2b344c8534fe9ca9e7 Mon Sep 17 00:00:00 2001 From: Christian Trott Date: Tue, 14 Feb 2023 16:27:55 -0700 Subject: [PATCH 3/4] Disable CTAD tests for layout mapping for NVCC doesn't work up through NVCC 12 --- tests/test_layout_ctors.cpp | 6 ++++-- tests/test_layout_stride.cpp | 4 ++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/tests/test_layout_ctors.cpp b/tests/test_layout_ctors.cpp index 5a83a585..c78e9ef7 100644 --- a/tests/test_layout_ctors.cpp +++ b/tests/test_layout_ctors.cpp @@ -203,7 +203,8 @@ TEST(TestLayoutLeftListInitialization, test_layout_left_extent_initialization) { ASSERT_TRUE(m.is_exhaustive()); } -#if defined(_MDSPAN_USE_CLASS_TEMPLATE_ARGUMENT_DEDUCTION) +// FIXME: CUDA NVCC including 12.0 does not like CTAD on nested classes +#if defined(_MDSPAN_USE_CLASS_TEMPLATE_ARGUMENT_DEDUCTION) && !defined(__NVCC__) TEST(TestLayoutLeftCTAD, test_layout_left_ctad) { stdex::layout_left::mapping m{stdex::extents{16, 32}}; ASSERT_EQ(m.extents().rank(), 2); @@ -227,7 +228,8 @@ TEST(TestLayoutRightListInitialization, test_layout_right_extent_initialization) ASSERT_TRUE(m.is_exhaustive()); } -#if defined(_MDSPAN_USE_CLASS_TEMPLATE_ARGUMENT_DEDUCTION) +// FIXME: CUDA NVCC including 12.0 does not like CTAD on nested classes +#if defined(_MDSPAN_USE_CLASS_TEMPLATE_ARGUMENT_DEDUCTION) && !defined(__NVCC__) TEST(TestLayoutRightCTAD, test_layout_right_ctad) { stdex::layout_right::mapping m{stdex::extents{16, 32}}; ASSERT_EQ(m.extents().rank(), 2); diff --git a/tests/test_layout_stride.cpp b/tests/test_layout_stride.cpp index 7d7d88e8..9ded69a3 100644 --- a/tests/test_layout_stride.cpp +++ b/tests/test_layout_stride.cpp @@ -152,7 +152,8 @@ TYPED_TEST(TestLayoutEquality, equality_op) { ASSERT_EQ(this->map1 == this->map2, this->equal); } -#if defined(_MDSPAN_USE_CLASS_TEMPLATE_ARGUMENT_DEDUCTION) +// FIXME: CUDA NVCC including 12.0 does not like CTAD on nested classes +#if defined(_MDSPAN_USE_CLASS_TEMPLATE_ARGUMENT_DEDUCTION) && !defined(__NVCC__) TEST(TestLayoutStrideCTAD, test_ctad) { // This is not possible wiht the array constructor we actually provide /* @@ -166,7 +167,6 @@ TEST(TestLayoutStrideCTAD, test_ctad) { ASSERT_EQ(m0.strides(), (std::array{1, 128})); ASSERT_FALSE(m0.is_exhaustive()); */ - stdex::layout_stride::mapping m1{stdex::extents{16, 32}, std::array{1, 128}}; ASSERT_EQ(m1.extents().rank(), 2); ASSERT_EQ(m1.extents().rank_dynamic(), 2); From 757f4fa1426b832563dcbfcdfaaca02e61a00a2f Mon Sep 17 00:00:00 2001 From: Christian Trott Date: Tue, 14 Feb 2023 16:28:45 -0700 Subject: [PATCH 4/4] Disable CTAD again for NVCC older than 11.7 Crashes with internal compiler error. Tested 11.2, 11.4, 11.6 with gcc 9/10 /ascldap/users/crtrott/Kokkos/mdspan/include/experimental/__p0009_bits/mdspan.hpp: In member function 'virtual void TestMdspanCTAD_extents_pack_Test::TestBody()': /ascldap/users/crtrott/Kokkos/mdspan/include/experimental/__p0009_bits/mdspan.hpp:78:25: internal compiler error: in tsubst, at cp/pt.c:14560 78 | MDSPAN_INLINE_FUNCTION static constexpr size_t rank() noexcept { return extents_type::rank(); } --- include/experimental/__p0009_bits/config.hpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/include/experimental/__p0009_bits/config.hpp b/include/experimental/__p0009_bits/config.hpp index 68750e9b..d35e201c 100644 --- a/include/experimental/__p0009_bits/config.hpp +++ b/include/experimental/__p0009_bits/config.hpp @@ -198,8 +198,9 @@ static_assert(_MDSPAN_CPLUSPLUS >= MDSPAN_CXX_STD_14, "mdspan requires C++14 or #endif #ifndef _MDSPAN_USE_CLASS_TEMPLATE_ARGUMENT_DEDUCTION -# if (defined(__cpp_deduction_guides) && __cpp_deduction_guides >= 201703) \ - || (!defined(__cpp_deduction_guides) && MDSPAN_HAS_CXX_17) +# if (!defined(__NVCC__) || (__CUDACC_VER_MAJOR__ >= 11 && __CUDACC_VER_MINOR__ >= 7)) && \ + ((defined(__cpp_deduction_guides) && __cpp_deduction_guides >= 201703) || \ + (!defined(__cpp_deduction_guides) && MDSPAN_HAS_CXX_17)) # define _MDSPAN_USE_CLASS_TEMPLATE_ARGUMENT_DEDUCTION 1 # endif #endif