11#include <Kokkos_Core.hpp>
13namespace ddc::detail {
15template <std::size_t N,
class ElementType,
bool CONTIGUOUS =
true>
18template <std::size_t N,
class ElementType>
19struct ViewNDMaker<N, ElementType,
true>
22 = Kokkos::mdspan<ElementType, Kokkos::dextents<std::size_t, N>, Kokkos::layout_right>;
25template <std::size_t N,
class ElementType>
26struct ViewNDMaker<N, ElementType,
false>
29 = Kokkos::mdspan<ElementType, Kokkos::dextents<std::size_t, N>, Kokkos::layout_stride>;
44std::ostream& stream_impl(
46 Kokkos::mdspan<ElementType, Extents, Layout, Accessor>
const& s,
47 std::index_sequence<I0, Is...>)
49 if constexpr (
sizeof...(Is) > 0) {
51 for (std::size_t i0 = 0; i0 < s.extent(I0); ++i0) {
54 Kokkos::submdspan(s, i0, ((
void)Is, Kokkos::full_extent)...),
55 std::make_index_sequence<
sizeof...(Is)>());
60 for (std::size_t i0 = 0; i0 < s.extent(I0) - 1; ++i0) {
63 os << s(s.extent(I0) - 1) <<
']';
70template <
class ElementType,
class Extents,
class Layout,
class Accessor>
71std::ostream& operator<<(
73 Kokkos::mdspan<ElementType, Extents, Layout, Accessor>
const& s)
75 return ddc::detail::stream_impl(os, s, std::make_index_sequence<Extents::rank()>());
82template <std::size_t N,
class ElementType>
83using SpanND = Kokkos::mdspan<ElementType, Kokkos::dextents<std::size_t, N>>;
85template <std::size_t N,
class ElementType>
86using ViewND = SpanND<N, ElementType
const>;
88template <
class ElementType>
89using Span1D = SpanND<1, ElementType>;
91template <
class ElementType>
92using Span2D = SpanND<2, ElementType>;
94template <
class ElementType>
95using View1D = ViewND<1, ElementType>;
97template <
class ElementType>
98using View2D = ViewND<2, ElementType>;
100using DSpan1D =
ddc::Span1D<
double>;
102using DSpan2D =
ddc::Span2D<
double>;
104using CDSpan1D =
ddc::Span1D<
double const>;
106using CDSpan2D =
ddc::Span2D<
double const>;
108using DView1D = View1D<
double>;
110using DView2D = View2D<
double>;
The top-level namespace of DDC.