From 09817fab4efd055864be27353090d80d64ce12d7 Mon Sep 17 00:00:00 2001 From: Christian Trott Date: Mon, 17 Jun 2024 12:15:03 -0600 Subject: [PATCH] Fix mdspan tpl issues exposed during Kokkos CUDA build --- .../experimental/__p0009_bits/extents.hpp | 2 ++ .../experimental/__p0009_bits/utility.hpp | 6 +++++ .../__p2630_bits/submdspan_mapping.hpp | 22 +++++++++++++++---- 3 files changed, 26 insertions(+), 4 deletions(-) diff --git a/tpls/mdspan/include/experimental/__p0009_bits/extents.hpp b/tpls/mdspan/include/experimental/__p0009_bits/extents.hpp index 98a57e34e64..d58d37732dd 100644 --- a/tpls/mdspan/include/experimental/__p0009_bits/extents.hpp +++ b/tpls/mdspan/include/experimental/__p0009_bits/extents.hpp @@ -33,6 +33,7 @@ namespace detail { // Function used to check compatibility of extents in converting constructor // can't be a private member function for some reason. template +MDSPAN_INLINE_FUNCTION static constexpr std::integral_constant __check_compatible_extents( std::integral_constant, std::integer_sequence, @@ -49,6 +50,7 @@ struct __compare_extent_compatible : std::integral_constant +MDSPAN_INLINE_FUNCTION static constexpr std::integral_constant< bool, _MDSPAN_FOLD_AND(__compare_extent_compatible::value)> __check_compatible_extents( diff --git a/tpls/mdspan/include/experimental/__p0009_bits/utility.hpp b/tpls/mdspan/include/experimental/__p0009_bits/utility.hpp index 560b7b5026d..e690cd6939b 100644 --- a/tpls/mdspan/include/experimental/__p0009_bits/utility.hpp +++ b/tpls/mdspan/include/experimental/__p0009_bits/utility.hpp @@ -14,6 +14,7 @@ template using with_rank = std::integral_constant; template +MDSPAN_INLINE_FUNCTION constexpr bool common_integral_compare(I1 x, I2 y) { static_assert(std::is_integral::value && @@ -24,11 +25,14 @@ constexpr bool common_integral_compare(I1 x, I2 y) } template +MDSPAN_INLINE_FUNCTION constexpr bool rankwise_equal(with_rank<0>, const T1&, const T2&, F) { return true; } + template +MDSPAN_INLINE_FUNCTION constexpr bool rankwise_equal(with_rank, const T1& x, const T2& y, F func) { bool match = true; @@ -43,6 +47,7 @@ constexpr bool rankwise_equal(with_rank, const T1& x, const T2& y, F func) constexpr struct { template + MDSPAN_INLINE_FUNCTION constexpr auto operator()(const T& x, I i) const { return x.extent(i); @@ -52,6 +57,7 @@ constexpr struct constexpr struct { template + MDSPAN_INLINE_FUNCTION constexpr auto operator()(const T& x, I i) const { return x.stride(i); diff --git a/tpls/mdspan/include/experimental/__p2630_bits/submdspan_mapping.hpp b/tpls/mdspan/include/experimental/__p2630_bits/submdspan_mapping.hpp index 1cb098a1368..947634502df 100644 --- a/tpls/mdspan/include/experimental/__p2630_bits/submdspan_mapping.hpp +++ b/tpls/mdspan/include/experimental/__p2630_bits/submdspan_mapping.hpp @@ -284,8 +284,19 @@ MDSPAN_IMPL_PROPOSED_NAMESPACE::layout_left_padded::mappingrequired_span_size() : this->operator()(MDSPAN_IMPL_STANDARD_NAMESPACE::detail::first_of(slices)...)); if constexpr (dst_ext_t::rank() == 0) { // result rank-0 - using dst_mapping_t = typename layout_left::template mapping; - return submdspan_mapping_result{dst_mapping_t{dst_ext}, offset}; + // The following for some reasons leads to compiler error later, while not using a typedef works: + // Compilers: CUDA 11.2 with GCC 9.1 + // + // using dst_mapping_t = typename layout_left::template mapping; + // return submdspan_mapping_result{dst_mapping_t{dst_ext}, offset}; + // + // Error: submdspan_mapping.hpp:299:23: error: 'dst_mapping_t' does not name a type + // 299 | using dst_mapping_t = typename layout_left::template mapping; + // The same error is given (about dst_mapping_t not naming type) when a different name is used in 299: + // using dst_mapping_t2 = typename layout_left::template mapping; + + return submdspan_mapping_result> + {typename layout_left::template mapping{dst_ext}, offset}; } else { // general case // Figure out if any slice's lower bound equals the corresponding extent. // If so, bypass evaluating the layout mapping. This fixes LWG Issue 4060. @@ -509,8 +520,11 @@ MDSPAN_IMPL_PROPOSED_NAMESPACE::layout_right_padded::mappingrequired_span_size() : this->operator()(MDSPAN_IMPL_STANDARD_NAMESPACE::detail::first_of(slices)...)); if constexpr (dst_ext_t::rank() == 0) { // result rank-0 - using dst_mapping_t = typename layout_right::template mapping; - return submdspan_mapping_result{dst_mapping_t{dst_ext}, offset}; + // Same issue as in layout_left_padded: see comment there + // using dst_mapping_t = typename layout_right::template mapping; + // return submdspan_mapping_result{dst_mapping_t{dst_ext}, offset}; + return submdspan_mapping_result> + {typename layout_right::template mapping{dst_ext}, offset}; } else { // general case using deduce_layout = MDSPAN_IMPL_STANDARD_NAMESPACE::detail::deduce_layout_right_submapping< typename dst_ext_t::index_type, dst_ext_t::rank(),