13#include <experimental/mdspan>
15#include "ddc/chunk_common.hpp"
16#include "ddc/detail/kokkos.hpp"
17#include "ddc/discrete_domain.hpp"
18#include "ddc/discrete_element.hpp"
22template <
class,
class,
class>
29 class MemorySpace = Kokkos::DefaultHostExecutionSpace::memory_space>
32template <
class ElementType,
class SupportType,
class LayoutStr
idedPolicy,
class MemorySpace>
36template <
class ElementType,
class SupportType,
class LayoutStr
idedPolicy,
class MemorySpace>
42 :
public ChunkCommon<ElementType, DiscreteDomain<DDims...>, LayoutStridedPolicy>
91 template <
class,
class,
class,
class>
102 return std::experimental::full_extent;
112 return std::pair<std::size_t, std::size_t>(
116 return std::experimental::full_extent;
141 class = std::enable_if_t<std::is_same_v<typename Allocator::memory_space, MemorySpace>>>
144 :
base_type(other.m_internal_mdspan, other.m_domain)
155 class = std::enable_if_t<std::is_const_v<SFINAEElementType>>,
157 class = std::enable_if_t<std::is_same_v<typename Allocator::memory_space, MemorySpace>>>
160 :
base_type(other.m_internal_mdspan, other.m_domain)
167 template <
class OElementType>
170 :
base_type(other.m_internal_mdspan, other.m_domain)
180 std::enable_if_t<std::is_constructible_v<Mapping, extents_type>,
int> = 0>
191 allocation_mdspan_type allocation_mdspan,
192 mdomain_type
const& domain)
195 ==
static_cast<std::size_t
>(domain.template
extent<DDims>().value()))
197 namespace stdex = std::experimental;
198 if (!domain.empty()) {
200 std::array<std::size_t,
sizeof...(DDims)>
strides_s {allocation_mdspan.mapping().stride(
203 this->m_internal_mdspan = internal_mdspan_type(
207 this->m_internal_mdspan = allocation_mdspan;
209 this->m_domain = domain;
219 detail::build_mdspan(
view, std::make_index_sequence<
sizeof...(
DDims)> {}),
244 auto subview = std::experimental::
246 using detail::TypeSeq;
251 typename decltype(
subview)::layout_type,
260 auto subview = std::experimental::
264 decltype(this->m_domain.restrict(
odomain)),
265 typename decltype(
subview)::layout_type,
277 sizeof...(DDims) == (0 + ... + DElems::size()),
278 "Invalid number of dimensions");
290 return base_type::data_handle();
296 KOKKOS_FUNCTION constexpr allocation_mdspan_type allocation_mdspan()
const
298 return base_type::allocation_mdspan();
306 auto s = this->allocation_mdspan();
310 std::make_index_sequence<
sizeof...(DDims)> {});
312 detail::mdspan_to_kokkos_element_t<
ElementType,
sizeof...(DDims)>,
331 class = std::enable_if_t<Kokkos::is_view<KokkosView>::value>>
333 detail::kokkos_to_mdspan_element_t<typename KokkosView::data_type>,
335 detail::kokkos_to_mdspan_layout_t<typename KokkosView::array_layout>,
336 typename KokkosView::memory_space>;
Definition chunk_common.hpp:38
std::experimental::mdspan< const ElementType, std::experimental::dextents< std::size_t, sizeof...(DDims)>, LayoutStridedPolicy > const_allocation_mdspan_type
Definition chunk_common.hpp:55
std::experimental::mdspan< ElementType, std::experimental::dextents< std::size_t, sizeof...(DDims)>, std::experimental::layout_stride > internal_mdspan_type
the raw mdspan underlying this, with the same indexing (0 might no be dereferenceable)
Definition chunk_common.hpp:41
typename allocation_mdspan_type::mapping_type mapping_type
Definition chunk_common.hpp:68
std::experimental::mdspan< ElementType, std::experimental::dextents< std::size_t, sizeof...(DDims)>, LayoutStridedPolicy > allocation_mdspan_type
The dereferenceable part of the co-domain but with a different domain, starting at 0.
Definition chunk_common.hpp:50
typename allocation_mdspan_type::size_type size_type
Definition chunk_common.hpp:74
typename allocation_mdspan_type::data_handle_type data_handle_type
Definition chunk_common.hpp:76
typename allocation_mdspan_type::layout_type layout_type
Definition chunk_common.hpp:64
typename allocation_mdspan_type::accessor_type accessor_type
Definition chunk_common.hpp:66
typename allocation_mdspan_type::reference reference
Definition chunk_common.hpp:78
typename allocation_mdspan_type::element_type element_type
Definition chunk_common.hpp:70
typename allocation_mdspan_type::extents_type extents_type
Definition chunk_common.hpp:62
typename allocation_mdspan_type::value_type value_type
Definition chunk_common.hpp:72
Definition chunk_span.hpp:43
typename base_type::const_allocation_mdspan_type const_allocation_mdspan_type
Definition chunk_span.hpp:68
MemorySpace memory_space
Definition chunk_span.hpp:63
typename base_type::mapping_type mapping_type
Definition chunk_span.hpp:78
typename mdomain_type::discrete_element_type discrete_element_type
Definition chunk_span.hpp:70
typename base_type::accessor_type accessor_type
Definition chunk_span.hpp:76
typename base_type::extents_type extents_type
Definition chunk_span.hpp:72
typename base_type::value_type value_type
Definition chunk_span.hpp:82
typename base_type::size_type size_type
Definition chunk_span.hpp:84
typename base_type::layout_type layout_type
Definition chunk_span.hpp:74
typename base_type::reference reference
Definition chunk_span.hpp:88
typename base_type::allocation_mdspan_type allocation_mdspan_type
The dereferenceable part of the co-domain but with a different domain, starting at 0.
Definition chunk_span.hpp:66
typename base_type::element_type element_type
Definition chunk_span.hpp:80
typename base_type::data_handle_type data_handle_type
Definition chunk_span.hpp:86
Definition discrete_domain.hpp:51
The top-level namespace of DDC.
Definition aligned_allocator.hpp:11
constexpr bool enable_borrowed_chunk
Definition chunk_traits.hpp:13
constexpr bool enable_chunk
Definition chunk_traits.hpp:16
ChunkSpan(KokkosView const &view, DiscreteDomain< DDims... > domain) -> ChunkSpan< detail::kokkos_to_mdspan_element_t< typename KokkosView::data_type >, DiscreteDomain< DDims... >, detail::kokkos_to_mdspan_layout_t< typename KokkosView::array_layout >, typename KokkosView::memory_space >
Chunk(std::string const &, DiscreteDomain< DDims... > const &, Allocator) -> Chunk< typename Allocator::value_type, DiscreteDomain< DDims... >, Allocator >
KOKKOS_FUNCTION constexpr DiscreteElementType const & uid(DiscreteElement< Tag > const &tuple) noexcept
Definition discrete_element.hpp:51
Definition chunk_common.hpp:34
Definition chunk_span.hpp:30