diff --git a/src/pystencilssfg/lang/cpp/std_mdspan.py b/src/pystencilssfg/lang/cpp/std_mdspan.py index a05a2980096669c2e96bb6715114b99a1bdc3b23..2ede10864d6745ea71605af9b1dd6f565f549155 100644 --- a/src/pystencilssfg/lang/cpp/std_mdspan.py +++ b/src/pystencilssfg/lang/cpp/std_mdspan.py @@ -11,17 +11,35 @@ from pystencils.types import ( from pystencilssfg.lang.expressions import AugExpr -from ...lang import SrcField, IFieldExtraction, cpptype, Ref +from ...lang import SrcField, IFieldExtraction, cpptype, Ref, HeaderFile class StdMdspan(SrcField): + """Represents an `std::mdspan` instance. + + **On Standard Library Adoption** + + Since `std::mdspan` is not yet widely adopted + (libc++ ships it as of LLVM 18, but GCC libstdc++ does not include it yet), + you might have to manually include an implementation in your project + (you can get a reference implementation [here](https://github.com/kokkos/mdspan)). + However, when working with a non-standard mdspan implementation, + the path to its the header and the namespace it is defined in will likely be different. + + To tell pystencils-sfg which headers to include and which namespace to use for `mdspan`, + use `StdMdspan.configure`. + """ + dynamic_extent = "std::dynamic_extent" + _namespace = "std" _template = cpptype("std::mdspan< {T}, {extents} >", "<mdspan>") - _template_experimental = cpptype( - "std::mdspan< {T}, {extents} >", "<experimental/mdspan>" - ) + @classmethod + def configure(cls, namespace: str = "std", header: str | HeaderFile = "<mdspan>"): + """Configure the namespace and header `mdspan` is defined in.""" + cls._namespace = namespace + cls._template = cpptype(f"{namespace}::mdspan< {{T}}, {{extents}} >", header) def __init__( self, @@ -30,19 +48,13 @@ class StdMdspan(SrcField): extents_type: PsType = PsUnsignedIntegerType(64), ref: bool = False, const: bool = False, - experimental: bool = True, ): T = create_type(T) extents_type_str = extents_type.c_string() - extents_str = ( - f"std::extents< {extents_type_str}, {', '.join(str(e) for e in extents)} >" - ) + extents_str = f"{self._namespace}::extents< {extents_type_str}, {', '.join(str(e) for e in extents)} >" - if experimental: - dtype = self._template_experimental(T=T, extents=extents_str, const=const) - else: - dtype = self._template(T=T, extents=extents_str, const=const) + dtype = self._template(T=T, extents=extents_str, const=const) if ref: dtype = Ref(dtype) @@ -74,7 +86,10 @@ class StdMdspan(SrcField): @staticmethod def from_field( - field: Field, extents_type: PsType = PsUnsignedIntegerType(64), ref: bool = False, const: bool = False, + field: Field, + extents_type: PsType = PsUnsignedIntegerType(64), + ref: bool = False, + const: bool = False, ): """Creates a `std::mdspan` instance for a given pystencils field.""" from pystencils.field import layout_string_to_tuple @@ -95,11 +110,7 @@ class StdMdspan(SrcField): extents.append(StdMdspan.dynamic_extent if isinstance(s, Symbol) else s) return StdMdspan( - field.dtype, - tuple(extents), - extents_type=extents_type, - ref=ref, - const=const + field.dtype, tuple(extents), extents_type=extents_type, ref=ref, const=const ).var(field.name) diff --git a/src/pystencilssfg/lang/types.py b/src/pystencilssfg/lang/types.py index 580183262a8be529c3e9de7ca49f0df8ed64811f..b3a634fbb63bb93d6c8e504030590df477cd200d 100644 --- a/src/pystencilssfg/lang/types.py +++ b/src/pystencilssfg/lang/types.py @@ -31,9 +31,15 @@ class CppType(PsCustomType, ABC): return set(str(h) for h in self.includes) -def cpptype(typestr: str, include: str | Iterable[str | HeaderFile] = ()): - if isinstance(include, str): - include = (include,) +def cpptype(typestr: str, include: str | HeaderFile | Iterable[str | HeaderFile] = ()): + headers: list[str | HeaderFile] + + if isinstance(include, (str, HeaderFile)): + headers = [ + include, + ] + else: + headers = list(include) def _fixarg(template_arg): if isinstance(template_arg, PsType): @@ -42,7 +48,7 @@ def cpptype(typestr: str, include: str | Iterable[str | HeaderFile] = ()): return str(template_arg) class TypeClass(CppType): - includes = frozenset(HeaderFile.parse(h) for h in include) + includes = frozenset(HeaderFile.parse(h) for h in headers) def __init__(self, *template_args, const: bool = False, **template_kwargs): template_args = tuple(_fixarg(arg) for arg in template_args) diff --git a/tests/generator_scripts/deps/mdspan/include/experimental/__p0009_bits/compressed_pair.hpp b/tests/generator_scripts/deps/mdspan/include/experimental/__p0009_bits/compressed_pair.hpp index 25389a2fa5e7be9c2f3bdb35d0a5ff4a746b027a..5783bdb800354e64fc6546b2462851c1f838168b 100644 --- a/tests/generator_scripts/deps/mdspan/include/experimental/__p0009_bits/compressed_pair.hpp +++ b/tests/generator_scripts/deps/mdspan/include/experimental/__p0009_bits/compressed_pair.hpp @@ -22,174 +22,176 @@ # include "no_unique_address.hpp" #endif -namespace MDSPAN_IMPL_STANDARD_NAMESPACE { +namespace std { +namespace experimental { namespace detail { // For no unique address emulation, this is the case taken when neither are empty. // For real `[[no_unique_address]]`, this case is always taken. -template <class _T1, class _T2, class _Enable = void> struct __compressed_pair { - _MDSPAN_NO_UNIQUE_ADDRESS _T1 __t1_val{}; - _MDSPAN_NO_UNIQUE_ADDRESS _T2 __t2_val{}; - MDSPAN_FORCE_INLINE_FUNCTION _MDSPAN_CONSTEXPR_14 _T1 &__first() noexcept { return __t1_val; } - MDSPAN_FORCE_INLINE_FUNCTION constexpr _T1 const &__first() const noexcept { - return __t1_val; +template <class _T, class _U, class _Enable = void> struct __compressed_pair { + _MDSPAN_NO_UNIQUE_ADDRESS _T __t_val; + _MDSPAN_NO_UNIQUE_ADDRESS _U __u_val; + MDSPAN_FORCE_INLINE_FUNCTION _MDSPAN_CONSTEXPR_14 _T &__first() noexcept { return __t_val; } + MDSPAN_FORCE_INLINE_FUNCTION constexpr _T const &__first() const noexcept { + return __t_val; } - MDSPAN_FORCE_INLINE_FUNCTION _MDSPAN_CONSTEXPR_14 _T2 &__second() noexcept { return __t2_val; } - MDSPAN_FORCE_INLINE_FUNCTION constexpr _T2 const &__second() const noexcept { - return __t2_val; + MDSPAN_FORCE_INLINE_FUNCTION _MDSPAN_CONSTEXPR_14 _U &__second() noexcept { return __u_val; } + MDSPAN_FORCE_INLINE_FUNCTION constexpr _U const &__second() const noexcept { + return __u_val; } MDSPAN_INLINE_FUNCTION_DEFAULTED - constexpr __compressed_pair() = default; + constexpr __compressed_pair() noexcept = default; MDSPAN_INLINE_FUNCTION_DEFAULTED - constexpr __compressed_pair(__compressed_pair const &) = default; + constexpr __compressed_pair(__compressed_pair const &) noexcept = default; MDSPAN_INLINE_FUNCTION_DEFAULTED - constexpr __compressed_pair(__compressed_pair &&) = default; + constexpr __compressed_pair(__compressed_pair &&) noexcept = default; MDSPAN_INLINE_FUNCTION_DEFAULTED _MDSPAN_CONSTEXPR_14_DEFAULTED __compressed_pair & - operator=(__compressed_pair const &) = default; + operator=(__compressed_pair const &) noexcept = default; MDSPAN_INLINE_FUNCTION_DEFAULTED _MDSPAN_CONSTEXPR_14_DEFAULTED __compressed_pair & - operator=(__compressed_pair &&) = default; + operator=(__compressed_pair &&) noexcept = default; MDSPAN_INLINE_FUNCTION_DEFAULTED - ~__compressed_pair() = default; - template <class _T1Like, class _T2Like> - MDSPAN_INLINE_FUNCTION constexpr __compressed_pair(_T1Like &&__t1, _T2Like &&__t2) - : __t1_val((_T1Like &&) __t1), __t2_val((_T2Like &&) __t2) {} + ~__compressed_pair() noexcept = default; + template <class _TLike, class _ULike> + MDSPAN_INLINE_FUNCTION constexpr __compressed_pair(_TLike &&__t, _ULike &&__u) + : __t_val((_TLike &&) __t), __u_val((_ULike &&) __u) {} }; #if !defined(_MDSPAN_USE_ATTRIBUTE_NO_UNIQUE_ADDRESS) // First empty. -template <class _T1, class _T2> +template <class _T, class _U> struct __compressed_pair< - _T1, _T2, - std::enable_if_t<_MDSPAN_TRAIT(std::is_empty, _T1) && !_MDSPAN_TRAIT(std::is_empty, _T2)>> - : private _T1 { - _T2 __t2_val{}; - MDSPAN_FORCE_INLINE_FUNCTION _MDSPAN_CONSTEXPR_14 _T1 &__first() noexcept { - return *static_cast<_T1 *>(this); + _T, _U, + enable_if_t<_MDSPAN_TRAIT(is_empty, _T) && !_MDSPAN_TRAIT(is_empty, _U)>> + : private _T { + _U __u_val; + MDSPAN_FORCE_INLINE_FUNCTION _MDSPAN_CONSTEXPR_14 _T &__first() noexcept { + return *static_cast<_T *>(this); } - MDSPAN_FORCE_INLINE_FUNCTION constexpr _T1 const &__first() const noexcept { - return *static_cast<_T1 const *>(this); + MDSPAN_FORCE_INLINE_FUNCTION constexpr _T const &__first() const noexcept { + return *static_cast<_T const *>(this); } - MDSPAN_FORCE_INLINE_FUNCTION _MDSPAN_CONSTEXPR_14 _T2 &__second() noexcept { return __t2_val; } - MDSPAN_FORCE_INLINE_FUNCTION constexpr _T2 const &__second() const noexcept { - return __t2_val; + MDSPAN_FORCE_INLINE_FUNCTION _MDSPAN_CONSTEXPR_14 _U &__second() noexcept { return __u_val; } + MDSPAN_FORCE_INLINE_FUNCTION constexpr _U const &__second() const noexcept { + return __u_val; } MDSPAN_INLINE_FUNCTION_DEFAULTED - constexpr __compressed_pair() = default; + constexpr __compressed_pair() noexcept = default; MDSPAN_INLINE_FUNCTION_DEFAULTED - constexpr __compressed_pair(__compressed_pair const &) = default; + constexpr __compressed_pair(__compressed_pair const &) noexcept = default; MDSPAN_INLINE_FUNCTION_DEFAULTED - constexpr __compressed_pair(__compressed_pair &&) = default; + constexpr __compressed_pair(__compressed_pair &&) noexcept = default; MDSPAN_INLINE_FUNCTION_DEFAULTED _MDSPAN_CONSTEXPR_14_DEFAULTED __compressed_pair & - operator=(__compressed_pair const &) = default; + operator=(__compressed_pair const &) noexcept = default; MDSPAN_INLINE_FUNCTION_DEFAULTED _MDSPAN_CONSTEXPR_14_DEFAULTED __compressed_pair & - operator=(__compressed_pair &&) = default; + operator=(__compressed_pair &&) noexcept = default; MDSPAN_INLINE_FUNCTION_DEFAULTED - ~__compressed_pair() = default; - template <class _T1Like, class _T2Like> - MDSPAN_INLINE_FUNCTION constexpr __compressed_pair(_T1Like &&__t1, _T2Like &&__t2) - : _T1((_T1Like &&) __t1), __t2_val((_T2Like &&) __t2) {} + ~__compressed_pair() noexcept = default; + template <class _TLike, class _ULike> + MDSPAN_INLINE_FUNCTION constexpr __compressed_pair(_TLike &&__t, _ULike &&__u) + : _T((_TLike &&) __t), __u_val((_ULike &&) __u) {} }; // Second empty. -template <class _T1, class _T2> +template <class _T, class _U> struct __compressed_pair< - _T1, _T2, - std::enable_if_t<!_MDSPAN_TRAIT(std::is_empty, _T1) && _MDSPAN_TRAIT(std::is_empty, _T2)>> - : private _T2 { - _T1 __t1_val{}; - MDSPAN_FORCE_INLINE_FUNCTION _MDSPAN_CONSTEXPR_14 _T1 &__first() noexcept { return __t1_val; } - MDSPAN_FORCE_INLINE_FUNCTION constexpr _T1 const &__first() const noexcept { - return __t1_val; + _T, _U, + enable_if_t<!_MDSPAN_TRAIT(is_empty, _T) && _MDSPAN_TRAIT(is_empty, _U)>> + : private _U { + _T __t_val; + MDSPAN_FORCE_INLINE_FUNCTION _MDSPAN_CONSTEXPR_14 _T &__first() noexcept { return __t_val; } + MDSPAN_FORCE_INLINE_FUNCTION constexpr _T const &__first() const noexcept { + return __t_val; } - MDSPAN_FORCE_INLINE_FUNCTION _MDSPAN_CONSTEXPR_14 _T2 &__second() noexcept { - return *static_cast<_T2 *>(this); + MDSPAN_FORCE_INLINE_FUNCTION _MDSPAN_CONSTEXPR_14 _U &__second() noexcept { + return *static_cast<_U *>(this); } - MDSPAN_FORCE_INLINE_FUNCTION constexpr _T2 const &__second() const noexcept { - return *static_cast<_T2 const *>(this); + MDSPAN_FORCE_INLINE_FUNCTION constexpr _U const &__second() const noexcept { + return *static_cast<_U const *>(this); } MDSPAN_INLINE_FUNCTION_DEFAULTED - constexpr __compressed_pair() = default; + constexpr __compressed_pair() noexcept = default; MDSPAN_INLINE_FUNCTION_DEFAULTED - constexpr __compressed_pair(__compressed_pair const &) = default; + constexpr __compressed_pair(__compressed_pair const &) noexcept = default; MDSPAN_INLINE_FUNCTION_DEFAULTED - constexpr __compressed_pair(__compressed_pair &&) = default; + constexpr __compressed_pair(__compressed_pair &&) noexcept = default; MDSPAN_INLINE_FUNCTION_DEFAULTED _MDSPAN_CONSTEXPR_14_DEFAULTED __compressed_pair & - operator=(__compressed_pair const &) = default; + operator=(__compressed_pair const &) noexcept = default; MDSPAN_INLINE_FUNCTION_DEFAULTED _MDSPAN_CONSTEXPR_14_DEFAULTED __compressed_pair & - operator=(__compressed_pair &&) = default; + operator=(__compressed_pair &&) noexcept = default; MDSPAN_INLINE_FUNCTION_DEFAULTED - ~__compressed_pair() = default; + ~__compressed_pair() noexcept = default; - template <class _T1Like, class _T2Like> - MDSPAN_INLINE_FUNCTION constexpr __compressed_pair(_T1Like &&__t1, _T2Like &&__t2) - : _T2((_T2Like &&) __t2), __t1_val((_T1Like &&) __t1) {} + template <class _TLike, class _ULike> + MDSPAN_INLINE_FUNCTION constexpr __compressed_pair(_TLike &&__t, _ULike &&__u) + : _U((_ULike &&) __u), __t_val((_TLike &&) __t) {} }; // Both empty. -template <class _T1, class _T2> +template <class _T, class _U> struct __compressed_pair< - _T1, _T2, - std::enable_if_t<_MDSPAN_TRAIT(std::is_empty, _T1) && _MDSPAN_TRAIT(std::is_empty, _T2)>> + _T, _U, + enable_if_t<_MDSPAN_TRAIT(is_empty, _T) && _MDSPAN_TRAIT(is_empty, _U)>> // We need to use the __no_unique_address_emulation wrapper here to avoid // base class ambiguities. #ifdef _MDSPAN_COMPILER_MSVC // MSVC doesn't allow you to access public static member functions of a type // when you *happen* to privately inherit from that type. - : protected __no_unique_address_emulation<_T1, 0>, - protected __no_unique_address_emulation<_T2, 1> + : protected __no_unique_address_emulation<_T, 0>, + protected __no_unique_address_emulation<_U, 1> #else - : private __no_unique_address_emulation<_T1, 0>, - private __no_unique_address_emulation<_T2, 1> + : private __no_unique_address_emulation<_T, 0>, + private __no_unique_address_emulation<_U, 1> #endif { - using __first_base_t = __no_unique_address_emulation<_T1, 0>; - using __second_base_t = __no_unique_address_emulation<_T2, 1>; + using __first_base_t = __no_unique_address_emulation<_T, 0>; + using __second_base_t = __no_unique_address_emulation<_U, 1>; - MDSPAN_FORCE_INLINE_FUNCTION _MDSPAN_CONSTEXPR_14 _T1 &__first() noexcept { + MDSPAN_FORCE_INLINE_FUNCTION _MDSPAN_CONSTEXPR_14 _T &__first() noexcept { return this->__first_base_t::__ref(); } - MDSPAN_FORCE_INLINE_FUNCTION constexpr _T1 const &__first() const noexcept { + MDSPAN_FORCE_INLINE_FUNCTION constexpr _T const &__first() const noexcept { return this->__first_base_t::__ref(); } - MDSPAN_FORCE_INLINE_FUNCTION _MDSPAN_CONSTEXPR_14 _T2 &__second() noexcept { + MDSPAN_FORCE_INLINE_FUNCTION _MDSPAN_CONSTEXPR_14 _U &__second() noexcept { return this->__second_base_t::__ref(); } - MDSPAN_FORCE_INLINE_FUNCTION constexpr _T2 const &__second() const noexcept { + MDSPAN_FORCE_INLINE_FUNCTION constexpr _U const &__second() const noexcept { return this->__second_base_t::__ref(); } MDSPAN_INLINE_FUNCTION_DEFAULTED - constexpr __compressed_pair() = default; + constexpr __compressed_pair() noexcept = default; MDSPAN_INLINE_FUNCTION_DEFAULTED - constexpr __compressed_pair(__compressed_pair const &) = default; + constexpr __compressed_pair(__compressed_pair const &) noexcept = default; MDSPAN_INLINE_FUNCTION_DEFAULTED - constexpr __compressed_pair(__compressed_pair &&) = default; + constexpr __compressed_pair(__compressed_pair &&) noexcept = default; MDSPAN_INLINE_FUNCTION_DEFAULTED _MDSPAN_CONSTEXPR_14_DEFAULTED __compressed_pair & - operator=(__compressed_pair const &) = default; + operator=(__compressed_pair const &) noexcept = default; MDSPAN_INLINE_FUNCTION_DEFAULTED _MDSPAN_CONSTEXPR_14_DEFAULTED __compressed_pair & - operator=(__compressed_pair &&) = default; + operator=(__compressed_pair &&) noexcept = default; MDSPAN_INLINE_FUNCTION_DEFAULTED - ~__compressed_pair() = default; - template <class _T1Like, class _T2Like> - MDSPAN_INLINE_FUNCTION constexpr __compressed_pair(_T1Like &&__t1, _T2Like &&__t2) noexcept - : __first_base_t(_T1((_T1Like &&) __t1)), - __second_base_t(_T2((_T2Like &&) __t2)) + ~__compressed_pair() noexcept = default; + template <class _TLike, class _ULike> + MDSPAN_INLINE_FUNCTION constexpr __compressed_pair(_TLike &&__t, _ULike &&__u) noexcept + : __first_base_t(_T((_TLike &&) __t)), + __second_base_t(_U((_ULike &&) __u)) { } }; #endif // !defined(_MDSPAN_USE_ATTRIBUTE_NO_UNIQUE_ADDRESS) } // end namespace detail -} // end namespace MDSPAN_IMPL_STANDARD_NAMESPACE +} // end namespace experimental +} // end namespace std diff --git a/tests/generator_scripts/deps/mdspan/include/experimental/__p0009_bits/config.hpp b/tests/generator_scripts/deps/mdspan/include/experimental/__p0009_bits/config.hpp index 24166462e7abd5e96a941b8ba9f5d302369d07c7..d35e201cebd2bd8d0b1b99e6409e618a440c7a68 100644 --- a/tests/generator_scripts/deps/mdspan/include/experimental/__p0009_bits/config.hpp +++ b/tests/generator_scripts/deps/mdspan/include/experimental/__p0009_bits/config.hpp @@ -35,17 +35,10 @@ #define MDSPAN_CXX_STD_14 201402L #define MDSPAN_CXX_STD_17 201703L #define MDSPAN_CXX_STD_20 202002L -// Note GCC has not updated this in version 13 -#ifdef __clang__ -#define MDSPAN_CXX_STD_23 202302L -#else -#define MDSPAN_CXX_STD_23 202100L -#endif #define MDSPAN_HAS_CXX_14 (_MDSPAN_CPLUSPLUS >= MDSPAN_CXX_STD_14) #define MDSPAN_HAS_CXX_17 (_MDSPAN_CPLUSPLUS >= MDSPAN_CXX_STD_17) #define MDSPAN_HAS_CXX_20 (_MDSPAN_CPLUSPLUS >= MDSPAN_CXX_STD_20) -#define MDSPAN_HAS_CXX_23 (_MDSPAN_CPLUSPLUS >= MDSPAN_CXX_STD_23) static_assert(_MDSPAN_CPLUSPLUS >= MDSPAN_CXX_STD_14, "mdspan requires C++14 or later."); @@ -205,7 +198,7 @@ static_assert(_MDSPAN_CPLUSPLUS >= MDSPAN_CXX_STD_14, "mdspan requires C++14 or #endif #ifndef _MDSPAN_USE_CLASS_TEMPLATE_ARGUMENT_DEDUCTION -# if (!defined(__NVCC__) || (__CUDACC_VER_MAJOR__ * 100 + __CUDACC_VER_MINOR__ * 10 >= 1170)) && \ +# 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 @@ -231,7 +224,7 @@ static_assert(_MDSPAN_CPLUSPLUS >= MDSPAN_CXX_STD_14, "mdspan requires C++14 or #endif #ifndef MDSPAN_CONDITIONAL_EXPLICIT -# if MDSPAN_HAS_CXX_20 +# if MDSPAN_HAS_CXX_20 && !defined(_MDSPAN_COMPILER_MSVC) # define MDSPAN_CONDITIONAL_EXPLICIT(COND) explicit(COND) # else # define MDSPAN_CONDITIONAL_EXPLICIT(COND) diff --git a/tests/generator_scripts/deps/mdspan/include/experimental/__p0009_bits/default_accessor.hpp b/tests/generator_scripts/deps/mdspan/include/experimental/__p0009_bits/default_accessor.hpp index ea0f537b2fe191ace9c6f5271d5b7331e172a4fd..f94816d7e2e1880703a7a02e53e6d900dd61d924 100644 --- a/tests/generator_scripts/deps/mdspan/include/experimental/__p0009_bits/default_accessor.hpp +++ b/tests/generator_scripts/deps/mdspan/include/experimental/__p0009_bits/default_accessor.hpp @@ -19,7 +19,8 @@ #include <cstddef> // size_t -namespace MDSPAN_IMPL_STANDARD_NAMESPACE { +namespace std { +namespace experimental { template <class ElementType> struct default_accessor { @@ -34,7 +35,7 @@ struct default_accessor { MDSPAN_TEMPLATE_REQUIRES( class OtherElementType, /* requires */ ( - _MDSPAN_TRAIT(std::is_convertible, OtherElementType(*)[], element_type(*)[]) + _MDSPAN_TRAIT(is_convertible, OtherElementType(*)[], element_type(*)[]) ) ) MDSPAN_INLINE_FUNCTION @@ -53,4 +54,5 @@ struct default_accessor { }; -} // end namespace MDSPAN_IMPL_STANDARD_NAMESPACE +} // end namespace experimental +} // end namespace std diff --git a/tests/generator_scripts/deps/mdspan/include/experimental/__p0009_bits/dynamic_extent.hpp b/tests/generator_scripts/deps/mdspan/include/experimental/__p0009_bits/dynamic_extent.hpp index 2e29da13d6adfd1107fe7ea3ff022bfcf376f189..9a8346bffcf74e5fb475ef9e3633b9a35c8b12ec 100644 --- a/tests/generator_scripts/deps/mdspan/include/experimental/__p0009_bits/dynamic_extent.hpp +++ b/tests/generator_scripts/deps/mdspan/include/experimental/__p0009_bits/dynamic_extent.hpp @@ -17,19 +17,15 @@ #include "macros.hpp" -#if defined(__cpp_lib_span) -#include <span> -#endif - #include <cstddef> // size_t #include <limits> // numeric_limits -namespace MDSPAN_IMPL_STANDARD_NAMESPACE { -#if defined(__cpp_lib_span) -using std::dynamic_extent; -#else +namespace std { +namespace experimental { + _MDSPAN_INLINE_VARIABLE constexpr auto dynamic_extent = std::numeric_limits<size_t>::max(); -#endif -} // namespace MDSPAN_IMPL_STANDARD_NAMESPACE + +} // end namespace experimental +} // namespace std //============================================================================================================== diff --git a/tests/generator_scripts/deps/mdspan/include/experimental/__p0009_bits/extents.hpp b/tests/generator_scripts/deps/mdspan/include/experimental/__p0009_bits/extents.hpp index 98a57e34e649bb6e026df34af073531883a3abbf..2295d81f9d9f514aa7e7b7287ff19648429e606b 100644 --- a/tests/generator_scripts/deps/mdspan/include/experimental/__p0009_bits/extents.hpp +++ b/tests/generator_scripts/deps/mdspan/include/experimental/__p0009_bits/extents.hpp @@ -16,18 +16,16 @@ #pragma once #include "dynamic_extent.hpp" -#include "utility.hpp" #ifdef __cpp_lib_span #include <span> #endif #include <array> -#include <type_traits> -#include <cassert> #include <cinttypes> -namespace MDSPAN_IMPL_STANDARD_NAMESPACE { +namespace std { +namespace experimental { namespace detail { // Function used to check compatibility of extents in converting constructor @@ -58,14 +56,6 @@ __check_compatible_extents( return {}; } -template<class IndexType, class ... Arguments> -MDSPAN_INLINE_FUNCTION -static constexpr bool are_valid_indices() { - return - _MDSPAN_FOLD_AND(std::is_convertible<Arguments, IndexType>::value) && - _MDSPAN_FOLD_AND(std::is_nothrow_constructible<IndexType, Arguments>::value); -} - // ------------------------------------------------------------------ // ------------ static_array ---------------------------------------- // ------------------------------------------------------------------ @@ -151,8 +141,7 @@ struct index_sequence_scan_impl<R, FirstVal, Values...> { template <size_t R, size_t FirstVal> struct index_sequence_scan_impl<R, FirstVal> { -#if defined(__NVCC__) || defined(__NVCOMPILER) || \ - defined(_MDSPAN_COMPILER_INTEL) +#if defined(__NVCC__) || defined(__NVCOMPILER) // NVCC warns about pointless comparison with 0 for R==0 and r being const // evaluatable and also 0. MDSPAN_INLINE_FUNCTION @@ -179,7 +168,7 @@ template <> struct index_sequence_scan_impl<0> { // all static values. template <class T, size_t N> struct possibly_empty_array { - T vals[N]{}; + T vals[N]; MDSPAN_INLINE_FUNCTION constexpr T &operator[](size_t r) { return vals[r]; } MDSPAN_INLINE_FUNCTION @@ -204,8 +193,8 @@ template <class T> struct possibly_empty_array<T, 0> { template <class TDynamic, class TStatic, TStatic dyn_tag, TStatic... Values> struct maybe_static_array { - static_assert(std::is_convertible<TStatic, TDynamic>::value, "maybe_static_array: TStatic must be convertible to TDynamic"); - static_assert(std::is_convertible<TDynamic, TStatic>::value, "maybe_static_array: TDynamic must be convertible to TStatic"); + static_assert(is_convertible<TStatic, TDynamic>::value, "maybe_static_array: TStatic must be convertible to TDynamic"); + static_assert(is_convertible<TDynamic, TStatic>::value, "maybe_static_array: TDynamic must be convertible to TStatic"); private: // Static values member @@ -263,17 +252,12 @@ public: #ifdef __cpp_lib_span MDSPAN_TEMPLATE_REQUIRES(class T, size_t N, - /* requires */ (N == m_size_dynamic && N > 0)) + /* requires */ (N == m_size_dynamic)) MDSPAN_INLINE_FUNCTION constexpr maybe_static_array(const std::span<T, N> &vals) { for (size_t r = 0; r < N; r++) m_dyn_vals[r] = static_cast<TDynamic>(vals[r]); } - - MDSPAN_TEMPLATE_REQUIRES(class T, size_t N, - /* requires */ (N == m_size_dynamic && N == 0)) - MDSPAN_INLINE_FUNCTION - constexpr maybe_static_array(const std::span<T, N> &) : m_dyn_vals{} {} #endif // constructors from all values @@ -282,8 +266,7 @@ public: m_size_dynamic && m_size_dynamic > 0)) MDSPAN_INLINE_FUNCTION - constexpr maybe_static_array(DynVals... vals) - : m_dyn_vals{} { + constexpr maybe_static_array(DynVals... vals) { static_assert((sizeof...(DynVals) == m_size), "Invalid number of values."); TDynamic values[m_size]{static_cast<TDynamic>(vals)...}; for (size_t r = 0; r < m_size; r++) { @@ -372,9 +355,11 @@ public: }; } // namespace detail -} // namespace MDSPAN_IMPL_STANDARD_NAMESPACE +} // namespace experimental +} // namespace std -namespace MDSPAN_IMPL_STANDARD_NAMESPACE { +namespace std { +namespace experimental { // ------------------------------------------------------------------ // ------------ extents --------------------------------------------- @@ -388,11 +373,11 @@ template <class IndexType, size_t... Extents> class extents { public: // typedefs for integral types used using index_type = IndexType; - using size_type = std::make_unsigned_t<index_type>; + using size_type = make_unsigned_t<index_type>; using rank_type = size_t; static_assert(std::is_integral<index_type>::value && !std::is_same<index_type, bool>::value, - MDSPAN_IMPL_STANDARD_NAMESPACE_STRING "::extents::index_type must be a signed or unsigned integer type"); + "extents::index_type must be a signed or unsigned integer type"); private: constexpr static rank_type m_rank = sizeof...(Extents); constexpr static rank_type m_rank_dynamic = @@ -426,9 +411,9 @@ public: MDSPAN_TEMPLATE_REQUIRES( class... OtherIndexTypes, /* requires */ ( - _MDSPAN_FOLD_AND(_MDSPAN_TRAIT(std::is_convertible, OtherIndexTypes, + _MDSPAN_FOLD_AND(_MDSPAN_TRAIT(is_convertible, OtherIndexTypes, index_type) /* && ... */) && - _MDSPAN_FOLD_AND(_MDSPAN_TRAIT(std::is_nothrow_constructible, index_type, + _MDSPAN_FOLD_AND(_MDSPAN_TRAIT(is_nothrow_constructible, index_type, OtherIndexTypes) /* && ... */) && (sizeof...(OtherIndexTypes) == m_rank || sizeof...(OtherIndexTypes) == m_rank_dynamic))) @@ -440,25 +425,25 @@ public: class OtherIndexType, size_t N, /* requires */ ( - _MDSPAN_TRAIT(std::is_convertible, const OtherIndexType&, index_type) && - _MDSPAN_TRAIT(std::is_nothrow_constructible, index_type, - const OtherIndexType&) && + _MDSPAN_TRAIT(is_convertible, OtherIndexType, index_type) && + _MDSPAN_TRAIT(is_nothrow_constructible, index_type, + OtherIndexType) && (N == m_rank || N == m_rank_dynamic))) MDSPAN_INLINE_FUNCTION MDSPAN_CONDITIONAL_EXPLICIT(N != m_rank_dynamic) - constexpr extents(const std::array<OtherIndexType, N> &exts) noexcept + constexpr extents(const array<OtherIndexType, N> &exts) noexcept : m_vals(std::move(exts)) {} #ifdef __cpp_lib_span MDSPAN_TEMPLATE_REQUIRES( class OtherIndexType, size_t N, /* requires */ - (_MDSPAN_TRAIT(std::is_convertible, const OtherIndexType&, index_type) && - _MDSPAN_TRAIT(std::is_nothrow_constructible, index_type, const OtherIndexType&) && + (_MDSPAN_TRAIT(is_convertible, OtherIndexType, index_type) && + _MDSPAN_TRAIT(is_nothrow_constructible, index_type, OtherIndexType) && (N == m_rank || N == m_rank_dynamic))) MDSPAN_INLINE_FUNCTION MDSPAN_CONDITIONAL_EXPLICIT(N != m_rank_dynamic) - constexpr extents(const std::span<OtherIndexType, N> &exts) noexcept + constexpr extents(const span<OtherIndexType, N> &exts) noexcept : m_vals(std::move(exts)) {} #endif @@ -471,7 +456,6 @@ private: size_t DynCount, size_t R, class OtherExtents, class... DynamicValues, /* requires */ ((R < m_rank) && (static_extent(R) == dynamic_extent))) MDSPAN_INLINE_FUNCTION - constexpr vals_t __construct_vals_from_extents(std::integral_constant<size_t, DynCount>, std::integral_constant<size_t, R>, const OtherExtents &exts, @@ -486,7 +470,6 @@ private: size_t DynCount, size_t R, class OtherExtents, class... DynamicValues, /* requires */ ((R < m_rank) && (static_extent(R) != dynamic_extent))) MDSPAN_INLINE_FUNCTION - constexpr vals_t __construct_vals_from_extents(std::integral_constant<size_t, DynCount>, std::integral_constant<size_t, R>, const OtherExtents &exts, @@ -500,7 +483,6 @@ private: size_t DynCount, size_t R, class OtherExtents, class... DynamicValues, /* requires */ ((R == m_rank) && (DynCount == m_rank_dynamic))) MDSPAN_INLINE_FUNCTION - constexpr vals_t __construct_vals_from_extents(std::integral_constant<size_t, DynCount>, std::integral_constant<size_t, R>, const OtherExtents &, @@ -511,20 +493,17 @@ private: public: // Converting constructor from other extents specializations - MDSPAN_TEMPLATE_REQUIRES( - class OtherIndexType, size_t... OtherExtents, - /* requires */ - ( - /* multi-stage check to protect from invalid pack expansion when sizes - don't match? */ - decltype(detail::__check_compatible_extents( - // using: sizeof...(Extents) == sizeof...(OtherExtents) as the second argument fails with MSVC+NVCC with some obscure expansion error - // MSVC: 19.38.33133 NVCC: 12.0 - std::integral_constant<bool, extents<int, Extents...>::rank() == extents<int, OtherExtents...>::rank()>{}, + MDSPAN_TEMPLATE_REQUIRES( + class OtherIndexType, size_t... OtherExtents, + /* requires */ + ( + /* multi-stage check to protect from invalid pack expansion when sizes + don't match? */ + decltype(detail::__check_compatible_extents( + std::integral_constant<bool, sizeof...(Extents) == + sizeof...(OtherExtents)>{}, std::integer_sequence<size_t, Extents...>{}, - std::integer_sequence<size_t, OtherExtents...>{}))::value - ) - ) + std::integer_sequence<size_t, OtherExtents...>{}))::value)) MDSPAN_INLINE_FUNCTION MDSPAN_CONDITIONAL_EXPLICIT((((Extents != dynamic_extent) && (OtherExtents == dynamic_extent)) || @@ -541,9 +520,10 @@ public: MDSPAN_INLINE_FUNCTION friend constexpr bool operator==(const extents &lhs, const extents<OtherIndexType, OtherExtents...> &rhs) noexcept { - return - rank() == extents<OtherIndexType, OtherExtents...>::rank() && - detail::rankwise_equal(detail::with_rank<rank()>{}, rhs, lhs, detail::extent); + bool value = true; + for (size_type r = 0; r < m_rank; r++) + value &= rhs.extent(r) == lhs.extent(r); + return value; } #if !(MDSPAN_HAS_CXX_20) @@ -560,25 +540,23 @@ public: namespace detail { template <class IndexType, size_t Rank, - class Extents = ::MDSPAN_IMPL_STANDARD_NAMESPACE::extents<IndexType>> + class Extents = ::std::experimental::extents<IndexType>> struct __make_dextents; template <class IndexType, size_t Rank, size_t... ExtentsPack> struct __make_dextents< - IndexType, Rank, ::MDSPAN_IMPL_STANDARD_NAMESPACE::extents<IndexType, ExtentsPack...>> -{ + IndexType, Rank, ::std::experimental::extents<IndexType, ExtentsPack...>> { using type = typename __make_dextents< IndexType, Rank - 1, - ::MDSPAN_IMPL_STANDARD_NAMESPACE::extents<IndexType, - ::MDSPAN_IMPL_STANDARD_NAMESPACE::dynamic_extent, - ExtentsPack...>>::type; + ::std::experimental::extents<IndexType, + ::std::experimental::dynamic_extent, + ExtentsPack...>>::type; }; template <class IndexType, size_t... ExtentsPack> struct __make_dextents< - IndexType, 0, ::MDSPAN_IMPL_STANDARD_NAMESPACE::extents<IndexType, ExtentsPack...>> -{ - using type = ::MDSPAN_IMPL_STANDARD_NAMESPACE::extents<IndexType, ExtentsPack...>; + IndexType, 0, ::std::experimental::extents<IndexType, ExtentsPack...>> { + using type = ::std::experimental::extents<IndexType, ExtentsPack...>; }; } // end namespace detail @@ -592,7 +570,7 @@ using dextents = typename detail::__make_dextents<IndexType, Rank>::type; template <class... IndexTypes> extents(IndexTypes...) -> extents<size_t, - ((void) sizeof(IndexTypes), ::MDSPAN_IMPL_STANDARD_NAMESPACE::dynamic_extent)...>; + size_t((IndexTypes(), ::std::experimental::dynamic_extent))...>; #endif // Helper type traits for identifying a class as extents. @@ -601,7 +579,7 @@ namespace detail { template <class T> struct __is_extents : ::std::false_type {}; template <class IndexType, size_t... ExtentsPack> -struct __is_extents<::MDSPAN_IMPL_STANDARD_NAMESPACE::extents<IndexType, ExtentsPack...>> +struct __is_extents<::std::experimental::extents<IndexType, ExtentsPack...>> : ::std::true_type {}; template <class T> @@ -612,80 +590,6 @@ static #endif constexpr bool __is_extents_v = __is_extents<T>::value; -template<class InputIndexType, class ExtentsIndexType> -MDSPAN_INLINE_FUNCTION -constexpr void -check_lower_bound(InputIndexType user_index, - ExtentsIndexType /* current_extent */, - std::true_type /* is_signed */) -{ - (void) user_index; // prevent unused variable warning -#ifdef _MDSPAN_DEBUG - assert(static_cast<ExtentsIndexType>(user_index) >= 0); -#endif -} - -template<class InputIndexType, class ExtentsIndexType> -MDSPAN_INLINE_FUNCTION -constexpr void -check_lower_bound(InputIndexType /* user_index */, - ExtentsIndexType /* current_extent */, - std::false_type /* is_signed */) -{} - -template<class InputIndexType, class ExtentsIndexType> -MDSPAN_INLINE_FUNCTION -constexpr void -check_upper_bound(InputIndexType user_index, - ExtentsIndexType current_extent) -{ - (void) user_index; // prevent unused variable warnings - (void) current_extent; -#ifdef _MDSPAN_DEBUG - assert(static_cast<ExtentsIndexType>(user_index) < current_extent); -#endif -} - -// Returning true to use AND fold instead of comma -// CPP14 mode doesn't like the use of void expressions -// with the way the _MDSPAN_FOLD_AND is set up -template<class InputIndex, class ExtentsIndexType> -MDSPAN_INLINE_FUNCTION -constexpr bool -check_one_index(InputIndex user_index, - ExtentsIndexType current_extent) -{ - check_lower_bound(user_index, current_extent, - std::integral_constant<bool, std::is_signed<ExtentsIndexType>::value>{}); - check_upper_bound(user_index, current_extent); - return true; -} - -template<size_t ... RankIndices, - class ExtentsIndexType, size_t ... Exts, - class ... Indices> -MDSPAN_INLINE_FUNCTION -constexpr void -check_all_indices_helper(std::index_sequence<RankIndices...>, - const extents<ExtentsIndexType, Exts...>& exts, - Indices... indices) -{ - // Suppress warning about statement has no effect - (void) _MDSPAN_FOLD_AND( - (check_one_index(indices, exts.extent(RankIndices))) - ); -} - -template<class ExtentsIndexType, size_t ... Exts, - class ... Indices> -MDSPAN_INLINE_FUNCTION -constexpr void -check_all_indices(const extents<ExtentsIndexType, Exts...>& exts, - Indices... indices) -{ - check_all_indices_helper(std::make_index_sequence<sizeof...(Indices)>(), - exts, indices...); -} - } // namespace detail -} // namespace MDSPAN_IMPL_STANDARD_NAMESPACE +} // namespace experimental +} // namespace std diff --git a/tests/generator_scripts/deps/mdspan/include/experimental/__p0009_bits/full_extent_t.hpp b/tests/generator_scripts/deps/mdspan/include/experimental/__p0009_bits/full_extent_t.hpp index bd4b5c6a8baa31a21281b1528ae2f57a264a7d53..a8742620ede1858418d0c057cd788355bc2d3e28 100644 --- a/tests/generator_scripts/deps/mdspan/include/experimental/__p0009_bits/full_extent_t.hpp +++ b/tests/generator_scripts/deps/mdspan/include/experimental/__p0009_bits/full_extent_t.hpp @@ -17,10 +17,12 @@ #include "macros.hpp" -namespace MDSPAN_IMPL_STANDARD_NAMESPACE { +namespace std { +namespace experimental { struct full_extent_t { explicit full_extent_t() = default; }; _MDSPAN_INLINE_VARIABLE constexpr auto full_extent = full_extent_t{ }; -} // namespace MDSPAN_IMPL_STANDARD_NAMESPACE +} // end namespace experimental +} // namespace std diff --git a/tests/generator_scripts/deps/mdspan/include/experimental/__p0009_bits/layout_left.hpp b/tests/generator_scripts/deps/mdspan/include/experimental/__p0009_bits/layout_left.hpp index 222fba7aa04951df4f73b7894db14b6ab34233c3..0bfa5680977d43c647d59f09ae0600e3ba00de91 100644 --- a/tests/generator_scripts/deps/mdspan/include/experimental/__p0009_bits/layout_left.hpp +++ b/tests/generator_scripts/deps/mdspan/include/experimental/__p0009_bits/layout_left.hpp @@ -18,14 +18,9 @@ #include "macros.hpp" #include "trait_backports.hpp" #include "extents.hpp" -#include "layout_stride.hpp" -#include "utility.hpp" -#if MDSPAN_HAS_CXX_17 -#include "../__p2642_bits/layout_padded_fwd.hpp" -#endif -#include <type_traits> -namespace MDSPAN_IMPL_STANDARD_NAMESPACE { +namespace std { +namespace experimental { //============================================================================== @@ -39,8 +34,7 @@ class layout_left::mapping { using layout_type = layout_left; private: - static_assert(detail::__is_extents_v<extents_type>, - MDSPAN_IMPL_STANDARD_NAMESPACE_STRING "::layout_left::mapping must be instantiated with a specialization of " MDSPAN_IMPL_STANDARD_NAMESPACE_STRING "::extents."); + static_assert(detail::__is_extents_v<extents_type>, "std::experimental::layout_left::mapping must be instantiated with a specialization of std::experimental::extents."); template <class> friend class mapping; @@ -82,10 +76,10 @@ class layout_left::mapping { MDSPAN_TEMPLATE_REQUIRES( class OtherExtents, /* requires */ ( - _MDSPAN_TRAIT(std::is_constructible, extents_type, OtherExtents) + _MDSPAN_TRAIT(is_constructible, extents_type, OtherExtents) ) ) - MDSPAN_CONDITIONAL_EXPLICIT((!std::is_convertible<OtherExtents, extents_type>::value)) // needs two () due to comma + MDSPAN_CONDITIONAL_EXPLICIT((!is_convertible<OtherExtents, extents_type>::value)) // needs two () due to comma MDSPAN_INLINE_FUNCTION _MDSPAN_CONSTEXPR_14 mapping(mapping<OtherExtents> const& other) noexcept // NOLINT(google-explicit-constructor) :__extents(other.extents()) @@ -99,11 +93,11 @@ class layout_left::mapping { MDSPAN_TEMPLATE_REQUIRES( class OtherExtents, /* requires */ ( - _MDSPAN_TRAIT(std::is_constructible, extents_type, OtherExtents) && + _MDSPAN_TRAIT(is_constructible, extents_type, OtherExtents) && (extents_type::rank() <= 1) ) ) - MDSPAN_CONDITIONAL_EXPLICIT((!std::is_convertible<OtherExtents, extents_type>::value)) // needs two () due to comma + MDSPAN_CONDITIONAL_EXPLICIT((!is_convertible<OtherExtents, extents_type>::value)) // needs two () due to comma MDSPAN_INLINE_FUNCTION _MDSPAN_CONSTEXPR_14 mapping(layout_right::mapping<OtherExtents> const& other) noexcept // NOLINT(google-explicit-constructor) :__extents(other.extents()) @@ -114,40 +108,10 @@ class layout_left::mapping { */ } -#if MDSPAN_HAS_CXX_17 - /** - * Converting constructor from `layout_left_padded::mapping`. - * - * This overload participates in overload resolution only if _Mapping is a layout_left_padded mapping and - * extents_type is constructible from _Mapping::extents_type. - * - * \note There is currently a difference from p2642r2, where this function is specified as taking - * `layout_left_padded< padding_value >::mapping< Extents>`. However, this makes `padding_value` non-deducible. - */ - MDSPAN_TEMPLATE_REQUIRES( - class _Mapping, - /* requires */ ( - MDSPAN_IMPL_PROPOSED_NAMESPACE::detail::is_layout_left_padded_mapping<_Mapping>::value - && std::is_constructible_v<extents_type, typename _Mapping::extents_type> - ) - ) - MDSPAN_CONDITIONAL_EXPLICIT((!std::is_convertible_v<typename _Mapping::extents_type, extents_type>)) - mapping(const _Mapping& __other) noexcept - : __extents(__other.extents()) - { - MDSPAN_IMPL_PROPOSED_NAMESPACE::detail:: - check_padded_layout_converting_constructor_mandates< - extents_type, _Mapping>(detail::with_rank<extents_type::rank()>{}); - MDSPAN_IMPL_PROPOSED_NAMESPACE::detail:: - check_padded_layout_converting_constructor_preconditions< - extents_type>(detail::with_rank<extents_type::rank()>{}, __other); - } -#endif - MDSPAN_TEMPLATE_REQUIRES( class OtherExtents, /* requires */ ( - _MDSPAN_TRAIT(std::is_constructible, extents_type, OtherExtents) + _MDSPAN_TRAIT(is_constructible, extents_type, OtherExtents) ) ) MDSPAN_CONDITIONAL_EXPLICIT((extents_type::rank() > 0)) @@ -159,7 +123,16 @@ class layout_left::mapping { * TODO: check precondition * other.required_span_size() is a representable value of type index_type */ - detail::validate_strides(detail::with_rank<extents_type::rank()>{}, layout_left{}, __extents, other); + #if !defined(_MDSPAN_HAS_CUDA) && !defined(_MDSPAN_HAS_HIP) && !defined(NDEBUG) + index_type stride = 1; + for(rank_type r=0; r<__extents.rank(); r++) { + if(stride != static_cast<index_type>(other.stride(r))) { + // Note this throw will lead to a terminate if triggered since this function is marked noexcept + throw std::runtime_error("Assigning layout_stride to layout_left with invalid strides."); + } + stride *= __extents.extent(r); + } + #endif } MDSPAN_INLINE_FUNCTION_DEFAULTED _MDSPAN_CONSTEXPR_14_DEFAULTED mapping& operator=(mapping const&) noexcept = default; @@ -182,14 +155,14 @@ class layout_left::mapping { class... Indices, /* requires */ ( (sizeof...(Indices) == extents_type::rank()) && - (detail::are_valid_indices<index_type, Indices...>()) + _MDSPAN_FOLD_AND( + (_MDSPAN_TRAIT(is_convertible, Indices, index_type) && + _MDSPAN_TRAIT(is_nothrow_constructible, index_type, Indices)) + ) ) ) _MDSPAN_HOST_DEVICE constexpr index_type operator()(Indices... idxs) const noexcept { -#if ! defined(NDEBUG) - detail::check_all_indices(this->extents(), idxs...); -#endif // ! NDEBUG return __compute_offset(__rank_count<0, extents_type::rank()>(), static_cast<index_type>(idxs)...); } @@ -199,9 +172,9 @@ class layout_left::mapping { MDSPAN_INLINE_FUNCTION static constexpr bool is_always_exhaustive() noexcept { return true; } MDSPAN_INLINE_FUNCTION static constexpr bool is_always_strided() noexcept { return true; } - MDSPAN_INLINE_FUNCTION static constexpr bool is_unique() noexcept { return true; } - MDSPAN_INLINE_FUNCTION static constexpr bool is_exhaustive() noexcept { return true; } - MDSPAN_INLINE_FUNCTION static constexpr bool is_strided() noexcept { return true; } + MDSPAN_INLINE_FUNCTION constexpr bool is_unique() const noexcept { return true; } + MDSPAN_INLINE_FUNCTION constexpr bool is_exhaustive() const noexcept { return true; } + MDSPAN_INLINE_FUNCTION constexpr bool is_strided() const noexcept { return true; } MDSPAN_INLINE_FUNCTION constexpr index_type stride(rank_type i) const noexcept @@ -214,10 +187,7 @@ class layout_left::mapping { return value; } - MDSPAN_TEMPLATE_REQUIRES( - class OtherExtents, - /* requires */ ( Extents::rank() == OtherExtents::rank()) - ) + template<class OtherExtents> MDSPAN_INLINE_FUNCTION friend constexpr bool operator==(mapping const& lhs, mapping<OtherExtents> const& rhs) noexcept { return lhs.extents() == rhs.extents(); @@ -225,10 +195,7 @@ class layout_left::mapping { // In C++ 20 the not equal exists if equal is found #if !(MDSPAN_HAS_CXX_20) - MDSPAN_TEMPLATE_REQUIRES( - class OtherExtents, - /* requires */ ( Extents::rank() == OtherExtents::rank()) - ) + template<class OtherExtents> MDSPAN_INLINE_FUNCTION friend constexpr bool operator!=(mapping const& lhs, mapping<OtherExtents> const& rhs) noexcept { return lhs.extents() != rhs.extents(); @@ -237,30 +204,20 @@ class layout_left::mapping { // Not really public, but currently needed to implement fully constexpr useable submdspan: template<size_t N, class SizeType, size_t ... E, size_t ... Idx> - constexpr index_type __get_stride(MDSPAN_IMPL_STANDARD_NAMESPACE::extents<SizeType, E...>,std::integer_sequence<size_t, Idx...>) const { + constexpr index_type __get_stride(std::experimental::extents<SizeType, E...>,integer_sequence<size_t, Idx...>) const { return _MDSPAN_FOLD_TIMES_RIGHT((Idx<N? __extents.template __extent<Idx>():1),1); } template<size_t N> constexpr index_type __stride() const noexcept { - return __get_stride<N>(__extents, std::make_index_sequence<extents_type::rank()>()); + return __get_stride<N>(__extents, make_index_sequence<extents_type::rank()>()); } private: _MDSPAN_NO_UNIQUE_ADDRESS extents_type __extents{}; - // [mdspan.submdspan.mapping], submdspan mapping specialization - template<class... SliceSpecifiers> - MDSPAN_INLINE_FUNCTION - constexpr auto submdspan_mapping_impl( - SliceSpecifiers... slices) const; - - template<class... SliceSpecifiers> - friend constexpr auto submdspan_mapping( - const mapping& src, SliceSpecifiers... slices) { - return src.submdspan_mapping_impl(slices...); - } }; -} // end namespace MDSPAN_IMPL_STANDARD_NAMESPACE +} // end namespace experimental +} // end namespace std diff --git a/tests/generator_scripts/deps/mdspan/include/experimental/__p0009_bits/layout_right.hpp b/tests/generator_scripts/deps/mdspan/include/experimental/__p0009_bits/layout_right.hpp index 284569f6533251667d07a8b98de2feb01bbd9381..a3f3ab8691c53301ead701d404129910ff5f7646 100644 --- a/tests/generator_scripts/deps/mdspan/include/experimental/__p0009_bits/layout_right.hpp +++ b/tests/generator_scripts/deps/mdspan/include/experimental/__p0009_bits/layout_right.hpp @@ -18,13 +18,11 @@ #include "macros.hpp" #include "trait_backports.hpp" #include "extents.hpp" +#include <stdexcept> #include "layout_stride.hpp" -#include "utility.hpp" -#if MDSPAN_HAS_CXX_17 -#include "../__p2642_bits/layout_padded_fwd.hpp" -#endif -namespace MDSPAN_IMPL_STANDARD_NAMESPACE { +namespace std { +namespace experimental { //============================================================================== template <class Extents> @@ -37,8 +35,7 @@ class layout_right::mapping { using layout_type = layout_right; private: - static_assert(detail::__is_extents_v<extents_type>, - MDSPAN_IMPL_STANDARD_NAMESPACE_STRING "::layout_right::mapping must be instantiated with a specialization of " MDSPAN_IMPL_STANDARD_NAMESPACE_STRING "::extents."); + static_assert(detail::__is_extents_v<extents_type>, "std::experimental::layout_right::mapping must be instantiated with a specialization of std::experimental::extents."); template <class> friend class mapping; @@ -84,10 +81,10 @@ class layout_right::mapping { MDSPAN_TEMPLATE_REQUIRES( class OtherExtents, /* requires */ ( - _MDSPAN_TRAIT(std::is_constructible, extents_type, OtherExtents) + _MDSPAN_TRAIT(is_constructible, extents_type, OtherExtents) ) ) - MDSPAN_CONDITIONAL_EXPLICIT((!std::is_convertible<OtherExtents, extents_type>::value)) // needs two () due to comma + MDSPAN_CONDITIONAL_EXPLICIT((!is_convertible<OtherExtents, extents_type>::value)) // needs two () due to comma MDSPAN_INLINE_FUNCTION _MDSPAN_CONSTEXPR_14 mapping(mapping<OtherExtents> const& other) noexcept // NOLINT(google-explicit-constructor) :__extents(other.extents()) @@ -101,11 +98,11 @@ class layout_right::mapping { MDSPAN_TEMPLATE_REQUIRES( class OtherExtents, /* requires */ ( - _MDSPAN_TRAIT(std::is_constructible, extents_type, OtherExtents) && + _MDSPAN_TRAIT(is_constructible, extents_type, OtherExtents) && (extents_type::rank() <= 1) ) ) - MDSPAN_CONDITIONAL_EXPLICIT((!std::is_convertible<OtherExtents, extents_type>::value)) // needs two () due to comma + MDSPAN_CONDITIONAL_EXPLICIT((!is_convertible<OtherExtents, extents_type>::value)) // needs two () due to comma MDSPAN_INLINE_FUNCTION _MDSPAN_CONSTEXPR_14 mapping(layout_left::mapping<OtherExtents> const& other) noexcept // NOLINT(google-explicit-constructor) :__extents(other.extents()) @@ -116,38 +113,10 @@ class layout_right::mapping { */ } - /** - * Converting constructor from `layout_right_padded::mapping`. - * - * This overload participates in overload resolution only if _Mapping is a layout_right_padded mapping and - * extents_type is constructible from _Mapping::extents_type. - * - * \note There is currently a difference from p2642r2, where this function is specified as taking - * `layout_right_padded< padding_value >::mapping< Extents>`. However, this makes `padding_value` non-deducible. - */ -#if MDSPAN_HAS_CXX_17 - MDSPAN_TEMPLATE_REQUIRES( - class _Mapping, - /* requires */ ( - MDSPAN_IMPL_PROPOSED_NAMESPACE::detail::is_layout_right_padded_mapping<_Mapping>::value - && std::is_constructible_v<extents_type, typename _Mapping::extents_type>)) - MDSPAN_CONDITIONAL_EXPLICIT((!std::is_convertible_v<typename _Mapping::extents_type, extents_type>)) - mapping(const _Mapping &__other) noexcept - : __extents(__other.extents()) - { - MDSPAN_IMPL_PROPOSED_NAMESPACE::detail:: - check_padded_layout_converting_constructor_mandates< - extents_type, _Mapping>(detail::with_rank<extents_type::rank()>{}); - MDSPAN_IMPL_PROPOSED_NAMESPACE::detail:: - check_padded_layout_converting_constructor_preconditions< - extents_type>(detail::with_rank<extents_type::rank()>{}, __other); - } -#endif - MDSPAN_TEMPLATE_REQUIRES( class OtherExtents, /* requires */ ( - _MDSPAN_TRAIT(std::is_constructible, extents_type, OtherExtents) + _MDSPAN_TRAIT(is_constructible, extents_type, OtherExtents) ) ) MDSPAN_CONDITIONAL_EXPLICIT((extents_type::rank() > 0)) @@ -159,7 +128,16 @@ class layout_right::mapping { * TODO: check precondition * other.required_span_size() is a representable value of type index_type */ - detail::validate_strides(detail::with_rank<extents_type::rank()>{}, layout_right{}, __extents, other); + #if !defined(_MDSPAN_HAS_CUDA) && !defined(_MDSPAN_HAS_HIP) && !defined(NDEBUG) + index_type stride = 1; + for(rank_type r=__extents.rank(); r>0; r--) { + if(stride != static_cast<index_type>(other.stride(r-1))) { + // Note this throw will lead to a terminate if triggered since this function is marked noexcept + throw std::runtime_error("Assigning layout_stride to layout_right with invalid strides."); + } + stride *= __extents.extent(r-1); + } + #endif } MDSPAN_INLINE_FUNCTION_DEFAULTED _MDSPAN_CONSTEXPR_14_DEFAULTED mapping& operator=(mapping const&) noexcept = default; @@ -179,26 +157,26 @@ class layout_right::mapping { //-------------------------------------------------------------------------------- MDSPAN_TEMPLATE_REQUIRES( - class ... Indices, + class... Indices, /* requires */ ( - (sizeof...(Indices) == extents_type::rank()) && - (detail::are_valid_indices<index_type, Indices...>()) + (sizeof...(Indices) == extents_type::rank()) && + _MDSPAN_FOLD_AND( + (_MDSPAN_TRAIT(is_convertible, Indices, index_type) && + _MDSPAN_TRAIT(is_nothrow_constructible, index_type, Indices)) + ) ) ) _MDSPAN_HOST_DEVICE constexpr index_type operator()(Indices... idxs) const noexcept { -#if ! defined(NDEBUG) - detail::check_all_indices(this->extents(), idxs...); -#endif // ! NDEBUG return __compute_offset(__rank_count<0, extents_type::rank()>(), static_cast<index_type>(idxs)...); } MDSPAN_INLINE_FUNCTION static constexpr bool is_always_unique() noexcept { return true; } MDSPAN_INLINE_FUNCTION static constexpr bool is_always_exhaustive() noexcept { return true; } MDSPAN_INLINE_FUNCTION static constexpr bool is_always_strided() noexcept { return true; } - MDSPAN_INLINE_FUNCTION static constexpr bool is_unique() noexcept { return true; } - MDSPAN_INLINE_FUNCTION static constexpr bool is_exhaustive() noexcept { return true; } - MDSPAN_INLINE_FUNCTION static constexpr bool is_strided() noexcept { return true; } + MDSPAN_INLINE_FUNCTION constexpr bool is_unique() const noexcept { return true; } + MDSPAN_INLINE_FUNCTION constexpr bool is_exhaustive() const noexcept { return true; } + MDSPAN_INLINE_FUNCTION constexpr bool is_strided() const noexcept { return true; } MDSPAN_INLINE_FUNCTION constexpr index_type stride(rank_type i) const noexcept @@ -211,10 +189,7 @@ class layout_right::mapping { return value; } - MDSPAN_TEMPLATE_REQUIRES( - class OtherExtents, - /* requires */ ( Extents::rank() == OtherExtents::rank()) - ) + template<class OtherExtents> MDSPAN_INLINE_FUNCTION friend constexpr bool operator==(mapping const& lhs, mapping<OtherExtents> const& rhs) noexcept { return lhs.extents() == rhs.extents(); @@ -222,10 +197,7 @@ class layout_right::mapping { // In C++ 20 the not equal exists if equal is found #if !(MDSPAN_HAS_CXX_20) - MDSPAN_TEMPLATE_REQUIRES( - class OtherExtents, - /* requires */ (Extents::rank() == OtherExtents::rank()) - ) + template<class OtherExtents> MDSPAN_INLINE_FUNCTION friend constexpr bool operator!=(mapping const& lhs, mapping<OtherExtents> const& rhs) noexcept { return lhs.extents() != rhs.extents(); @@ -234,29 +206,19 @@ class layout_right::mapping { // Not really public, but currently needed to implement fully constexpr useable submdspan: template<size_t N, class SizeType, size_t ... E, size_t ... Idx> - constexpr index_type __get_stride(MDSPAN_IMPL_STANDARD_NAMESPACE::extents<SizeType, E...>,std::integer_sequence<size_t, Idx...>) const { + constexpr index_type __get_stride(std::experimental::extents<SizeType, E...>,integer_sequence<size_t, Idx...>) const { return _MDSPAN_FOLD_TIMES_RIGHT((Idx>N? __extents.template __extent<Idx>():1),1); } template<size_t N> constexpr index_type __stride() const noexcept { - return __get_stride<N>(__extents, std::make_index_sequence<extents_type::rank()>()); + return __get_stride<N>(__extents, make_index_sequence<extents_type::rank()>()); } private: _MDSPAN_NO_UNIQUE_ADDRESS extents_type __extents{}; - // [mdspan.submdspan.mapping], submdspan mapping specialization - template<class... SliceSpecifiers> - MDSPAN_INLINE_FUNCTION - constexpr auto submdspan_mapping_impl( - SliceSpecifiers... slices) const; - - template<class... SliceSpecifiers> - friend constexpr auto submdspan_mapping( - const mapping& src, SliceSpecifiers... slices) { - return src.submdspan_mapping_impl(slices...); - } }; -} // end namespace MDSPAN_IMPL_STANDARD_NAMESPACE +} // end namespace experimental +} // end namespace std diff --git a/tests/generator_scripts/deps/mdspan/include/experimental/__p0009_bits/layout_stride.hpp b/tests/generator_scripts/deps/mdspan/include/experimental/__p0009_bits/layout_stride.hpp index ea2cd3802fd942d30dd8293217cc5c0dc498b8b1..cac4f90091da46a51017c11f33fe50e60953f57c 100644 --- a/tests/generator_scripts/deps/mdspan/include/experimental/__p0009_bits/layout_stride.hpp +++ b/tests/generator_scripts/deps/mdspan/include/experimental/__p0009_bits/layout_stride.hpp @@ -19,69 +19,50 @@ #include "extents.hpp" #include "trait_backports.hpp" #include "compressed_pair.hpp" -#include "utility.hpp" #if !defined(_MDSPAN_USE_ATTRIBUTE_NO_UNIQUE_ADDRESS) # include "no_unique_address.hpp" #endif +#include <algorithm> +#include <numeric> #include <array> -#include <type_traits> -#include <utility> - #ifdef __cpp_lib_span #include <span> #endif -#if defined(_MDSPAN_USE_CONCEPTS) && MDSPAN_HAS_CXX_20 && defined(__cpp_lib_concepts) -# include <concepts> +#if defined(_MDSPAN_USE_CONCEPTS) && MDSPAN_HAS_CXX_20 +#include<concepts> #endif -namespace MDSPAN_IMPL_STANDARD_NAMESPACE { +namespace std { +namespace experimental { struct layout_left { template<class Extents> - class mapping; + class mapping; }; struct layout_right { template<class Extents> - class mapping; + class mapping; }; namespace detail { template<class Layout, class Mapping> constexpr bool __is_mapping_of = - std::is_same<typename Layout::template mapping<typename Mapping::extents_type>, Mapping>::value; + is_same<typename Layout::template mapping<typename Mapping::extents_type>, Mapping>::value; #if defined(_MDSPAN_USE_CONCEPTS) && MDSPAN_HAS_CXX_20 -# if !defined(__cpp_lib_concepts) - namespace internal { - namespace detail { - template <typename _Tp, typename _Up> - concept __same_as = std::is_same_v<_Tp, _Up>; - } // namespace detail - template <class T, class U> - concept __same_as = detail::__same_as<T, U> && detail::__same_as<U, T>; - } // namespace internal -# endif - template<class M> concept __layout_mapping_alike = requires { requires __is_extents<typename M::extents_type>::value; -#if defined(__cpp_lib_concepts) - { M::is_always_strided() } -> std::same_as<bool>; - { M::is_always_exhaustive() } -> std::same_as<bool>; - { M::is_always_unique() } -> std::same_as<bool>; -#else - { M::is_always_strided() } -> internal::__same_as<bool>; - { M::is_always_exhaustive() } -> internal::__same_as<bool>; - { M::is_always_unique() } -> internal::__same_as<bool>; -#endif - std::bool_constant<M::is_always_strided()>::value; - std::bool_constant<M::is_always_exhaustive()>::value; - std::bool_constant<M::is_always_unique()>::value; + { M::is_always_strided() } -> same_as<bool>; + { M::is_always_exhaustive() } -> same_as<bool>; + { M::is_always_unique() } -> same_as<bool>; + bool_constant<M::is_always_strided()>::value; + bool_constant<M::is_always_exhaustive()>::value; + bool_constant<M::is_always_unique()>::value; }; #endif - } // namespace detail struct layout_stride { @@ -91,7 +72,7 @@ struct layout_stride { : private detail::__no_unique_address_emulation< detail::__compressed_pair< Extents, - detail::possibly_empty_array<typename Extents::index_type, Extents::rank()> + std::array<typename Extents::index_type, Extents::rank()> > > #endif @@ -104,15 +85,14 @@ struct layout_stride { using layout_type = layout_stride; // This could be a `requires`, but I think it's better and clearer as a `static_assert`. - static_assert(detail::__is_extents_v<Extents>, - MDSPAN_IMPL_STANDARD_NAMESPACE_STRING "::layout_stride::mapping must be instantiated with a specialization of " MDSPAN_IMPL_STANDARD_NAMESPACE_STRING "::extents."); + static_assert(detail::__is_extents_v<Extents>, "std::experimental::layout_stride::mapping must be instantiated with a specialization of std::experimental::extents."); private: //---------------------------------------------------------------------------- - using __strides_storage_t = detail::possibly_empty_array<index_type, extents_type::rank()>; + using __strides_storage_t = array<index_type, extents_type::rank()>;//::std::experimental::dextents<index_type, extents_type::rank()>; using __member_pair_t = detail::__compressed_pair<extents_type, __strides_storage_t>; #if defined(_MDSPAN_USE_ATTRIBUTE_NO_UNIQUE_ADDRESS) @@ -138,9 +118,9 @@ struct layout_stride { #endif } - template<class SizeType, size_t ... Ep, size_t ... Idx> + template<class SizeType, ::std::size_t ... Ep, ::std::size_t ... Idx> _MDSPAN_HOST_DEVICE - constexpr index_type __get_size(::MDSPAN_IMPL_STANDARD_NAMESPACE::extents<SizeType, Ep...>,std::integer_sequence<size_t, Idx...>) const { + constexpr index_type __get_size(::std::experimental::extents<SizeType, Ep...>,integer_sequence<::std::size_t, Idx...>) const { return _MDSPAN_FOLD_TIMES_RIGHT( static_cast<index_type>(extents().extent(Idx)), 1 ); } @@ -156,21 +136,19 @@ struct layout_stride { struct __deduction_workaround; template <size_t... Idxs> - struct __deduction_workaround<std::index_sequence<Idxs...>> + struct __deduction_workaround<index_sequence<Idxs...>> { template <class OtherExtents> MDSPAN_INLINE_FUNCTION static constexpr bool _eq_impl(mapping const& self, mapping<OtherExtents> const& other) noexcept { - using common_t = std::common_type_t<index_type, typename OtherExtents::index_type>; - return _MDSPAN_FOLD_AND((static_cast<common_t>(self.stride(Idxs)) == static_cast<common_t>(other.stride(Idxs))) /* && ... */) - && _MDSPAN_FOLD_AND((static_cast<common_t>(self.extents().extent(Idxs)) == static_cast<common_t>(other.extents().extent(Idxs))) /* || ... */); + return _MDSPAN_FOLD_AND((self.stride(Idxs) == other.stride(Idxs)) /* && ... */) + && _MDSPAN_FOLD_AND((self.extents().extent(Idxs) == other.extents().extent(Idxs)) /* || ... */); } template <class OtherExtents> MDSPAN_INLINE_FUNCTION static constexpr bool _not_eq_impl(mapping const& self, mapping<OtherExtents> const& other) noexcept { - using common_t = std::common_type_t<index_type, typename OtherExtents::index_type>; - return _MDSPAN_FOLD_OR((static_cast<common_t>(self.stride(Idxs)) != static_cast<common_t>(other.stride(Idxs))) /* || ... */) - || _MDSPAN_FOLD_OR((static_cast<common_t>(self.extents().extent(Idxs)) != static_cast<common_t>(other.extents().extent(Idxs))) /* || ... */); + return _MDSPAN_FOLD_OR((self.stride(Idxs) != other.stride(Idxs)) /* || ... */) + || _MDSPAN_FOLD_OR((self.extents().extent(Idxs) != other.extents().extent(Idxs)) /* || ... */); } template <class... Integral> @@ -198,37 +176,18 @@ struct layout_stride { template<class IntegralType> MDSPAN_INLINE_FUNCTION - static constexpr const __strides_storage_t fill_strides(const std::array<IntegralType,extents_type::rank()>& s) { - return __strides_storage_t{static_cast<index_type>(s[Idxs])...}; - } - - MDSPAN_TEMPLATE_REQUIRES( - class IntegralType, - // The is_convertible condition is added to make sfinae valid - // the extents_type::rank() > 0 is added to avoid use of non-standard zero length c-array - (std::is_convertible<IntegralType, typename extents_type::index_type>::value && (extents_type::rank() > 0)) - ) - MDSPAN_INLINE_FUNCTION - // despite the requirement some compilers still complain about zero length array during parsing - // making it length 1 now, but since the thing can't be instantiated due to requirement the actual - // instantiation of strides_storage will not fail despite mismatching length - static constexpr const __strides_storage_t fill_strides(mdspan_non_standard_tag, const IntegralType (&s)[extents_type::rank()>0?extents_type::rank():1]) { + static constexpr const __strides_storage_t fill_strides(const array<IntegralType,extents_type::rank()>& s) { return __strides_storage_t{static_cast<index_type>(s[Idxs])...}; } #ifdef __cpp_lib_span template<class IntegralType> MDSPAN_INLINE_FUNCTION - static constexpr const __strides_storage_t fill_strides(const std::span<IntegralType,extents_type::rank()>& s) { + static constexpr const __strides_storage_t fill_strides(const span<IntegralType,extents_type::rank()>& s) { return __strides_storage_t{static_cast<index_type>(s[Idxs])...}; } #endif - MDSPAN_INLINE_FUNCTION - static constexpr std::array<index_type, extents_type::rank()> return_strides(const __strides_storage_t& s) { - return std::array<index_type, extents_type::rank()>{s[Idxs]...}; - } - template<size_t K> MDSPAN_INLINE_FUNCTION static constexpr size_t __return_zero() { return 0; } @@ -240,24 +199,8 @@ struct layout_stride { }; // Can't use defaulted parameter in the __deduction_workaround template because of a bug in MSVC warning C4348. - using __impl = __deduction_workaround<std::make_index_sequence<Extents::rank()>>; - - static constexpr __strides_storage_t strides_storage(detail::with_rank<0>) { - return {}; - } - template <std::size_t N> - static constexpr __strides_storage_t strides_storage(detail::with_rank<N>) { - __strides_storage_t s{}; - - extents_type e; - index_type stride = 1; - for(int r = static_cast<int>(extents_type::rank() - 1); r >= 0; r--) { - s[r] = stride; - stride *= e.extent(r); - } + using __impl = __deduction_workaround<make_index_sequence<Extents::rank()>>; - return s; - } //---------------------------------------------------------------------------- @@ -273,37 +216,23 @@ struct layout_stride { //-------------------------------------------------------------------------------- - MDSPAN_INLINE_FUNCTION_DEFAULTED constexpr mapping() noexcept -#if defined(_MDSPAN_USE_ATTRIBUTE_NO_UNIQUE_ADDRESS) - : __members{ -#else - : __base_t(__base_t{__member_pair_t( -#endif - extents_type(), - __strides_storage_t(strides_storage(detail::with_rank<extents_type::rank()>{})) -#if defined(_MDSPAN_USE_ATTRIBUTE_NO_UNIQUE_ADDRESS) - } -#else - )}) -#endif - {} - + MDSPAN_INLINE_FUNCTION_DEFAULTED constexpr mapping() noexcept = default; MDSPAN_INLINE_FUNCTION_DEFAULTED constexpr mapping(mapping const&) noexcept = default; MDSPAN_TEMPLATE_REQUIRES( class IntegralTypes, /* requires */ ( // MSVC 19.32 does not like using index_type here, requires the typename Extents::index_type - // error C2641: cannot deduce template arguments for 'MDSPAN_IMPL_STANDARD_NAMESPACE::layout_stride::mapping' - _MDSPAN_TRAIT(std::is_convertible, const std::remove_const_t<IntegralTypes>&, typename Extents::index_type) && - _MDSPAN_TRAIT(std::is_nothrow_constructible, typename Extents::index_type, const std::remove_const_t<IntegralTypes>&) + // error C2641: cannot deduce template arguments for 'std::experimental::layout_stride::mapping' + _MDSPAN_TRAIT(is_convertible, const remove_const_t<IntegralTypes>&, typename Extents::index_type) && + _MDSPAN_TRAIT(is_nothrow_constructible, typename Extents::index_type, const remove_const_t<IntegralTypes>&) ) ) MDSPAN_INLINE_FUNCTION constexpr mapping( extents_type const& e, - std::array<IntegralTypes, extents_type::rank()> const& s + array<IntegralTypes, extents_type::rank()> const& s ) noexcept #if defined(_MDSPAN_USE_ATTRIBUTE_NO_UNIQUE_ADDRESS) : __members{ @@ -327,63 +256,21 @@ struct layout_stride { */ } - MDSPAN_TEMPLATE_REQUIRES( - class IntegralTypes, - /* requires */ ( - // MSVC 19.32 does not like using index_type here, requires the typename Extents::index_type - // error C2641: cannot deduce template arguments for 'MDSPAN_IMPL_STANDARD_NAMESPACE::layout_stride::mapping' - _MDSPAN_TRAIT(std::is_convertible, const std::remove_const_t<IntegralTypes>&, typename Extents::index_type) && - _MDSPAN_TRAIT(std::is_nothrow_constructible, typename Extents::index_type, const std::remove_const_t<IntegralTypes>&) && - (Extents::rank() > 0) - ) - ) - MDSPAN_INLINE_FUNCTION - constexpr - mapping( - mdspan_non_standard_tag, - extents_type const& e, - // despite the requirement some compilers still complain about zero length array during parsing - // making it length 1 now, but since the thing can't be instantiated due to requirement the actual - // instantiation of strides_storage will not fail despite mismatching length - IntegralTypes (&s)[extents_type::rank()>0?extents_type::rank():1] - ) noexcept -#if defined(_MDSPAN_USE_ATTRIBUTE_NO_UNIQUE_ADDRESS) - : __members{ -#else - : __base_t(__base_t{__member_pair_t( -#endif - e, __strides_storage_t(__impl::fill_strides(mdspan_non_standard, s)) -#if defined(_MDSPAN_USE_ATTRIBUTE_NO_UNIQUE_ADDRESS) - } -#else - )}) -#endif - { - /* - * TODO: check preconditions - * - s[i] > 0 is true for all i in the range [0, rank_ ). - * - REQUIRED-SPAN-SIZE(e, s) is a representable value of type index_type ([basic.fundamental]). - * - If rank_ is greater than 0, then there exists a permutation P of the integers in the - * range [0, rank_), such that s[ pi ] >= s[ pi − 1 ] * e.extent( pi − 1 ) is true for - * all i in the range [1, rank_ ), where pi is the ith element of P. - */ - } - #ifdef __cpp_lib_span MDSPAN_TEMPLATE_REQUIRES( class IntegralTypes, /* requires */ ( // MSVC 19.32 does not like using index_type here, requires the typename Extents::index_type - // error C2641: cannot deduce template arguments for 'MDSPAN_IMPL_STANDARD_NAMESPACE::layout_stride::mapping' - _MDSPAN_TRAIT(std::is_convertible, const std::remove_const_t<IntegralTypes>&, typename Extents::index_type) && - _MDSPAN_TRAIT(std::is_nothrow_constructible, typename Extents::index_type, const std::remove_const_t<IntegralTypes>&) + // error C2641: cannot deduce template arguments for 'std::experimental::layout_stride::mapping' + _MDSPAN_TRAIT(is_convertible, const remove_const_t<IntegralTypes>&, typename Extents::index_type) && + _MDSPAN_TRAIT(is_nothrow_constructible, typename Extents::index_type, const remove_const_t<IntegralTypes>&) ) ) MDSPAN_INLINE_FUNCTION constexpr mapping( extents_type const& e, - std::span<IntegralTypes, extents_type::rank()> const& s + span<IntegralTypes, extents_type::rank()> const& s ) noexcept #if defined(_MDSPAN_USE_ATTRIBUTE_NO_UNIQUE_ADDRESS) : __members{ @@ -412,7 +299,7 @@ struct layout_stride { MDSPAN_TEMPLATE_REQUIRES( class StridedLayoutMapping, /* requires */ ( - _MDSPAN_TRAIT(std::is_constructible, extents_type, typename StridedLayoutMapping::extents_type) && + _MDSPAN_TRAIT(is_constructible, extents_type, typename StridedLayoutMapping::extents_type) && detail::__is_mapping_of<typename StridedLayoutMapping::layout_type, StridedLayoutMapping> && StridedLayoutMapping::is_always_unique() && StridedLayoutMapping::is_always_strided() @@ -422,16 +309,16 @@ struct layout_stride { template<class StridedLayoutMapping> requires( detail::__layout_mapping_alike<StridedLayoutMapping> && - _MDSPAN_TRAIT(std::is_constructible, extents_type, typename StridedLayoutMapping::extents_type) && + _MDSPAN_TRAIT(is_constructible, extents_type, typename StridedLayoutMapping::extents_type) && StridedLayoutMapping::is_always_unique() && StridedLayoutMapping::is_always_strided() ) #endif MDSPAN_CONDITIONAL_EXPLICIT( - !(std::is_convertible<typename StridedLayoutMapping::extents_type, extents_type>::value && - (detail::__is_mapping_of<layout_left, StridedLayoutMapping> || - detail::__is_mapping_of<layout_right, StridedLayoutMapping> || - detail::__is_mapping_of<layout_stride, StridedLayoutMapping>)) + (!is_convertible<typename StridedLayoutMapping::extents_type, extents_type>::value) && + (detail::__is_mapping_of<layout_left, StridedLayoutMapping> || + detail::__is_mapping_of<layout_right, StridedLayoutMapping> || + detail::__is_mapping_of<layout_stride, StridedLayoutMapping>) ) // needs two () due to comma MDSPAN_INLINE_FUNCTION _MDSPAN_CONSTEXPR_14 mapping(StridedLayoutMapping const& other) noexcept // NOLINT(google-explicit-constructor) @@ -469,8 +356,8 @@ struct layout_stride { }; MDSPAN_INLINE_FUNCTION - constexpr std::array< index_type, extents_type::rank() > strides() const noexcept { - return __impl::return_strides(__strides_storage()); + constexpr array< index_type, extents_type::rank() > strides() const noexcept { + return __strides_storage(); } MDSPAN_INLINE_FUNCTION @@ -489,14 +376,12 @@ struct layout_stride { class... Indices, /* requires */ ( sizeof...(Indices) == Extents::rank() && - (detail::are_valid_indices<index_type, Indices...>()) + _MDSPAN_FOLD_AND(_MDSPAN_TRAIT(is_convertible, Indices, index_type) /*&& ...*/ ) && + _MDSPAN_FOLD_AND(_MDSPAN_TRAIT(is_nothrow_constructible, index_type, Indices) /*&& ...*/) ) ) MDSPAN_FORCE_INLINE_FUNCTION constexpr index_type operator()(Indices... idxs) const noexcept { -#if ! defined(NDEBUG) - detail::check_all_indices(this->extents(), idxs...); -#endif // ! NDEBUG return static_cast<index_type>(__impl::_call_op_impl(*this, static_cast<index_type>(idxs)...)); } @@ -507,54 +392,18 @@ struct layout_stride { MDSPAN_INLINE_FUNCTION static constexpr bool is_always_strided() noexcept { return true; } MDSPAN_INLINE_FUNCTION static constexpr bool is_unique() noexcept { return true; } - - private: - constexpr bool exhaustive_for_nonzero_span_size() const - { - return required_span_size() == __get_size(extents(), std::make_index_sequence<extents_type::rank()>()); - } - - constexpr bool is_exhaustive_impl(detail::with_rank<0>) const - { - return true; - } - constexpr bool is_exhaustive_impl(detail::with_rank<1>) const - { - if (required_span_size() != static_cast<index_type>(0)) { - return exhaustive_for_nonzero_span_size(); - } - return stride(0) == 1; - } - template <std::size_t N> - constexpr bool is_exhaustive_impl(detail::with_rank<N>) const - { - if (required_span_size() != static_cast<index_type>(0)) { - return exhaustive_for_nonzero_span_size(); - } - - rank_type r_largest = 0; - for (rank_type r = 1; r < extents_type::rank(); r++) { - if (stride(r) > stride(r_largest)) { - r_largest = r; - } - } - for (rank_type r = 0; r < extents_type::rank(); r++) { - if (extents().extent(r) == 0 && r != r_largest) { - return false; - } - } - return true; - } - - public: MDSPAN_INLINE_FUNCTION _MDSPAN_CONSTEXPR_14 bool is_exhaustive() const noexcept { - return is_exhaustive_impl(detail::with_rank<extents_type::rank()>{}); + return required_span_size() == __get_size(extents(), make_index_sequence<extents_type::rank()>()); } MDSPAN_INLINE_FUNCTION static constexpr bool is_strided() noexcept { return true; } MDSPAN_INLINE_FUNCTION - constexpr index_type stride(rank_type r) const noexcept { + constexpr index_type stride(rank_type r) const noexcept +#if MDSPAN_HAS_CXX_20 + requires ( Extents::rank() > 0 ) +#endif + { return __strides_storage()[r]; } @@ -577,9 +426,12 @@ struct layout_stride { #endif MDSPAN_INLINE_FUNCTION friend constexpr bool operator==(const mapping& x, const StridedLayoutMapping& y) noexcept { + bool strides_match = true; + for(rank_type r = 0; r < extents_type::rank(); r++) + strides_match = strides_match && (x.stride(r) == y.stride(r)); return (x.extents() == y.extents()) && - (__impl::__OFFSET(y) == static_cast<typename StridedLayoutMapping::index_type>(0)) && - detail::rankwise_equal(detail::with_rank<extents_type::rank()>{}, x, y, detail::stride); + (__impl::__OFFSET(y)== static_cast<typename StridedLayoutMapping::index_type>(0)) && + strides_match; } // This one is not technically part of the proposal. Just here to make implementation a bit more optimal hopefully @@ -620,48 +472,8 @@ struct layout_stride { } #endif - // [mdspan.submdspan.mapping], submdspan mapping specialization - template<class... SliceSpecifiers> - MDSPAN_INLINE_FUNCTION - constexpr auto submdspan_mapping_impl( - SliceSpecifiers... slices) const; - - template<class... SliceSpecifiers> - friend constexpr auto submdspan_mapping( - const mapping& src, SliceSpecifiers... slices) { - return src.submdspan_mapping_impl(slices...); - } }; }; -namespace detail { - -template <class Layout, class Extents, class Mapping> -constexpr void validate_strides(with_rank<0>, Layout, const Extents&, const Mapping&) -{} - -template <std::size_t N, class Layout, class Extents, class Mapping> -constexpr void validate_strides(with_rank<N>, Layout, const Extents& ext, const Mapping& other) -{ - static_assert(std::is_same<typename Mapping::layout_type, layout_stride>::value and - (std::is_same<Layout, layout_left>::value or - std::is_same<Layout, layout_right>::value) - , "This function is only intended to validate construction of " - "a layout_left or layout_right mapping from a layout_stride mapping."); - - constexpr auto is_left = std::is_same<Layout, layout_left>::value; - - typename Extents::index_type expected_stride = 1; - - for (std::size_t r = 0; r < N; r++) { - const std::size_t s = is_left ? r : N - 1 - r; - - MDSPAN_IMPL_PRECONDITION(common_integral_compare(expected_stride, other.stride(s)) - and "invalid strides for layout_{left,right}"); - - expected_stride *= ext.extent(s); - } -} - -} // namespace detail -} // end namespace MDSPAN_IMPL_STANDARD_NAMESPACE +} // end namespace experimental +} // end namespace std diff --git a/tests/generator_scripts/deps/mdspan/include/experimental/__p0009_bits/macros.hpp b/tests/generator_scripts/deps/mdspan/include/experimental/__p0009_bits/macros.hpp index 30209a6648b6ef8cc4d32d7bb49411275bc24a8f..586964f3c218c7f3c60fe138e287abf0d36417e0 100644 --- a/tests/generator_scripts/deps/mdspan/include/experimental/__p0009_bits/macros.hpp +++ b/tests/generator_scripts/deps/mdspan/include/experimental/__p0009_bits/macros.hpp @@ -18,12 +18,7 @@ #include "config.hpp" -#include <cstdio> -#include <cstdlib> #include <type_traits> // std::is_void -#if defined(_MDSPAN_HAS_CUDA) || defined(_MDSPAN_HAS_HIP) || defined(_MDSPAN_HAS_SYCL) -#include "assert.h" -#endif #ifndef _MDSPAN_HOST_DEVICE # if defined(_MDSPAN_HAS_CUDA) || defined(_MDSPAN_HAS_HIP) @@ -103,72 +98,6 @@ #define MDSPAN_PP_REMOVE_PARENS_IMPL(...) __VA_ARGS__ #define MDSPAN_PP_REMOVE_PARENS(...) MDSPAN_PP_REMOVE_PARENS_IMPL __VA_ARGS__ -#define MDSPAN_IMPL_STANDARD_NAMESPACE_STRING MDSPAN_PP_STRINGIFY(MDSPAN_IMPL_STANDARD_NAMESPACE) -#define MDSPAN_IMPL_PROPOSED_NAMESPACE_STRING MDSPAN_PP_STRINGIFY(MDSPAN_IMPL_STANDARD_NAMESPACE) "::" MDSPAN_PP_STRINGIFY(MDSPAN_IMPL_PROPOSED_NAMESPACE) - -namespace MDSPAN_IMPL_STANDARD_NAMESPACE { -namespace detail { - -#if defined(_MDSPAN_HAS_CUDA) || defined(_MDSPAN_HAS_HIP) -MDSPAN_FUNCTION inline void default_precondition_violation_handler(const char* cond, const char* file, unsigned line) -{ - printf("%s:%u: precondition failure: `%s`\n", file, line, cond); - assert(0); -} -#elif defined(_MDSPAN_HAS_SYCL) -MDSPAN_FUNCTION inline void default_precondition_violation_handler(const char* cond, const char* file, unsigned line) -{ - sycl::ext::oneapi::experimental::printf("%s:%u: precondition failure: `%s`\n", file, line, cond); - assert(0); -} -#else -MDSPAN_FUNCTION inline void default_precondition_violation_handler(const char* cond, const char* file, unsigned line) -{ - std::fprintf(stderr, "%s:%u: precondition failure: `%s`\n", file, line, cond); - std::abort(); -} -#endif - -} // namespace detail -} // namespace MDSPAN_IMPL_STANDARD_NAMESPACE - -#ifndef MDSPAN_IMPL_PRECONDITION_VIOLATION_HANDLER -#define MDSPAN_IMPL_PRECONDITION_VIOLATION_HANDLER(cond, file, line) \ - MDSPAN_IMPL_STANDARD_NAMESPACE::detail::default_precondition_violation_handler(cond, file, line) -#endif - -#ifndef MDSPAN_IMPL_CHECK_PRECONDITION - #ifndef NDEBUG - #define MDSPAN_IMPL_CHECK_PRECONDITION 0 - #else - #define MDSPAN_IMPL_CHECK_PRECONDITION 1 - #endif -#endif - -namespace MDSPAN_IMPL_STANDARD_NAMESPACE { -namespace detail { - -template <bool check = MDSPAN_IMPL_CHECK_PRECONDITION> -MDSPAN_FUNCTION constexpr void precondition(const char* cond, const char* file, unsigned line) -{ - if (not check) { return; } - // in case the macro doesn't use the arguments for custom macros - (void) cond; - (void) file; - (void) line; - MDSPAN_IMPL_PRECONDITION_VIOLATION_HANDLER(cond, file, line); -} - -} // namespace detail -} // namespace MDSPAN_IMPL_STANDARD_NAMESPACE - -#define MDSPAN_IMPL_PRECONDITION(...) \ - do { \ - if (not (__VA_ARGS__)) { \ - MDSPAN_IMPL_STANDARD_NAMESPACE::detail::precondition(#__VA_ARGS__, __FILE__, __LINE__); \ - } \ - } while (0) - // </editor-fold> end Preprocessor helpers }}}1 //============================================================================== @@ -346,7 +275,7 @@ struct __mdspan_enable_fold_comma { }; # define _MDSPAN_FOLD_COMMA(...) ((__VA_ARGS__), ...) #else -namespace MDSPAN_IMPL_STANDARD_NAMESPACE { +namespace std { namespace __fold_compatibility_impl { @@ -649,15 +578,15 @@ struct __bools; } // __fold_compatibility_impl -} // end namespace MDSPAN_IMPL_STANDARD_NAMESPACE +} // end namespace std -# define _MDSPAN_FOLD_AND(...) MDSPAN_IMPL_STANDARD_NAMESPACE::__fold_compatibility_impl::__fold_right_and_impl((__VA_ARGS__)...) -# define _MDSPAN_FOLD_OR(...) MDSPAN_IMPL_STANDARD_NAMESPACE::__fold_compatibility_impl::__fold_right_or_impl((__VA_ARGS__)...) -# define _MDSPAN_FOLD_ASSIGN_LEFT(INIT, ...) MDSPAN_IMPL_STANDARD_NAMESPACE::__fold_compatibility_impl::__fold_left_assign_impl(INIT, (__VA_ARGS__)...) -# define _MDSPAN_FOLD_ASSIGN_RIGHT(PACK, ...) MDSPAN_IMPL_STANDARD_NAMESPACE::__fold_compatibility_impl::__fold_right_assign_impl((PACK)..., __VA_ARGS__) -# define _MDSPAN_FOLD_TIMES_RIGHT(PACK, ...) MDSPAN_IMPL_STANDARD_NAMESPACE::__fold_compatibility_impl::__fold_right_times_impl((PACK)..., __VA_ARGS__) -# define _MDSPAN_FOLD_PLUS_RIGHT(PACK, ...) MDSPAN_IMPL_STANDARD_NAMESPACE::__fold_compatibility_impl::__fold_right_plus_impl((PACK)..., __VA_ARGS__) -# define _MDSPAN_FOLD_COMMA(...) MDSPAN_IMPL_STANDARD_NAMESPACE::__fold_compatibility_impl::__fold_comma_impl((__VA_ARGS__)...) +# define _MDSPAN_FOLD_AND(...) std::__fold_compatibility_impl::__fold_right_and_impl((__VA_ARGS__)...) +# define _MDSPAN_FOLD_OR(...) std::__fold_compatibility_impl::__fold_right_or_impl((__VA_ARGS__)...) +# define _MDSPAN_FOLD_ASSIGN_LEFT(INIT, ...) std::__fold_compatibility_impl::__fold_left_assign_impl(INIT, (__VA_ARGS__)...) +# define _MDSPAN_FOLD_ASSIGN_RIGHT(PACK, ...) std::__fold_compatibility_impl::__fold_right_assign_impl((PACK)..., __VA_ARGS__) +# define _MDSPAN_FOLD_TIMES_RIGHT(PACK, ...) std::__fold_compatibility_impl::__fold_right_times_impl((PACK)..., __VA_ARGS__) +# define _MDSPAN_FOLD_PLUS_RIGHT(PACK, ...) std::__fold_compatibility_impl::__fold_right_plus_impl((PACK)..., __VA_ARGS__) +# define _MDSPAN_FOLD_COMMA(...) std::__fold_compatibility_impl::__fold_comma_impl((__VA_ARGS__)...) # define _MDSPAN_FOLD_AND_TEMPLATE(...) \ _MDSPAN_TRAIT(std::is_same, __fold_compatibility_impl::__bools<(__VA_ARGS__)..., true>, __fold_compatibility_impl::__bools<true, (__VA_ARGS__)...>) diff --git a/tests/generator_scripts/deps/mdspan/include/experimental/__p0009_bits/mdspan.hpp b/tests/generator_scripts/deps/mdspan/include/experimental/__p0009_bits/mdspan.hpp index af4848248d64ced5f5ef0d383561db73a3ee7579..c81a88367714d22b336352acb95e5468455972e9 100644 --- a/tests/generator_scripts/deps/mdspan/include/experimental/__p0009_bits/mdspan.hpp +++ b/tests/generator_scripts/deps/mdspan/include/experimental/__p0009_bits/mdspan.hpp @@ -22,7 +22,9 @@ #include "trait_backports.hpp" #include "compressed_pair.hpp" -namespace MDSPAN_IMPL_STANDARD_NAMESPACE { +namespace std { +namespace experimental { + template < class ElementType, class Extents, @@ -32,17 +34,14 @@ template < class mdspan { private: - static_assert(detail::__is_extents_v<Extents>, - MDSPAN_IMPL_STANDARD_NAMESPACE_STRING "::mdspan's Extents template parameter must be a specialization of " MDSPAN_IMPL_STANDARD_NAMESPACE_STRING "::extents."); - static_assert(std::is_same<ElementType, typename AccessorPolicy::element_type>::value, - MDSPAN_IMPL_STANDARD_NAMESPACE_STRING "::mdspan's ElementType template parameter must be the same as its AccessorPolicy::element_type."); + static_assert(detail::__is_extents_v<Extents>, "std::experimental::mdspan's Extents template parameter must be a specialization of std::experimental::extents."); // Workaround for non-deducibility of the index sequence template parameter if it's given at the top level template <class> struct __deduction_workaround; template <size_t... Idxs> - struct __deduction_workaround<std::index_sequence<Idxs...>> + struct __deduction_workaround<index_sequence<Idxs...>> { MDSPAN_FORCE_INLINE_FUNCTION static constexpr size_t __size(mdspan const& __self) noexcept { @@ -54,16 +53,9 @@ private: } template <class ReferenceType, class SizeType, size_t N> MDSPAN_FORCE_INLINE_FUNCTION static constexpr - ReferenceType __callop(mdspan const& __self, const std::array<SizeType, N>& indices) noexcept { - return __self.__accessor_ref().access(__self.__ptr_ref(), __self.__mapping_ref()(indices[Idxs]...)); - } -#ifdef __cpp_lib_span - template <class ReferenceType, class SizeType, size_t N> - MDSPAN_FORCE_INLINE_FUNCTION static constexpr - ReferenceType __callop(mdspan const& __self, const std::span<SizeType, N>& indices) noexcept { + ReferenceType __callop(mdspan const& __self, const array<SizeType, N>& indices) noexcept { return __self.__accessor_ref().access(__self.__ptr_ref(), __self.__mapping_ref()(indices[Idxs]...)); } -#endif }; public: @@ -76,7 +68,7 @@ public: using accessor_type = AccessorPolicy; using mapping_type = typename layout_type::template mapping<extents_type>; using element_type = ElementType; - using value_type = std::remove_cv_t<element_type>; + using value_type = remove_cv_t<element_type>; using index_type = typename extents_type::index_type; using size_type = typename extents_type::size_type; using rank_type = typename extents_type::rank_type; @@ -91,7 +83,7 @@ public: private: // Can't use defaulted parameter in the __deduction_workaround template because of a bug in MSVC warning C4348. - using __impl = __deduction_workaround<std::make_index_sequence<extents_type::rank()>>; + using __impl = __deduction_workaround<make_index_sequence<extents_type::rank()>>; using __map_acc_pair_t = detail::__compressed_pair<mapping_type, accessor_type>; @@ -107,9 +99,9 @@ public: requires( // nvhpc has a bug where using just rank_dynamic() here doesn't work ... (extents_type::rank_dynamic() > 0) && - _MDSPAN_TRAIT(std::is_default_constructible, data_handle_type) && - _MDSPAN_TRAIT(std::is_default_constructible, mapping_type) && - _MDSPAN_TRAIT(std::is_default_constructible, accessor_type) + _MDSPAN_TRAIT(is_default_constructible, data_handle_type) && + _MDSPAN_TRAIT(is_default_constructible, mapping_type) && + _MDSPAN_TRAIT(is_default_constructible, accessor_type) ) = default; #endif MDSPAN_INLINE_FUNCTION_DEFAULTED constexpr mdspan(const mdspan&) = default; @@ -118,10 +110,11 @@ public: MDSPAN_TEMPLATE_REQUIRES( class... SizeTypes, /* requires */ ( + _MDSPAN_FOLD_AND(_MDSPAN_TRAIT(is_convertible, SizeTypes, index_type) /* && ... */) && + _MDSPAN_FOLD_AND(_MDSPAN_TRAIT(is_nothrow_constructible, index_type, SizeTypes) /* && ... */) && ((sizeof...(SizeTypes) == rank()) || (sizeof...(SizeTypes) == rank_dynamic())) && - (detail::are_valid_indices<index_type, SizeTypes...>()) && - _MDSPAN_TRAIT(std::is_constructible, mapping_type, extents_type) && - _MDSPAN_TRAIT(std::is_default_constructible, accessor_type) + _MDSPAN_TRAIT(is_constructible, mapping_type, extents_type) && + _MDSPAN_TRAIT(is_default_constructible, accessor_type) ) ) MDSPAN_INLINE_FUNCTION @@ -133,16 +126,16 @@ public: MDSPAN_TEMPLATE_REQUIRES( class SizeType, size_t N, /* requires */ ( - _MDSPAN_TRAIT(std::is_convertible, const SizeType&, index_type) && - _MDSPAN_TRAIT(std::is_nothrow_constructible, index_type, const SizeType&) && + _MDSPAN_TRAIT(is_convertible, SizeType, index_type) && + _MDSPAN_TRAIT(is_nothrow_constructible, index_type, SizeType) && ((N == rank()) || (N == rank_dynamic())) && - _MDSPAN_TRAIT(std::is_constructible, mapping_type, extents_type) && - _MDSPAN_TRAIT(std::is_default_constructible, accessor_type) + _MDSPAN_TRAIT(is_constructible, mapping_type, extents_type) && + _MDSPAN_TRAIT(is_default_constructible, accessor_type) ) ) MDSPAN_CONDITIONAL_EXPLICIT(N != rank_dynamic()) MDSPAN_INLINE_FUNCTION - constexpr mdspan(data_handle_type p, const std::array<SizeType, N>& dynamic_extents) + constexpr mdspan(data_handle_type p, const array<SizeType, N>& dynamic_extents) : __members(std::move(p), __map_acc_pair_t(mapping_type(extents_type(dynamic_extents)), accessor_type())) { } @@ -150,16 +143,16 @@ public: MDSPAN_TEMPLATE_REQUIRES( class SizeType, size_t N, /* requires */ ( - _MDSPAN_TRAIT(std::is_convertible, const SizeType&, index_type) && - _MDSPAN_TRAIT(std::is_nothrow_constructible, index_type, const SizeType&) && + _MDSPAN_TRAIT(is_convertible, SizeType, index_type) && + _MDSPAN_TRAIT(is_nothrow_constructible, index_type, SizeType) && ((N == rank()) || (N == rank_dynamic())) && - _MDSPAN_TRAIT(std::is_constructible, mapping_type, extents_type) && - _MDSPAN_TRAIT(std::is_default_constructible, accessor_type) + _MDSPAN_TRAIT(is_constructible, mapping_type, extents_type) && + _MDSPAN_TRAIT(is_default_constructible, accessor_type) ) ) MDSPAN_CONDITIONAL_EXPLICIT(N != rank_dynamic()) MDSPAN_INLINE_FUNCTION - constexpr mdspan(data_handle_type p, std::span<SizeType, N> dynamic_extents) + constexpr mdspan(data_handle_type p, span<SizeType, N> dynamic_extents) : __members(std::move(p), __map_acc_pair_t(mapping_type(extents_type(as_const(dynamic_extents))), accessor_type())) { } #endif @@ -167,15 +160,15 @@ public: MDSPAN_FUNCTION_REQUIRES( (MDSPAN_INLINE_FUNCTION constexpr), mdspan, (data_handle_type p, const extents_type& exts), , - /* requires */ (_MDSPAN_TRAIT(std::is_default_constructible, accessor_type) && - _MDSPAN_TRAIT(std::is_constructible, mapping_type, const extents_type&)) + /* requires */ (_MDSPAN_TRAIT(is_default_constructible, accessor_type) && + _MDSPAN_TRAIT(is_constructible, mapping_type, extents_type)) ) : __members(std::move(p), __map_acc_pair_t(mapping_type(exts), accessor_type())) { } MDSPAN_FUNCTION_REQUIRES( (MDSPAN_INLINE_FUNCTION constexpr), mdspan, (data_handle_type p, const mapping_type& m), , - /* requires */ (_MDSPAN_TRAIT(std::is_default_constructible, accessor_type)) + /* requires */ (_MDSPAN_TRAIT(is_default_constructible, accessor_type)) ) : __members(std::move(p), __map_acc_pair_t(m, accessor_type())) { } @@ -187,20 +180,16 @@ public: MDSPAN_TEMPLATE_REQUIRES( class OtherElementType, class OtherExtents, class OtherLayoutPolicy, class OtherAccessor, /* requires */ ( - _MDSPAN_TRAIT(std::is_constructible, mapping_type, const typename OtherLayoutPolicy::template mapping<OtherExtents>&) && - _MDSPAN_TRAIT(std::is_constructible, accessor_type, const OtherAccessor&) + _MDSPAN_TRAIT(is_constructible, mapping_type, typename OtherLayoutPolicy::template mapping<OtherExtents>) && + _MDSPAN_TRAIT(is_constructible, accessor_type, OtherAccessor) ) ) - MDSPAN_CONDITIONAL_EXPLICIT( - !_MDSPAN_TRAIT(std::is_convertible, const typename OtherLayoutPolicy::template mapping<OtherExtents>&, mapping_type) || - !_MDSPAN_TRAIT(std::is_convertible, const OtherAccessor&, accessor_type) - ) MDSPAN_INLINE_FUNCTION constexpr mdspan(const mdspan<OtherElementType, OtherExtents, OtherLayoutPolicy, OtherAccessor>& other) : __members(other.__ptr_ref(), __map_acc_pair_t(other.__mapping_ref(), other.__accessor_ref())) { - static_assert(_MDSPAN_TRAIT(std::is_constructible, data_handle_type, typename OtherAccessor::data_handle_type),"Incompatible data_handle_type for mdspan construction"); - static_assert(_MDSPAN_TRAIT(std::is_constructible, extents_type, OtherExtents),"Incompatible extents for mdspan construction"); + static_assert(_MDSPAN_TRAIT(is_constructible, data_handle_type, typename OtherAccessor::data_handle_type),"Incompatible data_handle_type for mdspan construction"); + static_assert(_MDSPAN_TRAIT(is_constructible, extents_type, OtherExtents),"Incompatible extents for mdspan construction"); /* * TODO: Check precondition * For each rank index r of extents_type, static_extent(r) == dynamic_extent || static_extent(r) == other.extent(r) is true. @@ -223,8 +212,8 @@ public: MDSPAN_TEMPLATE_REQUIRES( class... SizeTypes, /* requires */ ( - _MDSPAN_FOLD_AND(_MDSPAN_TRAIT(std::is_convertible, SizeTypes, index_type) /* && ... */) && - _MDSPAN_FOLD_AND(_MDSPAN_TRAIT(std::is_nothrow_constructible, index_type, SizeTypes) /* && ... */) && + _MDSPAN_FOLD_AND(_MDSPAN_TRAIT(is_convertible, SizeTypes, index_type) /* && ... */) && + _MDSPAN_FOLD_AND(_MDSPAN_TRAIT(is_nothrow_constructible, index_type, SizeTypes) /* && ... */) && (rank() == sizeof...(SizeTypes)) ) ) @@ -238,12 +227,12 @@ public: MDSPAN_TEMPLATE_REQUIRES( class SizeType, /* requires */ ( - _MDSPAN_TRAIT(std::is_convertible, const SizeType&, index_type) && - _MDSPAN_TRAIT(std::is_nothrow_constructible, index_type, const SizeType&) + _MDSPAN_TRAIT(is_convertible, SizeType, index_type) && + _MDSPAN_TRAIT(is_nothrow_constructible, index_type, SizeType) ) ) MDSPAN_FORCE_INLINE_FUNCTION - constexpr reference operator[](const std::array< SizeType, rank()>& indices) const + constexpr reference operator[](const array<SizeType, rank()>& indices) const { return __impl::template __callop<reference>(*this, indices); } @@ -252,12 +241,12 @@ public: MDSPAN_TEMPLATE_REQUIRES( class SizeType, /* requires */ ( - _MDSPAN_TRAIT(std::is_convertible, const SizeType&, index_type) && - _MDSPAN_TRAIT(std::is_nothrow_constructible, index_type, const SizeType&) + _MDSPAN_TRAIT(is_convertible, SizeType, index_type) && + _MDSPAN_TRAIT(is_nothrow_constructible, index_type, SizeType) ) ) MDSPAN_FORCE_INLINE_FUNCTION - constexpr reference operator[](std::span<SizeType, rank()> indices) const + constexpr reference operator[](span<SizeType, rank()> indices) const { return __impl::template __callop<reference>(*this, indices); } @@ -267,8 +256,8 @@ public: MDSPAN_TEMPLATE_REQUIRES( class Index, /* requires */ ( - _MDSPAN_TRAIT(std::is_convertible, Index, index_type) && - _MDSPAN_TRAIT(std::is_nothrow_constructible, index_type, Index) && + _MDSPAN_TRAIT(is_convertible, Index, index_type) && + _MDSPAN_TRAIT(is_nothrow_constructible, index_type, Index) && extents_type::rank() == 1 ) ) @@ -283,8 +272,9 @@ public: MDSPAN_TEMPLATE_REQUIRES( class... SizeTypes, /* requires */ ( - extents_type::rank() == sizeof...(SizeTypes) && - (detail::are_valid_indices<index_type, SizeTypes...>()) + _MDSPAN_FOLD_AND(_MDSPAN_TRAIT(is_convertible, SizeTypes, index_type) /* && ... */) && + _MDSPAN_FOLD_AND(_MDSPAN_TRAIT(is_nothrow_constructible, index_type, SizeTypes) /* && ... */) && + extents_type::rank() == sizeof...(SizeTypes) ) ) MDSPAN_FORCE_INLINE_FUNCTION @@ -296,12 +286,12 @@ public: MDSPAN_TEMPLATE_REQUIRES( class SizeType, /* requires */ ( - _MDSPAN_TRAIT(std::is_convertible, const SizeType&, index_type) && - _MDSPAN_TRAIT(std::is_nothrow_constructible, index_type, const SizeType&) + _MDSPAN_TRAIT(is_convertible, SizeType, index_type) && + _MDSPAN_TRAIT(is_nothrow_constructible, index_type, SizeType) ) ) MDSPAN_FORCE_INLINE_FUNCTION - constexpr reference operator()(const std::array<SizeType, rank()>& indices) const + constexpr reference operator()(const array<SizeType, rank()>& indices) const { return __impl::template __callop<reference>(*this, indices); } @@ -310,19 +300,19 @@ public: MDSPAN_TEMPLATE_REQUIRES( class SizeType, /* requires */ ( - _MDSPAN_TRAIT(std::is_convertible, const SizeType&, index_type) && - _MDSPAN_TRAIT(std::is_nothrow_constructible, index_type, const SizeType&) + _MDSPAN_TRAIT(is_convertible, SizeType, index_type) && + _MDSPAN_TRAIT(is_nothrow_constructible, index_type, SizeType) ) ) MDSPAN_FORCE_INLINE_FUNCTION - constexpr reference operator()(std::span<SizeType, rank()> indices) const + constexpr reference operator()(span<SizeType, rank()> indices) const { return __impl::template __callop<reference>(*this, indices); } #endif // __cpp_lib_span #endif // MDSPAN_USE_PAREN_OPERATOR - MDSPAN_INLINE_FUNCTION constexpr size_type size() const noexcept { + MDSPAN_INLINE_FUNCTION constexpr size_t size() const noexcept { return __impl::__size(*this); }; @@ -334,7 +324,6 @@ public: friend constexpr void swap(mdspan& x, mdspan& y) noexcept { // can't call the std::swap inside on HIP #if !defined(_MDSPAN_HAS_HIP) && !defined(_MDSPAN_HAS_CUDA) - using std::swap; swap(x.__ptr_ref(), y.__ptr_ref()); swap(x.__mapping_ref(), y.__mapping_ref()); swap(x.__accessor_ref(), y.__accessor_ref()); @@ -357,13 +346,13 @@ public: //-------------------------------------------------------------------------------- // [mdspan.basic.obs], mdspan observers of the mapping - MDSPAN_INLINE_FUNCTION static constexpr bool is_always_unique() { return mapping_type::is_always_unique(); }; - MDSPAN_INLINE_FUNCTION static constexpr bool is_always_exhaustive() { return mapping_type::is_always_exhaustive(); }; - MDSPAN_INLINE_FUNCTION static constexpr bool is_always_strided() { return mapping_type::is_always_strided(); }; + MDSPAN_INLINE_FUNCTION static constexpr bool is_always_unique() noexcept { return mapping_type::is_always_unique(); }; + MDSPAN_INLINE_FUNCTION static constexpr bool is_always_exhaustive() noexcept { return mapping_type::is_always_exhaustive(); }; + MDSPAN_INLINE_FUNCTION static constexpr bool is_always_strided() noexcept { return mapping_type::is_always_strided(); }; - MDSPAN_INLINE_FUNCTION constexpr bool is_unique() const { return __mapping_ref().is_unique(); }; - MDSPAN_INLINE_FUNCTION constexpr bool is_exhaustive() const { return __mapping_ref().is_exhaustive(); }; - MDSPAN_INLINE_FUNCTION constexpr bool is_strided() const { return __mapping_ref().is_strided(); }; + MDSPAN_INLINE_FUNCTION constexpr bool is_unique() const noexcept { return __mapping_ref().is_unique(); }; + MDSPAN_INLINE_FUNCTION constexpr bool is_exhaustive() const noexcept { return __mapping_ref().is_exhaustive(); }; + MDSPAN_INLINE_FUNCTION constexpr bool is_strided() const noexcept { return __mapping_ref().is_strided(); }; MDSPAN_INLINE_FUNCTION constexpr index_type stride(size_t r) const { return __mapping_ref().stride(r); }; private: @@ -385,32 +374,32 @@ private: #if defined(_MDSPAN_USE_CLASS_TEMPLATE_ARGUMENT_DEDUCTION) MDSPAN_TEMPLATE_REQUIRES( class ElementType, class... SizeTypes, - /* requires */ _MDSPAN_FOLD_AND(_MDSPAN_TRAIT(std::is_convertible, SizeTypes, size_t) /* && ... */) && + /* requires */ _MDSPAN_FOLD_AND(_MDSPAN_TRAIT(is_integral, SizeTypes) /* && ... */) && (sizeof...(SizeTypes) > 0) ) MDSPAN_DEDUCTION_GUIDE explicit mdspan(ElementType*, SizeTypes...) - -> mdspan<ElementType, ::MDSPAN_IMPL_STANDARD_NAMESPACE::dextents<size_t, sizeof...(SizeTypes)>>; + -> mdspan<ElementType, ::std::experimental::dextents<size_t, sizeof...(SizeTypes)>>; MDSPAN_TEMPLATE_REQUIRES( class Pointer, - (_MDSPAN_TRAIT(std::is_pointer, std::remove_reference_t<Pointer>)) + (_MDSPAN_TRAIT(is_pointer, std::remove_reference_t<Pointer>)) ) MDSPAN_DEDUCTION_GUIDE mdspan(Pointer&&) -> mdspan<std::remove_pointer_t<std::remove_reference_t<Pointer>>, extents<size_t>>; MDSPAN_TEMPLATE_REQUIRES( class CArray, - (_MDSPAN_TRAIT(std::is_array, CArray) && (std::rank_v<CArray> == 1)) + (_MDSPAN_TRAIT(is_array, CArray) && (rank_v<CArray> == 1)) ) MDSPAN_DEDUCTION_GUIDE mdspan(CArray&) -> mdspan<std::remove_all_extents_t<CArray>, extents<size_t, ::std::extent_v<CArray,0>>>; template <class ElementType, class SizeType, size_t N> MDSPAN_DEDUCTION_GUIDE mdspan(ElementType*, const ::std::array<SizeType, N>&) - -> mdspan<ElementType, ::MDSPAN_IMPL_STANDARD_NAMESPACE::dextents<size_t, N>>; + -> mdspan<ElementType, ::std::experimental::dextents<size_t, N>>; #ifdef __cpp_lib_span template <class ElementType, class SizeType, size_t N> MDSPAN_DEDUCTION_GUIDE mdspan(ElementType*, ::std::span<SizeType, N>) - -> mdspan<ElementType, ::MDSPAN_IMPL_STANDARD_NAMESPACE::dextents<size_t, N>>; + -> mdspan<ElementType, ::std::experimental::dextents<size_t, N>>; #endif // This one is necessary because all the constructors take `data_handle_type`s, not @@ -418,7 +407,7 @@ MDSPAN_DEDUCTION_GUIDE mdspan(ElementType*, ::std::span<SizeType, N>) // seems to throw off automatic deduction guides. template <class ElementType, class SizeType, size_t... ExtentsPack> MDSPAN_DEDUCTION_GUIDE mdspan(ElementType*, const extents<SizeType, ExtentsPack...>&) - -> mdspan<ElementType, ::MDSPAN_IMPL_STANDARD_NAMESPACE::extents<SizeType, ExtentsPack...>>; + -> mdspan<ElementType, ::std::experimental::extents<SizeType, ExtentsPack...>>; template <class ElementType, class MappingType> MDSPAN_DEDUCTION_GUIDE mdspan(ElementType*, const MappingType&) @@ -429,4 +418,7 @@ MDSPAN_DEDUCTION_GUIDE mdspan(const typename AccessorType::data_handle_type, con -> mdspan<typename AccessorType::element_type, typename MappingType::extents_type, typename MappingType::layout_type, AccessorType>; #endif -} // end namespace MDSPAN_IMPL_STANDARD_NAMESPACE + + +} // end namespace experimental +} // end namespace std diff --git a/tests/generator_scripts/deps/mdspan/include/experimental/__p0009_bits/no_unique_address.hpp b/tests/generator_scripts/deps/mdspan/include/experimental/__p0009_bits/no_unique_address.hpp index 36e64ee24dbb7166ac5da069bbbfbc4347026993..7e4c5f8ffe94fdc4e952bd15d92d91dbf009ca4e 100644 --- a/tests/generator_scripts/deps/mdspan/include/experimental/__p0009_bits/no_unique_address.hpp +++ b/tests/generator_scripts/deps/mdspan/include/experimental/__p0009_bits/no_unique_address.hpp @@ -18,7 +18,8 @@ #include "macros.hpp" #include "trait_backports.hpp" -namespace MDSPAN_IMPL_STANDARD_NAMESPACE { +namespace std { +namespace experimental { namespace detail { //============================================================================== @@ -41,17 +42,17 @@ struct __no_unique_address_emulation { template <class _T, size_t _Disambiguator> struct __no_unique_address_emulation< _T, _Disambiguator, - std::enable_if_t<_MDSPAN_TRAIT(std::is_empty, _T) && + enable_if_t<_MDSPAN_TRAIT(is_empty, _T) && // If the type isn't trivially destructible, its destructor // won't be called at the right time, so don't use this // specialization - _MDSPAN_TRAIT(std::is_trivially_destructible, _T)>> : + _MDSPAN_TRAIT(is_trivially_destructible, _T)>> : #ifdef _MDSPAN_COMPILER_MSVC // MSVC doesn't allow you to access public static member functions of a type // when you *happen* to privately inherit from that type. protected #else - // But we still want this to be private if possible so that we don't accidentally + // But we still want this to be private if possible so that we don't accidentally // access members of _T directly rather than calling __ref() first, which wouldn't // work if _T happens to be stateful and thus we're using the unspecialized definition // of __no_unique_address_emulation above. @@ -94,4 +95,5 @@ struct __no_unique_address_emulation< //============================================================================== } // end namespace detail -} // end namespace MDSPAN_IMPL_STANDARD_NAMESPACE +} // end namespace experimental +} // end namespace std diff --git a/tests/generator_scripts/deps/mdspan/include/experimental/__p0009_bits/trait_backports.hpp b/tests/generator_scripts/deps/mdspan/include/experimental/__p0009_bits/trait_backports.hpp index 4933dd9934ea0a967ff46b5afc303a1431df6748..b2bb5d21527235521260e8c25518de068fe172cf 100644 --- a/tests/generator_scripts/deps/mdspan/include/experimental/__p0009_bits/trait_backports.hpp +++ b/tests/generator_scripts/deps/mdspan/include/experimental/__p0009_bits/trait_backports.hpp @@ -28,7 +28,7 @@ #ifdef _MDSPAN_NEEDS_TRAIT_VARIABLE_TEMPLATE_BACKPORTS #if _MDSPAN_USE_VARIABLE_TEMPLATES -namespace MDSPAN_IMPL_STANDARD_NAMESPACE { +namespace std { #define _MDSPAN_BACKPORT_TRAIT(TRAIT) \ template <class... Args> _MDSPAN_INLINE_VARIABLE constexpr auto TRAIT##_v = TRAIT<Args...>::value; @@ -44,7 +44,7 @@ _MDSPAN_BACKPORT_TRAIT(is_void) #undef _MDSPAN_BACKPORT_TRAIT -} // end namespace MDSPAN_IMPL_STANDARD_NAMESPACE +} // end namespace std #endif // _MDSPAN_USE_VARIABLE_TEMPLATES @@ -58,16 +58,16 @@ _MDSPAN_BACKPORT_TRAIT(is_void) #if !defined(_MDSPAN_USE_INTEGER_SEQUENCE) || !_MDSPAN_USE_INTEGER_SEQUENCE -namespace MDSPAN_IMPL_STANDARD_NAMESPACE { +namespace std { template <class T, T... Vals> struct integer_sequence { - static constexpr size_t size() noexcept { return sizeof...(Vals); } + static constexpr std::size_t size() noexcept { return sizeof...(Vals); } using value_type = T; }; -template <size_t... Vals> -using index_sequence = std::integer_sequence<size_t, Vals...>; +template <std::size_t... Vals> +using index_sequence = std::integer_sequence<std::size_t, Vals...>; namespace __detail { @@ -91,13 +91,13 @@ struct __make_int_seq_impl< template <class T, T N> using make_integer_sequence = typename __detail::__make_int_seq_impl<T, N, 0, integer_sequence<T>>::type; -template <size_t N> +template <std::size_t N> using make_index_sequence = typename __detail::__make_int_seq_impl<size_t, N, 0, integer_sequence<size_t>>::type; template <class... T> using index_sequence_for = make_index_sequence<sizeof...(T)>; -} // end namespace MDSPAN_IMPL_STANDARD_NAMESPACE +} // end namespace std #endif @@ -109,7 +109,7 @@ using index_sequence_for = make_index_sequence<sizeof...(T)>; #if !defined(_MDSPAN_USE_STANDARD_TRAIT_ALIASES) || !_MDSPAN_USE_STANDARD_TRAIT_ALIASES -namespace MDSPAN_IMPL_STANDARD_NAMESPACE { +namespace std { #define _MDSPAN_BACKPORT_TRAIT_ALIAS(TRAIT) \ template <class... Args> using TRAIT##_t = typename TRAIT<Args...>::type; @@ -122,7 +122,7 @@ using enable_if_t = typename enable_if<_B, _T>::type; #undef _MDSPAN_BACKPORT_TRAIT_ALIAS -} // end namespace MDSPAN_IMPL_STANDARD_NAMESPACE +} // end namespace std #endif diff --git a/tests/generator_scripts/deps/mdspan/include/experimental/__p0009_bits/type_list.hpp b/tests/generator_scripts/deps/mdspan/include/experimental/__p0009_bits/type_list.hpp index deca7c15d095857a805fa00cbd1947ce8c434d65..6a7acd44b272303983de5d9d663f3b0667a06e1d 100644 --- a/tests/generator_scripts/deps/mdspan/include/experimental/__p0009_bits/type_list.hpp +++ b/tests/generator_scripts/deps/mdspan/include/experimental/__p0009_bits/type_list.hpp @@ -17,7 +17,8 @@ #include "trait_backports.hpp" // make_index_sequence -namespace MDSPAN_IMPL_STANDARD_NAMESPACE { +namespace std { +namespace experimental { //============================================================================== @@ -27,7 +28,7 @@ template <class... _Ts> struct __type_list { static constexpr auto __size = size // Implementation of type_list at() that's heavily optimized for small typelists template <size_t, class> struct __type_at; -template <size_t, class _Seq, class=std::make_index_sequence<_Seq::__size>> struct __type_at_large_impl; +template <size_t, class _Seq, class=make_index_sequence<_Seq::__size>> struct __type_at_large_impl; template <size_t _I, size_t _Idx, class _T> struct __type_at_entry { }; @@ -47,7 +48,7 @@ struct __type_at_assign_op_impl { }; template <size_t _I, class... _Ts, size_t... _Idxs> -struct __type_at_large_impl<_I, __type_list<_Ts...>, std::integer_sequence<size_t, _Idxs...>> +struct __type_at_large_impl<_I, __type_list<_Ts...>, integer_sequence<size_t, _Idxs...>> : decltype( _MDSPAN_FOLD_ASSIGN_LEFT(__type_at_assign_op_impl{}, /* = ... = */ __type_at_entry<_I, _Idxs, _Ts>{}) ) @@ -83,5 +84,6 @@ struct __type_at<3, __type_list<_T0, _T1, _T2, _T3, _Ts...>> { //============================================================================== -} // end namespace MDSPAN_IMPL_STANDARD_NAMESPACE +} // end namespace experimental +} // end namespace std diff --git a/tests/generator_scripts/deps/mdspan/include/experimental/__p0009_bits/utility.hpp b/tests/generator_scripts/deps/mdspan/include/experimental/__p0009_bits/utility.hpp deleted file mode 100644 index ca821176f875e4e650984a4d674e0a64dede53af..0000000000000000000000000000000000000000 --- a/tests/generator_scripts/deps/mdspan/include/experimental/__p0009_bits/utility.hpp +++ /dev/null @@ -1,66 +0,0 @@ -#pragma once - -#include <cstddef> -#include <type_traits> - -namespace MDSPAN_IMPL_STANDARD_NAMESPACE { -namespace detail { - -// type alias used for rank-based tag dispatch -// -// this is used to enable alternatives to constexpr if when building for C++14 -// -template <std::size_t N> -using with_rank = std::integral_constant<std::size_t, N>; - -template <class I1, class I2> -constexpr bool common_integral_compare(I1 x, I2 y) -{ - static_assert(std::is_integral<I1>::value and - std::is_integral<I2>::value, ""); - - using I = std::common_type_t<I1, I2>; - return static_cast<I>(x) == static_cast<I>(y); -} - -template <class T1, class T2, class F> -constexpr bool rankwise_equal(with_rank<0>, const T1&, const T2&, F) -{ - return true; -} -template <std::size_t N, class T1, class T2, class F> -constexpr bool rankwise_equal(with_rank<N>, const T1& x, const T2& y, F func) -{ - bool match = true; - - for (std::size_t r = 0; r < N; r++) { - match = match && common_integral_compare(func(x, r), func(y, r)); - } - - return match; -} - -constexpr struct -{ - template <class T, class I> - constexpr auto operator()(const T& x, I i) const - { - return x.extent(i); - } -} extent; - -constexpr struct -{ - template <class T, class I> - constexpr auto operator()(const T& x, I i) const - { - return x.stride(i); - } -} stride; - -} // namespace detail - -constexpr struct mdspan_non_standard_tag { -} mdspan_non_standard; - -} // namespace MDSPAN_IMPL_STANDARD_NAMESPACE diff --git a/tests/generator_scripts/deps/mdspan/include/experimental/__p1684_bits/mdarray.hpp b/tests/generator_scripts/deps/mdspan/include/experimental/__p1684_bits/mdarray.hpp index bdc5925f715190b2d7163ec75e0c5956df706df9..c84fd78a944fda5834871b33099271d911f1be77 100644 --- a/tests/generator_scripts/deps/mdspan/include/experimental/__p1684_bits/mdarray.hpp +++ b/tests/generator_scripts/deps/mdspan/include/experimental/__p1684_bits/mdarray.hpp @@ -20,8 +20,8 @@ #include <cassert> #include <vector> -namespace MDSPAN_IMPL_STANDARD_NAMESPACE { -namespace MDSPAN_IMPL_PROPOSED_NAMESPACE { +namespace std { +namespace experimental { namespace { template<class Extents> @@ -40,14 +40,14 @@ namespace { namespace { template<class C> - struct container_is_array : std::false_type { + struct container_is_array : false_type { template<class M> static constexpr C construct(const M& m) { return C(m.required_span_size()); } }; template<class T, size_t N> - struct container_is_array<std::array<T,N>> : std::true_type { + struct container_is_array<array<T,N>> : true_type { template<class M> - static constexpr std::array<T,N> construct(const M&) { return std::array<T,N>(); } + static constexpr array<T,N> construct(const M&) { return array<T,N>(); } }; } @@ -55,12 +55,12 @@ template < class ElementType, class Extents, class LayoutPolicy = layout_right, - class Container = std::vector<ElementType> + class Container = vector<ElementType> > class mdarray { private: - static_assert(::MDSPAN_IMPL_STANDARD_NAMESPACE::detail::__is_extents_v<Extents>, - MDSPAN_IMPL_PROPOSED_NAMESPACE_STRING "::mdspan's Extents template parameter must be a specialization of " MDSPAN_IMPL_STANDARD_NAMESPACE_STRING "::extents."); + static_assert(detail::__is_extents_v<Extents>, "std::experimental::mdspan's Extents template parameter must be a specialization of std::experimental::extents."); + public: @@ -74,7 +74,7 @@ public: using element_type = ElementType; using mdspan_type = mdspan<element_type, extents_type, layout_type>; using const_mdspan_type = mdspan<const element_type, extents_type, layout_type>; - using value_type = std::remove_cv_t<element_type>; + using value_type = remove_cv_t<element_type>; using index_type = typename Extents::index_type; using size_type = typename Extents::size_type; using rank_type = typename Extents::rank_type; @@ -103,10 +103,10 @@ public: MDSPAN_TEMPLATE_REQUIRES( class... SizeTypes, /* requires */ ( - (::MDSPAN_IMPL_STANDARD_NAMESPACE::detail::are_valid_indices<index_type, SizeTypes...>()) && - _MDSPAN_TRAIT( std::is_constructible, extents_type, SizeTypes...) && - _MDSPAN_TRAIT( std::is_constructible, mapping_type, extents_type) && - (_MDSPAN_TRAIT( std::is_constructible, container_type, size_t) || + _MDSPAN_FOLD_AND(_MDSPAN_TRAIT(is_convertible, SizeTypes, index_type) /* && ... */) && + _MDSPAN_TRAIT(is_constructible, extents_type, SizeTypes...) && + _MDSPAN_TRAIT(is_constructible, mapping_type, extents_type) && + (_MDSPAN_TRAIT(is_constructible, container_type, size_t) || container_is_array<container_type>::value) && (extents_type::rank()>0 || extents_type::rank_dynamic()==0) ) @@ -119,62 +119,94 @@ public: MDSPAN_FUNCTION_REQUIRES( (MDSPAN_INLINE_FUNCTION constexpr), mdarray, (const extents_type& exts), , - /* requires */ ((_MDSPAN_TRAIT( std::is_constructible, container_type, size_t) || + /* requires */ ((_MDSPAN_TRAIT(is_constructible, container_type, size_t) || container_is_array<container_type>::value) && - _MDSPAN_TRAIT( std::is_constructible, mapping_type, extents_type)) + _MDSPAN_TRAIT(is_constructible, mapping_type, extents_type)) ) : map_(exts), ctr_(container_is_array<container_type>::construct(map_)) { } MDSPAN_FUNCTION_REQUIRES( (MDSPAN_INLINE_FUNCTION constexpr), mdarray, (const mapping_type& m), , - /* requires */ (_MDSPAN_TRAIT( std::is_constructible, container_type, size_t) || + /* requires */ (_MDSPAN_TRAIT(is_constructible, container_type, size_t) || container_is_array<container_type>::value) ) : map_(m), ctr_(container_is_array<container_type>::construct(map_)) { } + // Constructors from container + MDSPAN_TEMPLATE_REQUIRES( + class... SizeTypes, + /* requires */ ( + _MDSPAN_FOLD_AND(_MDSPAN_TRAIT(is_convertible, SizeTypes, index_type) /* && ... */) && + _MDSPAN_TRAIT(is_constructible, extents_type, SizeTypes...) && + _MDSPAN_TRAIT(is_constructible, mapping_type, extents_type) + ) + ) + MDSPAN_INLINE_FUNCTION + explicit constexpr mdarray(const container_type& ctr, SizeTypes... dynamic_extents) + : map_(extents_type(dynamic_extents...)), ctr_(ctr) + { assert(ctr.size() >= static_cast<size_t>(map_.required_span_size())); } + + MDSPAN_FUNCTION_REQUIRES( (MDSPAN_INLINE_FUNCTION constexpr), - mdarray, (const extents_type& exts, const container_type& ctr), , - /* requires */ (_MDSPAN_TRAIT( std::is_constructible, mapping_type, extents_type)) + mdarray, (const container_type& ctr, const extents_type& exts), , + /* requires */ (_MDSPAN_TRAIT(is_constructible, mapping_type, extents_type)) ) : map_(exts), ctr_(ctr) { assert(ctr.size() >= static_cast<size_t>(map_.required_span_size())); } - constexpr mdarray(const mapping_type& m, const container_type& ctr) + constexpr mdarray(const container_type& ctr, const mapping_type& m) : map_(m), ctr_(ctr) { assert(ctr.size() >= static_cast<size_t>(map_.required_span_size())); } + + // Constructors from container + MDSPAN_TEMPLATE_REQUIRES( + class... SizeTypes, + /* requires */ ( + _MDSPAN_FOLD_AND(_MDSPAN_TRAIT(is_convertible, SizeTypes, index_type) /* && ... */) && + _MDSPAN_TRAIT(is_constructible, extents_type, SizeTypes...) && + _MDSPAN_TRAIT(is_constructible, mapping_type, extents_type) + ) + ) + MDSPAN_INLINE_FUNCTION + explicit constexpr mdarray(container_type&& ctr, SizeTypes... dynamic_extents) + : map_(extents_type(dynamic_extents...)), ctr_(std::move(ctr)) + { assert(ctr_.size() >= static_cast<size_t>(map_.required_span_size())); } + + MDSPAN_FUNCTION_REQUIRES( (MDSPAN_INLINE_FUNCTION constexpr), - mdarray, (const extents_type& exts, container_type&& ctr), , - /* requires */ (_MDSPAN_TRAIT( std::is_constructible, mapping_type, extents_type)) + mdarray, (container_type&& ctr, const extents_type& exts), , + /* requires */ (_MDSPAN_TRAIT(is_constructible, mapping_type, extents_type)) ) : map_(exts), ctr_(std::move(ctr)) { assert(ctr_.size() >= static_cast<size_t>(map_.required_span_size())); } - constexpr mdarray(const mapping_type& m, container_type&& ctr) + constexpr mdarray(container_type&& ctr, const mapping_type& m) : map_(m), ctr_(std::move(ctr)) { assert(ctr_.size() >= static_cast<size_t>(map_.required_span_size())); } + MDSPAN_TEMPLATE_REQUIRES( class OtherElementType, class OtherExtents, class OtherLayoutPolicy, class OtherContainer, /* requires */ ( - _MDSPAN_TRAIT( std::is_constructible, mapping_type, typename OtherLayoutPolicy::template mapping<OtherExtents>) && - _MDSPAN_TRAIT( std::is_constructible, container_type, OtherContainer) + _MDSPAN_TRAIT(is_constructible, mapping_type, typename OtherLayoutPolicy::template mapping<OtherExtents>) && + _MDSPAN_TRAIT(is_constructible, container_type, OtherContainer) ) ) MDSPAN_INLINE_FUNCTION constexpr mdarray(const mdarray<OtherElementType, OtherExtents, OtherLayoutPolicy, OtherContainer>& other) : map_(other.mapping()), ctr_(other.container()) { - static_assert( std::is_constructible<extents_type, OtherExtents>::value, ""); + static_assert(is_constructible<extents_type, OtherExtents>::value, ""); } // Constructors for container types constructible from a size and allocator MDSPAN_TEMPLATE_REQUIRES( class Alloc, - /* requires */ (_MDSPAN_TRAIT( std::is_constructible, container_type, size_t, Alloc) && - _MDSPAN_TRAIT( std::is_constructible, mapping_type, extents_type)) + /* requires */ (_MDSPAN_TRAIT(is_constructible, container_type, size_t, Alloc) && + _MDSPAN_TRAIT(is_constructible, mapping_type, extents_type)) ) MDSPAN_INLINE_FUNCTION constexpr mdarray(const extents_type& exts, const Alloc& a) @@ -183,7 +215,7 @@ public: MDSPAN_TEMPLATE_REQUIRES( class Alloc, - /* requires */ (_MDSPAN_TRAIT( std::is_constructible, container_type, size_t, Alloc)) + /* requires */ (_MDSPAN_TRAIT(is_constructible, container_type, size_t, Alloc)) ) MDSPAN_INLINE_FUNCTION constexpr mdarray(const mapping_type& map, const Alloc& a) @@ -193,54 +225,54 @@ public: // Constructors for container types constructible from a container and allocator MDSPAN_TEMPLATE_REQUIRES( class Alloc, - /* requires */ (_MDSPAN_TRAIT( std::is_constructible, container_type, container_type, Alloc) && - _MDSPAN_TRAIT( std::is_constructible, mapping_type, extents_type)) + /* requires */ (_MDSPAN_TRAIT(is_constructible, container_type, container_type, Alloc) && + _MDSPAN_TRAIT(is_constructible, mapping_type, extents_type)) ) MDSPAN_INLINE_FUNCTION - constexpr mdarray(const extents_type& exts, const container_type& ctr, const Alloc& a) + constexpr mdarray(const container_type& ctr, const extents_type& exts, const Alloc& a) : map_(exts), ctr_(ctr, a) { assert(ctr_.size() >= static_cast<size_t>(map_.required_span_size())); } MDSPAN_TEMPLATE_REQUIRES( class Alloc, - /* requires */ (_MDSPAN_TRAIT( std::is_constructible, container_type, size_t, Alloc)) + /* requires */ (_MDSPAN_TRAIT(is_constructible, container_type, size_t, Alloc)) ) MDSPAN_INLINE_FUNCTION - constexpr mdarray(const mapping_type& map, const container_type& ctr, const Alloc& a) + constexpr mdarray(const container_type& ctr, const mapping_type& map, const Alloc& a) : map_(map), ctr_(ctr, a) { assert(ctr_.size() >= static_cast<size_t>(map_.required_span_size())); } MDSPAN_TEMPLATE_REQUIRES( class Alloc, - /* requires */ (_MDSPAN_TRAIT( std::is_constructible, container_type, container_type, Alloc) && - _MDSPAN_TRAIT( std::is_constructible, mapping_type, extents_type)) + /* requires */ (_MDSPAN_TRAIT(is_constructible, container_type, container_type, Alloc) && + _MDSPAN_TRAIT(is_constructible, mapping_type, extents_type)) ) MDSPAN_INLINE_FUNCTION - constexpr mdarray(const extents_type& exts, container_type&& ctr, const Alloc& a) + constexpr mdarray(container_type&& ctr, const extents_type& exts, const Alloc& a) : map_(exts), ctr_(std::move(ctr), a) { assert(ctr_.size() >= static_cast<size_t>(map_.required_span_size())); } MDSPAN_TEMPLATE_REQUIRES( class Alloc, - /* requires */ (_MDSPAN_TRAIT( std::is_constructible, container_type, size_t, Alloc)) + /* requires */ (_MDSPAN_TRAIT(is_constructible, container_type, size_t, Alloc)) ) MDSPAN_INLINE_FUNCTION - constexpr mdarray(const mapping_type& map, container_type&& ctr, const Alloc& a) + constexpr mdarray(container_type&& ctr, const mapping_type& map, const Alloc& a) : map_(map), ctr_(std::move(ctr), a) { assert(ctr_.size() >= map_.required_span_size()); } MDSPAN_TEMPLATE_REQUIRES( class OtherElementType, class OtherExtents, class OtherLayoutPolicy, class OtherContainer, class Alloc, /* requires */ ( - _MDSPAN_TRAIT( std::is_constructible, mapping_type, typename OtherLayoutPolicy::template mapping<OtherExtents>) && - _MDSPAN_TRAIT( std::is_constructible, container_type, OtherContainer, Alloc) + _MDSPAN_TRAIT(is_constructible, mapping_type, typename OtherLayoutPolicy::template mapping<OtherExtents>) && + _MDSPAN_TRAIT(is_constructible, container_type, OtherContainer, Alloc) ) ) MDSPAN_INLINE_FUNCTION constexpr mdarray(const mdarray<OtherElementType, OtherExtents, OtherLayoutPolicy, OtherContainer>& other, const Alloc& a) : map_(other.mapping()), ctr_(other.container(), a) { - static_assert( std::is_constructible<extents_type, OtherExtents>::value, ""); + static_assert(is_constructible<extents_type, OtherExtents>::value, ""); } MDSPAN_INLINE_FUNCTION_DEFAULTED constexpr mdarray& operator= (const mdarray&) = default; @@ -255,7 +287,7 @@ public: MDSPAN_TEMPLATE_REQUIRES( class... SizeTypes, /* requires */ ( - _MDSPAN_FOLD_AND(_MDSPAN_TRAIT( std::is_convertible, SizeTypes, index_type) /* && ... */) && + _MDSPAN_FOLD_AND(_MDSPAN_TRAIT(is_convertible, SizeTypes, index_type) /* && ... */) && extents_type::rank() == sizeof...(SizeTypes) ) ) @@ -268,7 +300,7 @@ public: MDSPAN_TEMPLATE_REQUIRES( class... SizeTypes, /* requires */ ( - _MDSPAN_FOLD_AND(_MDSPAN_TRAIT( std::is_convertible, SizeTypes, index_type) /* && ... */) && + _MDSPAN_FOLD_AND(_MDSPAN_TRAIT(is_convertible, SizeTypes, index_type) /* && ... */) && extents_type::rank() == sizeof...(SizeTypes) ) ) @@ -283,12 +315,12 @@ public: MDSPAN_TEMPLATE_REQUIRES( class SizeType, size_t N, /* requires */ ( - _MDSPAN_TRAIT( std::is_convertible, SizeType, index_type) && + _MDSPAN_TRAIT(is_convertible, SizeType, index_type) && N == extents_type::rank() ) ) MDSPAN_FORCE_INLINE_FUNCTION - constexpr const_reference operator[](const std::array<SizeType, N>& indices) const noexcept + constexpr const_reference operator[](const array<SizeType, N>& indices) const noexcept { return __impl::template __callop<reference>(*this, indices); } @@ -296,12 +328,12 @@ public: MDSPAN_TEMPLATE_REQUIRES( class SizeType, size_t N, /* requires */ ( - _MDSPAN_TRAIT( std::is_convertible, SizeType, index_type) && + _MDSPAN_TRAIT(is_convertible, SizeType, index_type) && N == extents_type::rank() ) ) MDSPAN_FORCE_INLINE_FUNCTION - constexpr reference operator[](const std::array<SizeType, N>& indices) noexcept + constexpr reference operator[](const array<SizeType, N>& indices) noexcept { return __impl::template __callop<reference>(*this, indices); } @@ -312,8 +344,8 @@ public: MDSPAN_TEMPLATE_REQUIRES( class... SizeTypes, /* requires */ ( - (::MDSPAN_IMPL_STANDARD_NAMESPACE::detail::are_valid_indices<index_type, SizeTypes...>()) && - extents_type::rank() == sizeof...(SizeTypes) + _MDSPAN_FOLD_AND(_MDSPAN_TRAIT(is_convertible, SizeTypes, index_type) /* && ... */) && + extents_type::rank() == sizeof...(SizeTypes) ) ) MDSPAN_FORCE_INLINE_FUNCTION @@ -324,8 +356,8 @@ public: MDSPAN_TEMPLATE_REQUIRES( class... SizeTypes, /* requires */ ( - (::MDSPAN_IMPL_STANDARD_NAMESPACE::detail::are_valid_indices<index_type, SizeTypes...>()) && - extents_type::rank() == sizeof...(SizeTypes) + _MDSPAN_FOLD_AND(_MDSPAN_TRAIT(is_convertible, SizeTypes, index_type) /* && ... */) && + extents_type::rank() == sizeof...(SizeTypes) ) ) MDSPAN_FORCE_INLINE_FUNCTION @@ -338,12 +370,12 @@ public: MDSPAN_TEMPLATE_REQUIRES( class SizeType, size_t N, /* requires */ ( - _MDSPAN_TRAIT( std::is_convertible, SizeType, index_type) && + _MDSPAN_TRAIT(is_convertible, SizeType, index_type) && N == extents_type::rank() ) ) MDSPAN_FORCE_INLINE_FUNCTION - constexpr const_reference operator()(const std::array<SizeType, N>& indices) const noexcept + constexpr const_reference operator()(const array<SizeType, N>& indices) const noexcept { return __impl::template __callop<reference>(*this, indices); } @@ -351,12 +383,12 @@ public: MDSPAN_TEMPLATE_REQUIRES( class SizeType, size_t N, /* requires */ ( - _MDSPAN_TRAIT( std::is_convertible, SizeType, index_type) && + _MDSPAN_TRAIT(is_convertible, SizeType, index_type) && N == extents_type::rank() ) ) MDSPAN_FORCE_INLINE_FUNCTION - constexpr reference operator()(const std::array<SizeType, N>& indices) noexcept + constexpr reference operator()(const array<SizeType, N>& indices) noexcept { return __impl::template __callop<reference>(*this, indices); } @@ -401,9 +433,8 @@ public: class OtherElementType, class OtherExtents, class OtherLayoutType, class OtherAccessorType, /* requires */ ( - _MDSPAN_TRAIT(std::is_assignable, - mdspan<OtherElementType, OtherExtents, OtherLayoutType, OtherAccessorType>, - mdspan_type) + _MDSPAN_TRAIT(is_assignable, mdspan_type, + mdspan<OtherElementType, OtherExtents, OtherLayoutType, OtherAccessorType>) ) ) constexpr operator mdspan<OtherElementType, OtherExtents, OtherLayoutType, OtherAccessorType> () { @@ -414,9 +445,8 @@ public: class OtherElementType, class OtherExtents, class OtherLayoutType, class OtherAccessorType, /* requires */ ( - _MDSPAN_TRAIT(std::is_assignable, - mdspan<OtherElementType, OtherExtents, OtherLayoutType, OtherAccessorType>, - const_mdspan_type) + _MDSPAN_TRAIT(is_assignable, const_mdspan_type, + mdspan<OtherElementType, OtherExtents, OtherLayoutType, OtherAccessorType>) ) ) constexpr operator mdspan<OtherElementType, OtherExtents, OtherLayoutType, OtherAccessorType> () const { @@ -426,7 +456,7 @@ public: MDSPAN_TEMPLATE_REQUIRES( class OtherAccessorType = default_accessor<element_type>, /* requires */ ( - _MDSPAN_TRAIT(std::is_assignable, mdspan_type, + _MDSPAN_TRAIT(is_assignable, mdspan_type, mdspan<element_type, extents_type, layout_type, OtherAccessorType>) ) ) @@ -438,7 +468,7 @@ public: MDSPAN_TEMPLATE_REQUIRES( class OtherAccessorType = default_accessor<const element_type>, /* requires */ ( - _MDSPAN_TRAIT(std::is_assignable, const_mdspan_type, + _MDSPAN_TRAIT(is_assignable, const_mdspan_type, mdspan<const element_type, extents_type, layout_type, OtherAccessorType>) ) ) @@ -456,5 +486,5 @@ private: }; -} // end namespace MDSPAN_IMPL_PROPOSED_NAMESPACE -} // end namespace MDSPAN_IMPL_STANDARD_NAMESPACE +} // end namespace experimental +} // end namespace std diff --git a/tests/generator_scripts/deps/mdspan/include/experimental/__p2389_bits/dims.hpp b/tests/generator_scripts/deps/mdspan/include/experimental/__p2389_bits/dims.hpp deleted file mode 100644 index 00045215c489bfaa04bd0d7967a85b49559fb714..0000000000000000000000000000000000000000 --- a/tests/generator_scripts/deps/mdspan/include/experimental/__p2389_bits/dims.hpp +++ /dev/null @@ -1,28 +0,0 @@ -//@HEADER -// ************************************************************************ -// -// Kokkos v. 4.0 -// Copyright (2022) National Technology & Engineering -// Solutions of Sandia, LLC (NTESS). -// -// Under the terms of Contract DE-NA0003525 with NTESS, -// the U.S. Government retains certain rights in this software. -// -// Part of Kokkos, under the Apache License v2.0 with LLVM Exceptions. -// See https://kokkos.org/LICENSE for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//@HEADER - -#pragma once - -// backward compatibility import into experimental -namespace MDSPAN_IMPL_STANDARD_NAMESPACE { -namespace MDSPAN_IMPL_PROPOSED_NAMESPACE { - -template< ::std::size_t Rank, class IndexType = std::size_t> -using dims = - :: MDSPAN_IMPL_STANDARD_NAMESPACE :: dextents<IndexType, Rank>; - -} // namespace MDSPAN_IMPL_PROPOSED_NAMESPACE -} // namespace MDSPAN_IMPL_STANDARD_NAMESPACE diff --git a/tests/generator_scripts/deps/mdspan/include/experimental/__p2630_bits/strided_slice.hpp b/tests/generator_scripts/deps/mdspan/include/experimental/__p2630_bits/strided_slice.hpp index 89ba8202fb16a090bfa9352a4dcf7041cf53c90f..f2f51bbc701c8325226f0195e24d075409d335e2 100644 --- a/tests/generator_scripts/deps/mdspan/include/experimental/__p2630_bits/strided_slice.hpp +++ b/tests/generator_scripts/deps/mdspan/include/experimental/__p2630_bits/strided_slice.hpp @@ -15,20 +15,18 @@ // //@HEADER -#pragma once - #include <type_traits> -namespace MDSPAN_IMPL_STANDARD_NAMESPACE { +namespace std { +namespace experimental { namespace { template<class T> struct __mdspan_is_integral_constant: std::false_type {}; template<class T, T val> - struct __mdspan_is_integral_constant<std::integral_constant<T,val>>: std::true_type {}; + struct __mdspan_is_integral_constant<integral_constant<T,val>>: std::true_type {}; } - // Slice Specifier allowing for strides and compile time extent template <class OffsetType, class ExtentType, class StrideType> struct strided_slice { @@ -36,13 +34,14 @@ struct strided_slice { using extent_type = ExtentType; using stride_type = StrideType; - _MDSPAN_NO_UNIQUE_ADDRESS OffsetType offset{}; - _MDSPAN_NO_UNIQUE_ADDRESS ExtentType extent{}; - _MDSPAN_NO_UNIQUE_ADDRESS StrideType stride{}; + OffsetType offset; + ExtentType extent; + StrideType stride; - static_assert(std::is_integral_v<OffsetType> || __mdspan_is_integral_constant<OffsetType>::value); - static_assert(std::is_integral_v<ExtentType> || __mdspan_is_integral_constant<ExtentType>::value); - static_assert(std::is_integral_v<StrideType> || __mdspan_is_integral_constant<StrideType>::value); + static_assert(is_integral_v<OffsetType> || __mdspan_is_integral_constant<OffsetType>::value); + static_assert(is_integral_v<ExtentType> || __mdspan_is_integral_constant<ExtentType>::value); + static_assert(is_integral_v<StrideType> || __mdspan_is_integral_constant<StrideType>::value); }; -} // MDSPAN_IMPL_STANDARD_NAMESPACE +} // experimental +} // std diff --git a/tests/generator_scripts/deps/mdspan/include/experimental/__p2630_bits/submdspan.hpp b/tests/generator_scripts/deps/mdspan/include/experimental/__p2630_bits/submdspan.hpp index abddd0b59df170f2b16f7e5d301e45378a42bdee..7b2790013cbbc866f22d94176e54ae10515a0aeb 100644 --- a/tests/generator_scripts/deps/mdspan/include/experimental/__p2630_bits/submdspan.hpp +++ b/tests/generator_scripts/deps/mdspan/include/experimental/__p2630_bits/submdspan.hpp @@ -14,27 +14,27 @@ // //@HEADER -#pragma once - #include "submdspan_extents.hpp" #include "submdspan_mapping.hpp" -namespace MDSPAN_IMPL_STANDARD_NAMESPACE { +namespace std { +namespace experimental { template <class ElementType, class Extents, class LayoutPolicy, class AccessorPolicy, class... SliceSpecifiers> MDSPAN_INLINE_FUNCTION constexpr auto submdspan(const mdspan<ElementType, Extents, LayoutPolicy, AccessorPolicy> &src, SliceSpecifiers... slices) { - const auto sub_submdspan_mapping_result = submdspan_mapping(src.mapping(), slices...); + const auto sub_mapping_offset = submdspan_mapping(src.mapping(), slices...); // NVCC has a problem with the deduction so lets figure out the type - using sub_mapping_t = std::remove_cv_t<decltype(sub_submdspan_mapping_result.mapping)>; + using sub_mapping_t = std::remove_cv_t<decltype(sub_mapping_offset.mapping)>; using sub_extents_t = typename sub_mapping_t::extents_type; using sub_layout_t = typename sub_mapping_t::layout_type; using sub_accessor_t = typename AccessorPolicy::offset_policy; return mdspan<ElementType, sub_extents_t, sub_layout_t, sub_accessor_t>( - src.accessor().offset(src.data_handle(), sub_submdspan_mapping_result.offset), - sub_submdspan_mapping_result.mapping, + src.accessor().offset(src.data_handle(), sub_mapping_offset.offset), + sub_mapping_offset.mapping, sub_accessor_t(src.accessor())); } -} // namespace MDSPAN_IMPL_STANDARD_NAMESPACE +} // namespace experimental +} // namespace std diff --git a/tests/generator_scripts/deps/mdspan/include/experimental/__p2630_bits/submdspan_extents.hpp b/tests/generator_scripts/deps/mdspan/include/experimental/__p2630_bits/submdspan_extents.hpp index c3b2f78fb998cb1a3c77a9cac8738085d81cbbaf..6f2c6a2ec1ff38763a01d3226463385da716573b 100644 --- a/tests/generator_scripts/deps/mdspan/include/experimental/__p2630_bits/submdspan_extents.hpp +++ b/tests/generator_scripts/deps/mdspan/include/experimental/__p2630_bits/submdspan_extents.hpp @@ -14,12 +14,9 @@ // //@HEADER -#pragma once - -#include <tuple> - #include "strided_slice.hpp" -namespace MDSPAN_IMPL_STANDARD_NAMESPACE { +namespace std { +namespace experimental { namespace detail { // Mapping from submapping ranks to srcmapping ranks @@ -28,34 +25,34 @@ namespace detail { // end of recursion specialization containing the final index_sequence template <size_t Counter, size_t... MapIdxs> MDSPAN_INLINE_FUNCTION -constexpr auto inv_map_rank(std::integral_constant<size_t, Counter>, std::index_sequence<MapIdxs...>) { - return std::index_sequence<MapIdxs...>(); +constexpr auto inv_map_rank(integral_constant<size_t, Counter>, index_sequence<MapIdxs...>) { + return index_sequence<MapIdxs...>(); } // specialization reducing rank by one (i.e., integral slice specifier) template<size_t Counter, class Slice, class... SliceSpecifiers, size_t... MapIdxs> MDSPAN_INLINE_FUNCTION -constexpr auto inv_map_rank(std::integral_constant<size_t, Counter>, std::index_sequence<MapIdxs...>, Slice, +constexpr auto inv_map_rank(integral_constant<size_t, Counter>, index_sequence<MapIdxs...>, Slice, SliceSpecifiers... slices) { - using next_idx_seq_t = std::conditional_t<std::is_convertible_v<Slice, size_t>, - std::index_sequence<MapIdxs...>, - std::index_sequence<MapIdxs..., Counter>>; + using next_idx_seq_t = conditional_t<is_convertible_v<Slice, size_t>, + index_sequence<MapIdxs...>, + index_sequence<MapIdxs..., Counter>>; - return inv_map_rank(std::integral_constant<size_t,Counter + 1>(), next_idx_seq_t(), + return inv_map_rank(integral_constant<size_t,Counter + 1>(), next_idx_seq_t(), slices...); } // Helper for identifying strided_slice -template <class T> struct is_strided_slice : std::false_type {}; +template <class T> struct is_strided_slice : false_type {}; template <class OffsetType, class ExtentType, class StrideType> struct is_strided_slice< - strided_slice<OffsetType, ExtentType, StrideType>> : std::true_type {}; + strided_slice<OffsetType, ExtentType, StrideType>> : true_type {}; // first_of(slice): getting begin of slice specifier range MDSPAN_TEMPLATE_REQUIRES( class Integral, - /* requires */(std::is_convertible_v<Integral, size_t>) + /* requires */(is_convertible_v<Integral, size_t>) ) MDSPAN_INLINE_FUNCTION constexpr Integral first_of(const Integral &i) { @@ -63,18 +60,18 @@ constexpr Integral first_of(const Integral &i) { } MDSPAN_INLINE_FUNCTION -constexpr std::integral_constant<size_t, 0> -first_of(const ::MDSPAN_IMPL_STANDARD_NAMESPACE::full_extent_t &) { - return std::integral_constant<size_t, 0>(); +constexpr integral_constant<size_t, 0> +first_of(const experimental::full_extent_t &) { + return integral_constant<size_t, 0>(); } MDSPAN_TEMPLATE_REQUIRES( class Slice, - /* requires */(std::is_convertible_v<Slice, std::tuple<size_t, size_t>>) + /* requires */(is_convertible_v<Slice, tuple<size_t, size_t>>) ) MDSPAN_INLINE_FUNCTION constexpr auto first_of(const Slice &i) { - return std::get<0>(i); + return get<0>(i); } template <class OffsetType, class ExtentType, class StrideType> @@ -90,22 +87,22 @@ first_of(const strided_slice<OffsetType, ExtentType, StrideType> &r) { // This is needed in the case of slice being full_extent_t. MDSPAN_TEMPLATE_REQUIRES( size_t k, class Extents, class Integral, - /* requires */(std::is_convertible_v<Integral, size_t>) + /* requires */(is_convertible_v<Integral, size_t>) ) MDSPAN_INLINE_FUNCTION constexpr Integral - last_of(std::integral_constant<size_t, k>, const Extents &, const Integral &i) { + last_of(integral_constant<size_t, k>, const Extents &, const Integral &i) { return i; } MDSPAN_TEMPLATE_REQUIRES( size_t k, class Extents, class Slice, - /* requires */(std::is_convertible_v<Slice, std::tuple<size_t, size_t>>) + /* requires */(is_convertible_v<Slice, tuple<size_t, size_t>>) ) MDSPAN_INLINE_FUNCTION -constexpr auto last_of(std::integral_constant<size_t, k>, const Extents &, +constexpr auto last_of(integral_constant<size_t, k>, const Extents &, const Slice &i) { - return std::get<1>(i); + return get<1>(i); } // Suppress spurious warning with NVCC about no return statement. @@ -129,12 +126,12 @@ constexpr auto last_of(std::integral_constant<size_t, k>, const Extents &, #endif template <size_t k, class Extents> MDSPAN_INLINE_FUNCTION -constexpr auto last_of(std::integral_constant<size_t, k>, const Extents &ext, - ::MDSPAN_IMPL_STANDARD_NAMESPACE::full_extent_t) { +constexpr auto last_of(integral_constant<size_t, k>, const Extents &ext, + experimental::full_extent_t) { if constexpr (Extents::static_extent(k) == dynamic_extent) { return ext.extent(k); } else { - return std::integral_constant<size_t, Extents::static_extent(k)>(); + return integral_constant<size_t, Extents::static_extent(k)>(); } #if defined(__NVCC__) && !defined(__CUDA_ARCH__) && defined(__GNUC__) // Even with CUDA_ARCH protection this thing warns about calling host function @@ -157,7 +154,7 @@ template <size_t k, class Extents, class OffsetType, class ExtentType, class StrideType> MDSPAN_INLINE_FUNCTION constexpr OffsetType -last_of(std::integral_constant<size_t, k>, const Extents &, +last_of(integral_constant<size_t, k>, const Extents &, const strided_slice<OffsetType, ExtentType, StrideType> &r) { return r.extent; } @@ -166,7 +163,7 @@ last_of(std::integral_constant<size_t, k>, const Extents &, template <class T> MDSPAN_INLINE_FUNCTION constexpr auto stride_of(const T &) { - return std::integral_constant<size_t, 1>(); + return integral_constant<size_t, 1>(); } template <class OffsetType, class ExtentType, class StrideType> @@ -185,11 +182,11 @@ constexpr auto divide(const T0 &v0, const T1 &v1) { template <class IndexT, class T0, T0 v0, class T1, T1 v1> MDSPAN_INLINE_FUNCTION -constexpr auto divide(const std::integral_constant<T0, v0> &, - const std::integral_constant<T1, v1> &) { +constexpr auto divide(const integral_constant<T0, v0> &, + const integral_constant<T1, v1> &) { // cutting short division by zero // this is used for strided_slice with zero extent/stride - return std::integral_constant<IndexT, v0 == 0 ? 0 : v0 / v1>(); + return integral_constant<IndexT, v0 == 0 ? 0 : v0 / v1>(); } // multiply which can deal with integral constant preservation @@ -201,9 +198,9 @@ constexpr auto multiply(const T0 &v0, const T1 &v1) { template <class IndexT, class T0, T0 v0, class T1, T1 v1> MDSPAN_INLINE_FUNCTION -constexpr auto multiply(const std::integral_constant<T0, v0> &, - const std::integral_constant<T1, v1> &) { - return std::integral_constant<IndexT, v0 * v1>(); +constexpr auto multiply(const integral_constant<T0, v0> &, + const integral_constant<T1, v1> &) { + return integral_constant<IndexT, v0 * v1>(); } // compute new static extent from range, preserving static knowledge @@ -235,7 +232,7 @@ template <size_t K, class Extents, size_t... NewExtents> struct extents_constructor { MDSPAN_TEMPLATE_REQUIRES( class Slice, class... SlicesAndExtents, - /* requires */(!std::is_convertible_v<Slice, size_t> && + /* requires */(!is_convertible_v<Slice, size_t> && !is_strided_slice<Slice>::value) ) MDSPAN_INLINE_FUNCTION @@ -243,7 +240,7 @@ struct extents_constructor { SlicesAndExtents... slices_and_extents) { constexpr size_t new_static_extent = StaticExtentFromRange< decltype(first_of(std::declval<Slice>())), - decltype(last_of(std::integral_constant<size_t, Extents::rank() - K>(), + decltype(last_of(integral_constant<size_t, Extents::rank() - K>(), std::declval<Extents>(), std::declval<Slice>()))>::value; @@ -252,14 +249,14 @@ struct extents_constructor { using index_t = typename Extents::index_type; return next_t::next_extent( ext, slices_and_extents..., - index_t(last_of(std::integral_constant<size_t, Extents::rank() - K>(), ext, + index_t(last_of(integral_constant<size_t, Extents::rank() - K>(), ext, sl)) - index_t(first_of(sl))); } MDSPAN_TEMPLATE_REQUIRES( class Slice, class... SlicesAndExtents, - /* requires */ (std::is_convertible_v<Slice, size_t>) + /* requires */ (is_convertible_v<Slice, size_t>) ) MDSPAN_INLINE_FUNCTION constexpr static auto next_extent(const Extents &ext, const Slice &, @@ -318,4 +315,5 @@ constexpr auto submdspan_extents(const extents<IndexType, Extents...> &src_exts, return detail::extents_constructor<ext_t::rank(), ext_t>::next_extent( src_exts, slices...); } -} // namespace MDSPAN_IMPL_STANDARD_NAMESPACE +} // namespace experimental +} // namespace std diff --git a/tests/generator_scripts/deps/mdspan/include/experimental/__p2630_bits/submdspan_mapping.hpp b/tests/generator_scripts/deps/mdspan/include/experimental/__p2630_bits/submdspan_mapping.hpp index cf1bdd1e56f2b1ec356de554fe0cf8685aa76ded..fe930e07f78b342ae493c387633a7282c3d7bb20 100644 --- a/tests/generator_scripts/deps/mdspan/include/experimental/__p2630_bits/submdspan_mapping.hpp +++ b/tests/generator_scripts/deps/mdspan/include/experimental/__p2630_bits/submdspan_mapping.hpp @@ -14,105 +14,35 @@ // //@HEADER -#pragma once - #include <array> -#include <tuple> #include <type_traits> +#include <tuple> #include <utility> // index_sequence -// Suppress spurious warning with NVCC about no return statement. -// This is a known issue in NVCC and NVC++ -// Depending on the CUDA and GCC version we need both the builtin -// and the diagnostic push. I tried really hard to find something shorter -// but no luck ... -#if defined __NVCC__ -#ifdef __NVCC_DIAG_PRAGMA_SUPPORT__ -#pragma nv_diagnostic push -#pragma nv_diag_suppress = implicit_return_from_non_void_function -#else -#ifdef __CUDA_ARCH__ -#pragma diagnostic push -#pragma diag_suppress implicit_return_from_non_void_function -#endif -#endif -#elif defined __NVCOMPILER -#pragma diagnostic push -#pragma diag_suppress = implicit_return_from_non_void_function -#endif +namespace std { +namespace experimental { -namespace MDSPAN_IMPL_STANDARD_NAMESPACE { //****************************************** // Return type of submdspan_mapping overloads //****************************************** -template <class LayoutMapping> struct submdspan_mapping_result { - _MDSPAN_NO_UNIQUE_ADDRESS LayoutMapping mapping{}; +template <class Mapping> struct mapping_offset { + Mapping mapping; size_t offset; }; namespace detail { -// We use const Slice& and not Slice&& because the various -// submdspan_mapping_impl overloads use their slices arguments -// multiple times. This makes perfect forwarding not useful, but we -// still don't want to pass those (possibly of size 64 x 3 bits) -// objects by value. -template <class IndexType, class Slice> -MDSPAN_INLINE_FUNCTION constexpr bool -one_slice_out_of_bounds(const IndexType &ext, const Slice &slice) { - using common_t = - std::common_type_t<decltype(detail::first_of(slice)), IndexType>; - return static_cast<common_t>(detail::first_of(slice)) == - static_cast<common_t>(ext); -} - -template <size_t... RankIndices, class IndexType, size_t... Exts, - class... Slices> -MDSPAN_INLINE_FUNCTION constexpr bool -any_slice_out_of_bounds_helper(std::index_sequence<RankIndices...>, - const extents<IndexType, Exts...> &exts, - const Slices &... slices) { - return _MDSPAN_FOLD_OR( - (one_slice_out_of_bounds(exts.extent(RankIndices), slices))); -} - -template <class IndexType, size_t... Exts, class... Slices> -MDSPAN_INLINE_FUNCTION constexpr bool -any_slice_out_of_bounds(const extents<IndexType, Exts...> &exts, - const Slices &... slices) { - return any_slice_out_of_bounds_helper( - std::make_index_sequence<sizeof...(Slices)>(), exts, slices...); -} - // constructs sub strides template <class SrcMapping, class... slice_strides, size_t... InvMapIdxs> -MDSPAN_INLINE_FUNCTION constexpr auto construct_sub_strides( - const SrcMapping &src_mapping, std::index_sequence<InvMapIdxs...>, - const std::tuple<slice_strides...> &slices_stride_factor) { +MDSPAN_INLINE_FUNCTION +constexpr auto +construct_sub_strides(const SrcMapping &src_mapping, + index_sequence<InvMapIdxs...>, + const tuple<slice_strides...> &slices_stride_factor) { using index_type = typename SrcMapping::index_type; - return std::array<typename SrcMapping::index_type, sizeof...(InvMapIdxs)>{ + return array<typename SrcMapping::index_type, sizeof...(InvMapIdxs)>{ (static_cast<index_type>(src_mapping.stride(InvMapIdxs)) * - static_cast<index_type>(std::get<InvMapIdxs>(slices_stride_factor)))...}; + static_cast<index_type>(get<InvMapIdxs>(slices_stride_factor)))...}; } - -template<class SliceSpecifier, class IndexType> -struct is_range_slice { - constexpr static bool value = - std::is_same_v<SliceSpecifier, full_extent_t> || - std::is_convertible_v<SliceSpecifier, - std::tuple<IndexType, IndexType>>; -}; - -template<class SliceSpecifier, class IndexType> -constexpr bool is_range_slice_v = is_range_slice<SliceSpecifier, IndexType>::value; - -template<class SliceSpecifier, class IndexType> -struct is_index_slice { - constexpr static bool value = std::is_convertible_v<SliceSpecifier, IndexType>; -}; - -template<class SliceSpecifier, class IndexType> -constexpr bool is_index_slice_v = is_index_slice<SliceSpecifier, IndexType>::value; - } // namespace detail //********************************** @@ -121,137 +51,103 @@ constexpr bool is_index_slice_v = is_index_slice<SliceSpecifier, IndexType>::val namespace detail { // Figure out whether to preserve layout_left -template <class IndexType, size_t SubRank, class IndexSequence, - class... SliceSpecifiers> -struct deduce_layout_left_submapping; - -template <class IndexType, size_t SubRank, size_t... Idx, - class... SliceSpecifiers> -struct deduce_layout_left_submapping< - IndexType, SubRank, std::index_sequence<Idx...>, SliceSpecifiers...> { - - using count_range = index_sequence_scan_impl< - 0, (is_index_slice_v<SliceSpecifiers, IndexType> ? 0 : 1)...>; - - constexpr static int gap_len = - (((Idx > 0 && count_range::get(Idx) == 1 && - is_index_slice_v<SliceSpecifiers, IndexType>) - ? 1 - : 0) + - ... + 0); - - MDSPAN_INLINE_FUNCTION - constexpr static bool layout_left_value() { - // Use layout_left for rank 0 - if constexpr (SubRank == 0) { - return true; - // Use layout_left for rank 1 result if leftmost slice specifier is range like - } else if constexpr (SubRank == 1) { - return ((Idx > 0 || is_range_slice_v<SliceSpecifiers, IndexType>)&&...); - } else { - // Preserve if leftmost SubRank-1 slices are full_extent_t and - // the slice at idx Subrank - 1 is a range and - // for idx > SubRank the slice is an index - return ((((Idx < SubRank - 1) && std::is_same_v<SliceSpecifiers, full_extent_t>) || - ((Idx == SubRank - 1) && is_range_slice_v<SliceSpecifiers, IndexType>) || - ((Idx > SubRank - 1) && is_index_slice_v<SliceSpecifiers, IndexType>)) && ...); - } -#if defined(__NVCC__) && !defined(__CUDA_ARCH__) && defined(__GNUC__) - __builtin_unreachable(); -#endif - } +template <class IndexSequence, size_t SubRank, class... SliceSpecifiers> +struct preserve_layout_left_mapping; - MDSPAN_INLINE_FUNCTION - constexpr static bool layout_left_padded_value() { - // Technically could also keep layout_left_padded for SubRank==0 - // and SubRank==1 with leftmost slice specifier being a contiguous range - // but we intercept these cases separately - - // In all other cases: - // leftmost slice must be range - // then there can be a gap with index slices - // then SubRank - 2 full_extent slices - // then another range slice - // then more index slices - // e.g. R I I I F F F R I I for obtaining a rank-5 from a rank-10 - return ((((Idx == 0) && is_range_slice_v<SliceSpecifiers, IndexType>) || - ((Idx > 0 && Idx <= gap_len) && is_index_slice_v<SliceSpecifiers, IndexType>) || - ((Idx > gap_len && Idx < gap_len + SubRank - 1) && std::is_same_v<SliceSpecifiers, full_extent_t>) || - ((Idx == gap_len + SubRank - 1) && is_range_slice_v<SliceSpecifiers, IndexType>) || - ((Idx > gap_len + SubRank - 1) && is_index_slice_v<SliceSpecifiers, IndexType>)) && ... ); - } +template <class... SliceSpecifiers, size_t... Idx, size_t SubRank> +struct preserve_layout_left_mapping<index_sequence<Idx...>, SubRank, + SliceSpecifiers...> { + constexpr static bool value = + // Preserve layout for rank 0 + (SubRank == 0) || + ( + // Slice specifiers up to subrank need to be full_extent_t - except + // for the last one which could also be tuple but not a strided index + // range slice specifiers after subrank are integrals + ((Idx > SubRank - 1) || // these are only integral slice specifiers + (is_same_v<SliceSpecifiers, full_extent_t>) || + ((Idx == SubRank - 1) && + is_convertible_v<SliceSpecifiers, tuple<size_t, size_t>>)) && + ...); }; - } // namespace detail +// Suppress spurious warning with NVCC about no return statement. +// This is a known issue in NVCC and NVC++ +// Depending on the CUDA and GCC version we need both the builtin +// and the diagnostic push. I tried really hard to find something shorter +// but no luck ... +#if defined __NVCC__ + #ifdef __NVCC_DIAG_PRAGMA_SUPPORT__ + #pragma nv_diagnostic push + #pragma nv_diag_suppress = implicit_return_from_non_void_function + #else + #ifdef __CUDA_ARCH__ + #pragma diagnostic push + #pragma diag_suppress implicit_return_from_non_void_function + #endif + #endif +#elif defined __NVCOMPILER + #pragma diagnostic push + #pragma diag_suppress = implicit_return_from_non_void_function +#endif // Actual submdspan mapping call -template <class Extents> -template <class... SliceSpecifiers> -MDSPAN_INLINE_FUNCTION constexpr auto -layout_left::mapping<Extents>::submdspan_mapping_impl( - SliceSpecifiers... slices) const { +template <class Extents, class... SliceSpecifiers> +MDSPAN_INLINE_FUNCTION +constexpr auto +submdspan_mapping(const layout_left::mapping<Extents> &src_mapping, + SliceSpecifiers... slices) { // compute sub extents using src_ext_t = Extents; - auto dst_ext = submdspan_extents(extents(), slices...); + auto dst_ext = submdspan_extents(src_mapping.extents(), slices...); using dst_ext_t = decltype(dst_ext); // figure out sub layout type - using deduce_layout = detail::deduce_layout_left_submapping< - typename dst_ext_t::index_type, dst_ext_t::rank(), - std::make_index_sequence<src_ext_t::rank()>, - SliceSpecifiers...>; - - using dst_layout_t = std::conditional_t< - deduce_layout::layout_left_value(), layout_left, - std::conditional_t< - deduce_layout::layout_left_padded_value(), - MDSPAN_IMPL_PROPOSED_NAMESPACE::layout_left_padded<dynamic_extent>, - layout_stride>>; + constexpr bool preserve_layout = detail::preserve_layout_left_mapping< + decltype(make_index_sequence<src_ext_t::rank()>()), dst_ext_t::rank(), + SliceSpecifiers...>::value; + using dst_layout_t = + conditional_t<preserve_layout, layout_left, layout_stride>; using dst_mapping_t = typename dst_layout_t::template mapping<dst_ext_t>; - // Figure out if any slice's lower bound equals the corresponding extent. - // If so, bypass evaluating the layout mapping. This fixes LWG Issue 4060. - const bool out_of_bounds = - detail::any_slice_out_of_bounds(this->extents(), slices...); - auto offset = static_cast<size_t>( - out_of_bounds ? this->required_span_size() - : this->operator()(detail::first_of(slices)...)); - - if constexpr (std::is_same_v<dst_layout_t, layout_left>) { + if constexpr (is_same_v<dst_layout_t, layout_left>) { // layout_left case - return submdspan_mapping_result<dst_mapping_t>{dst_mapping_t(dst_ext), - offset}; - } else if constexpr (std::is_same_v<dst_layout_t, - MDSPAN_IMPL_PROPOSED_NAMESPACE:: - layout_left_padded<dynamic_extent>>) { - return submdspan_mapping_result<dst_mapping_t>{ - dst_mapping_t(dst_ext, stride(1 + deduce_layout::gap_len)), offset}; + return mapping_offset<dst_mapping_t>{ + dst_mapping_t(dst_ext), + static_cast<size_t>(src_mapping(detail::first_of(slices)...))}; } else { // layout_stride case - auto inv_map = detail::inv_map_rank(std::integral_constant<size_t, 0>(), - std::index_sequence<>(), slices...); - return submdspan_mapping_result<dst_mapping_t> { - dst_mapping_t(dst_ext, - detail::construct_sub_strides( - *this, inv_map, -// HIP needs deduction guides to have markups so we need to be explicit -// NVCC 11.0 has a bug with deduction guide here, tested that 11.2 does not have -// the issue But Clang-CUDA also doesn't accept the use of deduction guide so -// disable it for CUDA altogether -#if defined(_MDSPAN_HAS_HIP) || defined(_MDSPAN_HAS_CUDA) - std::tuple<decltype(detail::stride_of(slices))...>{ - detail::stride_of(slices)...})), -#else - std::tuple{detail::stride_of(slices)...})), -#endif - offset - }; + auto inv_map = detail::inv_map_rank( + integral_constant<size_t,0>(), + index_sequence<>(), + slices...); + return mapping_offset<dst_mapping_t>{ + dst_mapping_t(dst_ext, detail::construct_sub_strides( + src_mapping, inv_map, + // HIP needs deduction guides to have markups so we need to be explicit + #ifdef _MDSPAN_HAS_HIP + tuple<decltype(detail::stride_of(slices))...>{detail::stride_of(slices)...})), + #else + tuple{detail::stride_of(slices)...})), + #endif + static_cast<size_t>(src_mapping(detail::first_of(slices)...))}; } #if defined(__NVCC__) && !defined(__CUDA_ARCH__) && defined(__GNUC__) __builtin_unreachable(); #endif } +#if defined __NVCC__ + #ifdef __NVCC_DIAG_PRAGMA_SUPPORT__ + #pragma nv_diagnostic pop + #else + #ifdef __CUDA_ARCH__ + #pragma diagnostic pop + #endif + #endif +#elif defined __NVCOMPILER + #pragma diagnostic pop +#endif //********************************** // layout_right submdspan_mapping @@ -259,194 +155,126 @@ layout_left::mapping<Extents>::submdspan_mapping_impl( namespace detail { // Figure out whether to preserve layout_right -template <class IndexType, size_t SubRank, class IndexSequence, - class... SliceSpecifiers> -struct deduce_layout_right_submapping; - -template <class IndexType, size_t SubRank, size_t... Idx, - class... SliceSpecifiers> -struct deduce_layout_right_submapping< - IndexType, SubRank, std::index_sequence<Idx...>, SliceSpecifiers...> { - - static constexpr size_t Rank = sizeof...(Idx); - using count_range = index_sequence_scan_impl< - 0, (std::is_convertible_v<SliceSpecifiers, IndexType> ? 0 : 1)...>; - //__static_partial_sums<!std::is_convertible_v<SliceSpecifiers, - // IndexType>...>; - constexpr static int gap_len = - (((Idx < Rank - 1 && count_range::get(Idx) == SubRank - 1 && - std::is_convertible_v<SliceSpecifiers, IndexType>) - ? 1 - : 0) + - ... + 0); - - MDSPAN_INLINE_FUNCTION - constexpr static bool layout_right_value() { - // Use layout_right for rank 0 - if constexpr (SubRank == 0) { - return true; - // Use layout_right for rank 1 result if rightmost slice specifier is range like - } else if constexpr (SubRank == 1) { - return ((Idx < Rank - 1 || is_range_slice_v<SliceSpecifiers, IndexType>)&&...); - } else { - // Preserve if rightmost SubRank-1 slices are full_extent_t and - // the slice at idx Rank-Subrank is a range and - // for idx < Rank - SubRank the slice is an index - return ((((Idx >= Rank - SubRank) && std::is_same_v<SliceSpecifiers, full_extent_t>) || - ((Idx == Rank - SubRank) && is_range_slice_v<SliceSpecifiers, IndexType>) || - ((Idx < Rank - SubRank) && is_index_slice_v<SliceSpecifiers, IndexType>)) && ...); - } -#if defined(__NVCC__) && !defined(__CUDA_ARCH__) && defined(__GNUC__) - __builtin_unreachable(); -#endif - } - - MDSPAN_INLINE_FUNCTION - constexpr static bool layout_right_padded_value() { - // Technically could also keep layout_right_padded for SubRank==0 - // and SubRank==1 with rightmost slice specifier being a contiguous range - // but we intercept these cases separately +template <class IndexSequence, size_t SubRank, class... SliceSpecifiers> +struct preserve_layout_right_mapping; - // In all other cases: - // rightmost slice must be range - // then there can be a gap with index slices - // then SubRank - 2 full_extent slices - // then another range slice - // then more index slices - // e.g. I I R F F F I I I R for obtaining a rank-5 from a rank-10 - return ((((Idx == Rank - 1) && is_range_slice_v<SliceSpecifiers, IndexType>) || - ((Idx >= Rank - gap_len - 1 && Idx < Rank - 1) && is_index_slice_v<SliceSpecifiers, IndexType>) || - ((Idx > Rank - gap_len - SubRank && Idx < Rank - gap_len - 1) && std::is_same_v<SliceSpecifiers, full_extent_t>) || - ((Idx == Rank - gap_len - SubRank) && is_range_slice_v<SliceSpecifiers, IndexType>) || - ((Idx < Rank - gap_len - SubRank) && is_index_slice_v<SliceSpecifiers, IndexType>)) && ... ); - } +template <class... SliceSpecifiers, size_t... Idx, size_t SubRank> +struct preserve_layout_right_mapping<index_sequence<Idx...>, SubRank, + SliceSpecifiers...> { + constexpr static size_t SrcRank = sizeof...(SliceSpecifiers); + constexpr static bool value = + // Preserve layout for rank 0 + (SubRank == 0) || + ( + // The last subrank slice specifiers need to be full_extent_t - except + // for the srcrank-subrank one which could also be tuple but not a + // strided index range slice specifiers before srcrank-subrank are + // integrals + ((Idx < + SrcRank - SubRank) || // these are only integral slice specifiers + (is_same_v<SliceSpecifiers, full_extent_t>) || + ((Idx == SrcRank - SubRank) && + is_convertible_v<SliceSpecifiers, tuple<size_t, size_t>>)) && + ...); }; - } // namespace detail -// Actual submdspan mapping call -template <class Extents> -template <class... SliceSpecifiers> -MDSPAN_INLINE_FUNCTION constexpr auto -layout_right::mapping<Extents>::submdspan_mapping_impl( - SliceSpecifiers... slices) const { +// Suppress spurious warning with NVCC about no return statement. +// This is a known issue in NVCC and NVC++ +// Depending on the CUDA and GCC version we need both the builtin +// and the diagnostic push. I tried really hard to find something shorter +// but no luck ... +#if defined __NVCC__ + #ifdef __NVCC_DIAG_PRAGMA_SUPPORT__ + #pragma nv_diagnostic push + #pragma nv_diag_suppress = implicit_return_from_non_void_function + #else + #ifdef __CUDA_ARCH__ + #pragma diagnostic push + #pragma diag_suppress implicit_return_from_non_void_function + #endif + #endif +#elif defined __NVCOMPILER + #pragma diagnostic push + #pragma diag_suppress = implicit_return_from_non_void_function +#endif +template <class Extents, class... SliceSpecifiers> +MDSPAN_INLINE_FUNCTION +constexpr auto +submdspan_mapping(const layout_right::mapping<Extents> &src_mapping, + SliceSpecifiers... slices) { - // compute sub extents + // get sub extents using src_ext_t = Extents; - auto dst_ext = submdspan_extents(extents(), slices...); + auto dst_ext = submdspan_extents(src_mapping.extents(), slices...); using dst_ext_t = decltype(dst_ext); - // figure out sub layout type - using deduce_layout = detail::deduce_layout_right_submapping< - typename dst_ext_t::index_type, dst_ext_t::rank(), - std::make_index_sequence<src_ext_t::rank()>, - SliceSpecifiers...>; - - using dst_layout_t = std::conditional_t< - deduce_layout::layout_right_value(), layout_right, - std::conditional_t< - deduce_layout::layout_right_padded_value(), - MDSPAN_IMPL_PROPOSED_NAMESPACE::layout_right_padded<dynamic_extent>, - layout_stride>>; + // determine new layout type + constexpr bool preserve_layout = detail::preserve_layout_right_mapping< + decltype(make_index_sequence<src_ext_t::rank()>()), dst_ext_t::rank(), + SliceSpecifiers...>::value; + using dst_layout_t = + conditional_t<preserve_layout, layout_right, layout_stride>; using dst_mapping_t = typename dst_layout_t::template mapping<dst_ext_t>; - // Figure out if any slice's lower bound equals the corresponding extent. - // If so, bypass evaluating the layout mapping. This fixes LWG Issue 4060. - const bool out_of_bounds = - detail::any_slice_out_of_bounds(this->extents(), slices...); - auto offset = static_cast<size_t>( - out_of_bounds ? this->required_span_size() - : this->operator()(detail::first_of(slices)...)); - - if constexpr (std::is_same_v<dst_layout_t, layout_right>) { + if constexpr (is_same_v<dst_layout_t, layout_right>) { // layout_right case - return submdspan_mapping_result<dst_mapping_t>{dst_mapping_t(dst_ext), - offset}; - } else if constexpr (std::is_same_v< - dst_layout_t, - MDSPAN_IMPL_PROPOSED_NAMESPACE::layout_right_padded< - dynamic_extent>>) { - return submdspan_mapping_result<dst_mapping_t>{ - dst_mapping_t(dst_ext, - stride(src_ext_t::rank() - 2 - deduce_layout::gap_len)), - offset}; + return mapping_offset<dst_mapping_t>{ + dst_mapping_t(dst_ext), + static_cast<size_t>(src_mapping(detail::first_of(slices)...))}; } else { // layout_stride case - auto inv_map = detail::inv_map_rank(std::integral_constant<size_t, 0>(), - std::index_sequence<>(), slices...); - return submdspan_mapping_result<dst_mapping_t> { - dst_mapping_t(dst_ext, - detail::construct_sub_strides( - *this, inv_map, -// HIP needs deduction guides to have markups so we need to be explicit -// NVCC 11.0 has a bug with deduction guide here, tested that 11.2 does not have -// the issue But Clang-CUDA also doesn't accept the use of deduction guide so -// disable it for CUDA altogether -#if defined(_MDSPAN_HAS_HIP) || defined(_MDSPAN_HAS_CUDA) - std::tuple<decltype(detail::stride_of(slices))...>{ - detail::stride_of(slices)...})), -#else - std::tuple{detail::stride_of(slices)...})), -#endif - offset - }; + auto inv_map = detail::inv_map_rank( + integral_constant<size_t,0>(), + index_sequence<>(), + slices...); + return mapping_offset<dst_mapping_t>{ + dst_mapping_t(dst_ext, detail::construct_sub_strides( + src_mapping, inv_map, + // HIP needs deduction guides to have markups so we need to be explicit + #ifdef _MDSPAN_HAS_HIP + tuple<decltype(detail::stride_of(slices))...>{detail::stride_of(slices)...})), + #else + tuple{detail::stride_of(slices)...})), + #endif + static_cast<size_t>(src_mapping(detail::first_of(slices)...))}; } #if defined(__NVCC__) && !defined(__CUDA_ARCH__) && defined(__GNUC__) __builtin_unreachable(); #endif } +#if defined __NVCC__ + #ifdef __NVCC_DIAG_PRAGMA_SUPPORT__ + #pragma nv_diagnostic pop + #else + #ifdef __CUDA_ARCH__ + #pragma diagnostic pop + #endif + #endif +#elif defined __NVCOMPILER + #pragma diagnostic pop +#endif //********************************** // layout_stride submdspan_mapping //********************************* -template <class Extents> -template <class... SliceSpecifiers> -MDSPAN_INLINE_FUNCTION constexpr auto -layout_stride::mapping<Extents>::submdspan_mapping_impl( - SliceSpecifiers... slices) const { - auto dst_ext = submdspan_extents(extents(), slices...); +template <class Extents, class... SliceSpecifiers> +MDSPAN_INLINE_FUNCTION +constexpr auto +submdspan_mapping(const layout_stride::mapping<Extents> &src_mapping, + SliceSpecifiers... slices) { + auto dst_ext = submdspan_extents(src_mapping.extents(), slices...); using dst_ext_t = decltype(dst_ext); - auto inv_map = detail::inv_map_rank(std::integral_constant<size_t, 0>(), - std::index_sequence<>(), slices...); + auto inv_map = detail::inv_map_rank( + integral_constant<size_t,0>(), + index_sequence<>(), + slices...); using dst_mapping_t = typename layout_stride::template mapping<dst_ext_t>; - - // Figure out if any slice's lower bound equals the corresponding extent. - // If so, bypass evaluating the layout mapping. This fixes LWG Issue 4060. - const bool out_of_bounds = - detail::any_slice_out_of_bounds(this->extents(), slices...); - auto offset = static_cast<size_t>( - out_of_bounds ? this->required_span_size() - : this->operator()(detail::first_of(slices)...)); - - return submdspan_mapping_result<dst_mapping_t> { - dst_mapping_t(dst_ext, - detail::construct_sub_strides( - *this, inv_map, -// HIP needs deduction guides to have markups so we need to be explicit -// NVCC 11.0 has a bug with deduction guide here, tested that 11.2 does not have -// the issue -#if defined(_MDSPAN_HAS_HIP) || \ - (defined(__NVCC__) && \ - (__CUDACC_VER_MAJOR__ * 100 + __CUDACC_VER_MINOR__ * 10) < 1120) - std::tuple<decltype(detail::stride_of(slices))...>( - detail::stride_of(slices)...))), -#else - std::tuple(detail::stride_of(slices)...))), -#endif - offset - }; + return mapping_offset<dst_mapping_t>{ + dst_mapping_t(dst_ext, detail::construct_sub_strides( + src_mapping, inv_map, + tuple{detail::stride_of(slices)...})), + static_cast<size_t>(src_mapping(detail::first_of(slices)...))}; } - -} // namespace MDSPAN_IMPL_STANDARD_NAMESPACE - -#if defined __NVCC__ -#ifdef __NVCC_DIAG_PRAGMA_SUPPORT__ -#pragma nv_diagnostic pop -#else -#ifdef __CUDA_ARCH__ -#pragma diagnostic pop -#endif -#endif -#elif defined __NVCOMPILER -#pragma diagnostic pop -#endif +} // namespace experimental +} // namespace std diff --git a/tests/generator_scripts/deps/mdspan/include/experimental/__p2642_bits/layout_padded.hpp b/tests/generator_scripts/deps/mdspan/include/experimental/__p2642_bits/layout_padded.hpp deleted file mode 100644 index 99e24fa450ae7973c3ad44e314bbefbc5d82185a..0000000000000000000000000000000000000000 --- a/tests/generator_scripts/deps/mdspan/include/experimental/__p2642_bits/layout_padded.hpp +++ /dev/null @@ -1,852 +0,0 @@ -//@HEADER -// ************************************************************************ -// -// Kokkos v. 4.0 -// Copyright (2022) National Technology & Engineering -// Solutions of Sandia, LLC (NTESS). -// -// Under the terms of Contract DE-NA0003525 with NTESS, -// the U.S. Government retains certain rights in this software. -// -// Part of Kokkos, under the Apache License v2.0 with LLVM Exceptions. -// -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//@HEADER -#pragma once - -#include <cassert> -#include "layout_padded_fwd.hpp" -#include "../__p0009_bits/dynamic_extent.hpp" -#include "../__p0009_bits/extents.hpp" -#include "../__p0009_bits/mdspan.hpp" -#include "../__p0009_bits/layout_left.hpp" -#include "../__p0009_bits/layout_right.hpp" -#include "../__p0009_bits/layout_stride.hpp" - -namespace MDSPAN_IMPL_STANDARD_NAMESPACE { -namespace MDSPAN_IMPL_PROPOSED_NAMESPACE { - -namespace detail { -template<class _T> -MDSPAN_INLINE_FUNCTION -constexpr _T -find_next_multiple(_T alignment, _T offset) -{ - if ( alignment == 0 ) { - return _T(0); - } else { - return ( ( offset + alignment - 1 ) / alignment) * alignment; - } -} - -template <class _ExtentsType, size_t _PaddingValue, size_t _ExtentToPadIdx> -MDSPAN_INLINE_FUNCTION constexpr size_t get_actual_static_padding_value() { - constexpr auto rank = _ExtentsType::rank(); - - if constexpr (rank <= typename _ExtentsType::rank_type(1)) { - return 0; - } else if constexpr (_PaddingValue != dynamic_extent && - _ExtentsType::static_extent(_ExtentToPadIdx) != - dynamic_extent) { - static_assert( - (_PaddingValue != 0) || - (_ExtentsType::static_extent(_ExtentToPadIdx) == 0), - "padding stride can be 0 only if " - "extents_type::static_extent(extent-to-pad) is 0 or dynamic_extent"); - return find_next_multiple(_PaddingValue, - _ExtentsType::static_extent(_ExtentToPadIdx)); - } else { - return dynamic_extent; - } - // Missing return statement warning from NVCC -#ifdef __NVCC__ - return 0; -#endif -} - -template <size_t _PaddingValue, typename _Extents, size_t _ExtentToPadIdx, size_t _Rank, typename Enabled = void> -struct static_array_type_for_padded_extent -{ - static constexpr size_t padding_value = _PaddingValue; - using index_type = typename _Extents::index_type; - using extents_type = _Extents; - using type = ::MDSPAN_IMPL_STANDARD_NAMESPACE::detail::maybe_static_array< - index_type, size_t, dynamic_extent, - detail::get_actual_static_padding_value<extents_type, padding_value, - _ExtentToPadIdx>()>; -}; - -template <size_t _PaddingValue, typename _Extents, size_t _ExtentToPadIdx, size_t Rank> -struct static_array_type_for_padded_extent<_PaddingValue, _Extents, - _ExtentToPadIdx, Rank, std::enable_if_t<Rank <= 1>> { - using index_type = typename _Extents::index_type; - using extents_type = _Extents; - using type = - ::MDSPAN_IMPL_STANDARD_NAMESPACE::detail::maybe_static_array< - index_type, size_t, dynamic_extent, 0>; -}; - -template <size_t _PaddingValue, typename _Extents, size_t _ExtentToPadIdx> -struct padded_extent { - static constexpr size_t padding_value = _PaddingValue; - using index_type = typename _Extents::index_type; - using extents_type = _Extents; - using static_array_type = typename static_array_type_for_padded_extent< - padding_value, _Extents, _ExtentToPadIdx, _Extents::rank()>::type; - - static constexpr auto static_value() { return static_array_type::static_value(0); } - - MDSPAN_INLINE_FUNCTION - static constexpr static_array_type - init_padding(const _Extents &exts) { - if constexpr ((_Extents::rank() > 1) && (padding_value == dynamic_extent)) { - return {exts.extent(_ExtentToPadIdx)}; - } else { - return init_padding(exts, padding_value); - } - // Missing return statement warning from NVCC -#ifdef __NVCC__ - return {}; -#endif - } - - MDSPAN_INLINE_FUNCTION static constexpr static_array_type - init_padding([[maybe_unused]] const _Extents &exts, - [[maybe_unused]] index_type pv) { - if constexpr (_Extents::rank() > 1) { - return {find_next_multiple(pv, - exts.extent(_ExtentToPadIdx))}; - } else { - return {}; - } - // Missing return statement warning from NVCC -#ifdef __NVCC__ - return {}; -#endif - } - - template <typename _Mapping, size_t _PaddingStrideIdx> - MDSPAN_INLINE_FUNCTION static constexpr static_array_type - init_padding([[maybe_unused]] const _Mapping &other_mapping, - std::integral_constant<size_t, _PaddingStrideIdx>) { - if constexpr (_Extents::rank() > 1) { - return {other_mapping.stride(_PaddingStrideIdx)}; - } else { - return {}; - } - // Missing return statement warning from NVCC -#ifdef __NVCC__ - return {}; -#endif - } -}; -} // namespace detail - -template <size_t PaddingValue> -template <class Extents> -class layout_left_padded<PaddingValue>::mapping { -public: - static constexpr size_t padding_value = PaddingValue; - - using extents_type = Extents; - using index_type = typename extents_type::index_type; - using size_type = typename extents_type::size_type; - using rank_type = typename extents_type::rank_type; - using layout_type = layout_left_padded<padding_value>; - -#ifndef MDSPAN_INTERNAL_TEST -private: -#endif // MDSPAN_INTERNAL_TEST - - static constexpr rank_type padded_stride_idx = detail::layout_padded_constants<layout_type, extents_type>::padded_stride_idx; - static constexpr rank_type extent_to_pad_idx = detail::layout_padded_constants<layout_type, extents_type>::extent_to_pad_idx; - - static_assert((padding_value != 0) - || (extents_type::static_extent(extent_to_pad_idx) == 0) - || (extents_type::static_extent(extent_to_pad_idx) == dynamic_extent), - "out of bounds access for rank 0"); - - using padded_stride_type = detail::padded_extent< padding_value, extents_type, extent_to_pad_idx >; - - static constexpr size_t static_padding_stride = padded_stride_type::static_value(); - - typename padded_stride_type::static_array_type padded_stride = {}; - extents_type exts = {}; - - MDSPAN_INLINE_FUNCTION constexpr index_type - compute_offset(std::index_sequence<>) const { - return 0; - } - - template <size_t Rank, class IndexOffset> - MDSPAN_INLINE_FUNCTION constexpr index_type - compute_offset(std::index_sequence<Rank>, IndexOffset index_offset) const { - return index_offset; - } - - template <size_t... Ranks, class... IndexOffsets> - MDSPAN_INLINE_FUNCTION constexpr index_type - compute_offset(std::index_sequence<Ranks...>, - IndexOffsets... index_offsets) const { - index_type indices[] = {static_cast<index_type>(index_offsets)...}; - // self-recursive fold trick from - // https://github.com/llvm/llvm-project/blob/96e1914aa2e6d8966acbfbe2f4d184201f1aa318/libcxx/include/mdspan/layout_left.h#L144 - index_type res = 0; - ((res = indices[extents_type::rank() - 1 - Ranks] + - ((extents_type::rank() - 1 - Ranks) == extent_to_pad_idx - ? padded_stride.value(0) - : exts.extent(extents_type::rank() - 1 - Ranks)) * - res), - ...); - return res; - } - -public: -#if !MDSPAN_HAS_CXX_20 - MDSPAN_INLINE_FUNCTION_DEFAULTED - constexpr mapping() - : mapping(extents_type{}) - {} -#else - MDSPAN_INLINE_FUNCTION_DEFAULTED - constexpr mapping() - requires(static_padding_stride != dynamic_extent) = default; - - MDSPAN_INLINE_FUNCTION - constexpr mapping() - requires(static_padding_stride == dynamic_extent) - : mapping(extents_type{}) - {} -#endif - - MDSPAN_INLINE_FUNCTION_DEFAULTED constexpr mapping(const mapping&) noexcept = default; - MDSPAN_INLINE_FUNCTION_DEFAULTED mapping& operator=(const mapping&) noexcept = default; - - /** - * Initializes the mapping with the given extents. - * - * \param ext the given extents - */ - MDSPAN_INLINE_FUNCTION - constexpr mapping(const extents_type& ext) - : padded_stride(padded_stride_type::init_padding(ext)), exts(ext) - {} - - /** - * Initializes the mapping with the given extents and the specified padding value. - * - * This overload participates in overload resolution only if `is_convertible_v<Size, index_type>` - * is `true` and `is_nothrow_constructible_v<index_type, Size>` is `true` - * - * \param ext the given extents - * \param padding_value the padding value - */ - MDSPAN_TEMPLATE_REQUIRES( - class _Size, - /* requires */ ( - std::is_convertible_v<_Size, index_type> - && std::is_nothrow_constructible_v<index_type, _Size> - ) - ) - MDSPAN_INLINE_FUNCTION - constexpr mapping(const extents_type &ext, _Size dynamic_padding_value) - : padded_stride(padded_stride_type::init_padding(ext, dynamic_padding_value)), exts(ext) - { - assert((padding_value == dynamic_extent) || (static_cast<index_type>(padding_value) == static_cast<index_type>(dynamic_padding_value))); - } - - /** - * Converting constructor from `layout_left::mapping`. - * - * This overload participates in overload resolution only if - * `is_constructible_v<extents_type, OtherExtents>` is true. If - * `OtherExtents::rank() > 1` then one of `padding_value`, `static_extent(0)`, - * or `OtherExtents::static_extent(0)` must be `dynamic_extent`; otherwise, - * `OtherExtents::static_extent(0)` must be equal to the least multiple of - * `padding_value` greater than or equal to `extents_type::static_extent(0)` - */ - MDSPAN_TEMPLATE_REQUIRES( - class _OtherExtents, - /* requires */ (std::is_constructible_v<extents_type, _OtherExtents>)) - MDSPAN_CONDITIONAL_EXPLICIT( - (!std::is_convertible_v<_OtherExtents, extents_type>)) - MDSPAN_INLINE_FUNCTION - constexpr mapping(const layout_left::mapping<_OtherExtents> &other_mapping) - : padded_stride(padded_stride_type::init_padding( - other_mapping, - std::integral_constant<size_t, padded_stride_idx>{})), - exts(other_mapping.extents()) { - static_assert( - (_OtherExtents::rank() > 1) || - (static_padding_stride != dynamic_extent) || - (_OtherExtents::static_extent(extent_to_pad_idx) != dynamic_extent) || - (static_padding_stride == - _OtherExtents::static_extent(extent_to_pad_idx))); - } - - /** - * Converting constructor from `layout_stride::mapping`. - * - * This overload participates in overload resolution only if - * `is_constructible_v<extents_type, OtherExtents>` is true - */ - MDSPAN_TEMPLATE_REQUIRES( - class _OtherExtents, - /* requires */ (std::is_constructible_v<extents_type, _OtherExtents>)) - MDSPAN_CONDITIONAL_EXPLICIT((extents_type::rank() > 0)) - MDSPAN_INLINE_FUNCTION - constexpr mapping(const layout_stride::mapping<_OtherExtents> &other_mapping) - : padded_stride(padded_stride_type::init_padding( - other_mapping, - std::integral_constant<size_t, padded_stride_idx>{})), - exts(other_mapping.extents()) {} - - /** - * Converting constructor from `layout_left_padded::mapping`. - * - * This overload participates in overload resolution only if - * `is_constructible_v<extents_type, OtherExtents>` is true. Either - * `padding_value` or `OtherPaddingStride` must be `std::dynamic_extent`, or - * `padding_value == OtherPaddingStride`. - */ - MDSPAN_TEMPLATE_REQUIRES( - class _Mapping, - /* requires */ (detail::is_layout_left_padded_mapping<_Mapping>::value - &&std::is_constructible_v< - extents_type, typename _Mapping::extents_type>)) - MDSPAN_CONDITIONAL_EXPLICIT((extents_type::rank() > 1 && - (padding_value == dynamic_extent || - _Mapping::padding_value == dynamic_extent))) - MDSPAN_INLINE_FUNCTION - constexpr mapping(const _Mapping &other_mapping) - : padded_stride(padded_stride_type::init_padding( - other_mapping, - std::integral_constant<size_t, padded_stride_idx>{})), - exts(other_mapping.extents()) { - static_assert(padding_value == dynamic_extent || - _Mapping::padding_value == dynamic_extent || - padding_value == _Mapping::padding_value); - } - - /** - * Converting constructor from `layout_right_padded::mapping`. - * - * This overload participates in overload resolution only if - * `extents_type::rank()` is 0 or 1 and `is_constructible_v<extents_type, - * OtherExtents>` is `true`. - */ - MDSPAN_TEMPLATE_REQUIRES( - class _Mapping, - /* requires */ (detail::is_layout_right_padded_mapping<_Mapping>::value - &&extents_type::rank() <= 1 && - std::is_constructible_v<extents_type, - typename _Mapping::extents_type>)) - MDSPAN_CONDITIONAL_EXPLICIT( - (!std::is_convertible_v<typename _Mapping::extents_type, extents_type>)) - MDSPAN_INLINE_FUNCTION - constexpr mapping(const _Mapping &other_mapping) noexcept - : padded_stride(padded_stride_type::init_padding( - other_mapping.extents(), - other_mapping.extents().extent(extent_to_pad_idx))), - exts(other_mapping.extents()) {} - - MDSPAN_INLINE_FUNCTION constexpr const extents_type & - extents() const noexcept { - return exts; - } - - MDSPAN_INLINE_FUNCTION constexpr std::array<index_type, extents_type::rank()> - strides() const noexcept { - if constexpr (extents_type::rank() == 0) { - return {}; - } else if constexpr (extents_type::rank() == 1) { - return {1}; - } else { - index_type value = 1; - std::array<index_type, extents_type::rank()> s{}; - s[extent_to_pad_idx] = value; - value *= padded_stride.value(0); - for (rank_type r = extent_to_pad_idx + 1; r < extents_type::rank() - 1; - ++r) { - s[r] = value; - value *= exts.extent(r); - } - s[extents_type::rank() - 1] = value; - return s; - } - } - - MDSPAN_INLINE_FUNCTION constexpr index_type - required_span_size() const noexcept { - if constexpr (extents_type::rank() == 0) { - return 1; - } else if constexpr (extents_type::rank() == 1) { - return exts.extent(0); - } else { - index_type value = padded_stride.value(0); - for (rank_type r = 1; r < extents_type::rank(); ++r) { - value *= exts.extent(r); - } - return value; - } - } - - /** - * Return the mapping given the provided indices per rank. - * - * This overload participates in overload resolution only if: - * - `sizeof...(Indices) == extents_type::rank()`, - * - `(is_convertible_v<Indices, index_type> && ...) is true`, and - * - (is_nothrow_constructible_v<index_type, Indices> && ...) is true. - */ - MDSPAN_TEMPLATE_REQUIRES( - class... _Indices, - /* requires */ (sizeof...(_Indices) == extents_type::rank() && - (::MDSPAN_IMPL_STANDARD_NAMESPACE::detail:: - are_valid_indices<index_type, _Indices...>()))) - MDSPAN_INLINE_FUNCTION constexpr size_t - operator()(_Indices... idxs) const noexcept { -#if !defined(NDEBUG) - ::MDSPAN_IMPL_STANDARD_NAMESPACE::detail::check_all_indices(this->extents(), - idxs...); -#endif // ! NDEBUG - return compute_offset(std::index_sequence_for<_Indices...>{}, idxs...); - } - - MDSPAN_INLINE_FUNCTION static constexpr bool is_always_unique() noexcept { - return true; - } - MDSPAN_INLINE_FUNCTION static constexpr bool is_always_exhaustive() noexcept { - return (extents_type::rank() <= rank_type(1)) || - (extents_type::static_extent(extent_to_pad_idx) != dynamic_extent && - extents_type::static_extent(extent_to_pad_idx) == - padded_stride_type::static_value()); - } - MDSPAN_INLINE_FUNCTION static constexpr bool is_always_strided() noexcept { - return true; - } - - MDSPAN_INLINE_FUNCTION static constexpr bool is_unique() noexcept { - return true; - } - MDSPAN_INLINE_FUNCTION constexpr bool is_exhaustive() const noexcept { - return (extents_type::rank() < 2) || - (exts.extent(extent_to_pad_idx) == padded_stride.value(0)); - } - MDSPAN_INLINE_FUNCTION static constexpr bool is_strided() noexcept { - return true; - } - - MDSPAN_INLINE_FUNCTION - constexpr index_type stride(rank_type r) const noexcept { - assert(r < extents_type::rank()); - if (r == 0) - return index_type(1); - - index_type value = padded_stride.value(0); - for (rank_type k = 1; k < r; k++) - value *= exts.extent(k); - - return value; - } - - /** - * Equality operator between `layout_left_padded`s - * - * This overload only participates in overload resolution if - * `OtherExtents::rank() == extents_type::rank()`. - * - * \note There is currently a difference from p2642r2, where this function is - * specified as taking `layout_left_padded< padding_value >::mapping< - * Extents>`. However, this makes `padding_value` non-deducible. - */ - MDSPAN_TEMPLATE_REQUIRES( - class _Mapping, - /* requires */ (detail::is_layout_left_padded_mapping<_Mapping>::value && - (_Mapping::extents_type::rank() == extents_type::rank()))) - MDSPAN_INLINE_FUNCTION friend constexpr bool - operator==(const mapping &left, const _Mapping &right) noexcept { - // Workaround for some compilers not short-circuiting properly with - // compile-time checks i.e. we can't access stride(_padding_stride_idx) of a - // rank 0 mapping - bool strides_equal = true; - if constexpr (extents_type::rank() > rank_type(1)) { - strides_equal = - left.stride(padded_stride_idx) == right.stride(padded_stride_idx); - } - return (left.extents() == right.extents()) && strides_equal; - } - -#if !MDSPAN_HAS_CXX_20 - /** - * Inequality operator between `layout_left_padded`s - * - * This overload only participates in overload resolution if - * `OtherExtents::rank() == extents_type::rank()`. - */ - MDSPAN_TEMPLATE_REQUIRES( - class _Mapping, - /* requires */ (detail::is_layout_left_padded_mapping<_Mapping>::value && - (_Mapping::extents_type::rank() == extents_type::rank()))) - MDSPAN_INLINE_FUNCTION friend constexpr bool - operator!=(const mapping &left, const _Mapping &right) noexcept { - return !(left == right); - } -#endif - - // [mdspan.submdspan.mapping], submdspan mapping specialization - template<class... SliceSpecifiers> - constexpr auto submdspan_mapping_impl( - SliceSpecifiers... slices) const; - - template<class... SliceSpecifiers> - friend constexpr auto submdspan_mapping( - const mapping& src, SliceSpecifiers... slices) { - return src.submdspan_mapping_impl(slices...); - } -}; - -template <size_t PaddingValue> -template <class Extents> -class layout_right_padded<PaddingValue>::mapping { -public: - static constexpr size_t padding_value = PaddingValue; - - using extents_type = Extents; - using index_type = typename extents_type::index_type; - using size_type = typename extents_type::size_type; - using rank_type = typename extents_type::rank_type; - using layout_type = layout_right_padded<padding_value>; - -#ifndef MDSPAN_INTERNAL_TEST - private: -#endif // MDSPAN_INTERNAL_TEST - - static constexpr rank_type padded_stride_idx = detail::layout_padded_constants<layout_type, extents_type>::padded_stride_idx; - static constexpr rank_type extent_to_pad_idx = detail::layout_padded_constants<layout_type, extents_type>::extent_to_pad_idx; - - static_assert((padding_value != 0) - || (extents_type::static_extent(extent_to_pad_idx) == 0) - || (extents_type::static_extent(extent_to_pad_idx) == dynamic_extent), - "if padding stride is 0, static_extent(extent-to-pad-rank) must also be 0 or dynamic_extent"); - - using padded_stride_type = detail::padded_extent< padding_value, extents_type, extent_to_pad_idx >; - static constexpr size_t static_padding_stride = padded_stride_type::static_value(); - - typename padded_stride_type::static_array_type padded_stride = {}; - extents_type exts = {}; - - MDSPAN_INLINE_FUNCTION constexpr index_type - compute_offset(std::index_sequence<>) const { - return 0; - } - - template <size_t Rank, class IndexOffset> - MDSPAN_INLINE_FUNCTION constexpr index_type - compute_offset(std::index_sequence<Rank>, IndexOffset index_offset) const { - return index_offset; - } - - template <size_t... Ranks, class... IndexOffsets> - MDSPAN_INLINE_FUNCTION constexpr index_type - compute_offset(std::index_sequence<Ranks...>, - IndexOffsets... index_offsets) const { - // self-recursive fold trick from - // https://github.com/llvm/llvm-project/blob/4d9771741d40cc9cfcccb6b033f43689d36b705a/libcxx/include/mdspan/layout_right.h#L141 - index_type res = 0; - ((res = static_cast<index_type>(index_offsets) + - (Ranks == extent_to_pad_idx ? padded_stride.value(0) - : exts.extent(Ranks)) * - res), - ...); - return res; - } - -public: -#if !MDSPAN_HAS_CXX_20 - MDSPAN_INLINE_FUNCTION_DEFAULTED - constexpr mapping() - : mapping(extents_type{}) - {} -#else - MDSPAN_INLINE_FUNCTION_DEFAULTED - constexpr mapping() - requires(static_padding_stride != dynamic_extent) = default; - - MDSPAN_INLINE_FUNCTION - constexpr mapping() - requires(static_padding_stride == dynamic_extent) - : mapping(extents_type{}) - {} -#endif - - MDSPAN_INLINE_FUNCTION_DEFAULTED constexpr mapping(const mapping&) noexcept = default; - MDSPAN_INLINE_FUNCTION_DEFAULTED mapping& operator=(const mapping&) noexcept = default; - - /** - * Initializes the mapping with the given extents. - * - * \param ext the given extents - */ - MDSPAN_INLINE_FUNCTION - constexpr mapping(const extents_type &ext) - : padded_stride(padded_stride_type::init_padding(ext)), exts(ext) {} - - /** - * Initializes the mapping with the given extents and the specified padding value. - * - * This overload participates in overload resolution only if `is_convertible_v<Size, index_type>` - * is `true` and `is_nothrow_constructible_v<index_type, Size>` is `true` - * - * \param ext the given extents - * \param padding_value the padding value - */ - MDSPAN_TEMPLATE_REQUIRES( - class _Size, - /* requires */ ( - std::is_convertible_v<_Size, index_type> - && std::is_nothrow_constructible_v<index_type, _Size> - ) - ) - MDSPAN_INLINE_FUNCTION - constexpr mapping(const extents_type &ext, _Size dynamic_padding_value) - : padded_stride(padded_stride_type::init_padding(ext, static_cast<index_type>(dynamic_padding_value))), - exts(ext) { - assert((padding_value == dynamic_extent) || - (static_cast<index_type>(padding_value) == static_cast<index_type>(dynamic_padding_value))); - } - - /** - * Converting constructor from `layout_right::mapping`. - * - * This overload participates in overload resolution only if `is_constructible_v<extents_type, OtherExtents>` is true. - * If `OtherExtents::rank() > 1` then one of `padding_value`, `static_extent(0)`, or `OtherExtents::static_extent(0)` must be `dynamic_extent`; - * otherwise, `OtherExtents::static_extent(0)` must be equal to the least multiple of `padding_value` greater than or equal to `extents_type::static_extent(0)` - */ - MDSPAN_TEMPLATE_REQUIRES( - class _OtherExtents, - /* requires */ (std::is_constructible_v<extents_type, _OtherExtents>)) - MDSPAN_CONDITIONAL_EXPLICIT( - (!std::is_convertible_v<_OtherExtents, extents_type>)) - MDSPAN_INLINE_FUNCTION - constexpr mapping(const layout_right::mapping<_OtherExtents> &other_mapping) - : padded_stride(padded_stride_type::init_padding( - other_mapping, - std::integral_constant<size_t, padded_stride_idx>{})), - exts(other_mapping.extents()) { - static_assert( - (_OtherExtents::rank() > 1) || - (padded_stride_type::static_value() != dynamic_extent) || - (_OtherExtents::static_extent(extent_to_pad_idx) != dynamic_extent) || - (padded_stride_type::static_value() == - _OtherExtents::static_extent(extent_to_pad_idx))); - } - - /** - * Converting constructor from `layout_stride::mapping`. - * - * This overload participates in overload resolution only if - * `is_constructible_v<extents_type, OtherExtents>` is true - */ - MDSPAN_TEMPLATE_REQUIRES( - class _OtherExtents, - /* requires */ (std::is_constructible_v<extents_type, _OtherExtents>)) - MDSPAN_CONDITIONAL_EXPLICIT((extents_type::rank() > 0)) - MDSPAN_INLINE_FUNCTION - constexpr mapping(const layout_stride::mapping<_OtherExtents> &other_mapping) - : padded_stride(padded_stride_type::init_padding( - other_mapping, - std::integral_constant<size_t, padded_stride_idx>{})), - exts(other_mapping.extents()) {} - - /** - * Converting constructor from `layout_right_padded::mapping`. - * - * This overload participates in overload resolution only if - * `is_constructible_v<extents_type, OtherExtents>` is true. Either - * `padding_value` or `OtherPaddingStride` must be `std::dynamic_extent`, or - * `padding_value == OtherPaddingStride`. - */ - MDSPAN_TEMPLATE_REQUIRES( - class _Mapping, - /* requires */ (detail::is_layout_right_padded_mapping<_Mapping>::value - &&std::is_constructible_v< - extents_type, typename _Mapping::extents_type>)) - MDSPAN_CONDITIONAL_EXPLICIT((extents_type::rank() > 1 && - (padding_value == dynamic_extent || - _Mapping::padding_value == dynamic_extent))) - MDSPAN_INLINE_FUNCTION - constexpr mapping(const _Mapping &other_mapping) - : padded_stride(padded_stride_type::init_padding( - other_mapping, - std::integral_constant<size_t, padded_stride_idx>{})), - exts(other_mapping.extents()) { - static_assert(padding_value == dynamic_extent || - _Mapping::padding_value == dynamic_extent || - padding_value == _Mapping::padding_value); - } - - /** - * Converting constructor from `layout_left_padded::mapping`. - * - * This overload participates in overload resolution only if - * `extents_type::rank()` is 0 or 1 and `is_constructible_v<extents_type, - * OtherExtents>` is `true`. - */ - MDSPAN_TEMPLATE_REQUIRES( - class _Mapping, - /* requires */ (detail::is_layout_left_padded_mapping<_Mapping>::value - &&extents_type::rank() <= 1 && - std::is_constructible_v<extents_type, - typename _Mapping::extents_type>)) - MDSPAN_CONDITIONAL_EXPLICIT( - (!std::is_convertible_v<typename _Mapping::extents_type, extents_type>)) - MDSPAN_INLINE_FUNCTION - constexpr mapping(const _Mapping &other_mapping) noexcept - : padded_stride(padded_stride_type::init_padding( - other_mapping.extents(), - other_mapping.extents().extent(extent_to_pad_idx))), - exts(other_mapping.extents()) {} - - MDSPAN_INLINE_FUNCTION constexpr const extents_type & - extents() const noexcept { - return exts; - } - - MDSPAN_INLINE_FUNCTION constexpr std::array<index_type, extents_type::rank()> - strides() const noexcept { - if constexpr (extents_type::rank() == 0) { - return {}; - } else if constexpr (extents_type::rank() == 1) { - return {1}; - } else { - index_type value = 1; - std::array<index_type, extents_type::rank()> s{}; - s[extent_to_pad_idx] = value; - value *= padded_stride.value(0); - for (rank_type r = extent_to_pad_idx - 1; r > 0; --r) { - s[r] = value; - value *= exts.extent(r); - } - s[0] = value; - return s; - } - } - - MDSPAN_INLINE_FUNCTION constexpr index_type - required_span_size() const noexcept { - if constexpr (extents_type::rank() == 0) { - return 1; - } else if constexpr (extents_type::rank() == 1) { - return exts.extent(0); - } else { - index_type value = 1; - for (rank_type r = 0; r < extent_to_pad_idx; ++r) { - value *= exts.extent(r); - } - return value * padded_stride.value(0); - } - } - - /** - * Return the mapping given the provided indices per rank. - * - * This overload participates in overload resolution only if: - * - `sizeof...(Indices) == extents_type::rank()`, - * - `(is_convertible_v<Indices, index_type> && ...) is true`, and - * - (is_nothrow_constructible_v<index_type, Indices> && ...) is true. - */ - MDSPAN_TEMPLATE_REQUIRES( - class... _Indices, - /* requires */ (sizeof...(_Indices) == extents_type::rank() && - (::MDSPAN_IMPL_STANDARD_NAMESPACE::detail:: - are_valid_indices<index_type, _Indices...>()))) - MDSPAN_INLINE_FUNCTION constexpr size_t - operator()(_Indices... idxs) const noexcept { - return compute_offset(std::index_sequence_for<_Indices...>{}, idxs...); - } - - MDSPAN_INLINE_FUNCTION static constexpr bool is_always_unique() noexcept { - return true; - } - MDSPAN_INLINE_FUNCTION static constexpr bool is_always_exhaustive() noexcept { - return (extents_type::rank() <= rank_type(1)) || - (extents_type::static_extent(extent_to_pad_idx) != dynamic_extent && - extents_type::static_extent(extent_to_pad_idx) == - padded_stride_type::static_value()); - } - MDSPAN_INLINE_FUNCTION static constexpr bool is_always_strided() noexcept { - return true; - } - - MDSPAN_INLINE_FUNCTION static constexpr bool is_unique() noexcept { - return true; - } - MDSPAN_INLINE_FUNCTION constexpr bool is_exhaustive() const noexcept { - return (extents_type::rank() < 2) || - (exts.extent(extent_to_pad_idx) == padded_stride.value(0)); - } - MDSPAN_INLINE_FUNCTION static constexpr bool is_strided() noexcept { - return true; - } - - MDSPAN_INLINE_FUNCTION constexpr index_type - stride(rank_type r) const noexcept { - assert(r < extents_type::rank()); - if (r == extents_type::rank() - 1) - return index_type(1); - - index_type value = padded_stride.value(0); - for (rank_type k = extents_type::rank() - 2; k > r; k--) - value *= exts.extent(k); - - return value; - } - - /** - * Equality operator between `layout_right_padded`s - * - * This overload only participates in overload resolution if - * `OtherExtents::rank() == extents_type::rank()`. - * - * \note There is currently a difference from p2642r2, where this function is - * specified as taking `layout_right_padded< padding_value >::mapping< - * Extents>`. However, this makes `padding_value` non-deducible. - */ - MDSPAN_TEMPLATE_REQUIRES( - class _Mapping, - /* requires */ (detail::is_layout_right_padded_mapping<_Mapping>::value && - (_Mapping::extents_type::rank() == extents_type::rank()))) - MDSPAN_INLINE_FUNCTION friend constexpr bool - operator==(const mapping &left, const _Mapping &right) noexcept { - // Workaround for some compilers not short-circuiting properly with - // compile-time checks i.e. we can't access stride(_padding_stride_idx) of a - // rank 0 mapping - bool strides_equal = true; - if constexpr (extents_type::rank() > rank_type(1)) { - strides_equal = - left.stride(padded_stride_idx) == right.stride(padded_stride_idx); - } - return (left.extents() == right.extents()) && strides_equal; - } - -#if !MDSPAN_HAS_CXX_20 - /** - * Inequality operator between `layout_right_padded`s - * - * This overload only participates in overload resolution if - * `OtherExtents::rank() == extents_type::rank()`. - */ - MDSPAN_TEMPLATE_REQUIRES( - class _Mapping, - /* requires */ (detail::is_layout_right_padded_mapping<_Mapping>::value && - (_Mapping::extents_type::rank() == extents_type::rank()))) - MDSPAN_INLINE_FUNCTION friend constexpr bool - operator!=(const mapping &left, const _Mapping &right) noexcept { - return !(left == right); - } -#endif -}; -} -} diff --git a/tests/generator_scripts/deps/mdspan/include/experimental/__p2642_bits/layout_padded_fwd.hpp b/tests/generator_scripts/deps/mdspan/include/experimental/__p2642_bits/layout_padded_fwd.hpp deleted file mode 100644 index b5eaac952bc8998c9d9710d8c46004f3c5da6b10..0000000000000000000000000000000000000000 --- a/tests/generator_scripts/deps/mdspan/include/experimental/__p2642_bits/layout_padded_fwd.hpp +++ /dev/null @@ -1,131 +0,0 @@ -//@HEADER -// ************************************************************************ -// -// Kokkos v. 4.0 -// Copyright (2022) National Technology & Engineering -// Solutions of Sandia, LLC (NTESS). -// -// Under the terms of Contract DE-NA0003525 with NTESS, -// the U.S. Government retains certain rights in this software. -// -// Part of Kokkos, under the Apache License v2.0 with LLVM Exceptions. -// -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//@HEADER -#pragma once - -#include <cassert> -#include "../__p0009_bits/dynamic_extent.hpp" -#include "../__p0009_bits/utility.hpp" - -namespace MDSPAN_IMPL_STANDARD_NAMESPACE { -namespace MDSPAN_IMPL_PROPOSED_NAMESPACE { - -template <size_t padding_value = dynamic_extent> -struct layout_left_padded { - template <class _Extents> - class mapping; -}; - -template <size_t padding_value = dynamic_extent> -struct layout_right_padded { - template <class _Extents> - class mapping; -}; - -namespace detail { -// The layout_padded_constants structs are only useful if rank > 1, otherwise they may wrap -template <class _Layout, class _ExtentsType> -struct layout_padded_constants; - -template <class _ExtentsType, size_t _PaddingStride> -struct layout_padded_constants<layout_left_padded<_PaddingStride>, _ExtentsType> -{ - using rank_type = typename _ExtentsType::rank_type; - static constexpr rank_type padded_stride_idx = 1; - static constexpr rank_type extent_to_pad_idx = 0; -}; - -template <class _ExtentsType, size_t _PaddingStride> -struct layout_padded_constants<layout_right_padded<_PaddingStride>, _ExtentsType> -{ - using rank_type = typename _ExtentsType::rank_type; - static constexpr rank_type padded_stride_idx = _ExtentsType::rank() - 2; - static constexpr rank_type extent_to_pad_idx = _ExtentsType::rank() - 1; -}; - -template <class _Layout> -struct is_layout_left_padded : std::false_type {}; - -template <size_t _PaddingStride> -struct is_layout_left_padded<layout_left_padded<_PaddingStride>> : std::true_type {}; - -template <class _Mapping, class _Enabled = void> -struct is_layout_left_padded_mapping : std::false_type {}; - -template <class _Mapping> -struct is_layout_left_padded_mapping<_Mapping, - std::enable_if_t<std::is_same<_Mapping, typename layout_left_padded<_Mapping::padding_value>::template mapping<typename _Mapping::extents_type>>::value>> - : std::true_type {}; - -template <class _Layout> -struct is_layout_right_padded : std::false_type {}; - -template <size_t _PaddingStride> -struct is_layout_right_padded<layout_right_padded<_PaddingStride>> : std::true_type {}; - -template <class _Mapping, class _Enabled = void> -struct is_layout_right_padded_mapping : std::false_type {}; - -template <class _Mapping> -struct is_layout_right_padded_mapping<_Mapping, - std::enable_if_t<std::is_same<_Mapping, typename layout_right_padded<_Mapping::padding_value>::template mapping<typename _Mapping::extents_type>>::value>> - : std::true_type {}; - - -template <class _LayoutExtentsType, class _PaddedLayoutMappingType> -constexpr void check_padded_layout_converting_constructor_mandates(MDSPAN_IMPL_STANDARD_NAMESPACE::detail::with_rank<0>) {} - -template <class _LayoutExtentsType, class _PaddedLayoutMappingType> -constexpr void check_padded_layout_converting_constructor_mandates(MDSPAN_IMPL_STANDARD_NAMESPACE::detail::with_rank<1>) {} - -template <class _LayoutExtentsType, class _PaddedLayoutMappingType, std::size_t N> -constexpr void check_padded_layout_converting_constructor_mandates(MDSPAN_IMPL_STANDARD_NAMESPACE::detail::with_rank<N>) -{ - using extents_type = typename _PaddedLayoutMappingType::extents_type; - constexpr auto padding_value = _PaddedLayoutMappingType::padding_value; - constexpr auto idx = layout_padded_constants<typename _PaddedLayoutMappingType::layout_type, _LayoutExtentsType >::extent_to_pad_idx; - - constexpr auto statically_determinable = - (_LayoutExtentsType::static_extent(idx) != dynamic_extent) && - (extents_type::static_extent(idx) != dynamic_extent) && - (padding_value != dynamic_extent); - - static_assert(not statically_determinable or - (padding_value == 0 - ? _LayoutExtentsType::static_extent(idx) == 0 - : _LayoutExtentsType::static_extent(idx) % padding_value == 0), - ""); -} - -template <typename _ExtentsType, typename _OtherMapping> -constexpr void check_padded_layout_converting_constructor_preconditions(MDSPAN_IMPL_STANDARD_NAMESPACE::detail::with_rank<0>, - const _OtherMapping&) {} -template <typename _ExtentsType, typename _OtherMapping> -constexpr void check_padded_layout_converting_constructor_preconditions(MDSPAN_IMPL_STANDARD_NAMESPACE::detail::with_rank<1>, - const _OtherMapping&) {} -template <typename _ExtentsType, typename _OtherMapping, std::size_t N> -constexpr void check_padded_layout_converting_constructor_preconditions(MDSPAN_IMPL_STANDARD_NAMESPACE::detail::with_rank<N>, - const _OtherMapping &other_mapping) { - constexpr auto padded_stride_idx = - layout_padded_constants<typename _OtherMapping::layout_type, - _ExtentsType>::padded_stride_idx; - constexpr auto extent_to_pad_idx = layout_padded_constants<typename _OtherMapping::layout_type, _ExtentsType>::extent_to_pad_idx; - MDSPAN_IMPL_PRECONDITION(other_mapping.stride(padded_stride_idx) == other_mapping.extents().extent(extent_to_pad_idx)); -} - - -} -} -} diff --git a/tests/generator_scripts/deps/mdspan/include/experimental/mdarray b/tests/generator_scripts/deps/mdspan/include/experimental/mdarray index 642d1f5ad9e704ade699bbe89d97344c34e6d5a3..d5c857066a3c75ef0fc54532027f988c2dafec45 100644 --- a/tests/generator_scripts/deps/mdspan/include/experimental/mdarray +++ b/tests/generator_scripts/deps/mdspan/include/experimental/mdarray @@ -16,13 +16,6 @@ #pragma once -#ifndef MDSPAN_IMPL_STANDARD_NAMESPACE - #define MDSPAN_IMPL_STANDARD_NAMESPACE std -#endif - -#ifndef MDSPAN_IMPL_PROPOSED_NAMESPACE - #define MDSPAN_IMPL_PROPOSED_NAMESPACE experimental -#endif - #include "mdspan" -#include "../mdspan/mdarray.hpp" +#include "__p1684_bits/mdarray.hpp" + diff --git a/tests/generator_scripts/deps/mdspan/include/experimental/mdspan b/tests/generator_scripts/deps/mdspan/include/experimental/mdspan index e8ba715ec2fd7afad65627d2eb4b8fcc720b8a3e..9a8d6778116c00dacba0c7b768933e40e49e82b3 100644 --- a/tests/generator_scripts/deps/mdspan/include/experimental/mdspan +++ b/tests/generator_scripts/deps/mdspan/include/experimental/mdspan @@ -16,24 +16,15 @@ #pragma once -#ifndef MDSPAN_IMPL_STANDARD_NAMESPACE - #define MDSPAN_IMPL_STANDARD_NAMESPACE std +#include "__p0009_bits/default_accessor.hpp" +#include "__p0009_bits/full_extent_t.hpp" +#include "__p0009_bits/mdspan.hpp" +#include "__p0009_bits/dynamic_extent.hpp" +#include "__p0009_bits/extents.hpp" +#include "__p0009_bits/layout_stride.hpp" +#include "__p0009_bits/layout_left.hpp" +#include "__p0009_bits/layout_right.hpp" +#include "__p0009_bits/macros.hpp" +#if MDSPAN_HAS_CXX_17 +#include "__p2630_bits/submdspan.hpp" #endif - -#ifndef MDSPAN_IMPL_PROPOSED_NAMESPACE - #define MDSPAN_IMPL_PROPOSED_NAMESPACE experimental -#endif - -#include "../mdspan/mdspan.hpp" - -// backward compatibility import into experimental -namespace MDSPAN_IMPL_STANDARD_NAMESPACE { - namespace MDSPAN_IMPL_PROPOSED_NAMESPACE { - using ::MDSPAN_IMPL_STANDARD_NAMESPACE::mdspan; - using ::MDSPAN_IMPL_STANDARD_NAMESPACE::extents; - using ::MDSPAN_IMPL_STANDARD_NAMESPACE::layout_left; - using ::MDSPAN_IMPL_STANDARD_NAMESPACE::layout_right; - using ::MDSPAN_IMPL_STANDARD_NAMESPACE::layout_stride; - using ::MDSPAN_IMPL_STANDARD_NAMESPACE::default_accessor; - } -} diff --git a/tests/generator_scripts/deps/mdspan/include/mdspan/mdarray.hpp b/tests/generator_scripts/deps/mdspan/include/mdspan/mdarray.hpp deleted file mode 100644 index fd8f61c52f1b1836aea89f653e263cd33537e218..0000000000000000000000000000000000000000 --- a/tests/generator_scripts/deps/mdspan/include/mdspan/mdarray.hpp +++ /dev/null @@ -1,31 +0,0 @@ -//@HEADER -// ************************************************************************ -// -// Kokkos v. 4.0 -// Copyright (2022) National Technology & Engineering -// Solutions of Sandia, LLC (NTESS). -// -// Under the terms of Contract DE-NA0003525 with NTESS, -// the U.S. Government retains certain rights in this software. -// -// Part of Kokkos, under the Apache License v2.0 with LLVM Exceptions. -// See https://kokkos.org/LICENSE for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//@HEADER - -#ifndef MDARRAY_HPP_ -#define MDARRAY_HPP_ - -#ifndef MDSPAN_IMPL_STANDARD_NAMESPACE - #define MDSPAN_IMPL_STANDARD_NAMESPACE Kokkos -#endif - -#ifndef MDSPAN_IMPL_PROPOSED_NAMESPACE - #define MDSPAN_IMPL_PROPOSED_NAMESPACE Experimental -#endif - -#include "mdspan.hpp" -#include "../experimental/__p1684_bits/mdarray.hpp" - -#endif // MDARRAY_HPP_ diff --git a/tests/generator_scripts/deps/mdspan/include/mdspan/mdspan.hpp b/tests/generator_scripts/deps/mdspan/include/mdspan/mdspan.hpp deleted file mode 100644 index 4a0e354ffd02183e0c738c9c716c1228b3b180bc..0000000000000000000000000000000000000000 --- a/tests/generator_scripts/deps/mdspan/include/mdspan/mdspan.hpp +++ /dev/null @@ -1,43 +0,0 @@ -//@HEADER -// ************************************************************************ -// -// Kokkos v. 4.0 -// Copyright (2022) National Technology & Engineering -// Solutions of Sandia, LLC (NTESS). -// -// Under the terms of Contract DE-NA0003525 with NTESS, -// the U.S. Government retains certain rights in this software. -// -// Part of Kokkos, under the Apache License v2.0 with LLVM Exceptions. -// See https://kokkos.org/LICENSE for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//@HEADER - -#ifndef MDSPAN_HPP_ -#define MDSPAN_HPP_ - -#ifndef MDSPAN_IMPL_STANDARD_NAMESPACE - #define MDSPAN_IMPL_STANDARD_NAMESPACE Kokkos -#endif - -#ifndef MDSPAN_IMPL_PROPOSED_NAMESPACE - #define MDSPAN_IMPL_PROPOSED_NAMESPACE Experimental -#endif - -#include "../experimental/__p0009_bits/default_accessor.hpp" -#include "../experimental/__p0009_bits/full_extent_t.hpp" -#include "../experimental/__p0009_bits/mdspan.hpp" -#include "../experimental/__p0009_bits/dynamic_extent.hpp" -#include "../experimental/__p0009_bits/extents.hpp" -#include "../experimental/__p0009_bits/layout_stride.hpp" -#include "../experimental/__p0009_bits/layout_left.hpp" -#include "../experimental/__p0009_bits/layout_right.hpp" -#include "../experimental/__p0009_bits/macros.hpp" -#if MDSPAN_HAS_CXX_17 -#include "../experimental/__p2642_bits/layout_padded.hpp" -#include "../experimental/__p2630_bits/submdspan.hpp" -#endif -#include "../experimental/__p2389_bits/dims.hpp" - -#endif // MDSPAN_HPP_ diff --git a/tests/generator_scripts/source/JacobiMdspan.harness.cpp b/tests/generator_scripts/source/JacobiMdspan.harness.cpp index 95acf4fe3ca681d82c6527c8a92165b1c3171661..e2b8c716bf1427b3e915d6eb6c9756e7127df893 100644 --- a/tests/generator_scripts/source/JacobiMdspan.harness.cpp +++ b/tests/generator_scripts/source/JacobiMdspan.harness.cpp @@ -3,8 +3,10 @@ #include <experimental/mdspan> #include <memory> -using field_t = std::mdspan<double, std::extents< int64_t, std::dynamic_extent, std::dynamic_extent>>; -using scalar_field_t = std::mdspan<double, std::extents< int64_t, std::dynamic_extent, std::dynamic_extent, 1>>; +namespace stdex = std::experimental; + +using field_t = stdex::mdspan<double, stdex::extents< int64_t, std::dynamic_extent, std::dynamic_extent>>; +using scalar_field_t = stdex::mdspan<double, stdex::extents< int64_t, std::dynamic_extent, std::dynamic_extent, 1>>; int main(void) { diff --git a/tests/generator_scripts/source/JacobiMdspan.py b/tests/generator_scripts/source/JacobiMdspan.py index 2c6332e5d3cef37d05bc2aedfe9d0be798cff72a..41f149a8b36181a75728df2aa3d5819c53be8626 100644 --- a/tests/generator_scripts/source/JacobiMdspan.py +++ b/tests/generator_scripts/source/JacobiMdspan.py @@ -5,6 +5,8 @@ from pystencils import fields, kernel from pystencilssfg import SourceFileGenerator from pystencilssfg.lang.cpp.std import mdspan +mdspan.configure(namespace="std::experimental", header="<experimental/mdspan>") + with SourceFileGenerator() as sfg: sfg.namespace("gen")