diff --git a/.github/workflows/gha_ci.yml b/.github/workflows/gha_ci.yml index 3e7d455..aeb590f 100644 --- a/.github/workflows/gha_ci.yml +++ b/.github/workflows/gha_ci.yml @@ -26,52 +26,52 @@ jobs: fetch-depth: 2 - name: Build run: bash tools/gha_conda_coverage.sh - manylinux228-py311: - runs-on: ubuntu-latest - container: - image: pagmo2/manylinux228_x86_64_with_deps:latest - env: - CASCADE_PY_BUILD_TYPE: "Python311" - TWINE_PASSWORD: ${{ secrets.TWINE_PASSWORD }} - steps: - - uses: actions/checkout@v3 - - name: Build - run: bash tools/gha_manylinux.sh - manylinux228-py310: - runs-on: ubuntu-latest - container: - image: pagmo2/manylinux228_x86_64_with_deps:latest - env: - CASCADE_PY_BUILD_TYPE: "Python310" - TWINE_PASSWORD: ${{ secrets.TWINE_PASSWORD }} - steps: - - uses: actions/checkout@v3 - - name: Build - run: bash tools/gha_manylinux.sh - manylinux228-py39: - runs-on: ubuntu-latest - container: - image: pagmo2/manylinux228_x86_64_with_deps:latest - env: - CASCADE_PY_BUILD_TYPE: "Python39" - TWINE_PASSWORD: ${{ secrets.TWINE_PASSWORD }} - steps: - - uses: actions/checkout@v3 - - name: Build - run: bash tools/gha_manylinux.sh - manylinux228-py38: - runs-on: ubuntu-latest - container: - image: pagmo2/manylinux228_x86_64_with_deps:latest - env: - CASCADE_PY_BUILD_TYPE: "Python38" - TWINE_PASSWORD: ${{ secrets.TWINE_PASSWORD }} - steps: - - uses: actions/checkout@v3 - - name: Build - run: bash tools/gha_manylinux.sh + #manylinux228-py311: + # runs-on: ubuntu-latest + # container: + # image: pagmo2/manylinux228_x86_64_with_deps:latest + # env: + # CASCADE_PY_BUILD_TYPE: "Python311" + # TWINE_PASSWORD: ${{ secrets.TWINE_PASSWORD }} + # steps: + # - uses: actions/checkout@v3 + # - name: Build + # run: bash tools/gha_manylinux.sh + #manylinux228-py310: + # runs-on: ubuntu-latest + # container: + # image: pagmo2/manylinux228_x86_64_with_deps:latest + # env: + # CASCADE_PY_BUILD_TYPE: "Python310" + # TWINE_PASSWORD: ${{ secrets.TWINE_PASSWORD }} + # steps: + # - uses: actions/checkout@v3 + # - name: Build + # run: bash tools/gha_manylinux.sh + #manylinux228-py39: + # runs-on: ubuntu-latest + # container: + # image: pagmo2/manylinux228_x86_64_with_deps:latest + # env: + # CASCADE_PY_BUILD_TYPE: "Python39" + # TWINE_PASSWORD: ${{ secrets.TWINE_PASSWORD }} + # steps: + # - uses: actions/checkout@v3 + # - name: Build + # run: bash tools/gha_manylinux.sh + #manylinux228-py38: + # runs-on: ubuntu-latest + # container: + # image: pagmo2/manylinux228_x86_64_with_deps:latest + # env: + # CASCADE_PY_BUILD_TYPE: "Python38" + # TWINE_PASSWORD: ${{ secrets.TWINE_PASSWORD }} + # steps: + # - uses: actions/checkout@v3 + # - name: Build + # run: bash tools/gha_manylinux.sh windows_2019: - runs-on: windows-2019 + runs-on: windows-2022 steps: - uses: actions/checkout@v3 - name: Add msbuild to PATH @@ -89,7 +89,7 @@ jobs: run: | mkdir build cd build - cmake ../ -G "Visual Studio 16 2019" -A x64 -DCMAKE_INSTALL_PREFIX=C:\Miniconda\envs\cascade_devel\Library -DCASCADE_BUILD_TESTS=yes -DBoost_NO_BOOST_CMAKE=ON -DCASCADE_BUILD_PYTHON_BINDINGS=yes + cmake ../ -G "Visual Studio 17 2022" -A x64 -DCMAKE_INSTALL_PREFIX=C:\Miniconda\envs\cascade_devel\Library -DCASCADE_BUILD_TESTS=yes -DBoost_NO_BOOST_CMAKE=ON -DCASCADE_BUILD_PYTHON_BINDINGS=yes cmake --build . -j4 --config Release --target install ctest -j4 -V -C Release cd c:\ diff --git a/CMakeLists.txt b/CMakeLists.txt index a608e4a..30093a1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -179,7 +179,7 @@ find_package(fmt REQUIRED CONFIG) target_link_libraries(cascade PUBLIC fmt::fmt) # heyoka. -find_package(heyoka 3.0.0 REQUIRED CONFIG) +find_package(heyoka 5 REQUIRED CONFIG) target_link_libraries(cascade PUBLIC heyoka::heyoka) # spdlog. diff --git a/cascade.py/test.py b/cascade.py/test.py index cc38dd5..38cf3e4 100644 --- a/cascade.py/test.py +++ b/cascade.py/test.py @@ -60,7 +60,7 @@ def test_kepler_equivalence(self): def test_perturbation_magnitudes(self): from .dynamics import simple_earth, kepler import numpy as np - from heyoka import make_cfunc + from heyoka import cfunc, make_vars dynkep = simple_earth( J2=False, @@ -90,9 +90,11 @@ def test_perturbation_magnitudes(self): drag=False, ) - dynkep_c = make_cfunc([dynkep[i][1] for i in [3, 4, 5]]) - dynJ2_c = make_cfunc([dynJ2[i][1] for i in [3, 4, 5]]) - dynJ3_c = make_cfunc([dynJ3[i][1] for i in [3, 4, 5]]) + # Dynamical variables. + x, y, z, vx, vy, vz = make_vars("x", "y", "z", "vx", "vy", "vz") + dynkep_c = cfunc([dynkep[i][1] for i in [3, 4, 5]], vars=[x,y,z]) + dynJ2_c = cfunc([dynJ2[i][1] for i in [3, 4, 5]], vars=[x,y,z]) + dynJ3_c = cfunc([dynJ3[i][1] for i in [3, 4, 5]], vars=[x,y,z]) # We compute the various acceleration magnitudes at 7000 km pos = np.array([7000000.0, 0.0, 0.0]) diff --git a/cascade_devel.yml b/cascade_devel.yml index 0ae96b9..9a6316c 100644 --- a/cascade_devel.yml +++ b/cascade_devel.yml @@ -11,8 +11,8 @@ dependencies: - tbb - boost-cpp >=1.73 - fmt - - heyoka =3.0.* - - heyoka.py =3.0.* + - heyoka =5* + - heyoka.py =5* - spdlog - pybind11 >=2.10 - xtensor diff --git a/src/mdspan/__p0009_bits/compressed_pair.hpp b/src/mdspan/__p0009_bits/compressed_pair.hpp deleted file mode 100644 index 5783bdb..0000000 --- a/src/mdspan/__p0009_bits/compressed_pair.hpp +++ /dev/null @@ -1,197 +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 - -#include "macros.hpp" -#include "trait_backports.hpp" - -#if !defined(_MDSPAN_USE_ATTRIBUTE_NO_UNIQUE_ADDRESS) -# include "no_unique_address.hpp" -#endif - -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 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 _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() noexcept = default; - MDSPAN_INLINE_FUNCTION_DEFAULTED - constexpr __compressed_pair(__compressed_pair const &) noexcept = default; - MDSPAN_INLINE_FUNCTION_DEFAULTED - constexpr __compressed_pair(__compressed_pair &&) noexcept = default; - MDSPAN_INLINE_FUNCTION_DEFAULTED - _MDSPAN_CONSTEXPR_14_DEFAULTED __compressed_pair & - operator=(__compressed_pair const &) noexcept = default; - MDSPAN_INLINE_FUNCTION_DEFAULTED - _MDSPAN_CONSTEXPR_14_DEFAULTED __compressed_pair & - operator=(__compressed_pair &&) noexcept = default; - MDSPAN_INLINE_FUNCTION_DEFAULTED - ~__compressed_pair() noexcept = default; - template - 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 -struct __compressed_pair< - _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 _T const &__first() const noexcept { - return *static_cast<_T const *>(this); - } - 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() noexcept = default; - MDSPAN_INLINE_FUNCTION_DEFAULTED - constexpr __compressed_pair(__compressed_pair const &) noexcept = default; - MDSPAN_INLINE_FUNCTION_DEFAULTED - constexpr __compressed_pair(__compressed_pair &&) noexcept = default; - MDSPAN_INLINE_FUNCTION_DEFAULTED - _MDSPAN_CONSTEXPR_14_DEFAULTED __compressed_pair & - operator=(__compressed_pair const &) noexcept = default; - MDSPAN_INLINE_FUNCTION_DEFAULTED - _MDSPAN_CONSTEXPR_14_DEFAULTED __compressed_pair & - operator=(__compressed_pair &&) noexcept = default; - MDSPAN_INLINE_FUNCTION_DEFAULTED - ~__compressed_pair() noexcept = default; - template - MDSPAN_INLINE_FUNCTION constexpr __compressed_pair(_TLike &&__t, _ULike &&__u) - : _T((_TLike &&) __t), __u_val((_ULike &&) __u) {} -}; - -// Second empty. -template -struct __compressed_pair< - _T, _U, - enable_if_t> - : 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 _U &__second() noexcept { - return *static_cast<_U *>(this); - } - MDSPAN_FORCE_INLINE_FUNCTION constexpr _U const &__second() const noexcept { - return *static_cast<_U const *>(this); - } - - MDSPAN_INLINE_FUNCTION_DEFAULTED - constexpr __compressed_pair() noexcept = default; - MDSPAN_INLINE_FUNCTION_DEFAULTED - constexpr __compressed_pair(__compressed_pair const &) noexcept = default; - MDSPAN_INLINE_FUNCTION_DEFAULTED - constexpr __compressed_pair(__compressed_pair &&) noexcept = default; - MDSPAN_INLINE_FUNCTION_DEFAULTED - _MDSPAN_CONSTEXPR_14_DEFAULTED __compressed_pair & - operator=(__compressed_pair const &) noexcept = default; - MDSPAN_INLINE_FUNCTION_DEFAULTED - _MDSPAN_CONSTEXPR_14_DEFAULTED __compressed_pair & - operator=(__compressed_pair &&) noexcept = default; - MDSPAN_INLINE_FUNCTION_DEFAULTED - ~__compressed_pair() noexcept = default; - - template - MDSPAN_INLINE_FUNCTION constexpr __compressed_pair(_TLike &&__t, _ULike &&__u) - : _U((_ULike &&) __u), __t_val((_TLike &&) __t) {} -}; - -// Both empty. -template -struct __compressed_pair< - _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<_T, 0>, - protected __no_unique_address_emulation<_U, 1> -#else - : private __no_unique_address_emulation<_T, 0>, - private __no_unique_address_emulation<_U, 1> -#endif -{ - 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 _T &__first() noexcept { - return this->__first_base_t::__ref(); - } - MDSPAN_FORCE_INLINE_FUNCTION constexpr _T const &__first() const noexcept { - return this->__first_base_t::__ref(); - } - MDSPAN_FORCE_INLINE_FUNCTION _MDSPAN_CONSTEXPR_14 _U &__second() noexcept { - return this->__second_base_t::__ref(); - } - MDSPAN_FORCE_INLINE_FUNCTION constexpr _U const &__second() const noexcept { - return this->__second_base_t::__ref(); - } - - MDSPAN_INLINE_FUNCTION_DEFAULTED - constexpr __compressed_pair() noexcept = default; - MDSPAN_INLINE_FUNCTION_DEFAULTED - constexpr __compressed_pair(__compressed_pair const &) noexcept = default; - MDSPAN_INLINE_FUNCTION_DEFAULTED - constexpr __compressed_pair(__compressed_pair &&) noexcept = default; - MDSPAN_INLINE_FUNCTION_DEFAULTED - _MDSPAN_CONSTEXPR_14_DEFAULTED __compressed_pair & - operator=(__compressed_pair const &) noexcept = default; - MDSPAN_INLINE_FUNCTION_DEFAULTED - _MDSPAN_CONSTEXPR_14_DEFAULTED __compressed_pair & - operator=(__compressed_pair &&) noexcept = default; - MDSPAN_INLINE_FUNCTION_DEFAULTED - ~__compressed_pair() noexcept = default; - template - 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 experimental -} // end namespace std diff --git a/src/mdspan/__p0009_bits/config.hpp b/src/mdspan/__p0009_bits/config.hpp deleted file mode 100644 index 727a565..0000000 --- a/src/mdspan/__p0009_bits/config.hpp +++ /dev/null @@ -1,274 +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 - -#ifndef __has_include -# define __has_include(x) 0 -#endif - -#if __has_include() -# include -#else -# include -# include -#endif - -#ifdef _MSVC_LANG -#define _MDSPAN_CPLUSPLUS _MSVC_LANG -#else -#define _MDSPAN_CPLUSPLUS __cplusplus -#endif - -#define MDSPAN_CXX_STD_14 201402L -#define MDSPAN_CXX_STD_17 201703L -#define MDSPAN_CXX_STD_20 202002L - -#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) - -static_assert(_MDSPAN_CPLUSPLUS >= MDSPAN_CXX_STD_14, "mdspan requires C++14 or later."); - -#ifndef _MDSPAN_COMPILER_CLANG -# if defined(__clang__) -# define _MDSPAN_COMPILER_CLANG __clang__ -# endif -#endif - -#if !defined(_MDSPAN_COMPILER_MSVC) && !defined(_MDSPAN_COMPILER_MSVC_CLANG) -# if defined(_MSC_VER) -# if !defined(_MDSPAN_COMPILER_CLANG) -# define _MDSPAN_COMPILER_MSVC _MSC_VER -# else -# define _MDSPAN_COMPILER_MSVC_CLANG _MSC_VER -# endif -# endif -#endif - -#ifndef _MDSPAN_COMPILER_INTEL -# ifdef __INTEL_COMPILER -# define _MDSPAN_COMPILER_INTEL __INTEL_COMPILER -# endif -#endif - -#ifndef _MDSPAN_COMPILER_APPLECLANG -# ifdef __apple_build_version__ -# define _MDSPAN_COMPILER_APPLECLANG __apple_build_version__ -# endif -#endif - -#ifndef _MDSPAN_HAS_CUDA -# if defined(__CUDACC__) -# define _MDSPAN_HAS_CUDA __CUDACC__ -# endif -#endif - -#ifndef _MDSPAN_HAS_HIP -# if defined(__HIPCC__) -# define _MDSPAN_HAS_HIP __HIPCC__ -# endif -#endif - -#ifndef __has_cpp_attribute -# define __has_cpp_attribute(x) 0 -#endif - -#ifndef _MDSPAN_PRESERVE_STANDARD_LAYOUT -// Preserve standard layout by default, but we're not removing the old version -// that turns this off until we're sure this doesn't have an unreasonable cost -// to the compiler or optimizer. -# define _MDSPAN_PRESERVE_STANDARD_LAYOUT 1 -#endif - -#if !defined(_MDSPAN_USE_ATTRIBUTE_NO_UNIQUE_ADDRESS) -# if ((__has_cpp_attribute(no_unique_address) >= 201803L) && \ - (!defined(__NVCC__) || MDSPAN_HAS_CXX_20) && \ - (!defined(_MDSPAN_COMPILER_MSVC) || MDSPAN_HAS_CXX_20)) -# define _MDSPAN_USE_ATTRIBUTE_NO_UNIQUE_ADDRESS 1 -# define _MDSPAN_NO_UNIQUE_ADDRESS [[no_unique_address]] -# else -# define _MDSPAN_NO_UNIQUE_ADDRESS -# endif -#endif - -// NVCC older than 11.6 chokes on the no-unique-address-emulation -// so just pretend to use it (to avoid the full blown EBO workaround -// which NVCC also doesn't like ...), and leave the macro empty -#ifndef _MDSPAN_NO_UNIQUE_ADDRESS -# if defined(__NVCC__) -# define _MDSPAN_USE_ATTRIBUTE_NO_UNIQUE_ADDRESS 1 -# define _MDSPAN_USE_FAKE_ATTRIBUTE_NO_UNIQUE_ADDRESS -# endif -# define _MDSPAN_NO_UNIQUE_ADDRESS -#endif - -#ifndef _MDSPAN_USE_CONCEPTS -# if defined(__cpp_concepts) && __cpp_concepts >= 201507L -# define _MDSPAN_USE_CONCEPTS 1 -# endif -#endif - -#ifndef _MDSPAN_USE_FOLD_EXPRESSIONS -# if (defined(__cpp_fold_expressions) && __cpp_fold_expressions >= 201603L) \ - || (!defined(__cpp_fold_expressions) && MDSPAN_HAS_CXX_17) -# define _MDSPAN_USE_FOLD_EXPRESSIONS 1 -# endif -#endif - -#ifndef _MDSPAN_USE_INLINE_VARIABLES -# if defined(__cpp_inline_variables) && __cpp_inline_variables >= 201606L \ - || (!defined(__cpp_inline_variables) && MDSPAN_HAS_CXX_17) -# define _MDSPAN_USE_INLINE_VARIABLES 1 -# endif -#endif - -#ifndef _MDSPAN_NEEDS_TRAIT_VARIABLE_TEMPLATE_BACKPORTS -# if (!(defined(__cpp_lib_type_trait_variable_templates) && __cpp_lib_type_trait_variable_templates >= 201510L) \ - || !MDSPAN_HAS_CXX_17) -# if !(defined(_MDSPAN_COMPILER_APPLECLANG) && MDSPAN_HAS_CXX_17) -# define _MDSPAN_NEEDS_TRAIT_VARIABLE_TEMPLATE_BACKPORTS 1 -# endif -# endif -#endif - -#ifndef _MDSPAN_USE_VARIABLE_TEMPLATES -# if (defined(__cpp_variable_templates) && __cpp_variable_templates >= 201304 && MDSPAN_HAS_CXX_17) \ - || (!defined(__cpp_variable_templates) && MDSPAN_HAS_CXX_17) -# define _MDSPAN_USE_VARIABLE_TEMPLATES 1 -# endif -#endif // _MDSPAN_USE_VARIABLE_TEMPLATES - -#ifndef _MDSPAN_USE_CONSTEXPR_14 -# if (defined(__cpp_constexpr) && __cpp_constexpr >= 201304) \ - || (!defined(__cpp_constexpr) && MDSPAN_HAS_CXX_14) \ - && (!(defined(__INTEL_COMPILER) && __INTEL_COMPILER <= 1700)) -# define _MDSPAN_USE_CONSTEXPR_14 1 -# endif -#endif - -#ifndef _MDSPAN_USE_INTEGER_SEQUENCE -# if defined(_MDSPAN_COMPILER_MSVC) -# if (defined(__cpp_lib_integer_sequence) && __cpp_lib_integer_sequence >= 201304) -# define _MDSPAN_USE_INTEGER_SEQUENCE 1 -# endif -# endif -#endif -#ifndef _MDSPAN_USE_INTEGER_SEQUENCE -# if (defined(__cpp_lib_integer_sequence) && __cpp_lib_integer_sequence >= 201304) \ - || (!defined(__cpp_lib_integer_sequence) && MDSPAN_HAS_CXX_14) \ - /* as far as I can tell, libc++ seems to think this is a C++11 feature... */ \ - || (defined(__GLIBCXX__) && __GLIBCXX__ > 20150422 && __GNUC__ < 5 && !defined(__INTEL_CXX11_MODE__)) - // several compilers lie about integer_sequence working properly unless the C++14 standard is used -# define _MDSPAN_USE_INTEGER_SEQUENCE 1 -# elif defined(_MDSPAN_COMPILER_APPLECLANG) && MDSPAN_HAS_CXX_14 - // appleclang seems to be missing the __cpp_lib_... macros, but doesn't seem to lie about C++14 making - // integer_sequence work -# define _MDSPAN_USE_INTEGER_SEQUENCE 1 -# endif -#endif - -#ifndef _MDSPAN_USE_RETURN_TYPE_DEDUCTION -# if (defined(__cpp_return_type_deduction) && __cpp_return_type_deduction >= 201304) \ - || (!defined(__cpp_return_type_deduction) && MDSPAN_HAS_CXX_14) -# define _MDSPAN_USE_RETURN_TYPE_DEDUCTION 1 -# endif -#endif - -#ifndef _MDSPAN_USE_CLASS_TEMPLATE_ARGUMENT_DEDUCTION -// GCC 10's CTAD seems sufficiently broken to prevent its use. -# if (defined(_MDSPAN_COMPILER_CLANG) || !defined(__GNUC__) || __GNUC__ >= 11) \ - && ((defined(__cpp_deduction_guides) && __cpp_deduction_guides >= 201703) \ - || (!defined(__cpp_deduction_guides) && MDSPAN_HAS_CXX_17)) -# define _MDSPAN_USE_CLASS_TEMPLATE_ARGUMENT_DEDUCTION 1 -# endif -#endif - -#ifndef _MDSPAN_USE_ALIAS_TEMPLATE_ARGUMENT_DEDUCTION -// GCC 10's CTAD seems sufficiently broken to prevent its use. -# if (defined(_MDSPAN_COMPILER_CLANG) || !defined(__GNUC__) || __GNUC__ >= 11) \ - && ((defined(__cpp_deduction_guides) && __cpp_deduction_guides >= 201907) \ - || (!defined(__cpp_deduction_guides) && MDSPAN_HAS_CXX_20)) -# define _MDSPAN_USE_ALIAS_TEMPLATE_ARGUMENT_DEDUCTION 1 -# endif -#endif - -#ifndef _MDSPAN_USE_STANDARD_TRAIT_ALIASES -# if (defined(__cpp_lib_transformation_trait_aliases) && __cpp_lib_transformation_trait_aliases >= 201304) \ - || (!defined(__cpp_lib_transformation_trait_aliases) && MDSPAN_HAS_CXX_14) -# define _MDSPAN_USE_STANDARD_TRAIT_ALIASES 1 -# elif defined(_MDSPAN_COMPILER_APPLECLANG) && MDSPAN_HAS_CXX_14 - // appleclang seems to be missing the __cpp_lib_... macros, but doesn't seem to lie about C++14 -# define _MDSPAN_USE_STANDARD_TRAIT_ALIASES 1 -# endif -#endif - -#ifndef _MDSPAN_DEFAULTED_CONSTRUCTORS_INHERITANCE_WORKAROUND -# ifdef __GNUC__ -# if __GNUC__ < 9 -# define _MDSPAN_DEFAULTED_CONSTRUCTORS_INHERITANCE_WORKAROUND 1 -# endif -# endif -#endif - -#ifndef MDSPAN_CONDITIONAL_EXPLICIT -# if MDSPAN_HAS_CXX_20 && !defined(_MDSPAN_COMPILER_MSVC) -# define MDSPAN_CONDITIONAL_EXPLICIT(COND) explicit(COND) -# else -# define MDSPAN_CONDITIONAL_EXPLICIT(COND) -# endif -#endif - -#ifndef MDSPAN_USE_BRACKET_OPERATOR -# if defined(__cpp_multidimensional_subscript) -# define MDSPAN_USE_BRACKET_OPERATOR 1 -# else -# define MDSPAN_USE_BRACKET_OPERATOR 0 -# endif -#endif - -#ifndef MDSPAN_USE_PAREN_OPERATOR -# if !MDSPAN_USE_BRACKET_OPERATOR -# define MDSPAN_USE_PAREN_OPERATOR 1 -# else -# define MDSPAN_USE_PAREN_OPERATOR 0 -# endif -#endif - -#if MDSPAN_USE_BRACKET_OPERATOR -# define __MDSPAN_OP(mds,...) mds[__VA_ARGS__] -// Corentins demo compiler for subscript chokes on empty [] call, -// though I believe the proposal supports it? -#ifdef MDSPAN_NO_EMPTY_BRACKET_OPERATOR -# define __MDSPAN_OP0(mds) mds.accessor().access(mds.data_handle(),0) -#else -# define __MDSPAN_OP0(mds) mds[] -#endif -# define __MDSPAN_OP1(mds, a) mds[a] -# define __MDSPAN_OP2(mds, a, b) mds[a,b] -# define __MDSPAN_OP3(mds, a, b, c) mds[a,b,c] -# define __MDSPAN_OP4(mds, a, b, c, d) mds[a,b,c,d] -# define __MDSPAN_OP5(mds, a, b, c, d, e) mds[a,b,c,d,e] -# define __MDSPAN_OP6(mds, a, b, c, d, e, f) mds[a,b,c,d,e,f] -#else -# define __MDSPAN_OP(mds,...) mds(__VA_ARGS__) -# define __MDSPAN_OP0(mds) mds() -# define __MDSPAN_OP1(mds, a) mds(a) -# define __MDSPAN_OP2(mds, a, b) mds(a,b) -# define __MDSPAN_OP3(mds, a, b, c) mds(a,b,c) -# define __MDSPAN_OP4(mds, a, b, c, d) mds(a,b,c,d) -# define __MDSPAN_OP5(mds, a, b, c, d, e) mds(a,b,c,d,e) -# define __MDSPAN_OP6(mds, a, b, c, d, e, f) mds(a,b,c,d,e,f) -#endif diff --git a/src/mdspan/__p0009_bits/default_accessor.hpp b/src/mdspan/__p0009_bits/default_accessor.hpp deleted file mode 100644 index f94816d..0000000 --- a/src/mdspan/__p0009_bits/default_accessor.hpp +++ /dev/null @@ -1,58 +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 - -#include "macros.hpp" - -#include // size_t - -namespace std { -namespace experimental { - -template -struct default_accessor { - - using offset_policy = default_accessor; - using element_type = ElementType; - using reference = ElementType&; - using data_handle_type = ElementType*; - - MDSPAN_INLINE_FUNCTION_DEFAULTED constexpr default_accessor() noexcept = default; - - MDSPAN_TEMPLATE_REQUIRES( - class OtherElementType, - /* requires */ ( - _MDSPAN_TRAIT(is_convertible, OtherElementType(*)[], element_type(*)[]) - ) - ) - MDSPAN_INLINE_FUNCTION - constexpr default_accessor(default_accessor) noexcept {} - - MDSPAN_INLINE_FUNCTION - constexpr data_handle_type - offset(data_handle_type p, size_t i) const noexcept { - return p + i; - } - - MDSPAN_FORCE_INLINE_FUNCTION - constexpr reference access(data_handle_type p, size_t i) const noexcept { - return p[i]; - } - -}; - -} // end namespace experimental -} // end namespace std diff --git a/src/mdspan/__p0009_bits/dynamic_extent.hpp b/src/mdspan/__p0009_bits/dynamic_extent.hpp deleted file mode 100644 index 9a8346b..0000000 --- a/src/mdspan/__p0009_bits/dynamic_extent.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 -#pragma once - -#include "macros.hpp" - -#include // size_t -#include // numeric_limits - -namespace std { -namespace experimental { - -_MDSPAN_INLINE_VARIABLE constexpr auto dynamic_extent = std::numeric_limits::max(); - -} // end namespace experimental -} // namespace std - -//============================================================================================================== diff --git a/src/mdspan/__p0009_bits/extents.hpp b/src/mdspan/__p0009_bits/extents.hpp deleted file mode 100644 index 760c3da..0000000 --- a/src/mdspan/__p0009_bits/extents.hpp +++ /dev/null @@ -1,517 +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 - -#include "macros.hpp" -#include "static_array.hpp" -#include "standard_layout_static_array.hpp" -#include "trait_backports.hpp" // integer_sequence, etc. - -#if !defined(_MDSPAN_USE_ATTRIBUTE_NO_UNIQUE_ADDRESS) -# include "no_unique_address.hpp" -#endif - -#include -#include - -namespace std { -namespace experimental { - -namespace detail { - -template -struct _count_dynamic_extents; - -template -struct _count_dynamic_extents { - static constexpr size_t val = (E==dynamic_extent?1:0) + _count_dynamic_extents::val; -}; - -template<> -struct _count_dynamic_extents<> { - static constexpr size_t val = 0; -}; - -template -static constexpr std::false_type _check_compatible_extents( - std::false_type, std::integer_sequence, std::integer_sequence -) noexcept { return { }; } - -template -static std::integral_constant< - bool, - _MDSPAN_FOLD_AND( - ( - Extents == dynamic_extent - || OtherExtents == dynamic_extent - || Extents == OtherExtents - ) /* && ... */ - ) -> -_check_compatible_extents( - std::true_type, std::integer_sequence, std::integer_sequence -) noexcept { return { }; } - -struct __extents_tag { }; - -} // end namespace detail - -template -class extents -#if !defined(_MDSPAN_USE_ATTRIBUTE_NO_UNIQUE_ADDRESS) - : private detail::__no_unique_address_emulation< - detail::__partially_static_sizes_tagged> -#endif -{ -public: - - using rank_type = size_t; - using index_type = ThisIndexType; - static_assert(std::is_integral::value && !std::is_same::value, - "std::extents requires a signed or unsigned integer as index_type parameter"); - using size_type = make_unsigned_t; - -// internal typedefs which for technical reasons are public - using __storage_t = detail::__partially_static_sizes_tagged; - -#if defined(_MDSPAN_USE_ATTRIBUTE_NO_UNIQUE_ADDRESS) - _MDSPAN_NO_UNIQUE_ADDRESS __storage_t __storage_; -#else - using __base_t = detail::__no_unique_address_emulation<__storage_t>; -#endif - -// private members dealing with the way we internally store dynamic extents - private: - - MDSPAN_FORCE_INLINE_FUNCTION _MDSPAN_CONSTEXPR_14 - __storage_t& __storage() noexcept { -#if defined(_MDSPAN_USE_ATTRIBUTE_NO_UNIQUE_ADDRESS) - return __storage_; -#else - return this->__base_t::__ref(); -#endif - } - MDSPAN_FORCE_INLINE_FUNCTION - constexpr __storage_t const& __storage() const noexcept { -#if defined(_MDSPAN_USE_ATTRIBUTE_NO_UNIQUE_ADDRESS) - return __storage_; -#else - return this->__base_t::__ref(); -#endif - } - - template - MDSPAN_FORCE_INLINE_FUNCTION - static constexpr - std::size_t _static_extent_impl(size_t n, std::integer_sequence) noexcept { - return _MDSPAN_FOLD_PLUS_RIGHT(((Idxs == n) ? Extents : 0), /* + ... + */ 0); - } - - template - friend class extents; - - template - MDSPAN_INLINE_FUNCTION - constexpr bool _eq_impl(std::experimental::extents, false_type, index_sequence) const noexcept { return false; } - template - MDSPAN_INLINE_FUNCTION - constexpr bool _eq_impl( - std::experimental::extents other, - true_type, index_sequence - ) const noexcept { - return _MDSPAN_FOLD_AND( - (__storage().template __get_n() == other.__storage().template __get_n()) /* && ... */ - ); - } - - template - MDSPAN_INLINE_FUNCTION - constexpr bool _not_eq_impl(std::experimental::extents, false_type, index_sequence) const noexcept { return true; } - template - MDSPAN_INLINE_FUNCTION - constexpr bool _not_eq_impl( - std::experimental::extents other, - true_type, index_sequence - ) const noexcept { - return _MDSPAN_FOLD_OR( - (__storage().template __get_n() != other.__storage().template __get_n()) /* || ... */ - ); - } - -#if !defined(_MDSPAN_USE_ATTRIBUTE_NO_UNIQUE_ADDRESS) - MDSPAN_INLINE_FUNCTION constexpr explicit - extents(__base_t&& __b) noexcept - : __base_t(::std::move(__b)) - { } -#endif - - -// public interface: -public: - /* Defined above for use in the private code - using rank_type = size_t; - using index_type = ThisIndexType; - */ - - MDSPAN_INLINE_FUNCTION - static constexpr rank_type rank() noexcept { return sizeof...(Extents); } - MDSPAN_INLINE_FUNCTION - static constexpr rank_type rank_dynamic() noexcept { return _MDSPAN_FOLD_PLUS_RIGHT((rank_type(Extents == dynamic_extent)), /* + ... + */ 0); } - - //-------------------------------------------------------------------------------- - // Constructors, Destructors, and Assignment - - // Default constructor - MDSPAN_INLINE_FUNCTION_DEFAULTED constexpr extents() noexcept = default; - - // Converting constructor - 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{}, - std::integer_sequence{}, - std::integer_sequence{} - ))::value - ) - ) - MDSPAN_INLINE_FUNCTION - MDSPAN_CONDITIONAL_EXPLICIT( - (((Extents != dynamic_extent) && (OtherExtents == dynamic_extent)) || ...) || - (std::numeric_limits::max() < std::numeric_limits::max())) - constexpr extents(const extents& __other) - noexcept -#if defined(_MDSPAN_USE_ATTRIBUTE_NO_UNIQUE_ADDRESS) - : __storage_{ -#else - : __base_t(__base_t{__storage_t{ -#endif - __other.__storage().__enable_psa_conversion() -#if defined(_MDSPAN_USE_ATTRIBUTE_NO_UNIQUE_ADDRESS) - } -#else - }}) -#endif - { - /* TODO: precondition check - * other.extent(r) equals Er for each r for which Er is a static extent, and - * either - * - sizeof...(OtherExtents) is zero, or - * - other.extent(r) is a representable value of type index_type for all rank index r of other - */ - } - -#ifdef __NVCC__ - MDSPAN_TEMPLATE_REQUIRES( - class... Integral, - /* requires */ ( - // TODO: check whether the other version works with newest NVCC, doesn't with 11.4 - // NVCC seems to pick up rank_dynamic from the wrong extents type??? - _MDSPAN_FOLD_AND(_MDSPAN_TRAIT(is_convertible, Integral, index_type) /* && ... */) && - _MDSPAN_FOLD_AND(_MDSPAN_TRAIT(is_nothrow_constructible, index_type, Integral) /* && ... */) && - // NVCC chokes on the fold thingy here so wrote the workaround - ((sizeof...(Integral) == detail::_count_dynamic_extents::val) || - (sizeof...(Integral) == sizeof...(Extents))) - ) - ) -#else - MDSPAN_TEMPLATE_REQUIRES( - class... Integral, - /* requires */ ( - _MDSPAN_FOLD_AND(_MDSPAN_TRAIT(is_convertible, Integral, index_type) /* && ... */) && - _MDSPAN_FOLD_AND(_MDSPAN_TRAIT(is_nothrow_constructible, index_type, Integral) /* && ... */) && - ((sizeof...(Integral) == rank_dynamic()) || (sizeof...(Integral) == rank())) - ) - ) -#endif - MDSPAN_INLINE_FUNCTION - explicit constexpr extents(Integral... exts) noexcept -#if defined(_MDSPAN_USE_ATTRIBUTE_NO_UNIQUE_ADDRESS) - : __storage_{ -#else - : __base_t(__base_t{typename __base_t::__stored_type{ -#endif - std::conditional_t(), - static_cast(exts)... -#if defined(_MDSPAN_USE_ATTRIBUTE_NO_UNIQUE_ADDRESS) - } -#else - }}) -#endif - { - /* TODO: precondition check - * If sizeof...(IndexTypes) != rank_dynamic() is true, exts_arr[r] equals Er for each r for which Er is a static extent, and - * either - * - sizeof...(exts) == 0 is true, or - * - each element of exts is nonnegative and is a representable value of type index_type. - */ - } - - // TODO: check whether this works with newest NVCC, doesn't with 11.4 -#ifdef __NVCC__ - // NVCC seems to pick up rank_dynamic from the wrong extents type??? - // NVCC chokes on the fold thingy here so wrote the workaround - MDSPAN_TEMPLATE_REQUIRES( - class IndexType, size_t N, - /* requires */ ( - _MDSPAN_TRAIT(is_convertible, IndexType, index_type) && - _MDSPAN_TRAIT(is_nothrow_constructible, index_type, IndexType) && - ((N == detail::_count_dynamic_extents::val) || - (N == sizeof...(Extents))) - ) - ) -#else - MDSPAN_TEMPLATE_REQUIRES( - class IndexType, size_t N, - /* requires */ ( - _MDSPAN_TRAIT(is_convertible, IndexType, index_type) && - _MDSPAN_TRAIT(is_nothrow_constructible, index_type, IndexType) && - (N == rank() || N == rank_dynamic()) - ) - ) -#endif - MDSPAN_CONDITIONAL_EXPLICIT(N != rank_dynamic()) - MDSPAN_INLINE_FUNCTION - constexpr - extents(std::array const& exts) noexcept -#if defined(_MDSPAN_USE_ATTRIBUTE_NO_UNIQUE_ADDRESS) - : __storage_{ -#else - : __base_t(__base_t{typename __base_t::__stored_type{ -#endif - std::conditional_t, - detail::__construct_psa_from_all_exts_array_tag_t>(), - std::array{exts} -#if defined(_MDSPAN_USE_ATTRIBUTE_NO_UNIQUE_ADDRESS) - } -#else - }}) -#endif - { - /* TODO: precondition check - * If N != rank_dynamic() is true, exts[r] equals Er for each r for which Er is a static extent, and - * either - * - N is zero, or - * - exts[r] is nonnegative and is a representable value of type index_type for all rank index r - */ - } - -#ifdef __cpp_lib_span - // TODO: check whether the below works with newest NVCC, doesn't with 11.4 -#ifdef __NVCC__ - // NVCC seems to pick up rank_dynamic from the wrong extents type??? - // NVCC chokes on the fold thingy here so wrote the workaround - MDSPAN_TEMPLATE_REQUIRES( - class IndexType, size_t N, - /* requires */ ( - _MDSPAN_TRAIT(is_convertible, IndexType, index_type) && - _MDSPAN_TRAIT(is_nothrow_constructible, index_type, IndexType) && - ((N == detail::_count_dynamic_extents::val) || - (N == sizeof...(Extents))) - ) - ) -#else - MDSPAN_TEMPLATE_REQUIRES( - class IndexType, size_t N, - /* requires */ ( - _MDSPAN_TRAIT(is_convertible, IndexType, index_type) && - _MDSPAN_TRAIT(is_nothrow_constructible, index_type, IndexType) && - (N == rank() || N == rank_dynamic()) - ) - ) -#endif - MDSPAN_CONDITIONAL_EXPLICIT(N != rank_dynamic()) - MDSPAN_INLINE_FUNCTION - constexpr - extents(std::span exts) noexcept -#if defined(_MDSPAN_USE_ATTRIBUTE_NO_UNIQUE_ADDRESS) - : __storage_{ -#else - : __base_t(__base_t{typename __base_t::__stored_type{ -#endif - std::conditional_t, - detail::__construct_psa_from_all_exts_array_tag_t>(), - exts -#if defined(_MDSPAN_USE_ATTRIBUTE_NO_UNIQUE_ADDRESS) - } -#else - }}) -#endif - { - /* TODO: precondition check - * If N != rank_dynamic() is true, exts[r] equals Er for each r for which Er is a static extent, and - * either - * - N is zero, or - * - exts[r] is nonnegative and is a representable value of type index_type for all rank index r - */ - } -#endif - - // Need this constructor for some submdspan implementation stuff - // for the layout_stride case where I use an extents object for strides - MDSPAN_INLINE_FUNCTION - constexpr explicit - extents(__storage_t const& sto ) noexcept -#if defined(_MDSPAN_USE_ATTRIBUTE_NO_UNIQUE_ADDRESS) - : __storage_{ -#else - : __base_t(__base_t{ -#endif - sto -#if defined(_MDSPAN_USE_ATTRIBUTE_NO_UNIQUE_ADDRESS) - } -#else - }) -#endif - { } - - //-------------------------------------------------------------------------------- - - MDSPAN_INLINE_FUNCTION - static constexpr - size_t static_extent(size_t n) noexcept { - // Can't do assert here since that breaks true constexpr ness - // assert(n{}); - } - - MDSPAN_INLINE_FUNCTION - constexpr - index_type extent(size_t n) const noexcept { - // Can't do assert here since that breaks true constexpr ness - // assert(n - MDSPAN_INLINE_FUNCTION - friend constexpr bool operator==(extents const& lhs, extents const& rhs) noexcept { - return lhs._eq_impl( - rhs, std::integral_constant{}, - make_index_sequence{} - ); - } - -#if !(MDSPAN_HAS_CXX_20) - template - MDSPAN_INLINE_FUNCTION - friend constexpr bool operator!=(extents const& lhs, extents const& rhs) noexcept { - return lhs._not_eq_impl( - rhs, std::integral_constant{}, - make_index_sequence{} - ); - } -#endif - - // End of public interface - -public: // (but not really) - - MDSPAN_INLINE_FUNCTION static constexpr - extents __make_extents_impl(detail::__partially_static_sizes&& __bs) noexcept { - // This effectively amounts to a sideways cast that can be done in a constexpr - // context, but we have to do it to handle the case where the extents and the - // strides could accidentally end up with the same types in their hierarchies - // somehow (which would cause layout_stride::mapping to not be standard_layout) - return extents( -#if !defined(_MDSPAN_USE_ATTRIBUTE_NO_UNIQUE_ADDRESS) - __base_t{ -#endif - ::std::move(__bs.template __with_tag()) -#if !defined(_MDSPAN_USE_ATTRIBUTE_NO_UNIQUE_ADDRESS) - } -#endif - ); - } - - template - MDSPAN_FORCE_INLINE_FUNCTION - constexpr - index_type __extent() const noexcept { - return __storage().template __get_n(); - } - - template - MDSPAN_INLINE_FUNCTION - static constexpr - index_type __static_extent() noexcept { - return __storage_t::template __get_static_n(); - } - -}; - -namespace detail { - -template > -struct __make_dextents; - -template -struct __make_dextents> { - using type = typename __make_dextents>::type; -}; - -template -struct __make_dextents> { - using type = ::std::experimental::extents; -}; - -} // end namespace detail - -template -using dextents = typename detail::__make_dextents::type; - -#if defined(_MDSPAN_USE_CLASS_TEMPLATE_ARGUMENT_DEDUCTION) -template -extents(IndexTypes...) - -> extents; -#endif - -namespace detail { - -template -struct __is_extents : ::std::false_type {}; - -template -struct __is_extents<::std::experimental::extents> : ::std::true_type {}; - -template -static constexpr bool __is_extents_v = __is_extents::value; - - -template -struct __extents_to_partially_static_sizes; - -template -struct __extents_to_partially_static_sizes<::std::experimental::extents> { - using type = detail::__partially_static_sizes< - typename ::std::experimental::extents::index_type, size_t, - ExtentsPack...>; -}; - -template -using __extents_to_partially_static_sizes_t = typename __extents_to_partially_static_sizes::type; - -} // end namespace detail -} // end namespace experimental -} // end namespace std diff --git a/src/mdspan/__p0009_bits/full_extent_t.hpp b/src/mdspan/__p0009_bits/full_extent_t.hpp deleted file mode 100644 index a874262..0000000 --- a/src/mdspan/__p0009_bits/full_extent_t.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 - -#include "macros.hpp" - -namespace std { -namespace experimental { - -struct full_extent_t { explicit full_extent_t() = default; }; - -_MDSPAN_INLINE_VARIABLE constexpr auto full_extent = full_extent_t{ }; - -} // end namespace experimental -} // namespace std diff --git a/src/mdspan/__p0009_bits/layout_left.hpp b/src/mdspan/__p0009_bits/layout_left.hpp deleted file mode 100644 index 2b3a9bd..0000000 --- a/src/mdspan/__p0009_bits/layout_left.hpp +++ /dev/null @@ -1,217 +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 - -#include "macros.hpp" -#include "trait_backports.hpp" -#include "extents.hpp" - -namespace std { -namespace experimental { - -//============================================================================== - -template -class layout_left::mapping { - public: - 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; - private: - - static_assert(detail::__is_extents_v, "std::experimental::layout_left::mapping must be instantiated with a specialization of std::experimental::extents."); - - template - friend class mapping; - - // i0+(i1 + E(1)*(i2 + E(2)*i3)) - template - struct __rank_count {}; - - template - _MDSPAN_HOST_DEVICE - constexpr index_type __compute_offset( - __rank_count, const I& i, Indices... idx) const { - return __compute_offset(__rank_count(), idx...) * - __extents.template __extent() + i; - } - - template - _MDSPAN_HOST_DEVICE - constexpr index_type __compute_offset( - __rank_count, const I& i) const { - return i; - } - - _MDSPAN_HOST_DEVICE - constexpr index_type __compute_offset(__rank_count<0,0>) const { return 0; } - - public: - - //-------------------------------------------------------------------------------- - - MDSPAN_INLINE_FUNCTION_DEFAULTED constexpr mapping() noexcept = default; - MDSPAN_INLINE_FUNCTION_DEFAULTED constexpr mapping(mapping const&) noexcept = default; - - _MDSPAN_HOST_DEVICE - constexpr mapping(extents_type const& __exts) noexcept - :__extents(__exts) - { } - - MDSPAN_TEMPLATE_REQUIRES( - class OtherExtents, - /* requires */ ( - _MDSPAN_TRAIT(is_constructible, extents_type, OtherExtents) - ) - ) - MDSPAN_CONDITIONAL_EXPLICIT((!is_convertible::value)) // needs two () due to comma - MDSPAN_INLINE_FUNCTION _MDSPAN_CONSTEXPR_14 - mapping(mapping const& other) noexcept // NOLINT(google-explicit-constructor) - :__extents(other.extents()) - { - /* - * TODO: check precondition - * other.required_span_size() is a representable value of type index_type - */ - } - - MDSPAN_TEMPLATE_REQUIRES( - class OtherExtents, - /* requires */ ( - _MDSPAN_TRAIT(is_constructible, extents_type, OtherExtents) && - (extents_type::rank() <= 1) - ) - ) - MDSPAN_CONDITIONAL_EXPLICIT((!is_convertible::value)) // needs two () due to comma - MDSPAN_INLINE_FUNCTION _MDSPAN_CONSTEXPR_14 - mapping(layout_right::mapping const& other) noexcept // NOLINT(google-explicit-constructor) - :__extents(other.extents()) - { - /* - * TODO: check precondition - * other.required_span_size() is a representable value of type index_type - */ - } - - MDSPAN_TEMPLATE_REQUIRES( - class OtherExtents, - /* requires */ ( - _MDSPAN_TRAIT(is_constructible, extents_type, OtherExtents) - ) - ) - MDSPAN_CONDITIONAL_EXPLICIT((extents_type::rank() > 0)) - MDSPAN_INLINE_FUNCTION _MDSPAN_CONSTEXPR_14 - mapping(layout_stride::mapping const& other) // NOLINT(google-explicit-constructor) - :__extents(other.extents()) - { - /* - * TODO: check precondition - * other.required_span_size() is a representable value of type index_type - */ - #ifndef __CUDA_ARCH__ - size_t stride = 1; - for(rank_type r=0; r<__extents.rank(); r++) { - if(stride != other.stride(r)) - 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; - - MDSPAN_INLINE_FUNCTION - constexpr const extents_type& extents() const noexcept { - return __extents; - } - - MDSPAN_INLINE_FUNCTION - constexpr index_type required_span_size() const noexcept { - index_type value = 1; - for(rank_type r=0; r(), 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 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 { - index_type value = 1; - for(rank_type r=0; r - MDSPAN_INLINE_FUNCTION - friend constexpr bool operator==(mapping const& lhs, mapping const& rhs) noexcept { - return lhs.extents() == rhs.extents(); - } - - // In C++ 20 the not equal exists if equal is found -#if MDSPAN_HAS_CXX_20 - template - MDSPAN_INLINE_FUNCTION - friend constexpr bool operator!=(mapping const& lhs, mapping const& rhs) noexcept { - return lhs.extents() != rhs.extents(); - } -#endif - - // Not really public, but currently needed to implement fully constexpr useable submdspan: - template - constexpr index_type __get_stride(std::experimental::extents,integer_sequence) const { - return _MDSPAN_FOLD_TIMES_RIGHT((Idx():1),1); - } - template - constexpr index_type __stride() const noexcept { - return __get_stride(__extents, make_index_sequence()); - } - -private: - _MDSPAN_NO_UNIQUE_ADDRESS extents_type __extents{}; - -}; - - -} // end namespace experimental -} // end namespace std - diff --git a/src/mdspan/__p0009_bits/layout_right.hpp b/src/mdspan/__p0009_bits/layout_right.hpp deleted file mode 100644 index 2ab20f1..0000000 --- a/src/mdspan/__p0009_bits/layout_right.hpp +++ /dev/null @@ -1,218 +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 - -#include "macros.hpp" -#include "trait_backports.hpp" -#include "extents.hpp" -#include -#include "layout_stride.hpp" - -namespace std { -namespace experimental { - -//============================================================================== -template -class layout_right::mapping { - public: - 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; - private: - - static_assert(detail::__is_extents_v, "std::experimental::layout_right::mapping must be instantiated with a specialization of std::experimental::extents."); - - template - friend class mapping; - - // i0+(i1 + E(1)*(i2 + E(2)*i3)) - template - struct __rank_count {}; - - template - _MDSPAN_HOST_DEVICE - constexpr index_type __compute_offset( - index_type offset, __rank_count, const I& i, Indices... idx) const { - return __compute_offset(offset * __extents.template __extent() + i,__rank_count(), idx...); - } - - template - _MDSPAN_HOST_DEVICE - constexpr index_type __compute_offset( - __rank_count<0,extents_type::rank()>, const I& i, Indices... idx) const { - return __compute_offset(i,__rank_count<1,extents_type::rank()>(),idx...); - } - - _MDSPAN_HOST_DEVICE - constexpr index_type __compute_offset(size_t offset, __rank_count) const { - return static_cast(offset); - } - - _MDSPAN_HOST_DEVICE - constexpr index_type __compute_offset(__rank_count<0,0>) const { return 0; } - - public: - - //-------------------------------------------------------------------------------- - - MDSPAN_INLINE_FUNCTION_DEFAULTED constexpr mapping() noexcept = default; - MDSPAN_INLINE_FUNCTION_DEFAULTED constexpr mapping(mapping const&) noexcept = default; - - _MDSPAN_HOST_DEVICE - constexpr mapping(extents_type const& __exts) noexcept - :__extents(__exts) - { } - - MDSPAN_TEMPLATE_REQUIRES( - class OtherExtents, - /* requires */ ( - _MDSPAN_TRAIT(is_constructible, extents_type, OtherExtents) - ) - ) - MDSPAN_CONDITIONAL_EXPLICIT((!is_convertible::value)) // needs two () due to comma - MDSPAN_INLINE_FUNCTION _MDSPAN_CONSTEXPR_14 - mapping(mapping const& other) noexcept // NOLINT(google-explicit-constructor) - :__extents(other.extents()) - { - /* - * TODO: check precondition - * other.required_span_size() is a representable value of type index_type - */ - } - - MDSPAN_TEMPLATE_REQUIRES( - class OtherExtents, - /* requires */ ( - _MDSPAN_TRAIT(is_constructible, extents_type, OtherExtents) && - (extents_type::rank() <= 1) - ) - ) - MDSPAN_CONDITIONAL_EXPLICIT((!is_convertible::value)) // needs two () due to comma - MDSPAN_INLINE_FUNCTION _MDSPAN_CONSTEXPR_14 - mapping(layout_left::mapping const& other) noexcept // NOLINT(google-explicit-constructor) - :__extents(other.extents()) - { - /* - * TODO: check precondition - * other.required_span_size() is a representable value of type index_type - */ - } - - MDSPAN_TEMPLATE_REQUIRES( - class OtherExtents, - /* requires */ ( - _MDSPAN_TRAIT(is_constructible, extents_type, OtherExtents) - ) - ) - MDSPAN_CONDITIONAL_EXPLICIT((extents_type::rank() > 0)) - MDSPAN_INLINE_FUNCTION _MDSPAN_CONSTEXPR_14 - mapping(layout_stride::mapping const& other) // NOLINT(google-explicit-constructor) - :__extents(other.extents()) - { - /* - * TODO: check precondition - * other.required_span_size() is a representable value of type index_type - */ - #ifndef __CUDA_ARCH__ - size_t stride = 1; - for(rank_type r=__extents.rank(); r>0; r--) { - if(stride != other.stride(r-1)) - 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; - - MDSPAN_INLINE_FUNCTION - constexpr const extents_type& extents() const noexcept { - return __extents; - } - - MDSPAN_INLINE_FUNCTION - constexpr index_type required_span_size() const noexcept { - index_type value = 1; - for(rank_type r=0; r != extents_type::rank(); ++r) value*=__extents.extent(r); - return value; - } - - //-------------------------------------------------------------------------------- - - MDSPAN_TEMPLATE_REQUIRES( - class... Indices, - /* requires */ ( - (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 { - return __compute_offset(__rank_count<0, extents_type::rank()>(), 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 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 { - index_type value = 1; - for(rank_type r=extents_type::rank()-1; r>i; r--) value*=__extents.extent(r); - return value; - } - - template - MDSPAN_INLINE_FUNCTION - friend constexpr bool operator==(mapping const& lhs, mapping const& rhs) noexcept { - return lhs.extents() == rhs.extents(); - } - - // In C++ 20 the not equal exists if equal is found -#if MDSPAN_HAS_CXX_20 - template - MDSPAN_INLINE_FUNCTION - friend constexpr bool operator!=(mapping const& lhs, mapping const& rhs) noexcept { - return lhs.extents() != rhs.extents(); - } -#endif - - // Not really public, but currently needed to implement fully constexpr useable submdspan: - template - constexpr index_type __get_stride(std::experimental::extents,integer_sequence) const { - return _MDSPAN_FOLD_TIMES_RIGHT((Idx>N? __extents.template __extent():1),1); - } - template - constexpr index_type __stride() const noexcept { - return __get_stride(__extents, make_index_sequence()); - } - -private: - _MDSPAN_NO_UNIQUE_ADDRESS extents_type __extents{}; - -}; - -} // end namespace experimental -} // end namespace std - diff --git a/src/mdspan/__p0009_bits/layout_stride.hpp b/src/mdspan/__p0009_bits/layout_stride.hpp deleted file mode 100644 index 861cdef..0000000 --- a/src/mdspan/__p0009_bits/layout_stride.hpp +++ /dev/null @@ -1,536 +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 - -#include "macros.hpp" -#include "static_array.hpp" -#include "extents.hpp" -#include "trait_backports.hpp" -#include "compressed_pair.hpp" - -#if !defined(_MDSPAN_USE_ATTRIBUTE_NO_UNIQUE_ADDRESS) -# include "no_unique_address.hpp" -#endif - -#include -#include -#include -#ifdef __cpp_lib_span -#include -#endif -#if defined(_MDSPAN_USE_CONCEPTS) && MDSPAN_HAS_CXX_20 -#include -#endif - -namespace std { -namespace experimental { - -struct layout_left { - template - class mapping; -}; -struct layout_right { - template - class mapping; -}; - -namespace detail { - template - constexpr bool __is_mapping_of = - is_same, Mapping>::value; - -#if defined(_MDSPAN_USE_CONCEPTS) && MDSPAN_HAS_CXX_20 - template - concept __layout_mapping_alike = requires { - requires __is_extents::value; - { M::is_always_strided() } -> same_as; - { M::is_always_exhaustive() } -> same_as; - { M::is_always_unique() } -> same_as; - bool_constant::value; - bool_constant::value; - bool_constant::value; - }; -#endif -} // namespace detail - -struct layout_stride { - template - class mapping -#if !defined(_MDSPAN_USE_ATTRIBUTE_NO_UNIQUE_ADDRESS) - : private detail::__no_unique_address_emulation< - detail::__compressed_pair< - Extents, - std::array - > - > -#endif - { - public: - 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_stride; - - // This could be a `requires`, but I think it's better and clearer as a `static_assert`. - static_assert(detail::__is_extents_v, "std::experimental::layout_stride::mapping must be instantiated with a specialization of std::experimental::extents."); - - - private: - - //---------------------------------------------------------------------------- - - using __strides_storage_t = array;//::std::experimental::dextents; - using __member_pair_t = detail::__compressed_pair; - -#if defined(_MDSPAN_USE_ATTRIBUTE_NO_UNIQUE_ADDRESS) - _MDSPAN_NO_UNIQUE_ADDRESS __member_pair_t __members; -#else - using __base_t = detail::__no_unique_address_emulation<__member_pair_t>; -#endif - - MDSPAN_FORCE_INLINE_FUNCTION constexpr __strides_storage_t const& - __strides_storage() const noexcept { -#if defined(_MDSPAN_USE_ATTRIBUTE_NO_UNIQUE_ADDRESS) - return __members.__second(); -#else - return this->__base_t::__ref().__second(); -#endif - } - MDSPAN_FORCE_INLINE_FUNCTION _MDSPAN_CONSTEXPR_14 __strides_storage_t& - __strides_storage() noexcept { -#if defined(_MDSPAN_USE_ATTRIBUTE_NO_UNIQUE_ADDRESS) - return __members.__second(); -#else - return this->__base_t::__ref().__second(); -#endif - } - - //---------------------------------------------------------------------------- - - template - friend class mapping; - - //---------------------------------------------------------------------------- - - // Workaround for non-deducibility of the index sequence template parameter if it's given at the top level - template - struct __deduction_workaround; - - template - struct __deduction_workaround> - { - template - MDSPAN_INLINE_FUNCTION - static constexpr bool _eq_impl(mapping const& self, mapping const& other) noexcept { - return _MDSPAN_FOLD_AND((self.stride(Idxs) == other.stride(Idxs)) /* && ... */); - } - template - MDSPAN_INLINE_FUNCTION - static constexpr bool _not_eq_impl(mapping const& self, mapping const& other) noexcept { - return _MDSPAN_FOLD_OR((self.stride(Idxs) != other.stride(Idxs)) /* || ... */); - } - - template - MDSPAN_FORCE_INLINE_FUNCTION - static constexpr size_t _call_op_impl(mapping const& self, Integral... idxs) noexcept { - return _MDSPAN_FOLD_PLUS_RIGHT((idxs * self.stride(Idxs)), /* + ... + */ 0); - } - - MDSPAN_INLINE_FUNCTION - static constexpr size_t _req_span_size_impl(mapping const& self) noexcept { - // assumes no negative strides; not sure if I'm allowed to assume that or not - return __impl::_call_op_impl(self, (self.extents().template __extent() - 1)...) + 1; - } - - template - MDSPAN_INLINE_FUNCTION - static constexpr const __strides_storage_t fill_strides(const OtherMapping& map) { - return __strides_storage_t{static_cast(map.stride(Idxs))...}; - } - - MDSPAN_INLINE_FUNCTION - static constexpr const __strides_storage_t& fill_strides(const __strides_storage_t& s) { - return s; - } - - template - MDSPAN_INLINE_FUNCTION - static constexpr const __strides_storage_t fill_strides(const array& s) { - return __strides_storage_t{static_cast(s[Idxs])...}; - } - -#ifdef __cpp_lib_span - template - MDSPAN_INLINE_FUNCTION - static constexpr const __strides_storage_t fill_strides(const span& s) { - return __strides_storage_t{static_cast(s[Idxs])...}; - } -#endif - - MDSPAN_INLINE_FUNCTION - static constexpr const __strides_storage_t fill_strides( - detail::__extents_to_partially_static_sizes_t< - ::std::experimental::dextents>&& s) { - return __strides_storage_t{static_cast(s.template __get_n())...}; - } - - template - MDSPAN_INLINE_FUNCTION - static constexpr size_t __return_zero() { return 0; } - - template - MDSPAN_INLINE_FUNCTION - static constexpr typename Mapping::index_type - __OFFSET(const Mapping& m) { return m(__return_zero()...); } - }; - - // Can't use defaulted parameter in the __deduction_workaround template because of a bug in MSVC warning C4348. - using __impl = __deduction_workaround>; - - - //---------------------------------------------------------------------------- - -#if defined(_MDSPAN_USE_ATTRIBUTE_NO_UNIQUE_ADDRESS) - MDSPAN_INLINE_FUNCTION constexpr explicit - mapping(__member_pair_t&& __m) : __members(::std::move(__m)) {} -#else - MDSPAN_INLINE_FUNCTION constexpr explicit - mapping(__base_t&& __b) : __base_t(::std::move(__b)) {} -#endif - - public: // but not really - MDSPAN_INLINE_FUNCTION - static constexpr mapping - __make_mapping( - detail::__extents_to_partially_static_sizes_t&& __exts, - detail::__extents_to_partially_static_sizes_t< - ::std::experimental::dextents>&& __strs - ) noexcept { - // call the private constructor we created for this purpose - return mapping( -#if !defined(_MDSPAN_USE_ATTRIBUTE_NO_UNIQUE_ADDRESS) - __base_t{ -#endif - __member_pair_t( - extents_type::__make_extents_impl(::std::move(__exts)), - __strides_storage_t{__impl::fill_strides(::std::move(__strs))} - ) -#if !defined(_MDSPAN_USE_ATTRIBUTE_NO_UNIQUE_ADDRESS) - } -#endif - ); - } - //---------------------------------------------------------------------------- - - - public: - - //-------------------------------------------------------------------------------- - - 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 'std::experimental::layout_stride::mapping' - _MDSPAN_TRAIT(is_convertible, const remove_const_t&, typename Extents::index_type) && - _MDSPAN_TRAIT(is_nothrow_constructible, typename Extents::index_type, const remove_const_t&) - ) - ) - MDSPAN_INLINE_FUNCTION - constexpr - mapping( - extents_type const& e, - array const& s - ) 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(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 'std::experimental::layout_stride::mapping' - _MDSPAN_TRAIT(is_convertible, const remove_const_t&, typename Extents::index_type) && - _MDSPAN_TRAIT(is_nothrow_constructible, typename Extents::index_type, const remove_const_t&) - ) - ) - MDSPAN_INLINE_FUNCTION - constexpr - mapping( - extents_type const& e, - span const& s - ) 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(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. - */ - } -#endif // __cpp_lib_span - -#if !(defined(_MDSPAN_USE_CONCEPTS) && MDSPAN_HAS_CXX_20) - MDSPAN_TEMPLATE_REQUIRES( - class StridedLayoutMapping, - /* requires */ ( - _MDSPAN_TRAIT(is_constructible, extents_type, typename StridedLayoutMapping::extents_type) && - detail::__is_mapping_of && - StridedLayoutMapping::is_always_unique() && - StridedLayoutMapping::is_always_strided() - ) - ) -#else - template - requires( - detail::__layout_mapping_alike && - _MDSPAN_TRAIT(is_constructible, extents_type, typename StridedLayoutMapping::extents_type) && - StridedLayoutMapping::is_always_unique() && - StridedLayoutMapping::is_always_strided() - ) -#endif - MDSPAN_CONDITIONAL_EXPLICIT( - (!is_convertible::value) && - (detail::__is_mapping_of || - detail::__is_mapping_of || - detail::__is_mapping_of) - ) // needs two () due to comma - MDSPAN_INLINE_FUNCTION _MDSPAN_CONSTEXPR_14 - mapping(StridedLayoutMapping const& other) noexcept // NOLINT(google-explicit-constructor) -#if defined(_MDSPAN_USE_ATTRIBUTE_NO_UNIQUE_ADDRESS) - : __members{ -#else - : __base_t(__base_t{__member_pair_t( -#endif - other.extents(), __strides_storage_t(__impl::fill_strides(other)) -#if defined(_MDSPAN_USE_ATTRIBUTE_NO_UNIQUE_ADDRESS) - } -#else - )}) -#endif - { - /* - * TODO: check preconditions - * - other.stride(i) > 0 is true for all i in the range [0, rank_ ). - * - other.required_span_size() is a representable value of type index_type ([basic.fundamental]). - * - OFFSET(other) == 0 - */ - } - - //-------------------------------------------------------------------------------- - - MDSPAN_INLINE_FUNCTION_DEFAULTED _MDSPAN_CONSTEXPR_14_DEFAULTED - mapping& operator=(mapping const&) noexcept = default; - - MDSPAN_INLINE_FUNCTION constexpr const extents_type& extents() const noexcept { -#if defined(_MDSPAN_USE_ATTRIBUTE_NO_UNIQUE_ADDRESS) - return __members.__first(); -#else - return this->__base_t::__ref().__first(); -#endif - }; - - MDSPAN_INLINE_FUNCTION - constexpr array< index_type, extents_type::rank() > strides() const noexcept { - return __strides_storage(); - } - - MDSPAN_INLINE_FUNCTION - constexpr index_type required_span_size() const noexcept { - index_type span_size = 1; - for(unsigned r = 0; r < extents_type::rank(); r++) { - // Return early if any of the extents are zero - if(extents().extent(r)==0) return 0; - span_size = std::max(span_size, static_cast(extents().extent(r) * __strides_storage()[r])); - } - return span_size; - } - - - MDSPAN_TEMPLATE_REQUIRES( - class... Indices, - /* requires */ ( - sizeof...(Indices) == Extents::rank() && - _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 size_t operator()(Indices... idxs) const noexcept { - return __impl::_call_op_impl(*this, static_cast(idxs)...); - } - - MDSPAN_INLINE_FUNCTION static constexpr bool is_always_unique() noexcept { return true; } - MDSPAN_INLINE_FUNCTION static constexpr bool is_always_exhaustive() noexcept { - return false; - } - 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 _MDSPAN_CONSTEXPR_14 bool is_exhaustive() const noexcept { -// TODO @testing test layout_stride is_exhaustive() -// FIXME CUDA -#ifdef __CUDA_ARCH__ - return false; -#else - auto rem = array{ }; - std::iota(rem.begin(), rem.end(), size_t(0)); - auto next_idx_iter = std::find_if( - rem.begin(), rem.end(), - [&](size_t i) { return this->stride(i) == 1; } - ); - if(next_idx_iter != rem.end()) { - size_t prev_stride_times_prev_extent = - this->extents().extent(*next_idx_iter) * this->stride(*next_idx_iter); - // "remove" the index - constexpr auto removed_index_sentinel = static_cast(-1); - *next_idx_iter = removed_index_sentinel; - size_t found_count = 1; - while (found_count != Extents::rank()) { - next_idx_iter = std::find_if( - rem.begin(), rem.end(), - [&](size_t i) { - return i != removed_index_sentinel - && static_cast(this->extents().extent(i)) == prev_stride_times_prev_extent; - } - ); - if (next_idx_iter != rem.end()) { - // "remove" the index - *next_idx_iter = removed_index_sentinel; - ++found_count; - prev_stride_times_prev_extent = stride(*next_idx_iter) * this->extents().extent(*next_idx_iter); - } else { break; } - } - return found_count == Extents::rank(); - } - return false; -#endif - } - MDSPAN_INLINE_FUNCTION static constexpr bool is_strided() noexcept { return true; } - - - MDSPAN_INLINE_FUNCTION - constexpr index_type stride(rank_type r) const noexcept { - return __strides_storage()[r]; - } - -#if !(defined(_MDSPAN_USE_CONCEPTS) && MDSPAN_HAS_CXX_20) - MDSPAN_TEMPLATE_REQUIRES( - class StridedLayoutMapping, - /* requires */ ( - detail::__is_mapping_of && - (extents_type::rank() == StridedLayoutMapping::extents_type::rank()) && - StridedLayoutMapping::is_always_strided() - ) - ) -#else - template - requires( - detail::__layout_mapping_alike && - (extents_type::rank() == StridedLayoutMapping::extents_type::rank()) && - StridedLayoutMapping::is_always_strided() - ) -#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(0)) && - strides_match; - } - - // This one is not technically part of the proposal. Just here to make implementation a bit more optimal hopefully - MDSPAN_TEMPLATE_REQUIRES( - class OtherExtents, - /* requires */ ( - (extents_type::rank() == OtherExtents::rank()) - ) - ) - MDSPAN_INLINE_FUNCTION - friend constexpr bool operator==(mapping const& lhs, mapping const& rhs) noexcept { - return __impl::_eq_impl(lhs, rhs); - } - -#if !MDSPAN_HAS_CXX_20 - MDSPAN_TEMPLATE_REQUIRES( - class StridedLayoutMapping, - /* requires */ ( - detail::__is_mapping_of && - (extents_type::rank() == StridedLayoutMapping::extents_type::rank()) && - StridedLayoutMapping::is_always_strided() - ) - ) - MDSPAN_INLINE_FUNCTION - friend constexpr bool operator!=(const mapping& x, const StridedLayoutMapping& y) noexcept { - return not (x == y); - } - - MDSPAN_TEMPLATE_REQUIRES( - class OtherExtents, - /* requires */ ( - (extents_type::rank() == OtherExtents::rank()) - ) - ) - MDSPAN_INLINE_FUNCTION - friend constexpr bool operator!=(mapping const& lhs, mapping const& rhs) noexcept { - return __impl::_not_eq_impl(lhs, rhs); - } -#endif - - }; -}; - -} // end namespace experimental -} // end namespace std diff --git a/src/mdspan/__p0009_bits/macros.hpp b/src/mdspan/__p0009_bits/macros.hpp deleted file mode 100644 index d649691..0000000 --- a/src/mdspan/__p0009_bits/macros.hpp +++ /dev/null @@ -1,619 +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 - -#include "config.hpp" - -#include // std::is_void - -#ifndef _MDSPAN_HOST_DEVICE -# if defined(_MDSPAN_HAS_CUDA) || defined(_MDSPAN_HAS_HIP) -# define _MDSPAN_HOST_DEVICE __host__ __device__ -# else -# define _MDSPAN_HOST_DEVICE -# endif -#endif - -#ifndef MDSPAN_FORCE_INLINE_FUNCTION -# ifdef _MDSPAN_COMPILER_MSVC // Microsoft compilers -# define MDSPAN_FORCE_INLINE_FUNCTION __forceinline _MDSPAN_HOST_DEVICE -# else -# define MDSPAN_FORCE_INLINE_FUNCTION __attribute__((always_inline)) _MDSPAN_HOST_DEVICE -# endif -#endif - -#ifndef MDSPAN_INLINE_FUNCTION -# define MDSPAN_INLINE_FUNCTION inline _MDSPAN_HOST_DEVICE -#endif - -// In CUDA defaulted functions do not need host device markup -#ifndef MDSPAN_INLINE_FUNCTION_DEFAULTED -# define MDSPAN_INLINE_FUNCTION_DEFAULTED -#endif - -//============================================================================== -// {{{1 - -#define MDSPAN_PP_COUNT(...) \ - _MDSPAN_PP_INTERNAL_EXPAND_ARGS_PRIVATE( \ - _MDSPAN_PP_INTERNAL_ARGS_AUGMENTER(__VA_ARGS__) \ - ) - -#define _MDSPAN_PP_INTERNAL_ARGS_AUGMENTER(...) unused, __VA_ARGS__ -#define _MDSPAN_PP_INTERNAL_EXPAND(x) x -#define _MDSPAN_PP_INTERNAL_EXPAND_ARGS_PRIVATE(...) \ - _MDSPAN_PP_INTERNAL_EXPAND( \ - _MDSPAN_PP_INTERNAL_COUNT_PRIVATE( \ - __VA_ARGS__, 69, 68, 67, 66, 65, 64, 63, 62, 61, \ - 60, 59, 58, 57, 56, 55, 54, 53, 52, 51, 50, 49, \ - 48, 47, 46, 45, 44, 43, 42, 41, 40, 39, 38, 37, \ - 36, 35, 34, 33, 32, 31, 30, 29, 28, 27, 26, 25, \ - 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, \ - 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0 \ - ) \ - ) -# define _MDSPAN_PP_INTERNAL_COUNT_PRIVATE( \ - _1_, _2_, _3_, _4_, _5_, _6_, _7_, _8_, _9_, \ - _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, \ - _20, _21, _22, _23, _24, _25, _26, _27, _28, _29, \ - _30, _31, _32, _33, _34, _35, _36, _37, _38, _39, \ - _40, _41, _42, _43, _44, _45, _46, _47, _48, _49, \ - _50, _51, _52, _53, _54, _55, _56, _57, _58, _59, \ - _60, _61, _62, _63, _64, _65, _66, _67, _68, _69, \ - _70, count, ...) count \ - /**/ - -#define MDSPAN_PP_STRINGIFY_IMPL(x) #x -#define MDSPAN_PP_STRINGIFY(x) MDSPAN_PP_STRINGIFY_IMPL(x) - -#define MDSPAN_PP_CAT_IMPL(x, y) x ## y -#define MDSPAN_PP_CAT(x, y) MDSPAN_PP_CAT_IMPL(x, y) - -#define MDSPAN_PP_EVAL(X, ...) X(__VA_ARGS__) - -#define MDSPAN_PP_REMOVE_PARENS_IMPL(...) __VA_ARGS__ -#define MDSPAN_PP_REMOVE_PARENS(...) MDSPAN_PP_REMOVE_PARENS_IMPL __VA_ARGS__ - -// end Preprocessor helpers }}}1 -//============================================================================== - -//============================================================================== -// {{{1 - -// These compatibility macros don't help with partial ordering, but they should do the trick -// for what we need to do with concepts in mdspan -#ifdef _MDSPAN_USE_CONCEPTS -# define MDSPAN_CLOSE_ANGLE_REQUIRES(REQ) > requires REQ -# define MDSPAN_FUNCTION_REQUIRES(PAREN_PREQUALS, FNAME, PAREN_PARAMS, QUALS, REQ) \ - MDSPAN_PP_REMOVE_PARENS(PAREN_PREQUALS) FNAME PAREN_PARAMS QUALS requires REQ \ - /**/ -#else -# define MDSPAN_CLOSE_ANGLE_REQUIRES(REQ) , typename ::std::enable_if<(REQ), int>::type = 0> -# define MDSPAN_FUNCTION_REQUIRES(PAREN_PREQUALS, FNAME, PAREN_PARAMS, QUALS, REQ) \ - MDSPAN_TEMPLATE_REQUIRES( \ - class __function_requires_ignored=void, \ - (std::is_void<__function_requires_ignored>::value && REQ) \ - ) MDSPAN_PP_REMOVE_PARENS(PAREN_PREQUALS) FNAME PAREN_PARAMS QUALS \ - /**/ -#endif - - -#if defined(_MDSPAN_COMPILER_MSVC) -# define MDSPAN_TEMPLATE_REQUIRES(...) \ - MDSPAN_PP_CAT( \ - MDSPAN_PP_CAT(MDSPAN_TEMPLATE_REQUIRES_, MDSPAN_PP_COUNT(__VA_ARGS__))\ - (__VA_ARGS__), \ - ) \ - /**/ -#else -# define MDSPAN_TEMPLATE_REQUIRES(...) \ - MDSPAN_PP_EVAL( \ - MDSPAN_PP_CAT(MDSPAN_TEMPLATE_REQUIRES_, MDSPAN_PP_COUNT(__VA_ARGS__)), \ - __VA_ARGS__ \ - ) \ - /**/ -#endif - -#define MDSPAN_TEMPLATE_REQUIRES_2(TP1, REQ) \ - template end Concept emulation }}}1 -//============================================================================== - -//============================================================================== -// {{{1 - -#ifdef _MDSPAN_USE_INLINE_VARIABLES -# define _MDSPAN_INLINE_VARIABLE inline -#else -# define _MDSPAN_INLINE_VARIABLE -#endif - -// end inline variables }}}1 -//============================================================================== - -//============================================================================== -// {{{1 - -#if _MDSPAN_USE_RETURN_TYPE_DEDUCTION -# define _MDSPAN_DEDUCE_RETURN_TYPE_SINGLE_LINE(SIGNATURE, BODY) \ - auto MDSPAN_PP_REMOVE_PARENS(SIGNATURE) { return MDSPAN_PP_REMOVE_PARENS(BODY); } -# define _MDSPAN_DEDUCE_DECLTYPE_AUTO_RETURN_TYPE_SINGLE_LINE(SIGNATURE, BODY) \ - decltype(auto) MDSPAN_PP_REMOVE_PARENS(SIGNATURE) { return MDSPAN_PP_REMOVE_PARENS(BODY); } -#else -# define _MDSPAN_DEDUCE_RETURN_TYPE_SINGLE_LINE(SIGNATURE, BODY) \ - auto MDSPAN_PP_REMOVE_PARENS(SIGNATURE) \ - -> std::remove_cv_t> \ - { return MDSPAN_PP_REMOVE_PARENS(BODY); } -# define _MDSPAN_DEDUCE_DECLTYPE_AUTO_RETURN_TYPE_SINGLE_LINE(SIGNATURE, BODY) \ - auto MDSPAN_PP_REMOVE_PARENS(SIGNATURE) \ - -> decltype(BODY) \ - { return MDSPAN_PP_REMOVE_PARENS(BODY); } - -#endif - -// end Return type deduction }}}1 -//============================================================================== - -//============================================================================== -// {{{1 - -struct __mdspan_enable_fold_comma { }; - -#ifdef _MDSPAN_USE_FOLD_EXPRESSIONS -# define _MDSPAN_FOLD_AND(...) ((__VA_ARGS__) && ...) -# define _MDSPAN_FOLD_AND_TEMPLATE(...) ((__VA_ARGS__) && ...) -# define _MDSPAN_FOLD_OR(...) ((__VA_ARGS__) || ...) -# define _MDSPAN_FOLD_ASSIGN_LEFT(INIT, ...) (INIT = ... = (__VA_ARGS__)) -# define _MDSPAN_FOLD_ASSIGN_RIGHT(PACK, ...) (PACK = ... = (__VA_ARGS__)) -# define _MDSPAN_FOLD_TIMES_RIGHT(PACK, ...) (PACK * ... * (__VA_ARGS__)) -# define _MDSPAN_FOLD_PLUS_RIGHT(PACK, ...) (PACK + ... + (__VA_ARGS__)) -# define _MDSPAN_FOLD_COMMA(...) ((__VA_ARGS__), ...) -#else - -namespace std { - -namespace __fold_compatibility_impl { - -// We could probably be more clever here, but at the (small) risk of losing some compiler understanding. For the -// few operations we need, it's not worth generalizing over the operation - -#if _MDSPAN_USE_RETURN_TYPE_DEDUCTION - -MDSPAN_FORCE_INLINE_FUNCTION -constexpr decltype(auto) __fold_right_and_impl() { - return true; -} - -template -MDSPAN_FORCE_INLINE_FUNCTION -constexpr decltype(auto) __fold_right_and_impl(Arg&& arg, Args&&... args) { - return ((Arg&&)arg) && __fold_compatibility_impl::__fold_right_and_impl((Args&&)args...); -} - -MDSPAN_FORCE_INLINE_FUNCTION -constexpr decltype(auto) __fold_right_or_impl() { - return false; -} - -template -MDSPAN_FORCE_INLINE_FUNCTION -constexpr auto __fold_right_or_impl(Arg&& arg, Args&&... args) { - return ((Arg&&)arg) || __fold_compatibility_impl::__fold_right_or_impl((Args&&)args...); -} - -template -MDSPAN_FORCE_INLINE_FUNCTION -constexpr auto __fold_left_assign_impl(Arg1&& arg1) { - return (Arg1&&)arg1; -} - -template -MDSPAN_FORCE_INLINE_FUNCTION -constexpr auto __fold_left_assign_impl(Arg1&& arg1, Arg2&& arg2, Args&&... args) { - return __fold_compatibility_impl::__fold_left_assign_impl((((Arg1&&)arg1) = ((Arg2&&)arg2)), (Args&&)args...); -} - -template -MDSPAN_FORCE_INLINE_FUNCTION -constexpr auto __fold_right_assign_impl(Arg1&& arg1) { - return (Arg1&&)arg1; -} - -template -MDSPAN_FORCE_INLINE_FUNCTION -constexpr auto __fold_right_assign_impl(Arg1&& arg1, Arg2&& arg2, Args&&... args) { - return ((Arg1&&)arg1) = __fold_compatibility_impl::__fold_right_assign_impl((Arg2&&)arg2, (Args&&)args...); -} - -template -MDSPAN_FORCE_INLINE_FUNCTION -constexpr auto __fold_right_plus_impl(Arg1&& arg1) { - return (Arg1&&)arg1; -} - -template -MDSPAN_FORCE_INLINE_FUNCTION -constexpr auto __fold_right_plus_impl(Arg1&& arg1, Arg2&& arg2, Args&&... args) { - return ((Arg1&&)arg1) + __fold_compatibility_impl::__fold_right_plus_impl((Arg2&&)arg2, (Args&&)args...); -} - -template -MDSPAN_FORCE_INLINE_FUNCTION -constexpr auto __fold_right_times_impl(Arg1&& arg1) { - return (Arg1&&)arg1; -} - -template -MDSPAN_FORCE_INLINE_FUNCTION -constexpr auto __fold_right_times_impl(Arg1&& arg1, Arg2&& arg2, Args&&... args) { - return ((Arg1&&)arg1) * __fold_compatibility_impl::__fold_right_times_impl((Arg2&&)arg2, (Args&&)args...); -} - -#else - -//------------------------------------------------------------------------------ -// {{{2 - -template -struct __fold_right_and_impl_; -template <> -struct __fold_right_and_impl_<> { - using __rv = bool; - MDSPAN_FORCE_INLINE_FUNCTION - static constexpr __rv - __impl() noexcept { - return true; - } -}; -template -struct __fold_right_and_impl_ { - using __next_t = __fold_right_and_impl_; - using __rv = decltype(std::declval() && std::declval()); - MDSPAN_FORCE_INLINE_FUNCTION - static constexpr __rv - __impl(Arg&& arg, Args&&... args) noexcept { - return ((Arg&&)arg) && __next_t::__impl((Args&&)args...); - } -}; - -template -MDSPAN_FORCE_INLINE_FUNCTION -constexpr typename __fold_right_and_impl_::__rv -__fold_right_and_impl(Args&&... args) { - return __fold_right_and_impl_::__impl((Args&&)args...); -} - -// end right and }}}2 -//------------------------------------------------------------------------------ - -//------------------------------------------------------------------------------ -// {{{2 - -template -struct __fold_right_or_impl_; -template <> -struct __fold_right_or_impl_<> { - using __rv = bool; - MDSPAN_FORCE_INLINE_FUNCTION - static constexpr __rv - __impl() noexcept { - return false; - } -}; -template -struct __fold_right_or_impl_ { - using __next_t = __fold_right_or_impl_; - using __rv = decltype(std::declval() || std::declval()); - MDSPAN_FORCE_INLINE_FUNCTION - static constexpr __rv - __impl(Arg&& arg, Args&&... args) noexcept { - return ((Arg&&)arg) || __next_t::__impl((Args&&)args...); - } -}; - -template -MDSPAN_FORCE_INLINE_FUNCTION -constexpr typename __fold_right_or_impl_::__rv -__fold_right_or_impl(Args&&... args) { - return __fold_right_or_impl_::__impl((Args&&)args...); -} - -// end right or }}}2 -//------------------------------------------------------------------------------ - -//------------------------------------------------------------------------------ -// {{{2 - -template -struct __fold_right_plus_impl_; -template -struct __fold_right_plus_impl_ { - using __rv = Arg&&; - MDSPAN_FORCE_INLINE_FUNCTION - static constexpr __rv - __impl(Arg&& arg) noexcept { - return (Arg&&)arg; - } -}; -template -struct __fold_right_plus_impl_ { - using __next_t = __fold_right_plus_impl_; - using __rv = decltype(std::declval() + std::declval()); - MDSPAN_FORCE_INLINE_FUNCTION - static constexpr __rv - __impl(Arg1&& arg, Arg2&& arg2, Args&&... args) noexcept { - return ((Arg1&&)arg) + __next_t::__impl((Arg2&&)arg2, (Args&&)args...); - } -}; - -template -MDSPAN_FORCE_INLINE_FUNCTION -constexpr typename __fold_right_plus_impl_::__rv -__fold_right_plus_impl(Args&&... args) { - return __fold_right_plus_impl_::__impl((Args&&)args...); -} - -// end right plus }}}2 -//------------------------------------------------------------------------------ - -//------------------------------------------------------------------------------ -// {{{2 - -template -struct __fold_right_times_impl_; -template -struct __fold_right_times_impl_ { - using __rv = Arg&&; - MDSPAN_FORCE_INLINE_FUNCTION - static constexpr __rv - __impl(Arg&& arg) noexcept { - return (Arg&&)arg; - } -}; -template -struct __fold_right_times_impl_ { - using __next_t = __fold_right_times_impl_; - using __rv = decltype(std::declval() * std::declval()); - MDSPAN_FORCE_INLINE_FUNCTION - static constexpr __rv - __impl(Arg1&& arg, Arg2&& arg2, Args&&... args) noexcept { - return ((Arg1&&)arg) * __next_t::__impl((Arg2&&)arg2, (Args&&)args...); - } -}; - -template -MDSPAN_FORCE_INLINE_FUNCTION -constexpr typename __fold_right_times_impl_::__rv -__fold_right_times_impl(Args&&... args) { - return __fold_right_times_impl_::__impl((Args&&)args...); -} - -// end right times }}}2 -//------------------------------------------------------------------------------ - -//------------------------------------------------------------------------------ -// {{{2 - -template -struct __fold_right_assign_impl_; -template -struct __fold_right_assign_impl_ { - using __rv = Arg&&; - MDSPAN_FORCE_INLINE_FUNCTION - static constexpr __rv - __impl(Arg&& arg) noexcept { - return (Arg&&)arg; - } -}; -template -struct __fold_right_assign_impl_ { - using __next_t = __fold_right_assign_impl_; - using __rv = decltype(std::declval() = std::declval()); - MDSPAN_FORCE_INLINE_FUNCTION - static constexpr __rv - __impl(Arg1&& arg, Arg2&& arg2, Args&&... args) noexcept { - return ((Arg1&&)arg) = __next_t::__impl((Arg2&&)arg2, (Args&&)args...); - } -}; - -template -MDSPAN_FORCE_INLINE_FUNCTION -constexpr typename __fold_right_assign_impl_::__rv -__fold_right_assign_impl(Args&&... args) { - return __fold_right_assign_impl_::__impl((Args&&)args...); -} - -// end right assign }}}2 -//------------------------------------------------------------------------------ - -//------------------------------------------------------------------------------ -// {{{2 - -template -struct __fold_left_assign_impl_; -template -struct __fold_left_assign_impl_ { - using __rv = Arg&&; - MDSPAN_FORCE_INLINE_FUNCTION - static constexpr __rv - __impl(Arg&& arg) noexcept { - return (Arg&&)arg; - } -}; -template -struct __fold_left_assign_impl_ { - using __assign_result_t = decltype(std::declval() = std::declval()); - using __next_t = __fold_left_assign_impl_<__assign_result_t, Args...>; - using __rv = typename __next_t::__rv; - MDSPAN_FORCE_INLINE_FUNCTION - static constexpr __rv - __impl(Arg1&& arg, Arg2&& arg2, Args&&... args) noexcept { - return __next_t::__impl(((Arg1&&)arg) = (Arg2&&)arg2, (Args&&)args...); - } -}; - -template -MDSPAN_FORCE_INLINE_FUNCTION -constexpr typename __fold_left_assign_impl_::__rv -__fold_left_assign_impl(Args&&... args) { - return __fold_left_assign_impl_::__impl((Args&&)args...); -} - -// end left assign }}}2 -//------------------------------------------------------------------------------ - -#endif - - -template -constexpr __mdspan_enable_fold_comma __fold_comma_impl(Args&&... args) noexcept { return { }; } - -template -struct __bools; - -} // __fold_compatibility_impl - -} // end namespace std - -# 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) - -#endif - -// end fold expressions }}}1 -//============================================================================== - -//============================================================================== -// {{{1 - -#if _MDSPAN_USE_VARIABLE_TEMPLATES -# define _MDSPAN_TRAIT(TRAIT, ...) TRAIT##_v<__VA_ARGS__> -#else -# define _MDSPAN_TRAIT(TRAIT, ...) TRAIT<__VA_ARGS__>::value -#endif - -// end Variable template compatibility }}}1 -//============================================================================== - -//============================================================================== -// {{{1 - -#if _MDSPAN_USE_CONSTEXPR_14 -# define _MDSPAN_CONSTEXPR_14 constexpr -// Workaround for a bug (I think?) in EDG frontends -# ifdef __EDG__ -# define _MDSPAN_CONSTEXPR_14_DEFAULTED -# else -# define _MDSPAN_CONSTEXPR_14_DEFAULTED constexpr -# endif -#else -# define _MDSPAN_CONSTEXPR_14 -# define _MDSPAN_CONSTEXPR_14_DEFAULTED -#endif - -// end Pre-C++14 constexpr }}}1 -//============================================================================== diff --git a/src/mdspan/__p0009_bits/maybe_static_value.hpp b/src/mdspan/__p0009_bits/maybe_static_value.hpp deleted file mode 100644 index 5e4437f..0000000 --- a/src/mdspan/__p0009_bits/maybe_static_value.hpp +++ /dev/null @@ -1,124 +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 -#include "macros.hpp" - -#include "dynamic_extent.hpp" - -#if !defined(_MDSPAN_USE_ATTRIBUTE_NO_UNIQUE_ADDRESS) -# include "no_unique_address.hpp" -#endif - -// This is only needed for the non-standard-layout version of partially -// static array. -// Needs to be after the includes above to work with the single header generator -#if !_MDSPAN_PRESERVE_STANDARD_LAYOUT -namespace std { -namespace experimental { - -//============================================================================== - -namespace detail { - -// static case -template -struct __maybe_static_value { - static constexpr _static_t __static_value = __v; - MDSPAN_FORCE_INLINE_FUNCTION constexpr _dynamic_t __value() const noexcept { - return static_cast<_dynamic_t>(__v); - } - template - MDSPAN_FORCE_INLINE_FUNCTION _MDSPAN_CONSTEXPR_14 - __mdspan_enable_fold_comma - __set_value(_U&& /*__rhs*/) noexcept { - // Should we assert that the value matches the static value here? - return {}; - } - - //-------------------------------------------------------------------------- - - MDSPAN_INLINE_FUNCTION_DEFAULTED - constexpr __maybe_static_value() noexcept = default; - MDSPAN_INLINE_FUNCTION_DEFAULTED - constexpr __maybe_static_value(__maybe_static_value const&) noexcept = default; - MDSPAN_INLINE_FUNCTION_DEFAULTED - constexpr __maybe_static_value(__maybe_static_value&&) noexcept = default; - MDSPAN_INLINE_FUNCTION_DEFAULTED - _MDSPAN_CONSTEXPR_14_DEFAULTED __maybe_static_value& operator=(__maybe_static_value const&) noexcept = default; - MDSPAN_INLINE_FUNCTION_DEFAULTED - _MDSPAN_CONSTEXPR_14_DEFAULTED __maybe_static_value& operator=(__maybe_static_value&&) noexcept = default; - MDSPAN_INLINE_FUNCTION_DEFAULTED - ~__maybe_static_value() noexcept = default; - - MDSPAN_INLINE_FUNCTION - constexpr explicit __maybe_static_value(_dynamic_t const&) noexcept { - // Should we assert that the value matches the static value here? - } - - //-------------------------------------------------------------------------- - -}; - -// dynamic case -template -struct __maybe_static_value<_dynamic_t, _static_t, __is_dynamic_sentinal, __is_dynamic_sentinal, - __array_entry_index> -#if !defined(_MDSPAN_USE_ATTRIBUTE_NO_UNIQUE_ADDRESS) - : __no_unique_address_emulation<_T> -#endif -{ - static constexpr _static_t __static_value = __is_dynamic_sentinal; -#if defined(_MDSPAN_USE_ATTRIBUTE_NO_UNIQUE_ADDRESS) - _MDSPAN_NO_UNIQUE_ADDRESS _dynamic_t __v = {}; - MDSPAN_FORCE_INLINE_FUNCTION constexpr _dynamic_t __value() const noexcept { - return __v; - } - MDSPAN_FORCE_INLINE_FUNCTION _MDSPAN_CONSTEXPR_14 _dynamic_t &__ref() noexcept { - return __v; - } - template - MDSPAN_FORCE_INLINE_FUNCTION _MDSPAN_CONSTEXPR_14 - __mdspan_enable_fold_comma - __set_value(_U&& __rhs) noexcept { - __v = (_U &&)rhs; - return {}; - } -#else - MDSPAN_FORCE_INLINE_FUNCTION constexpr _dynamic_t __value() const noexcept { - return this->__no_unique_address_emulation<_dynamic_t>::__ref(); - } - MDSPAN_FORCE_INLINE_FUNCTION _MDSPAN_CONSTEXPR_14 _dynamic_t &__ref() noexcept { - return this->__no_unique_address_emulation<_dynamic_t>::__ref(); - } - template - MDSPAN_FORCE_INLINE_FUNCTION _MDSPAN_CONSTEXPR_14 - __mdspan_enable_fold_comma - __set_value(_U&& __rhs) noexcept { - this->__no_unique_address_emulation<_dynamic_t>::__ref() = (_U &&)__rhs; - return {}; - } -#endif -}; - -} // namespace detail - -//============================================================================== - -} // end namespace experimental -} // end namespace std - -#endif // !_MDSPAN_PRESERVE_STANDARD_LAYOUT diff --git a/src/mdspan/__p0009_bits/mdspan.hpp b/src/mdspan/__p0009_bits/mdspan.hpp deleted file mode 100644 index 23bffe2..0000000 --- a/src/mdspan/__p0009_bits/mdspan.hpp +++ /dev/null @@ -1,416 +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 - -#include "default_accessor.hpp" -#include "layout_right.hpp" -#include "extents.hpp" -#include "trait_backports.hpp" -#include "compressed_pair.hpp" - -namespace std { -namespace experimental { - -template < - class ElementType, - class Extents, - class LayoutPolicy = layout_right, - class AccessorPolicy = default_accessor -> -class mdspan -{ -private: - static_assert(detail::__is_extents_v, "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 - struct __deduction_workaround; - - template - struct __deduction_workaround> - { - MDSPAN_FORCE_INLINE_FUNCTION static constexpr - size_t __size(mdspan const& __self) noexcept { - return _MDSPAN_FOLD_TIMES_RIGHT((__self.__mapping_ref().extents().template __extent()), /* * ... * */ size_t(1)); - } - MDSPAN_FORCE_INLINE_FUNCTION static constexpr - bool __empty(mdspan const& __self) noexcept { - return (__self.rank()>0) && _MDSPAN_FOLD_OR((__self.__mapping_ref().extents().template __extent()==index_type(0))); - } - template - MDSPAN_FORCE_INLINE_FUNCTION static constexpr - ReferenceType __callop(mdspan const& __self, const array& indices) noexcept { - return __self.__accessor_ref().access(__self.__ptr_ref(), __self.__mapping_ref()(indices[Idxs]...)); - } - }; - -public: - - //-------------------------------------------------------------------------------- - // Domain and codomain types - - using extents_type = Extents; - using layout_type = LayoutPolicy; - using accessor_type = AccessorPolicy; - using mapping_type = typename layout_type::template mapping; - using element_type = ElementType; - using value_type = remove_cv_t; - 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 data_handle_type = typename accessor_type::data_handle_type; - using reference = typename accessor_type::reference; - - MDSPAN_INLINE_FUNCTION static constexpr size_t rank() noexcept { return extents_type::rank(); } - MDSPAN_INLINE_FUNCTION static constexpr size_t rank_dynamic() noexcept { return extents_type::rank_dynamic(); } - MDSPAN_INLINE_FUNCTION static constexpr size_t static_extent(size_t r) noexcept { return extents_type::static_extent(r); } - MDSPAN_INLINE_FUNCTION constexpr index_type extent(size_t r) const noexcept { return __mapping_ref().extents().extent(r); }; - -private: - - // Can't use defaulted parameter in the __deduction_workaround template because of a bug in MSVC warning C4348. - using __impl = __deduction_workaround>; - - using __map_acc_pair_t = detail::__compressed_pair; - -public: - - //-------------------------------------------------------------------------------- - // [mdspan.basic.cons], mdspan constructors, assignment, and destructor - -#if !MDSPAN_HAS_CXX_20 - MDSPAN_INLINE_FUNCTION_DEFAULTED constexpr mdspan() = default; -#else - MDSPAN_INLINE_FUNCTION_DEFAULTED constexpr mdspan() - requires( - (rank_dynamic() > 0) && - _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; - MDSPAN_INLINE_FUNCTION_DEFAULTED constexpr mdspan(mdspan&&) = default; - - 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())) && - _MDSPAN_TRAIT(is_constructible, mapping_type, extents_type) && - _MDSPAN_TRAIT(is_default_constructible, accessor_type) - ) - ) - MDSPAN_INLINE_FUNCTION - explicit constexpr mdspan(data_handle_type p, SizeTypes... dynamic_extents) - // TODO @proposal-bug shouldn't I be allowed to do `move(p)` here? - : __members(std::move(p), __map_acc_pair_t(mapping_type(extents_type(static_cast(std::move(dynamic_extents))...)), accessor_type())) - { } - - MDSPAN_TEMPLATE_REQUIRES( - class SizeType, size_t N, - /* requires */ ( - _MDSPAN_TRAIT(is_convertible, SizeType, index_type) && - _MDSPAN_TRAIT(is_nothrow_constructible, index_type, SizeType) && - ((N == rank()) || (N == rank_dynamic())) && - _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 array& dynamic_extents) - : __members(std::move(p), __map_acc_pair_t(mapping_type(extents_type(dynamic_extents)), accessor_type())) - { } - -#ifdef __cpp_lib_span - MDSPAN_TEMPLATE_REQUIRES( - class SizeType, size_t N, - /* requires */ ( - _MDSPAN_TRAIT(is_convertible, SizeType, index_type) && - _MDSPAN_TRAIT(is_nothrow_constructible, index_type, SizeType) && - ((N == rank()) || (N == rank_dynamic())) && - _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, span dynamic_extents) - : __members(std::move(p), __map_acc_pair_t(mapping_type(extents_type(as_const(dynamic_extents))), accessor_type())) - { } -#endif - - MDSPAN_FUNCTION_REQUIRES( - (MDSPAN_INLINE_FUNCTION constexpr), - mdspan, (data_handle_type p, const extents_type& exts), , - /* 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(is_default_constructible, accessor_type)) - ) : __members(std::move(p), __map_acc_pair_t(m, accessor_type())) - { } - - MDSPAN_INLINE_FUNCTION - constexpr mdspan(data_handle_type p, const mapping_type& m, const accessor_type& a) - : __members(std::move(p), __map_acc_pair_t(m, a)) - { } - - MDSPAN_TEMPLATE_REQUIRES( - class OtherElementType, class OtherExtents, class OtherLayoutPolicy, class OtherAccessor, - /* requires */ ( - _MDSPAN_TRAIT(is_constructible, mapping_type, typename OtherLayoutPolicy::template mapping) && - _MDSPAN_TRAIT(is_constructible, accessor_type, OtherAccessor) - ) - ) - MDSPAN_INLINE_FUNCTION - constexpr mdspan(const mdspan& other) - : __members(other.__ptr_ref(), __map_acc_pair_t(other.__mapping_ref(), other.__accessor_ref())) - { - 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. - */ - } - - /* Might need this on NVIDIA? - MDSPAN_INLINE_FUNCTION_DEFAULTED - ~mdspan() = default; - */ - - MDSPAN_INLINE_FUNCTION_DEFAULTED _MDSPAN_CONSTEXPR_14_DEFAULTED mdspan& operator=(const mdspan&) = default; - MDSPAN_INLINE_FUNCTION_DEFAULTED _MDSPAN_CONSTEXPR_14_DEFAULTED mdspan& operator=(mdspan&&) = default; - - - //-------------------------------------------------------------------------------- - // [mdspan.basic.mapping], mdspan mapping domain multidimensional index to access codomain element - - #if MDSPAN_USE_BRACKET_OPERATOR - 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) /* && ... */) && - (rank() == sizeof...(SizeTypes)) - ) - ) - MDSPAN_FORCE_INLINE_FUNCTION - constexpr reference operator[](SizeTypes... indices) const - { - return __accessor_ref().access(__ptr_ref(), __mapping_ref()(static_cast(std::move(indices))...)); - } - #endif - - MDSPAN_TEMPLATE_REQUIRES( - class SizeType, - /* requires */ ( - _MDSPAN_TRAIT(is_convertible, SizeType, index_type) && - _MDSPAN_TRAIT(is_nothrow_constructible, index_type, SizeType) - ) - ) - MDSPAN_FORCE_INLINE_FUNCTION - constexpr reference operator[](const array& indices) const - { - return __impl::template __callop(*this, indices); - } - - #ifdef __cpp_lib_span - MDSPAN_TEMPLATE_REQUIRES( - class SizeType, - /* requires */ ( - _MDSPAN_TRAIT(is_convertible, SizeType, index_type) && - _MDSPAN_TRAIT(is_nothrow_constructible, index_type, SizeType) - ) - ) - MDSPAN_FORCE_INLINE_FUNCTION - constexpr reference operator[](span indices) const - { - return __impl::template __callop(*this, indices); - } - #endif // __cpp_lib_span - - #if !MDSPAN_USE_BRACKET_OPERATOR - MDSPAN_TEMPLATE_REQUIRES( - class Index, - /* requires */ ( - _MDSPAN_TRAIT(is_convertible, Index, index_type) && - _MDSPAN_TRAIT(is_nothrow_constructible, index_type, Index) && - extents_type::rank() == 1 - ) - ) - MDSPAN_FORCE_INLINE_FUNCTION - constexpr reference operator[](Index idx) const - { - return __accessor_ref().access(__ptr_ref(), __mapping_ref()(static_cast(std::move(idx)))); - } - #endif - - #if MDSPAN_USE_PAREN_OPERATOR - 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) /* && ... */) && - extents_type::rank() == sizeof...(SizeTypes) - ) - ) - MDSPAN_FORCE_INLINE_FUNCTION - constexpr reference operator()(SizeTypes... indices) const - { - return __accessor_ref().access(__ptr_ref(), __mapping_ref()(static_cast(std::move(indices))...)); - } - - MDSPAN_TEMPLATE_REQUIRES( - class SizeType, - /* requires */ ( - _MDSPAN_TRAIT(is_convertible, SizeType, index_type) && - _MDSPAN_TRAIT(is_nothrow_constructible, index_type, SizeType) - ) - ) - MDSPAN_FORCE_INLINE_FUNCTION - constexpr reference operator()(const array& indices) const - { - return __impl::template __callop(*this, indices); - } - - #ifdef __cpp_lib_span - MDSPAN_TEMPLATE_REQUIRES( - class SizeType, - /* requires */ ( - _MDSPAN_TRAIT(is_convertible, SizeType, index_type) && - _MDSPAN_TRAIT(is_nothrow_constructible, index_type, SizeType) - ) - ) - MDSPAN_FORCE_INLINE_FUNCTION - constexpr reference operator()(span indices) const - { - return __impl::template __callop(*this, indices); - } - #endif // __cpp_lib_span - #endif // MDSPAN_USE_PAREN_OPERATOR - - MDSPAN_INLINE_FUNCTION constexpr size_t size() const noexcept { - return __impl::__size(*this); - }; - - MDSPAN_INLINE_FUNCTION constexpr bool empty() const noexcept { - return __impl::__empty(*this); - }; - - MDSPAN_INLINE_FUNCTION - friend constexpr void swap(mdspan& x, mdspan& y) noexcept { - swap(x.__ptr_ref(), y.__ptr_ref()); - swap(x.__mapping_ref(), y.__mapping_ref()); - swap(x.__accessor_ref(), y.__accessor_ref()); - } - - //-------------------------------------------------------------------------------- - // [mdspan.basic.domobs], mdspan observers of the domain multidimensional index space - - - MDSPAN_INLINE_FUNCTION constexpr const extents_type& extents() const noexcept { return __mapping_ref().extents(); }; - MDSPAN_INLINE_FUNCTION constexpr const data_handle_type& data_handle() const noexcept { return __ptr_ref(); }; - MDSPAN_INLINE_FUNCTION constexpr const mapping_type& mapping() const noexcept { return __mapping_ref(); }; - MDSPAN_INLINE_FUNCTION constexpr const accessor_type& accessor() const noexcept { return __accessor_ref(); }; - - //-------------------------------------------------------------------------------- - // [mdspan.basic.obs], mdspan observers of the mapping - - 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 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: - - detail::__compressed_pair __members{}; - - MDSPAN_FORCE_INLINE_FUNCTION _MDSPAN_CONSTEXPR_14 data_handle_type& __ptr_ref() noexcept { return __members.__first(); } - MDSPAN_FORCE_INLINE_FUNCTION constexpr data_handle_type const& __ptr_ref() const noexcept { return __members.__first(); } - MDSPAN_FORCE_INLINE_FUNCTION _MDSPAN_CONSTEXPR_14 mapping_type& __mapping_ref() noexcept { return __members.__second().__first(); } - MDSPAN_FORCE_INLINE_FUNCTION constexpr mapping_type const& __mapping_ref() const noexcept { return __members.__second().__first(); } - MDSPAN_FORCE_INLINE_FUNCTION _MDSPAN_CONSTEXPR_14 accessor_type& __accessor_ref() noexcept { return __members.__second().__second(); } - MDSPAN_FORCE_INLINE_FUNCTION constexpr accessor_type const& __accessor_ref() const noexcept { return __members.__second().__second(); } - - template - friend class mdspan; - -}; - -#if defined(_MDSPAN_USE_CLASS_TEMPLATE_ARGUMENT_DEDUCTION) -MDSPAN_TEMPLATE_REQUIRES( - class ElementType, class... SizeTypes, - /* requires */ _MDSPAN_FOLD_AND(_MDSPAN_TRAIT(is_integral, SizeTypes) /* && ... */) && - (sizeof...(SizeTypes) > 0) -) -explicit mdspan(ElementType*, SizeTypes...) - -> mdspan>; - -MDSPAN_TEMPLATE_REQUIRES( - class Pointer, - (_MDSPAN_TRAIT(is_pointer, std::remove_reference_t)) -) -mdspan(Pointer&&) -> mdspan>, extents>; - -MDSPAN_TEMPLATE_REQUIRES( - class CArray, - (_MDSPAN_TRAIT(is_array, CArray) && (rank_v == 1)) -) -mdspan(CArray&) -> mdspan, extents>>; - -template -mdspan(ElementType*, const ::std::array&) - -> mdspan>; - -#ifdef __cpp_lib_span -template -mdspan(ElementType*, ::std::span) - -> mdspan>; -#endif - -// This one is necessary because all the constructors take `data_handle_type`s, not -// `ElementType*`s, and `data_handle_type` is taken from `accessor_type::data_handle_type`, which -// seems to throw off automatic deduction guides. -template -mdspan(ElementType*, const extents&) - -> mdspan>; - -template -mdspan(ElementType*, const MappingType&) - -> mdspan; - -template -mdspan(const typename AccessorType::data_handle_type, const MappingType&, const AccessorType&) - -> mdspan; -#endif - - - -} // end namespace experimental -} // end namespace std diff --git a/src/mdspan/__p0009_bits/no_unique_address.hpp b/src/mdspan/__p0009_bits/no_unique_address.hpp deleted file mode 100644 index 7e4c5f8..0000000 --- a/src/mdspan/__p0009_bits/no_unique_address.hpp +++ /dev/null @@ -1,99 +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 - -#include "macros.hpp" -#include "trait_backports.hpp" - -namespace std { -namespace experimental { -namespace detail { - -//============================================================================== - -template -struct __no_unique_address_emulation { - using __stored_type = _T; - _T __v; - MDSPAN_FORCE_INLINE_FUNCTION constexpr _T const &__ref() const noexcept { - return __v; - } - MDSPAN_FORCE_INLINE_FUNCTION _MDSPAN_CONSTEXPR_14 _T &__ref() noexcept { - return __v; - } -}; - -// Empty case -// This doesn't work if _T is final, of course, but we're not using anything -// like that currently. That kind of thing could be added pretty easily though -template -struct __no_unique_address_emulation< - _T, _Disambiguator, - 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(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 - // 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. - private -#endif - _T { - using __stored_type = _T; - MDSPAN_FORCE_INLINE_FUNCTION constexpr _T const &__ref() const noexcept { - return *static_cast<_T const *>(this); - } - MDSPAN_FORCE_INLINE_FUNCTION _MDSPAN_CONSTEXPR_14 _T &__ref() noexcept { - return *static_cast<_T *>(this); - } - - MDSPAN_INLINE_FUNCTION_DEFAULTED - constexpr __no_unique_address_emulation() noexcept = default; - MDSPAN_INLINE_FUNCTION_DEFAULTED - constexpr __no_unique_address_emulation( - __no_unique_address_emulation const &) noexcept = default; - MDSPAN_INLINE_FUNCTION_DEFAULTED - constexpr __no_unique_address_emulation( - __no_unique_address_emulation &&) noexcept = default; - MDSPAN_INLINE_FUNCTION_DEFAULTED - _MDSPAN_CONSTEXPR_14_DEFAULTED __no_unique_address_emulation & - operator=(__no_unique_address_emulation const &) noexcept = default; - MDSPAN_INLINE_FUNCTION_DEFAULTED - _MDSPAN_CONSTEXPR_14_DEFAULTED __no_unique_address_emulation & - operator=(__no_unique_address_emulation &&) noexcept = default; - MDSPAN_INLINE_FUNCTION_DEFAULTED - ~__no_unique_address_emulation() noexcept = default; - - // Explicitly make this not a reference so that the copy or move - // constructor still gets called. - MDSPAN_INLINE_FUNCTION - explicit constexpr __no_unique_address_emulation(_T const& __v) noexcept : _T(__v) {} - MDSPAN_INLINE_FUNCTION - explicit constexpr __no_unique_address_emulation(_T&& __v) noexcept : _T(::std::move(__v)) {} -}; - -//============================================================================== - -} // end namespace detail -} // end namespace experimental -} // end namespace std diff --git a/src/mdspan/__p0009_bits/standard_layout_static_array.hpp b/src/mdspan/__p0009_bits/standard_layout_static_array.hpp deleted file mode 100644 index c515ccc..0000000 --- a/src/mdspan/__p0009_bits/standard_layout_static_array.hpp +++ /dev/null @@ -1,657 +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 - -#include "macros.hpp" -#include "dynamic_extent.hpp" -#include "trait_backports.hpp" // enable_if -#include "compressed_pair.hpp" - -#if !defined(_MDSPAN_USE_ATTRIBUTE_NO_UNIQUE_ADDRESS) -# include "no_unique_address.hpp" -#endif - -#include -#ifdef __cpp_lib_span -#include -#endif -#include // integer_sequence -#include - -namespace std { -namespace experimental { -namespace detail { - -//============================================================================== - -_MDSPAN_INLINE_VARIABLE constexpr struct - __construct_psa_from_dynamic_exts_values_tag_t { -} __construct_psa_from_dynamic_exts_values_tag = {}; - -_MDSPAN_INLINE_VARIABLE constexpr struct - __construct_psa_from_all_exts_values_tag_t { -} __construct_psa_from_all_exts_values_tag = {}; - -struct __construct_psa_from_all_exts_array_tag_t {}; -template struct __construct_psa_from_dynamic_exts_array_tag_t {}; - -//============================================================================== - -template using __repeated_with_idxs = _T; - -//============================================================================== - -#if _MDSPAN_PRESERVE_STANDARD_LAYOUT - -/** - * PSA = "partially static array" - * - * @tparam _T - * @tparam _ValsSeq - * @tparam __sentinal - */ -template (dynamic_extent), - class _IdxsSeq = make_index_sequence<_ValsSeq::size()>> -struct __standard_layout_psa; - -//============================================================================== -// Static case -template -struct __standard_layout_psa< - _Tag, _T, _static_t, integer_sequence<_static_t, __value, __values_or_sentinals...>, - __sentinal, integer_sequence> -#if !defined(_MDSPAN_USE_ATTRIBUTE_NO_UNIQUE_ADDRESS) - : private __no_unique_address_emulation<__standard_layout_psa< - _Tag, _T, _static_t, integer_sequence<_static_t, __values_or_sentinals...>, __sentinal, - integer_sequence>> -#endif -{ - - //-------------------------------------------------------------------------- - - using __next_t = - __standard_layout_psa<_Tag, _T, _static_t, - integer_sequence<_static_t, __values_or_sentinals...>, - __sentinal, integer_sequence>; - -#if defined(_MDSPAN_USE_ATTRIBUTE_NO_UNIQUE_ADDRESS) - _MDSPAN_NO_UNIQUE_ADDRESS __next_t __next_; -#else - using __base_t = __no_unique_address_emulation<__next_t>; -#endif - - MDSPAN_FORCE_INLINE_FUNCTION _MDSPAN_CONSTEXPR_14 __next_t &__next() noexcept { -#if defined(_MDSPAN_USE_ATTRIBUTE_NO_UNIQUE_ADDRESS) - return __next_; -#else - return this->__base_t::__ref(); -#endif - } - MDSPAN_FORCE_INLINE_FUNCTION constexpr __next_t const &__next() const noexcept { -#if defined(_MDSPAN_USE_ATTRIBUTE_NO_UNIQUE_ADDRESS) - return __next_; -#else - return this->__base_t::__ref(); -#endif - } - - static constexpr auto __size = sizeof...(_Idxs) + 1; - static constexpr auto __size_dynamic = __next_t::__size_dynamic; - - //-------------------------------------------------------------------------- - - MDSPAN_INLINE_FUNCTION_DEFAULTED - constexpr __standard_layout_psa() noexcept = default; - MDSPAN_INLINE_FUNCTION_DEFAULTED - constexpr __standard_layout_psa(__standard_layout_psa const &) noexcept = - default; - MDSPAN_INLINE_FUNCTION_DEFAULTED - constexpr __standard_layout_psa(__standard_layout_psa &&) noexcept = default; - MDSPAN_INLINE_FUNCTION_DEFAULTED - _MDSPAN_CONSTEXPR_14_DEFAULTED __standard_layout_psa & - operator=(__standard_layout_psa const &) noexcept = default; - MDSPAN_INLINE_FUNCTION_DEFAULTED - _MDSPAN_CONSTEXPR_14_DEFAULTED __standard_layout_psa & - operator=(__standard_layout_psa &&) noexcept = default; - MDSPAN_INLINE_FUNCTION_DEFAULTED - ~__standard_layout_psa() noexcept = default; - - //-------------------------------------------------------------------------- - - MDSPAN_INLINE_FUNCTION - constexpr __standard_layout_psa( - __construct_psa_from_all_exts_values_tag_t, _T const & /*__val*/, - __repeated_with_idxs<_Idxs, _T> const &... __vals) noexcept -#if defined(_MDSPAN_USE_ATTRIBUTE_NO_UNIQUE_ADDRESS) - : __next_{ -#else - : __base_t(__base_t{__next_t( -#endif - __construct_psa_from_all_exts_values_tag, __vals... -#if defined(_MDSPAN_USE_ATTRIBUTE_NO_UNIQUE_ADDRESS) - } -#else - )}) -#endif - { } - - template - MDSPAN_INLINE_FUNCTION constexpr __standard_layout_psa( - __construct_psa_from_dynamic_exts_values_tag_t, - _Ts const &... __vals) noexcept -#if defined(_MDSPAN_USE_ATTRIBUTE_NO_UNIQUE_ADDRESS) - : __next_{ -#else - : __base_t(__base_t{__next_t( -#endif - __construct_psa_from_dynamic_exts_values_tag, __vals... -#if defined(_MDSPAN_USE_ATTRIBUTE_NO_UNIQUE_ADDRESS) - } -#else - )}) -#endif - { } - - template - MDSPAN_INLINE_FUNCTION constexpr explicit __standard_layout_psa( - array<_U, _N> const &__vals) noexcept -#if defined(_MDSPAN_USE_ATTRIBUTE_NO_UNIQUE_ADDRESS) - : __next_{ -#else - : __base_t(__base_t{__next_t( -#endif - __vals -#if defined(_MDSPAN_USE_ATTRIBUTE_NO_UNIQUE_ADDRESS) - } -#else - )}) -#endif - { } - - template - MDSPAN_INLINE_FUNCTION constexpr explicit __standard_layout_psa( - __construct_psa_from_all_exts_array_tag_t const & __tag, - array<_U, _NStatic> const &__vals) noexcept -#if defined(_MDSPAN_USE_ATTRIBUTE_NO_UNIQUE_ADDRESS) - : __next_{ -#else - : __base_t(__base_t{__next_t( -#endif - __tag, __vals -#if defined(_MDSPAN_USE_ATTRIBUTE_NO_UNIQUE_ADDRESS) - } -#else - )}) -#endif - { } - - template - MDSPAN_INLINE_FUNCTION constexpr explicit __standard_layout_psa( - __construct_psa_from_dynamic_exts_array_tag_t<_IDynamic> __tag, - array<_U, _NDynamic> const &__vals) noexcept -#if defined(_MDSPAN_USE_ATTRIBUTE_NO_UNIQUE_ADDRESS) - : __next_{ -#else - : __base_t(__base_t{__next_t( -#endif - __tag, __vals -#if defined(_MDSPAN_USE_ATTRIBUTE_NO_UNIQUE_ADDRESS) - } -#else - )}) -#endif - { } - -#ifdef __cpp_lib_span - template - MDSPAN_INLINE_FUNCTION constexpr explicit __standard_layout_psa( - span<_U, _N> const &__vals) noexcept -#if defined(_MDSPAN_USE_ATTRIBUTE_NO_UNIQUE_ADDRESS) - : __next_{ -#else - : __base_t(__base_t{__next_t( -#endif - __vals -#if defined(_MDSPAN_USE_ATTRIBUTE_NO_UNIQUE_ADDRESS) - } -#else - )}) -#endif - { } - - template - MDSPAN_INLINE_FUNCTION constexpr explicit __standard_layout_psa( - __construct_psa_from_all_exts_array_tag_t const & __tag, - span<_U, _NStatic> const &__vals) noexcept -#if defined(_MDSPAN_USE_ATTRIBUTE_NO_UNIQUE_ADDRESS) - : __next_{ -#else - : __base_t(__base_t{__next_t( -#endif - __tag, __vals -#if defined(_MDSPAN_USE_ATTRIBUTE_NO_UNIQUE_ADDRESS) - } -#else - )}) -#endif - { } - - template - MDSPAN_INLINE_FUNCTION constexpr explicit __standard_layout_psa( - __construct_psa_from_dynamic_exts_array_tag_t<_IDynamic> __tag, - span<_U, _NDynamic> const &__vals) noexcept -#if defined(_MDSPAN_USE_ATTRIBUTE_NO_UNIQUE_ADDRESS) - : __next_{ -#else - : __base_t(__base_t{__next_t( -#endif - __tag, __vals -#if defined(_MDSPAN_USE_ATTRIBUTE_NO_UNIQUE_ADDRESS) - } -#else - )}) -#endif - { } -#endif - - template - MDSPAN_INLINE_FUNCTION constexpr __standard_layout_psa( - __standard_layout_psa<_UTag, _U, _static_U, _UValsSeq, __u_sentinal, _IdxsSeq> const - &__rhs) noexcept -#if defined(_MDSPAN_USE_ATTRIBUTE_NO_UNIQUE_ADDRESS) - : __next_{ -#else - : __base_t(__base_t{__next_t( -#endif - __rhs.__next() -#if defined(_MDSPAN_USE_ATTRIBUTE_NO_UNIQUE_ADDRESS) - } -#else - )}) -#endif - { } - - //-------------------------------------------------------------------------- - - // See https://godbolt.org/z/_KSDNX for a summary-by-example of why this is - // necessary. We're using inheritance here instead of an alias template - // because we have to deduce __values_or_sentinals in several places, and - // alias templates don't permit that in this context. - MDSPAN_FORCE_INLINE_FUNCTION - constexpr __standard_layout_psa const &__enable_psa_conversion() const - noexcept { - return *this; - } - - template = 0> - MDSPAN_FORCE_INLINE_FUNCTION constexpr _T __get_n() const noexcept { - return __next().template __get_n<_I>(); - } - template = 1> - MDSPAN_FORCE_INLINE_FUNCTION constexpr _T __get_n() const noexcept { - return __value; - } - template = 0> - MDSPAN_FORCE_INLINE_FUNCTION _MDSPAN_CONSTEXPR_14 void - __set_n(_T const &__rhs) noexcept { - __next().__set_value(__rhs); - } - template = 1> - MDSPAN_FORCE_INLINE_FUNCTION _MDSPAN_CONSTEXPR_14 void - __set_n(_T const &) noexcept { - // Don't assert here because that would break constexpr. This better - // not change anything, though - } - template = __sentinal> - MDSPAN_FORCE_INLINE_FUNCTION static constexpr _static_t __get_static_n() noexcept { - return __value; - } - template __default = __sentinal> - MDSPAN_FORCE_INLINE_FUNCTION static constexpr _static_t __get_static_n() noexcept { - return __next_t::template __get_static_n<_I, __default>(); - } - MDSPAN_FORCE_INLINE_FUNCTION constexpr _T __get(size_t __n) const noexcept { - return __value * (_T(_Idx == __n)) + __next().__get(__n); - } - - //-------------------------------------------------------------------------- -}; - -//============================================================================== - -// Dynamic case, __next_t may or may not be empty -template -struct __standard_layout_psa< - _Tag, _T, _static_t, integer_sequence<_static_t, __sentinal, __values_or_sentinals...>, - __sentinal, integer_sequence> { - //-------------------------------------------------------------------------- - - using __next_t = - __standard_layout_psa<_Tag, _T, _static_t, - integer_sequence<_static_t, __values_or_sentinals...>, - __sentinal, integer_sequence>; - - using __value_pair_t = __compressed_pair<_T, __next_t>; - __value_pair_t __value_pair; - MDSPAN_FORCE_INLINE_FUNCTION _MDSPAN_CONSTEXPR_14 __next_t &__next() noexcept { - return __value_pair.__second(); - } - MDSPAN_FORCE_INLINE_FUNCTION constexpr __next_t const &__next() const noexcept { - return __value_pair.__second(); - } - - static constexpr auto __size = sizeof...(_Idxs) + 1; - static constexpr auto __size_dynamic = 1 + __next_t::__size_dynamic; - - //-------------------------------------------------------------------------- - - MDSPAN_INLINE_FUNCTION_DEFAULTED - constexpr __standard_layout_psa() noexcept = default; - MDSPAN_INLINE_FUNCTION_DEFAULTED - constexpr __standard_layout_psa(__standard_layout_psa const &) noexcept = - default; - MDSPAN_INLINE_FUNCTION_DEFAULTED - constexpr __standard_layout_psa(__standard_layout_psa &&) noexcept = default; - MDSPAN_INLINE_FUNCTION_DEFAULTED - _MDSPAN_CONSTEXPR_14_DEFAULTED __standard_layout_psa & - operator=(__standard_layout_psa const &) noexcept = default; - MDSPAN_INLINE_FUNCTION_DEFAULTED - _MDSPAN_CONSTEXPR_14_DEFAULTED __standard_layout_psa & - operator=(__standard_layout_psa &&) noexcept = default; - MDSPAN_INLINE_FUNCTION_DEFAULTED - ~__standard_layout_psa() noexcept = default; - - //-------------------------------------------------------------------------- - - MDSPAN_INLINE_FUNCTION - constexpr __standard_layout_psa( - __construct_psa_from_all_exts_values_tag_t, _T const &__val, - __repeated_with_idxs<_Idxs, _T> const &... __vals) noexcept - : __value_pair(__val, - __next_t(__construct_psa_from_all_exts_values_tag, - __vals...)) {} - - template - MDSPAN_INLINE_FUNCTION constexpr __standard_layout_psa( - __construct_psa_from_dynamic_exts_values_tag_t, _T const &__val, - _Ts const &... __vals) noexcept - : __value_pair(__val, - __next_t(__construct_psa_from_dynamic_exts_values_tag, - __vals...)) {} - - template - MDSPAN_INLINE_FUNCTION constexpr explicit __standard_layout_psa( - array<_U, _N> const &__vals) noexcept - : __value_pair(::std::get<_Idx>(__vals), __vals) {} - - template - MDSPAN_INLINE_FUNCTION constexpr explicit __standard_layout_psa( - __construct_psa_from_all_exts_array_tag_t __tag, - array<_U, _NStatic> const &__vals) noexcept - : __value_pair( - ::std::get<_Idx>(__vals), - __next_t(__tag, - __vals)) {} - - template - MDSPAN_INLINE_FUNCTION constexpr explicit __standard_layout_psa( - __construct_psa_from_dynamic_exts_array_tag_t<_IDynamic>, - array<_U, _NDynamic> const &__vals) noexcept - : __value_pair( - ::std::get<_IDynamic>(__vals), - __next_t(__construct_psa_from_dynamic_exts_array_tag_t<_IDynamic + 1>{}, - __vals)) {} - -#ifdef __cpp_lib_span - template - MDSPAN_INLINE_FUNCTION constexpr explicit __standard_layout_psa( - span<_U, _N> const &__vals) noexcept - : __value_pair(__vals[_Idx], __vals) {} - - template - MDSPAN_INLINE_FUNCTION constexpr explicit __standard_layout_psa( - __construct_psa_from_all_exts_array_tag_t __tag, - span<_U, _NStatic> const &__vals) noexcept - : __value_pair( - __vals[_Idx], - __next_t(__tag, - __vals)) {} - - template - MDSPAN_INLINE_FUNCTION constexpr explicit __standard_layout_psa( - __construct_psa_from_dynamic_exts_array_tag_t<_IDynamic>, - span<_U, _NDynamic> const &__vals) noexcept - : __value_pair( - __vals[_IDynamic], - __next_t(__construct_psa_from_dynamic_exts_array_tag_t<_IDynamic + 1>{}, - __vals)) {} -#endif - - template - MDSPAN_INLINE_FUNCTION constexpr __standard_layout_psa( - __standard_layout_psa<_UTag, _U, _static_U, _UValsSeq, __u_sentinal, _UIdxsSeq> const - &__rhs) noexcept - : __value_pair(__rhs.template __get_n<_Idx>(), __rhs.__next()) {} - - //-------------------------------------------------------------------------- - - // See comment in the previous partial specialization for why this is - // necessary. Or just trust me that it's messy. - MDSPAN_FORCE_INLINE_FUNCTION - constexpr __standard_layout_psa const &__enable_psa_conversion() const - noexcept { - return *this; - } - - template = 0> - MDSPAN_FORCE_INLINE_FUNCTION constexpr _T __get_n() const noexcept { - return __next().template __get_n<_I>(); - } - template = 1> - MDSPAN_FORCE_INLINE_FUNCTION constexpr _T __get_n() const noexcept { - return __value_pair.__first(); - } - template = 0> - MDSPAN_FORCE_INLINE_FUNCTION _MDSPAN_CONSTEXPR_14 void - __set_n(_T const &__rhs) noexcept { - __next().__set_value(__rhs); - } - template = 1> - MDSPAN_FORCE_INLINE_FUNCTION _MDSPAN_CONSTEXPR_14 void - __set_n(_T const &__rhs) noexcept { - __value_pair.__first() = __rhs; - } - template __default = __sentinal> - MDSPAN_FORCE_INLINE_FUNCTION static constexpr _static_t __get_static_n() noexcept { - return __default; - } - template __default = __sentinal> - MDSPAN_FORCE_INLINE_FUNCTION static constexpr _static_t __get_static_n() noexcept { - return __next_t::template __get_static_n<_I, __default>(); - } - MDSPAN_FORCE_INLINE_FUNCTION constexpr _T __get(size_t __n) const noexcept { - return __value_pair.__first() * (_T(_Idx == __n)) + __next().__get(__n); - } - - //-------------------------------------------------------------------------- -}; - -// empty/terminal case -template -struct __standard_layout_psa<_Tag, _T, _static_t, integer_sequence<_static_t>, __sentinal, - integer_sequence> { - //-------------------------------------------------------------------------- - - static constexpr auto __size = 0; - static constexpr auto __size_dynamic = 0; - - //-------------------------------------------------------------------------- - - MDSPAN_INLINE_FUNCTION_DEFAULTED - constexpr __standard_layout_psa() noexcept -#if defined(__clang__) || defined(_MDSPAN_DEFAULTED_CONSTRUCTORS_INHERITANCE_WORKAROUND) - // As far as I can tell, there appears to be a bug in clang that's causing - // this to be non-constexpr when it's defaulted. - { } -#else - = default; -#endif - MDSPAN_INLINE_FUNCTION_DEFAULTED - constexpr __standard_layout_psa(__standard_layout_psa const &) noexcept = - default; - MDSPAN_INLINE_FUNCTION_DEFAULTED - constexpr __standard_layout_psa(__standard_layout_psa &&) noexcept = default; - MDSPAN_INLINE_FUNCTION_DEFAULTED - _MDSPAN_CONSTEXPR_14_DEFAULTED __standard_layout_psa & - operator=(__standard_layout_psa const &) noexcept = default; - MDSPAN_INLINE_FUNCTION_DEFAULTED - _MDSPAN_CONSTEXPR_14_DEFAULTED __standard_layout_psa & - operator=(__standard_layout_psa &&) noexcept = default; - MDSPAN_INLINE_FUNCTION_DEFAULTED - ~__standard_layout_psa() noexcept = default; - - MDSPAN_INLINE_FUNCTION - constexpr __standard_layout_psa( - __construct_psa_from_all_exts_values_tag_t) noexcept {} - - template - MDSPAN_INLINE_FUNCTION constexpr __standard_layout_psa( - __construct_psa_from_dynamic_exts_values_tag_t) noexcept {} - - template - MDSPAN_INLINE_FUNCTION constexpr explicit __standard_layout_psa( - array<_U, _N> const &) noexcept {} - - template - MDSPAN_INLINE_FUNCTION constexpr explicit __standard_layout_psa( - __construct_psa_from_all_exts_array_tag_t, - array<_U, _NStatic> const &) noexcept {} - - template - MDSPAN_INLINE_FUNCTION constexpr explicit __standard_layout_psa( - __construct_psa_from_dynamic_exts_array_tag_t<_IDynamic>, - array<_U, _NDynamic> const &) noexcept {} - -#ifdef __cpp_lib_span - template - MDSPAN_INLINE_FUNCTION constexpr explicit __standard_layout_psa( - span<_U, _N> const &) noexcept {} - - template - MDSPAN_INLINE_FUNCTION constexpr explicit __standard_layout_psa( - __construct_psa_from_all_exts_array_tag_t, - span<_U, _NStatic> const &) noexcept {} - - template - MDSPAN_INLINE_FUNCTION constexpr explicit __standard_layout_psa( - __construct_psa_from_dynamic_exts_array_tag_t<_IDynamic>, - span<_U, _NDynamic> const &) noexcept {} -#endif - - template - MDSPAN_INLINE_FUNCTION constexpr __standard_layout_psa( - __standard_layout_psa<_UTag, _U, _static_U, _UValsSeq, __u_sentinal, _UIdxsSeq> const&) noexcept {} - - // See comment in the previous partial specialization for why this is - // necessary. Or just trust me that it's messy. - MDSPAN_FORCE_INLINE_FUNCTION - constexpr __standard_layout_psa const &__enable_psa_conversion() const - noexcept { - return *this; - } - - MDSPAN_FORCE_INLINE_FUNCTION constexpr _T __get(size_t /*n*/) const noexcept { - return 0; - } -}; - -// Same thing, but with a disambiguator so that same-base issues doesn't cause -// a loss of standard-layout-ness. -template -struct __partially_static_sizes_tagged - : __standard_layout_psa< - _Tag, T, _static_t, - integer_sequence<_static_t, __values_or_sentinals...>> { - using __tag_t = _Tag; - using __psa_impl_t = __standard_layout_psa< - _Tag, T, _static_t, integer_sequence<_static_t, __values_or_sentinals...>>; - using __psa_impl_t::__psa_impl_t; -#ifdef _MDSPAN_DEFAULTED_CONSTRUCTORS_INHERITANCE_WORKAROUND - MDSPAN_INLINE_FUNCTION -#endif - constexpr __partially_static_sizes_tagged() noexcept -#ifdef _MDSPAN_DEFAULTED_CONSTRUCTORS_INHERITANCE_WORKAROUND - : __psa_impl_t() { } -#else - = default; -#endif - MDSPAN_INLINE_FUNCTION_DEFAULTED - constexpr __partially_static_sizes_tagged( - __partially_static_sizes_tagged const &) noexcept = default; - MDSPAN_INLINE_FUNCTION_DEFAULTED - constexpr __partially_static_sizes_tagged( - __partially_static_sizes_tagged &&) noexcept = default; - MDSPAN_INLINE_FUNCTION_DEFAULTED - _MDSPAN_CONSTEXPR_14_DEFAULTED __partially_static_sizes_tagged & - operator=(__partially_static_sizes_tagged const &) noexcept = default; - MDSPAN_INLINE_FUNCTION_DEFAULTED - _MDSPAN_CONSTEXPR_14_DEFAULTED __partially_static_sizes_tagged & - operator=(__partially_static_sizes_tagged &&) noexcept = default; - MDSPAN_INLINE_FUNCTION_DEFAULTED - ~__partially_static_sizes_tagged() noexcept = default; - - template - MDSPAN_FORCE_INLINE_FUNCTION constexpr explicit __partially_static_sizes_tagged( - __partially_static_sizes_tagged<_UTag, T, _static_t, __values_or_sentinals...> const& __vals - ) noexcept : __psa_impl_t(__vals.__enable_psa_conversion()) { } -}; - -struct __no_tag {}; -template -struct __partially_static_sizes - : __partially_static_sizes_tagged<__no_tag, T, _static_t, __values_or_sentinals...> { -private: - using __base_t = - __partially_static_sizes_tagged<__no_tag, T, _static_t, __values_or_sentinals...>; - template - MDSPAN_FORCE_INLINE_FUNCTION constexpr __partially_static_sizes( - __partially_static_sizes_tagged<_UTag, T, _static_t, __values_or_sentinals...>&& __vals - ) noexcept : __base_t(::std::move(__vals)) { } -public: - using __base_t::__base_t; - -#ifdef _MDSPAN_DEFAULTED_CONSTRUCTORS_INHERITANCE_WORKAROUND - MDSPAN_INLINE_FUNCTION - constexpr __partially_static_sizes() noexcept : __base_t() { } -#endif - template - MDSPAN_FORCE_INLINE_FUNCTION constexpr __partially_static_sizes_tagged< - _UTag, T, _static_t, __values_or_sentinals...> - __with_tag() const noexcept { - return __partially_static_sizes_tagged<_UTag, T, _static_t, __values_or_sentinals...>(*this); - } -}; - -#endif // _MDSPAN_PRESERVE_STATIC_LAYOUT - -} // end namespace detail -} // end namespace experimental -} // end namespace std diff --git a/src/mdspan/__p0009_bits/static_array.hpp b/src/mdspan/__p0009_bits/static_array.hpp deleted file mode 100644 index fe9322f..0000000 --- a/src/mdspan/__p0009_bits/static_array.hpp +++ /dev/null @@ -1,258 +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 - -#include "macros.hpp" - -#include "dynamic_extent.hpp" -#include "trait_backports.hpp" -#include "maybe_static_value.hpp" -#include "standard_layout_static_array.hpp" -#include "type_list.hpp" - -// Needs to be after the includes above to work with the single header generator -#if !_MDSPAN_PRESERVE_STANDARD_LAYOUT -#include // size_t -#include // integer_sequence -#include - -namespace std { -namespace experimental { -namespace detail { - -//============================================================================== - -template struct __mask_element {}; - -template -struct __mask_sequence_assign_op { - template <_T _V> - __mask_sequence_assign_op<_T, _Result..., _V> - operator=(__mask_element<_T, _V, true>&&); - template <_T _V> - __mask_sequence_assign_op<_T, _Result...> - operator=(__mask_element<_T, _V, false>&&); - using __result = integer_sequence<_T, _Result...>; -}; - -template -struct __mask_sequence; - -template -struct __mask_sequence, integer_sequence> -{ - using type = typename decltype( - _MDSPAN_FOLD_ASSIGN_LEFT( - __mask_sequence_assign_op<_T>{}, /* = ... = */ __mask_element<_T, _Vals, _Masks>{} - ) - )::__result; -}; - -//============================================================================== - -template -class __partially_static_array_impl; - -template < - class _T, class _static_t, - _static_t... __values_or_sentinals, _static_t __sentinal, - size_t... _Idxs, - size_t... _IdxsDynamic, - size_t... _IdxsDynamicIdxs -> -class __partially_static_array_impl< - _T, - _static_t, - integer_sequence<_static_t, __values_or_sentinals...>, - __sentinal, - integer_sequence, - integer_sequence, - integer_sequence -> - : private __maybe_static_value<_T, _static_t, __values_or_sentinals, __sentinal, - _Idxs>... { -private: - - template - using __base_n = typename __type_at<_N, - __type_list<__maybe_static_value<_T, _static_t, __values_or_sentinals, __sentinal, _Idxs>...> - >::type; - -public: - - static constexpr auto __size = sizeof...(_Idxs); - static constexpr auto __size_dynamic = - _MDSPAN_FOLD_PLUS_RIGHT(static_cast((__values_or_sentinals == __sentinal)), /* + ... + */ 0); - - //-------------------------------------------------------------------------- - - MDSPAN_INLINE_FUNCTION_DEFAULTED - constexpr __partially_static_array_impl() = default; - MDSPAN_INLINE_FUNCTION_DEFAULTED - constexpr __partially_static_array_impl( - __partially_static_array_impl const &) noexcept = default; - MDSPAN_INLINE_FUNCTION_DEFAULTED - constexpr __partially_static_array_impl( - __partially_static_array_impl &&) noexcept = default; - MDSPAN_INLINE_FUNCTION_DEFAULTED - _MDSPAN_CONSTEXPR_14_DEFAULTED __partially_static_array_impl & - operator=(__partially_static_array_impl const &) noexcept = default; - MDSPAN_INLINE_FUNCTION_DEFAULTED - _MDSPAN_CONSTEXPR_14_DEFAULTED __partially_static_array_impl & - operator=(__partially_static_array_impl &&) noexcept = default; - MDSPAN_INLINE_FUNCTION_DEFAULTED - ~__partially_static_array_impl() noexcept = default; - - MDSPAN_INLINE_FUNCTION - constexpr __partially_static_array_impl( - __construct_psa_from_all_exts_values_tag_t, - __repeated_with_idxs<_Idxs, _T> const &... __vals) noexcept - : __base_n<_Idxs>(__base_n<_Idxs>{{__vals}})... {} - - MDSPAN_INLINE_FUNCTION - constexpr __partially_static_array_impl( - __construct_psa_from_dynamic_exts_values_tag_t, - __repeated_with_idxs<_IdxsDynamicIdxs, _T> const &... __vals) noexcept - : __base_n<_IdxsDynamic>(__base_n<_IdxsDynamic>{{__vals}})... {} - - MDSPAN_INLINE_FUNCTION constexpr explicit __partially_static_array_impl( - array<_T, sizeof...(_Idxs)> const& __vals) noexcept - : __partially_static_array_impl( - __construct_psa_from_all_exts_values_tag, - ::std::get<_Idxs>(__vals)...) {} - - // clang-format off - MDSPAN_FUNCTION_REQUIRES( - (MDSPAN_INLINE_FUNCTION constexpr explicit), - __partially_static_array_impl, - (array<_T, __size_dynamic> const &__vals), noexcept, - /* requires */ - (sizeof...(_Idxs) != __size_dynamic) - ): __partially_static_array_impl( - __construct_psa_from_dynamic_exts_values_tag, - ::std::get<_IdxsDynamicIdxs>(__vals)...) {} - // clang-format on - - template - MDSPAN_INLINE_FUNCTION constexpr __partially_static_array_impl( - __partially_static_array_impl< - _U, _static_u, _UValsSeq, __u_sentinal, _UIdxsSeq, - _UIdxsDynamicSeq, _UIdxsDynamicIdxsSeq> const &__rhs) noexcept - : __partially_static_array_impl( - __construct_psa_from_all_exts_values_tag, - __rhs.template __get_n<_Idxs>()...) {} - - //-------------------------------------------------------------------------- - - // See comment in the previous partial specialization for why this is - // necessary. Or just trust me that it's messy. - MDSPAN_FORCE_INLINE_FUNCTION - constexpr __partially_static_array_impl const &__enable_psa_conversion() const - noexcept { - return *this; - } - - template - MDSPAN_FORCE_INLINE_FUNCTION constexpr _T __get_n() const noexcept { - return static_cast<__base_n<_I> const*>(this)->__value(); - } - - template - MDSPAN_FORCE_INLINE_FUNCTION _MDSPAN_CONSTEXPR_14 void __set_n(_U&& __rhs) noexcept { - static_cast<__base_n<_I>*>(this)->__set_value((_U&&)__rhs); - } - - template - MDSPAN_FORCE_INLINE_FUNCTION static constexpr _static_t - __get_static_n() noexcept { - return __base_n<_I>::__static_value == __sentinal ? - __default : __base_n<_I>::__static_value; - } - - MDSPAN_FORCE_INLINE_FUNCTION constexpr _T - __get(size_t __n) const noexcept { - return _MDSPAN_FOLD_PLUS_RIGHT( - (_T(_Idxs == __n) * __get_n<_Idxs>()), /* + ... + */ _T(0) - ); - } - -}; - -//============================================================================== - -template > -struct __partially_static_array_impl_maker; - -template < - class _T, class _static_t, _static_t... _Vals, _static_t __sentinal, size_t... _Idxs -> -struct __partially_static_array_impl_maker< - _T, _static_t, integer_sequence<_static_t, _Vals...>, __sentinal, integer_sequence -> -{ - using __dynamic_idxs = typename __mask_sequence< - integer_sequence, - integer_sequence - >::type; - using __impl_base = - __partially_static_array_impl<_T, _static_t, - integer_sequence<_static_t, _Vals...>, - __sentinal, integer_sequence, - __dynamic_idxs, - make_index_sequence<__dynamic_idxs::size()> - >; -}; - -template -class __partially_static_array_with_sentinal - : public __partially_static_array_impl_maker<_T, _static_t, _ValsSeq, __sentinal>::__impl_base -{ -private: - using __base_t = typename __partially_static_array_impl_maker<_T, _static_t, _ValsSeq, __sentinal>::__impl_base; -public: - using __base_t::__base_t; -}; - -//============================================================================== - -template -struct __partially_static_sizes : - __partially_static_array_with_sentinal< - T, _static_t, ::std::integer_sequence<_static_t, __values_or_sentinals...>> -{ -private: - using __base_t = __partially_static_array_with_sentinal< - T, _static_t, ::std::integer_sequence<_static_t, __values_or_sentinals...>>; -public: - using __base_t::__base_t; - template - MDSPAN_FORCE_INLINE_FUNCTION constexpr __partially_static_sizes - __with_tag() const noexcept { - return *this; - } -}; - -// Tags are needed for the standard layout version, but not here -template -using __partially_static_sizes_tagged = __partially_static_sizes; - -} // end namespace detail -} // end namespace experimental -} // end namespace std - -#endif // !_MDSPAN_PRESERVE_STANDARD_LAYOUT diff --git a/src/mdspan/__p0009_bits/submdspan.hpp b/src/mdspan/__p0009_bits/submdspan.hpp deleted file mode 100644 index 42ef1f8..0000000 --- a/src/mdspan/__p0009_bits/submdspan.hpp +++ /dev/null @@ -1,558 +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 - -#include "mdspan.hpp" -#include "full_extent_t.hpp" -#include "dynamic_extent.hpp" -#include "layout_left.hpp" -#include "layout_right.hpp" -#include "layout_stride.hpp" -#include "macros.hpp" -#include "trait_backports.hpp" - -#include // std::apply -#include // std::pair - -namespace std { -namespace experimental { - -namespace detail { - -template -struct __slice_wrap { - T slice; - size_t old_extent; - size_t old_stride; -}; - -//-------------------------------------------------------------------------------- - -template -MDSPAN_INLINE_FUNCTION constexpr -__slice_wrap -__wrap_slice(size_t val, size_t ext, size_t stride) { return { val, ext, stride }; } - -template -MDSPAN_INLINE_FUNCTION constexpr -__slice_wrap> -__wrap_slice(size_t val, size_t ext, std::integral_constant stride) -{ -#if MDSPAN_HAS_CXX_17 - if constexpr (std::is_signed_v) { - static_assert(Value0 >= IntegerType(0), "Invalid slice specifier"); - } -#endif // MDSPAN_HAS_CXX_17 - - return { val, ext, stride }; -} - -template -MDSPAN_INLINE_FUNCTION constexpr -__slice_wrap -__wrap_slice(full_extent_t val, size_t ext, size_t stride) { return { val, ext, stride }; } - -// TODO generalize this to anything that works with std::get<0> and std::get<1> -template -MDSPAN_INLINE_FUNCTION constexpr -__slice_wrap> -__wrap_slice(std::tuple const& val, size_t ext, size_t stride) -{ - return { val, ext, stride }; -} - -template -MDSPAN_INLINE_FUNCTION constexpr - __slice_wrap, - std::integral_constant>> -__wrap_slice(std::tuple, std::integral_constant> const& val, size_t ext, size_t stride) -{ - static_assert(Value1 >= Value0, "Invalid slice tuple"); - return { val, ext, stride }; -} - -//-------------------------------------------------------------------------------- - - -// a layout right remains a layout right if it is indexed by 0 or more scalars, -// then optionally a pair and finally 0 or more all -template < - // what we encountered until now preserves the layout right - bool result=true, - // we only encountered 0 or more scalars, no pair or all - bool encountered_only_scalar=true -> -struct preserve_layout_right_analysis : integral_constant { - using layout_type_if_preserved = layout_right; - using encounter_pair = preserve_layout_right_analysis< - // if we encounter a pair, the layout remains a layout right only if it was one before - // and that only scalars were encountered until now - result && encountered_only_scalar, - // if we encounter a pair, we didn't encounter scalars only - false - >; - using encounter_all = preserve_layout_right_analysis< - // if we encounter a all, the layout remains a layout right if it was one before - result, - // if we encounter a all, we didn't encounter scalars only - false - >; - using encounter_scalar = preserve_layout_right_analysis< - // if we encounter a scalar, the layout remains a layout right only if it was one before - // and that only scalars were encountered until now - result && encountered_only_scalar, - // if we encounter a scalar, the fact that we encountered scalars only doesn't change - encountered_only_scalar - >; -}; - -// a layout left remains a layout left if it is indexed by 0 or more all, -// then optionally a pair and finally 0 or more scalars -template < - bool result=true, - bool encountered_only_all=true -> -struct preserve_layout_left_analysis : integral_constant { - using layout_type_if_preserved = layout_left; - using encounter_pair = preserve_layout_left_analysis< - // if we encounter a pair, the layout remains a layout left only if it was one before - // and that only all were encountered until now - result && encountered_only_all, - // if we encounter a pair, we didn't encounter all only - false - >; - using encounter_all = preserve_layout_left_analysis< - // if we encounter a all, the layout remains a layout left only if it was one before - // and that only all were encountered until now - result && encountered_only_all, - // if we encounter a all, the fact that we encountered scalars all doesn't change - encountered_only_all - >; - using encounter_scalar = preserve_layout_left_analysis< - // if we encounter a scalar, the layout remains a layout left if it was one before - result, - // if we encounter a scalar, we didn't encounter scalars only - false - >; -}; - -struct ignore_layout_preservation : std::integral_constant { - using layout_type_if_preserved = void; - using encounter_pair = ignore_layout_preservation; - using encounter_all = ignore_layout_preservation; - using encounter_scalar = ignore_layout_preservation; -}; - -template -struct preserve_layout_analysis - : ignore_layout_preservation { }; -template <> -struct preserve_layout_analysis - : preserve_layout_right_analysis<> { }; -template <> -struct preserve_layout_analysis - : preserve_layout_left_analysis<> { }; - -//-------------------------------------------------------------------------------- - -template < - class _IndexT, - class _PreserveLayoutAnalysis, - class _OffsetsArray=__partially_static_sizes<_IndexT, size_t>, - class _ExtsArray=__partially_static_sizes<_IndexT, size_t>, - class _StridesArray=__partially_static_sizes<_IndexT, size_t>, - class = make_index_sequence<_OffsetsArray::__size>, - class = make_index_sequence<_ExtsArray::__size>, - class = make_index_sequence<_StridesArray::__size> -> -struct __assign_op_slice_handler; - -/* clang-format: off */ -template < - class _IndexT, - class _PreserveLayoutAnalysis, - size_t... _Offsets, - size_t... _Exts, - size_t... _Strides, - size_t... _OffsetIdxs, - size_t... _ExtIdxs, - size_t... _StrideIdxs> -struct __assign_op_slice_handler< - _IndexT, - _PreserveLayoutAnalysis, - __partially_static_sizes<_IndexT, size_t, _Offsets...>, - __partially_static_sizes<_IndexT, size_t, _Exts...>, - __partially_static_sizes<_IndexT, size_t, _Strides...>, - integer_sequence, - integer_sequence, - integer_sequence> -{ - // TODO remove this for better compiler performance - static_assert( - _MDSPAN_FOLD_AND((_Strides == dynamic_extent || _Strides > 0) /* && ... */), - " " - ); - static_assert( - _MDSPAN_FOLD_AND((_Offsets == dynamic_extent || _Offsets >= 0) /* && ... */), - " " - ); - - using __offsets_storage_t = __partially_static_sizes<_IndexT, size_t, _Offsets...>; - using __extents_storage_t = __partially_static_sizes<_IndexT, size_t, _Exts...>; - using __strides_storage_t = __partially_static_sizes<_IndexT, size_t, _Strides...>; - __offsets_storage_t __offsets; - __extents_storage_t __exts; - __strides_storage_t __strides; - -#ifdef __INTEL_COMPILER -#if __INTEL_COMPILER <= 1800 - MDSPAN_INLINE_FUNCTION constexpr __assign_op_slice_handler(__assign_op_slice_handler&& __other) noexcept - : __offsets(::std::move(__other.__offsets)), __exts(::std::move(__other.__exts)), __strides(::std::move(__other.__strides)) - { } - MDSPAN_INLINE_FUNCTION constexpr __assign_op_slice_handler( - __offsets_storage_t&& __o, - __extents_storage_t&& __e, - __strides_storage_t&& __s - ) noexcept - : __offsets(::std::move(__o)), __exts(::std::move(__e)), __strides(::std::move(__s)) - { } -#endif -#endif - -// Don't define this unless we need it; they have a cost to compile -#ifndef _MDSPAN_USE_RETURN_TYPE_DEDUCTION - using __extents_type = ::std::experimental::extents<_IndexT, _Exts...>; -#endif - - // For size_t slice, skip the extent and stride, but add an offset corresponding to the value - template - MDSPAN_FORCE_INLINE_FUNCTION // NOLINT (misc-unconventional-assign-operator) - _MDSPAN_CONSTEXPR_14 auto - operator=(__slice_wrap<_OldStaticExtent, _OldStaticStride, size_t>&& __slice) noexcept - -> __assign_op_slice_handler< - _IndexT, - typename _PreserveLayoutAnalysis::encounter_scalar, - __partially_static_sizes<_IndexT, size_t, _Offsets..., dynamic_extent>, - __partially_static_sizes<_IndexT, size_t, _Exts...>, - __partially_static_sizes<_IndexT, size_t, _Strides...>/* intentional space here to work around ICC bug*/> { - return { - __partially_static_sizes<_IndexT, size_t, _Offsets..., dynamic_extent>( - __construct_psa_from_all_exts_values_tag, - __offsets.template __get_n<_OffsetIdxs>()..., __slice.slice), - ::std::move(__exts), - ::std::move(__strides) - }; - } - - // Treat integral_constant slice like size_t slice, but with a compile-time offset. - // The result's extents_type can't take advantage of that, - // but it might help for specialized layouts. - template - MDSPAN_FORCE_INLINE_FUNCTION // NOLINT (misc-unconventional-assign-operator) - _MDSPAN_CONSTEXPR_14 auto - operator=(__slice_wrap<_OldStaticExtent, _OldStaticStride, std::integral_constant>&&) noexcept - -> __assign_op_slice_handler< - _IndexT, - typename _PreserveLayoutAnalysis::encounter_scalar, - __partially_static_sizes<_IndexT, size_t, _Offsets..., Value0>, - __partially_static_sizes<_IndexT, size_t, _Exts...>, - __partially_static_sizes<_IndexT, size_t, _Strides...>/* intentional space here to work around ICC bug*/> { -#if MDSPAN_HAS_CXX_17 - if constexpr (std::is_signed_v) { - static_assert(Value0 >= IntegerType(0), "Invalid slice specifier"); - } -#endif // MDSPAN_HAS_CXX_17 - return { - __partially_static_sizes<_IndexT, size_t, _Offsets..., Value0>( - __construct_psa_from_all_exts_values_tag, - __offsets.template __get_n<_OffsetIdxs>()..., size_t(Value0)), - ::std::move(__exts), - ::std::move(__strides) - }; - } - - // For a std::full_extent, offset 0 and old extent - template - MDSPAN_FORCE_INLINE_FUNCTION // NOLINT (misc-unconventional-assign-operator) - _MDSPAN_CONSTEXPR_14 auto - operator=(__slice_wrap<_OldStaticExtent, _OldStaticStride, full_extent_t>&& __slice) noexcept - -> __assign_op_slice_handler< - _IndexT, - typename _PreserveLayoutAnalysis::encounter_all, - __partially_static_sizes<_IndexT, size_t, _Offsets..., 0>, - __partially_static_sizes<_IndexT, size_t, _Exts..., _OldStaticExtent>, - __partially_static_sizes<_IndexT, size_t, _Strides..., _OldStaticStride>/* intentional space here to work around ICC bug*/> { - return { - __partially_static_sizes<_IndexT, size_t, _Offsets..., 0>( - __construct_psa_from_all_exts_values_tag, - __offsets.template __get_n<_OffsetIdxs>()..., size_t(0)), - __partially_static_sizes<_IndexT, size_t, _Exts..., _OldStaticExtent>( - __construct_psa_from_all_exts_values_tag, - __exts.template __get_n<_ExtIdxs>()..., __slice.old_extent), - __partially_static_sizes<_IndexT, size_t, _Strides..., _OldStaticStride>( - __construct_psa_from_all_exts_values_tag, - __strides.template __get_n<_StrideIdxs>()..., __slice.old_stride) - }; - } - - // For a std::tuple, add an offset and add a new dynamic extent (strides still preserved) - template - MDSPAN_FORCE_INLINE_FUNCTION // NOLINT (misc-unconventional-assign-operator) - _MDSPAN_CONSTEXPR_14 auto - operator=(__slice_wrap<_OldStaticExtent, _OldStaticStride, tuple>&& __slice) noexcept - -> __assign_op_slice_handler< - _IndexT, - typename _PreserveLayoutAnalysis::encounter_pair, - __partially_static_sizes<_IndexT, size_t, _Offsets..., dynamic_extent>, - __partially_static_sizes<_IndexT, size_t, _Exts..., dynamic_extent>, - __partially_static_sizes<_IndexT, size_t, _Strides..., _OldStaticStride>/* intentional space here to work around ICC bug*/> { - return { - __partially_static_sizes<_IndexT, size_t, _Offsets..., dynamic_extent>( - __construct_psa_from_all_exts_values_tag, - __offsets.template __get_n<_OffsetIdxs>()..., ::std::get<0>(__slice.slice)), - __partially_static_sizes<_IndexT, size_t, _Exts..., dynamic_extent>( - __construct_psa_from_all_exts_values_tag, - __exts.template __get_n<_ExtIdxs>()..., ::std::get<1>(__slice.slice) - ::std::get<0>(__slice.slice)), - __partially_static_sizes<_IndexT, size_t, _Strides..., _OldStaticStride>( - __construct_psa_from_all_exts_values_tag, - __strides.template __get_n<_StrideIdxs>()..., __slice.old_stride) - }; - } - - // For a std::tuple of two std::integral_constant, do something like - // we did above for a tuple of two size_t, but make sure the - // result's extents type make the values compile-time constants. - template - MDSPAN_FORCE_INLINE_FUNCTION // NOLINT (misc-unconventional-assign-operator) - _MDSPAN_CONSTEXPR_14 auto - operator=(__slice_wrap<_OldStaticExtent, _OldStaticStride, tuple, std::integral_constant>>&& __slice) noexcept - -> __assign_op_slice_handler< - _IndexT, - typename _PreserveLayoutAnalysis::encounter_pair, - __partially_static_sizes<_IndexT, size_t, _Offsets..., size_t(Value0)>, - __partially_static_sizes<_IndexT, size_t, _Exts..., size_t(Value1 - Value0)>, - __partially_static_sizes<_IndexT, size_t, _Strides..., _OldStaticStride>/* intentional space here to work around ICC bug*/> { - static_assert(Value1 >= Value0, "Invalid slice specifier"); - return { - // We're still turning the template parameters Value0 and Value1 - // into (constexpr) run-time values here. - __partially_static_sizes<_IndexT, size_t, _Offsets..., size_t(Value0) > ( - __construct_psa_from_all_exts_values_tag, - __offsets.template __get_n<_OffsetIdxs>()..., Value0), - __partially_static_sizes<_IndexT, size_t, _Exts..., size_t(Value1 - Value0) > ( - __construct_psa_from_all_exts_values_tag, - __exts.template __get_n<_ExtIdxs>()..., Value1 - Value0), - __partially_static_sizes<_IndexT, size_t, _Strides..., _OldStaticStride>( - __construct_psa_from_all_exts_values_tag, - __strides.template __get_n<_StrideIdxs>()..., __slice.old_stride) - }; - } - - // TODO defer instantiation of this? - using layout_type = typename conditional< - _PreserveLayoutAnalysis::value, - typename _PreserveLayoutAnalysis::layout_type_if_preserved, - layout_stride - >::type; - - // TODO noexcept specification - template - MDSPAN_INLINE_FUNCTION - _MDSPAN_DEDUCE_RETURN_TYPE_SINGLE_LINE( - ( - _MDSPAN_CONSTEXPR_14 /* auto */ - _make_layout_mapping_impl(NewLayout) noexcept - ), - ( - /* not layout stride, so don't pass dynamic_strides */ - /* return */ typename NewLayout::template mapping<::std::experimental::extents<_IndexT, _Exts...>>( - experimental::extents<_IndexT, _Exts...>::__make_extents_impl(::std::move(__exts)) - ) /* ; */ - ) - ) - - MDSPAN_INLINE_FUNCTION - _MDSPAN_DEDUCE_RETURN_TYPE_SINGLE_LINE( - ( - _MDSPAN_CONSTEXPR_14 /* auto */ - _make_layout_mapping_impl(layout_stride) noexcept - ), - ( - /* return */ layout_stride::template mapping<::std::experimental::extents<_IndexT, _Exts...>> - ::__make_mapping(::std::move(__exts), ::std::move(__strides)) /* ; */ - ) - ) - - template // mostly for deferred instantiation, but maybe we'll use this in the future - MDSPAN_INLINE_FUNCTION - _MDSPAN_DEDUCE_RETURN_TYPE_SINGLE_LINE( - ( - _MDSPAN_CONSTEXPR_14 /* auto */ - make_layout_mapping(OldLayoutMapping const&) noexcept - ), - ( - /* return */ this->_make_layout_mapping_impl(layout_type{}) /* ; */ - ) - ) -}; - -//============================================================================== - -#if _MDSPAN_USE_RETURN_TYPE_DEDUCTION -// Forking this because the C++11 version will be *completely* unreadable -template -MDSPAN_INLINE_FUNCTION -constexpr auto _submdspan_impl( - integer_sequence, - mdspan, LP, AP> const& src, - SliceSpecs&&... slices -) noexcept -{ - using _IndexT = ST; - auto _handled = - _MDSPAN_FOLD_ASSIGN_LEFT( - ( - detail::__assign_op_slice_handler< - _IndexT, - detail::preserve_layout_analysis - >{ - __partially_static_sizes<_IndexT, size_t>{}, - __partially_static_sizes<_IndexT, size_t>{}, - __partially_static_sizes<_IndexT, size_t>{} - } - ), - /* = ... = */ - detail::__wrap_slice< - Exts, dynamic_extent - >( - slices, src.extents().template __extent(), - src.mapping().stride(Idxs) - ) - ); - - size_t offset_size = src.mapping()(_handled.__offsets.template __get_n()...); - auto offset_ptr = src.accessor().offset(src.data_handle(), offset_size); - auto map = _handled.make_layout_mapping(src.mapping()); - auto acc_pol = typename AP::offset_policy(src.accessor()); - return mdspan< - ET, remove_const_t>, - typename decltype(_handled)::layout_type, remove_const_t> - >( - std::move(offset_ptr), std::move(map), std::move(acc_pol) - ); -} -#else - -template -auto _submdspan_impl_helper(Src&& src, Handled&& h, std::integer_sequence) - -> mdspan< - ET, typename Handled::__extents_type, typename Handled::layout_type, typename AP::offset_policy - > -{ - return { - src.accessor().offset(src.data_handle(), src.mapping()(h.__offsets.template __get_n()...)), - h.make_layout_mapping(src.mapping()), - typename AP::offset_policy(src.accessor()) - }; -} - -template -MDSPAN_INLINE_FUNCTION -_MDSPAN_DEDUCE_RETURN_TYPE_SINGLE_LINE( - ( - constexpr /* auto */ _submdspan_impl( - std::integer_sequence seq, - mdspan, LP, AP> const& src, - SliceSpecs&&... slices - ) noexcept - ), - ( - /* return */ _submdspan_impl_helper( - src, - _MDSPAN_FOLD_ASSIGN_LEFT( - ( - detail::__assign_op_slice_handler< - size_t, - detail::preserve_layout_analysis - >{ - __partially_static_sizes{}, - __partially_static_sizes{}, - __partially_static_sizes{} - } - ), - /* = ... = */ - detail::__wrap_slice< - Exts, dynamic_extent - >( - slices, src.extents().template __extent(), src.mapping().stride(Idxs) - ) - ), - seq - ) /* ; */ - ) -) - -#endif - -template struct _is_layout_stride : std::false_type { }; -template<> -struct _is_layout_stride< - layout_stride -> : std::true_type -{ }; - -} // namespace detail - -//============================================================================== - -MDSPAN_TEMPLATE_REQUIRES( - class ET, class EXT, class LP, class AP, class... SliceSpecs, - /* requires */ ( - ( - _MDSPAN_TRAIT(is_same, LP, layout_left) - || _MDSPAN_TRAIT(is_same, LP, layout_right) - || detail::_is_layout_stride::value - ) && - _MDSPAN_FOLD_AND(( - _MDSPAN_TRAIT(is_convertible, SliceSpecs, size_t) - || _MDSPAN_TRAIT(is_convertible, SliceSpecs, tuple) - || _MDSPAN_TRAIT(is_convertible, SliceSpecs, full_extent_t) - ) /* && ... */) && - sizeof...(SliceSpecs) == EXT::rank() - ) -) -MDSPAN_INLINE_FUNCTION -_MDSPAN_DEDUCE_RETURN_TYPE_SINGLE_LINE( - ( - constexpr submdspan( - mdspan const& src, SliceSpecs... slices - ) noexcept - ), - ( - /* return */ - detail::_submdspan_impl(std::make_index_sequence{}, src, slices...) /*;*/ - ) -) -/* clang-format: on */ - -} // end namespace experimental -} // namespace std diff --git a/src/mdspan/__p0009_bits/trait_backports.hpp b/src/mdspan/__p0009_bits/trait_backports.hpp deleted file mode 100644 index b2bb5d2..0000000 --- a/src/mdspan/__p0009_bits/trait_backports.hpp +++ /dev/null @@ -1,132 +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_INCLUDE_EXPERIMENTAL_BITS_TRAIT_BACKPORTS_HPP_ -#define MDSPAN_INCLUDE_EXPERIMENTAL_BITS_TRAIT_BACKPORTS_HPP_ - -#include "macros.hpp" -#include "config.hpp" - -#include -#include // integer_sequence - -//============================================================================== -// {{{1 - -#ifdef _MDSPAN_NEEDS_TRAIT_VARIABLE_TEMPLATE_BACKPORTS - -#if _MDSPAN_USE_VARIABLE_TEMPLATES -namespace std { - -#define _MDSPAN_BACKPORT_TRAIT(TRAIT) \ - template _MDSPAN_INLINE_VARIABLE constexpr auto TRAIT##_v = TRAIT::value; - -_MDSPAN_BACKPORT_TRAIT(is_assignable) -_MDSPAN_BACKPORT_TRAIT(is_constructible) -_MDSPAN_BACKPORT_TRAIT(is_convertible) -_MDSPAN_BACKPORT_TRAIT(is_default_constructible) -_MDSPAN_BACKPORT_TRAIT(is_trivially_destructible) -_MDSPAN_BACKPORT_TRAIT(is_same) -_MDSPAN_BACKPORT_TRAIT(is_empty) -_MDSPAN_BACKPORT_TRAIT(is_void) - -#undef _MDSPAN_BACKPORT_TRAIT - -} // end namespace std - -#endif // _MDSPAN_USE_VARIABLE_TEMPLATES - -#endif // _MDSPAN_NEEDS_TRAIT_VARIABLE_TEMPLATE_BACKPORTS - -// end Variable template trait backports (e.g., is_void_v) }}}1 -//============================================================================== - -//============================================================================== -// {{{1 - -#if !defined(_MDSPAN_USE_INTEGER_SEQUENCE) || !_MDSPAN_USE_INTEGER_SEQUENCE - -namespace std { - -template -struct integer_sequence { - static constexpr std::size_t size() noexcept { return sizeof...(Vals); } - using value_type = T; -}; - -template -using index_sequence = std::integer_sequence; - -namespace __detail { - -template -struct __make_int_seq_impl; - -template -struct __make_int_seq_impl> -{ - using type = integer_sequence; -}; - -template -struct __make_int_seq_impl< - T, N, I, integer_sequence -> : __make_int_seq_impl> -{ }; - -} // end namespace __detail - -template -using make_integer_sequence = typename __detail::__make_int_seq_impl>::type; - -template -using make_index_sequence = typename __detail::__make_int_seq_impl>::type; - -template -using index_sequence_for = make_index_sequence; - -} // end namespace std - -#endif - -// end integer sequence (ugh...) }}}1 -//============================================================================== - -//============================================================================== -// {{{1 - -#if !defined(_MDSPAN_USE_STANDARD_TRAIT_ALIASES) || !_MDSPAN_USE_STANDARD_TRAIT_ALIASES - -namespace std { - -#define _MDSPAN_BACKPORT_TRAIT_ALIAS(TRAIT) \ - template using TRAIT##_t = typename TRAIT::type; - -_MDSPAN_BACKPORT_TRAIT_ALIAS(remove_cv) -_MDSPAN_BACKPORT_TRAIT_ALIAS(remove_reference) - -template -using enable_if_t = typename enable_if<_B, _T>::type; - -#undef _MDSPAN_BACKPORT_TRAIT_ALIAS - -} // end namespace std - -#endif - -// end standard trait aliases }}}1 -//============================================================================== - -#endif //MDSPAN_INCLUDE_EXPERIMENTAL_BITS_TRAIT_BACKPORTS_HPP_ diff --git a/src/mdspan/__p0009_bits/type_list.hpp b/src/mdspan/__p0009_bits/type_list.hpp deleted file mode 100644 index 6a7acd4..0000000 --- a/src/mdspan/__p0009_bits/type_list.hpp +++ /dev/null @@ -1,89 +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 -#include "macros.hpp" - -#include "trait_backports.hpp" // make_index_sequence - -namespace std { -namespace experimental { - -//============================================================================== - -namespace detail { - -template struct __type_list { static constexpr auto __size = sizeof...(_Ts); }; - -// Implementation of type_list at() that's heavily optimized for small typelists -template struct __type_at; -template > struct __type_at_large_impl; - -template -struct __type_at_entry { }; - -template -struct __type_at_assign_op_ignore_rest { - template - __type_at_assign_op_ignore_rest<_Result> operator=(_T&&); - using type = _Result; -}; - -struct __type_at_assign_op_impl { - template - __type_at_assign_op_impl operator=(__type_at_entry<_I, _Idx, _T>&&); - template - __type_at_assign_op_ignore_rest<_T> operator=(__type_at_entry<_I, _I, _T>&&); -}; - -template -struct __type_at_large_impl<_I, __type_list<_Ts...>, integer_sequence> - : decltype( - _MDSPAN_FOLD_ASSIGN_LEFT(__type_at_assign_op_impl{}, /* = ... = */ __type_at_entry<_I, _Idxs, _Ts>{}) - ) -{ }; - -template -struct __type_at<_I, __type_list<_Ts...>> - : __type_at_large_impl<_I, __type_list<_Ts...>> -{ }; - -template -struct __type_at<0, __type_list<_T0, _Ts...>> { - using type = _T0; -}; - -template -struct __type_at<1, __type_list<_T0, _T1, _Ts...>> { - using type = _T1; -}; - -template -struct __type_at<2, __type_list<_T0, _T1, _T2, _Ts...>> { - using type = _T2; -}; - -template -struct __type_at<3, __type_list<_T0, _T1, _T2, _T3, _Ts...>> { - using type = _T3; -}; - - -} // namespace detail - -//============================================================================== - -} // end namespace experimental -} // end namespace std - diff --git a/src/mdspan/__p1684_bits/mdarray.hpp b/src/mdspan/__p1684_bits/mdarray.hpp deleted file mode 100644 index ea5b9cf..0000000 --- a/src/mdspan/__p1684_bits/mdarray.hpp +++ /dev/null @@ -1,439 +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 - -#include "../mdspan" -#include -#include - -namespace std { -namespace experimental { - -namespace { - template - struct size_of_extents; - - template - struct size_of_extents> { - constexpr static size_t value() { - size_t size = 1; - for(size_t r=0; r::rank(); r++) - size *= extents::static_extent(r); - return size; - } - }; -} - -namespace { - template - struct container_is_array : false_type { - template - static constexpr C construct(const M& m) { return C(m.required_span_size()); } - }; - template - struct container_is_array> : true_type { - template - static constexpr array construct(const M&) { return array(); } - }; -} - -template < - class ElementType, - class Extents, - class LayoutPolicy = layout_right, - class Container = vector -> -class mdarray { -private: - static_assert(detail::__is_extents_v, "std::experimental::mdspan's Extents template parameter must be a specialization of std::experimental::extents."); - - -public: - - //-------------------------------------------------------------------------------- - // Domain and codomain types - - using extents_type = Extents; - using layout_type = LayoutPolicy; - using container_type = Container; - using mapping_type = typename layout_type::template mapping; - using element_type = ElementType; - using value_type = remove_cv_t; - using index_type = typename Extents::index_type; - using size_type = typename Extents::size_type; - using rank_type = typename Extents::rank_type; - using pointer = typename container_type::pointer; - using reference = typename container_type::reference; - using const_pointer = typename container_type::const_pointer; - using const_reference = typename container_type::const_reference; - -public: - - //-------------------------------------------------------------------------------- - // [mdspan.basic.cons], mdspan constructors, assignment, and destructor - -#if !(MDSPAN_HAS_CXX_20) - MDSPAN_FUNCTION_REQUIRES( - (MDSPAN_INLINE_FUNCTION_DEFAULTED constexpr), - mdarray, (), , - /* requires */ (extents_type::rank_dynamic()!=0)) {} -#else - MDSPAN_INLINE_FUNCTION_DEFAULTED constexpr mdarray() requires(extents_type::rank_dynamic()!=0) = default; -#endif - MDSPAN_INLINE_FUNCTION_DEFAULTED constexpr mdarray(const mdarray&) = default; - MDSPAN_INLINE_FUNCTION_DEFAULTED constexpr mdarray(mdarray&&) = default; - - // Constructors for container types constructible from a size - 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_TRAIT(is_constructible, container_type, size_t) || - container_is_array::value) && - (extents_type::rank()>0 || extents_type::rank_dynamic()==0) - ) - ) - MDSPAN_INLINE_FUNCTION - explicit constexpr mdarray(SizeTypes... dynamic_extents) - : map_(extents_type(dynamic_extents...)), ctr_(container_is_array::construct(map_)) - { } - - MDSPAN_FUNCTION_REQUIRES( - (MDSPAN_INLINE_FUNCTION constexpr), - mdarray, (const extents_type& exts), , - /* requires */ ((_MDSPAN_TRAIT(is_constructible, container_type, size_t) || - container_is_array::value) && - _MDSPAN_TRAIT(is_constructible, mapping_type, extents_type)) - ) : map_(exts), ctr_(container_is_array::construct(map_)) - { } - - MDSPAN_FUNCTION_REQUIRES( - (MDSPAN_INLINE_FUNCTION constexpr), - mdarray, (const mapping_type& m), , - /* requires */ (_MDSPAN_TRAIT(is_constructible, container_type, size_t) || - container_is_array::value) - ) : map_(m), ctr_(container_is_array::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(map_.required_span_size())); } - - - MDSPAN_FUNCTION_REQUIRES( - (MDSPAN_INLINE_FUNCTION constexpr), - 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(map_.required_span_size())); } - - constexpr mdarray(const container_type& ctr, const mapping_type& m) - : map_(m), ctr_(ctr) - { assert(ctr.size() >= static_cast(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(map_.required_span_size())); } - - - MDSPAN_FUNCTION_REQUIRES( - (MDSPAN_INLINE_FUNCTION constexpr), - 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(map_.required_span_size())); } - - constexpr mdarray(container_type&& ctr, const mapping_type& m) - : map_(m), ctr_(std::move(ctr)) - { assert(ctr_.size() >= static_cast(map_.required_span_size())); } - - - - MDSPAN_TEMPLATE_REQUIRES( - class OtherElementType, class OtherExtents, class OtherLayoutPolicy, class OtherContainer, - /* requires */ ( - _MDSPAN_TRAIT(is_constructible, mapping_type, typename OtherLayoutPolicy::template mapping) && - _MDSPAN_TRAIT(is_constructible, container_type, OtherContainer) - ) - ) - MDSPAN_INLINE_FUNCTION - constexpr mdarray(const mdarray& other) - : map_(other.mapping()), ctr_(other.container()) - { - static_assert(is_constructible::value, ""); - } - - // Constructors for container types constructible from a size and allocator - MDSPAN_TEMPLATE_REQUIRES( - class Alloc, - /* 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) - : map_(exts), ctr_(map_.required_span_size(), a) - { } - - MDSPAN_TEMPLATE_REQUIRES( - class Alloc, - /* requires */ (_MDSPAN_TRAIT(is_constructible, container_type, size_t, Alloc)) - ) - MDSPAN_INLINE_FUNCTION - constexpr mdarray(const mapping_type& map, const Alloc& a) - : map_(map), ctr_(map_.required_span_size(), a) - { } - - // Constructors for container types constructible from a container and allocator - MDSPAN_TEMPLATE_REQUIRES( - class Alloc, - /* requires */ (_MDSPAN_TRAIT(is_constructible, container_type, container_type, Alloc) && - _MDSPAN_TRAIT(is_constructible, mapping_type, extents_type)) - ) - MDSPAN_INLINE_FUNCTION - constexpr mdarray(const container_type& ctr, const extents_type& exts, const Alloc& a) - : map_(exts), ctr_(ctr, a) - { assert(ctr_.size() >= static_cast(map_.required_span_size())); } - - MDSPAN_TEMPLATE_REQUIRES( - class Alloc, - /* requires */ (_MDSPAN_TRAIT(is_constructible, container_type, size_t, Alloc)) - ) - MDSPAN_INLINE_FUNCTION - constexpr mdarray(const container_type& ctr, const mapping_type& map, const Alloc& a) - : map_(map), ctr_(ctr, a) - { assert(ctr_.size() >= static_cast(map_.required_span_size())); } - - MDSPAN_TEMPLATE_REQUIRES( - class Alloc, - /* requires */ (_MDSPAN_TRAIT(is_constructible, container_type, container_type, Alloc) && - _MDSPAN_TRAIT(is_constructible, mapping_type, extents_type)) - ) - MDSPAN_INLINE_FUNCTION - constexpr mdarray(container_type&& ctr, const extents_type& exts, const Alloc& a) - : map_(exts), ctr_(std::move(ctr), a) - { assert(ctr_.size() >= static_cast(map_.required_span_size())); } - - MDSPAN_TEMPLATE_REQUIRES( - class Alloc, - /* requires */ (_MDSPAN_TRAIT(is_constructible, container_type, size_t, Alloc)) - ) - MDSPAN_INLINE_FUNCTION - 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(is_constructible, mapping_type, typename OtherLayoutPolicy::template mapping) && - _MDSPAN_TRAIT(is_constructible, container_type, OtherContainer, Alloc) - ) - ) - MDSPAN_INLINE_FUNCTION - constexpr mdarray(const mdarray& other, const Alloc& a) - : map_(other.mapping()), ctr_(other.container(), a) - { - static_assert(is_constructible::value, ""); - } - - MDSPAN_INLINE_FUNCTION_DEFAULTED constexpr mdarray& operator= (const mdarray&) = default; - MDSPAN_INLINE_FUNCTION_DEFAULTED constexpr mdarray& operator= (mdarray&&) = default; - MDSPAN_INLINE_FUNCTION_DEFAULTED - ~mdarray() = default; - - //-------------------------------------------------------------------------------- - // [mdspan.basic.mapping], mdspan mapping domain multidimensional index to access codomain element - - #if MDSPAN_USE_BRACKET_OPERATOR - MDSPAN_TEMPLATE_REQUIRES( - class... SizeTypes, - /* requires */ ( - _MDSPAN_FOLD_AND(_MDSPAN_TRAIT(is_convertible, SizeTypes, index_type) /* && ... */) && - extents_type::rank() == sizeof...(SizeTypes) - ) - ) - MDSPAN_FORCE_INLINE_FUNCTION - constexpr const_reference operator[](SizeTypes... indices) const noexcept - { - return ctr_[map_(static_cast(std::move(indices))...)]; - } - - MDSPAN_TEMPLATE_REQUIRES( - class... SizeTypes, - /* requires */ ( - _MDSPAN_FOLD_AND(_MDSPAN_TRAIT(is_convertible, SizeTypes, index_type) /* && ... */) && - extents_type::rank() == sizeof...(SizeTypes) - ) - ) - MDSPAN_FORCE_INLINE_FUNCTION - constexpr reference operator[](SizeTypes... indices) noexcept - { - return ctr_[map_(static_cast(std::move(indices))...)]; - } - #endif - -#if 0 - MDSPAN_TEMPLATE_REQUIRES( - class SizeType, size_t N, - /* requires */ ( - _MDSPAN_TRAIT(is_convertible, SizeType, index_type) && - N == extents_type::rank() - ) - ) - MDSPAN_FORCE_INLINE_FUNCTION - constexpr const_reference operator[](const array& indices) const noexcept - { - return __impl::template __callop(*this, indices); - } - - MDSPAN_TEMPLATE_REQUIRES( - class SizeType, size_t N, - /* requires */ ( - _MDSPAN_TRAIT(is_convertible, SizeType, index_type) && - N == extents_type::rank() - ) - ) - MDSPAN_FORCE_INLINE_FUNCTION - constexpr reference operator[](const array& indices) noexcept - { - return __impl::template __callop(*this, indices); - } -#endif - - - #if MDSPAN_USE_PAREN_OPERATOR - MDSPAN_TEMPLATE_REQUIRES( - class... SizeTypes, - /* requires */ ( - _MDSPAN_FOLD_AND(_MDSPAN_TRAIT(is_convertible, SizeTypes, index_type) /* && ... */) && - extents_type::rank() == sizeof...(SizeTypes) - ) - ) - MDSPAN_FORCE_INLINE_FUNCTION - constexpr const_reference operator()(SizeTypes... indices) const noexcept - { - return ctr_[map_(static_cast(std::move(indices))...)]; - } - MDSPAN_TEMPLATE_REQUIRES( - class... SizeTypes, - /* requires */ ( - _MDSPAN_FOLD_AND(_MDSPAN_TRAIT(is_convertible, SizeTypes, index_type) /* && ... */) && - extents_type::rank() == sizeof...(SizeTypes) - ) - ) - MDSPAN_FORCE_INLINE_FUNCTION - constexpr reference operator()(SizeTypes... indices) noexcept - { - return ctr_[map_(static_cast(std::move(indices))...)]; - } - -#if 0 - MDSPAN_TEMPLATE_REQUIRES( - class SizeType, size_t N, - /* requires */ ( - _MDSPAN_TRAIT(is_convertible, SizeType, index_type) && - N == extents_type::rank() - ) - ) - MDSPAN_FORCE_INLINE_FUNCTION - constexpr const_reference operator()(const array& indices) const noexcept - { - return __impl::template __callop(*this, indices); - } - - MDSPAN_TEMPLATE_REQUIRES( - class SizeType, size_t N, - /* requires */ ( - _MDSPAN_TRAIT(is_convertible, SizeType, index_type) && - N == extents_type::rank() - ) - ) - MDSPAN_FORCE_INLINE_FUNCTION - constexpr reference operator()(const array& indices) noexcept - { - return __impl::template __callop(*this, indices); - } -#endif - #endif - - MDSPAN_INLINE_FUNCTION constexpr pointer data() noexcept { return ctr_.data(); }; - MDSPAN_INLINE_FUNCTION constexpr const_pointer data() const noexcept { return ctr_.data(); }; - MDSPAN_INLINE_FUNCTION constexpr container_type& container() noexcept { return ctr_; }; - MDSPAN_INLINE_FUNCTION constexpr const container_type& container() const noexcept { return ctr_; }; - - //-------------------------------------------------------------------------------- - // [mdspan.basic.domobs], mdspan observers of the domain multidimensional index space - - MDSPAN_INLINE_FUNCTION static constexpr rank_type rank() noexcept { return extents_type::rank(); } - MDSPAN_INLINE_FUNCTION static constexpr rank_type rank_dynamic() noexcept { return extents_type::rank_dynamic(); } - MDSPAN_INLINE_FUNCTION static constexpr size_t static_extent(size_t r) noexcept { return extents_type::static_extent(r); } - - MDSPAN_INLINE_FUNCTION constexpr extents_type extents() const noexcept { return map_.extents(); }; - MDSPAN_INLINE_FUNCTION constexpr index_type extent(size_t r) const noexcept { return map_.extents().extent(r); }; - MDSPAN_INLINE_FUNCTION constexpr index_type size() const noexcept { -// return __impl::__size(*this); - return ctr_.size(); - }; - - - //-------------------------------------------------------------------------------- - // [mdspan.basic.obs], mdspan observers of the mapping - - 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 mapping_type mapping() const noexcept { return map_; }; - MDSPAN_INLINE_FUNCTION constexpr bool is_unique() const noexcept { return map_.is_unique(); }; - MDSPAN_INLINE_FUNCTION constexpr bool is_exhaustive() const noexcept { return map_.is_exhaustive(); }; - MDSPAN_INLINE_FUNCTION constexpr bool is_strided() const noexcept { return map_.is_strided(); }; - MDSPAN_INLINE_FUNCTION constexpr index_type stride(size_t r) const { return map_.stride(r); }; - -private: - mapping_type map_; - container_type ctr_; - - template - friend class mdarray; -}; - - -} // end namespace experimental -} // end namespace std diff --git a/src/mdspan/mdarray b/src/mdspan/mdarray deleted file mode 100644 index fa710a5..0000000 --- a/src/mdspan/mdarray +++ /dev/null @@ -1,48 +0,0 @@ -/* -//@HEADER -// ************************************************************************ -// -// Kokkos v. 2.0 -// Copyright (2019) Sandia Corporation -// -// Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation, -// the U.S. Government retains certain rights in this software. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// 1. Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// 2. Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// 3. Neither the name of the Corporation nor the names of the -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY -// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -// Questions? Contact Christian R. Trott (crtrott@sandia.gov) -// -// ************************************************************************ -//@HEADER -*/ - -#pragma once - -#include "mdspan" -#include "__p1684_bits/mdarray.hpp" - diff --git a/src/mdspan/mdspan b/src/mdspan/mdspan deleted file mode 100644 index ca6f6b8..0000000 --- a/src/mdspan/mdspan +++ /dev/null @@ -1,56 +0,0 @@ -/* -//@HEADER -// ************************************************************************ -// -// Kokkos v. 2.0 -// Copyright (2019) Sandia Corporation -// -// Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation, -// the U.S. Government retains certain rights in this software. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// 1. Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// 2. Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// 3. Neither the name of the Corporation nor the names of the -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY -// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -// Questions? Contact Christian R. Trott (crtrott@sandia.gov) -// -// ************************************************************************ -//@HEADER -*/ - -#pragma once - -#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" -#include "__p0009_bits/static_array.hpp" -#include "__p0009_bits/submdspan.hpp" diff --git a/src/sim_basic.cpp b/src/sim_basic.cpp index 7af6aa8..e4cda2b 100644 --- a/src/sim_basic.cpp +++ b/src/sim_basic.cpp @@ -52,7 +52,7 @@ #endif -#include "mdspan/mdspan" +#include #if defined(__clang__) || defined(__GNUC__) @@ -508,14 +508,14 @@ void sim::finalise_ctor(std::vector 0); - return fix_nn(x * x + y * y + z * z) - m_exit_radius * m_exit_radius; + return x * x + y * y + z * z - m_exit_radius * m_exit_radius; }; auto make_reentry_eq = [&]() { if (auto *dbl_ptr = std::get_if(&m_reentry_radius)) { assert(*dbl_ptr > 0); - return fix_nn(x * x + y * y + z * z) - *dbl_ptr * *dbl_ptr; + return x * x + y * y + z * z - *dbl_ptr * *dbl_ptr; } else { const auto &ax_vec = std::get>(m_reentry_radius); @@ -525,8 +525,8 @@ void sim::finalise_ctor(std::vector #if defined(__clang__) || defined(__GNUC__) diff --git a/src/sim_bvh.cpp b/src/sim_bvh.cpp index 5e162a4..238dca1 100644 --- a/src/sim_bvh.cpp +++ b/src/sim_bvh.cpp @@ -35,7 +35,7 @@ #endif -#include "mdspan/mdspan" +#include #if defined(__clang__) || defined(__GNUC__) diff --git a/src/sim_jit.cpp b/src/sim_jit.cpp index 4145579..9d3cdac 100644 --- a/src/sim_jit.cpp +++ b/src/sim_jit.cpp @@ -33,7 +33,7 @@ #endif -#include "mdspan/mdspan" +#include #if defined(__clang__) || defined(__GNUC__) @@ -109,7 +109,7 @@ void add_poly_translator_a(hy::llvm_state &s, std::uint32_t order) } // Add the compiled function. - hy::add_cfunc(s, "pta_cfunc", out, hy::kw::vars = std::move(cfs)); + hy::add_cfunc(s, "pta_cfunc", out, cfs); } // Add a compiled function to compute the sum of the squares @@ -214,7 +214,7 @@ void add_poly_ssdiff3_cfunc(hy::llvm_state &s, std::uint32_t order) } // Add the compiled function. - hy::add_cfunc(s, "ssdiff3_cfunc", out, hy::kw::vars = std::move(vars)); + hy::add_cfunc(s, "ssdiff3_cfunc", out, vars); } } // namespace diff --git a/src/sim_narrow_phase.cpp b/src/sim_narrow_phase.cpp index 326881c..6c71f0f 100644 --- a/src/sim_narrow_phase.cpp +++ b/src/sim_narrow_phase.cpp @@ -47,7 +47,7 @@ #endif -#include "mdspan/mdspan" +#include #if defined(__clang__) || defined(__GNUC__) diff --git a/src/sim_propagate.cpp b/src/sim_propagate.cpp index cb53c5f..4967b14 100644 --- a/src/sim_propagate.cpp +++ b/src/sim_propagate.cpp @@ -64,7 +64,7 @@ #endif -#include "mdspan/mdspan" +#include #if defined(__clang__) || defined(__GNUC__) diff --git a/tools/gha_manylinux.sh b/tools/gha_manylinux.sh index 72301c4..ff81f17 100644 --- a/tools/gha_manylinux.sh +++ b/tools/gha_manylinux.sh @@ -43,8 +43,8 @@ else fi # The heyoka/heyoka.py versions to be used. -export HEYOKA_VERSION="3.0.0" -export HEYOKA_PY_VERSION="3.0.0" +export HEYOKA_VERSION="5.0.0" +export HEYOKA_PY_VERSION="5.0.1" # Python mandatory deps. /opt/python/${PYTHON_DIR}/bin/pip install heyoka==${HEYOKA_PY_VERSION} numpy