12#include <Kokkos_Core.hpp>
14#include "detail/macros.hpp"
16#include "chunk_traits.hpp"
17#include "discrete_domain.hpp"
22
23
24
25template <
class... QueryDDims,
class ChunkType>
28 static_assert(is_chunk_v<ChunkType>,
"Not a chunk span type");
29 return chunk.
template domain<QueryDDims...>();
32template <
class ElementType,
class SupportType,
class LayoutStridedPolicy>
36 using discrete_domain_type = SupportType;
39 using allocation_mdspan_type = Kokkos::mdspan<
41 Kokkos::dextents<std::size_t, SupportType::rank()>,
44 using const_allocation_mdspan_type = Kokkos::mdspan<
46 Kokkos::dextents<std::size_t, SupportType::rank()>,
49 using discrete_element_type =
typename discrete_domain_type::discrete_element_type;
51 using discrete_vector_type =
typename discrete_domain_type::discrete_vector_type;
53 using extents_type =
typename allocation_mdspan_type::extents_type;
55 using layout_type =
typename allocation_mdspan_type::layout_type;
57 using accessor_type =
typename allocation_mdspan_type::accessor_type;
59 using mapping_type =
typename allocation_mdspan_type::mapping_type;
61 using element_type =
typename allocation_mdspan_type::element_type;
63 using value_type =
typename allocation_mdspan_type::value_type;
65 using size_type =
typename allocation_mdspan_type::size_type;
67 using data_handle_type =
typename allocation_mdspan_type::data_handle_type;
69 using reference =
typename allocation_mdspan_type::reference;
72 template <
class,
class,
class>
75 template <
class,
class,
class,
class>
78 template <
class,
class,
class>
81 static_assert(mapping_type::is_always_strided());
93 return extents_type::rank();
98 return extents_type::rank_dynamic();
103 return extents_type::static_extent(r);
108 return mapping_type::is_always_unique();
113 return mapping_type::is_always_exhaustive();
118 return mapping_type::is_always_strided();
122 template <
class Mapping = mapping_type>
123 static KOKKOS_FUNCTION
constexpr std::
124 enable_if_t<std::is_constructible_v<Mapping, extents_type>, allocation_mdspan_type>
125 make_allocation_mdspan(ElementType* ptr, SupportType
const& domain)
127 return allocation_mdspan_type(ptr, detail::array(domain.extents()));
141 template <
class QueryDDim>
144 return m_domain.
template extent<QueryDDim>();
172 template <
class QueryDDim>
179
180
187
188
189 template <
class... QueryDDims>
200
201
202
204 allocation_mdspan_type allocation_mdspan,
205 SupportType
const& domain)
noexcept
212
213
214
216 class Mapping = mapping_type,
217 std::enable_if_t<std::is_constructible_v<Mapping, extents_type>,
int> = 0>
223 KOKKOS_ASSERT(domain.empty() || ((ptr !=
nullptr) && !domain.empty()))
227
228
232
233
239
240
241
245
246
247
252
253
260
261
KOKKOS_FUNCTION constexpr bool is_strided() const noexcept
KOKKOS_DEFAULTED_FUNCTION ~ChunkCommon() noexcept=default
KOKKOS_FUNCTION constexpr ElementType * data_handle() const
Access to the underlying allocation pointer.
KOKKOS_DEFAULTED_FUNCTION constexpr ChunkCommon()=default
Empty ChunkCommon.
allocation_mdspan_type m_allocation_mdspan
The raw view of the data.
KOKKOS_FUNCTION constexpr SupportType domain() const noexcept
Provide access to the domain on which this chunk is defined.
static KOKKOS_FUNCTION constexpr bool is_always_strided() noexcept
KOKKOS_FUNCTION constexpr allocation_mdspan_type allocation_mdspan() const
Provide a modifiable view of the data.
KOKKOS_FUNCTION constexpr ChunkCommon(allocation_mdspan_type allocation_mdspan, SupportType const &domain) noexcept
Constructs a new ChunkCommon from scratch.
KOKKOS_FUNCTION constexpr ChunkCommon(ElementType *ptr, SupportType const &domain)
Constructs a new ChunkCommon from scratch.
KOKKOS_DEFAULTED_FUNCTION constexpr ChunkCommon(ChunkCommon const &other)=default
Constructs a new ChunkCommon by copy, yields a new view to the same data.
static KOKKOS_FUNCTION constexpr bool is_always_unique() noexcept
KOKKOS_FUNCTION constexpr DiscreteDomain< QueryDDims... > domain() const noexcept
Provide access to the domain on which this chunk is defined.
KOKKOS_DEFAULTED_FUNCTION constexpr ChunkCommon & operator=(ChunkCommon const &other)=default
Copy-assigns a new value to this ChunkCommon, yields a new view to the same data.
KOKKOS_DEFAULTED_FUNCTION constexpr ChunkCommon(ChunkCommon &&other) noexcept=default
Constructs a new ChunkCommon by move.
KOKKOS_DEFAULTED_FUNCTION constexpr ChunkCommon & operator=(ChunkCommon &&other) noexcept=default
Move-assigns a new value to this ChunkCommon.
KOKKOS_FUNCTION constexpr size_type extent() const noexcept
KOKKOS_FUNCTION constexpr size_type stride() const
KOKKOS_FUNCTION constexpr bool is_exhaustive() const noexcept
KOKKOS_FUNCTION constexpr mapping_type mapping() const noexcept
static KOKKOS_FUNCTION constexpr int rank() noexcept
KOKKOS_FUNCTION constexpr bool is_unique() const noexcept
KOKKOS_FUNCTION constexpr accessor_type accessor() const
KOKKOS_FUNCTION constexpr SupportType::discrete_vector_type extents() const noexcept
KOKKOS_FUNCTION constexpr size_type size() const noexcept
SupportType m_domain
The mesh on which this chunk is defined.
static KOKKOS_FUNCTION constexpr int rank_dynamic() noexcept
static KOKKOS_FUNCTION constexpr size_type static_extent(std::size_t r) noexcept
static KOKKOS_FUNCTION constexpr bool is_always_exhaustive() noexcept
friend class DiscreteDomain
The top-level namespace of DDC.
KOKKOS_FUNCTION auto get_domain(ChunkType const &chunk) noexcept
Access the domain (or subdomain) of a view.