13#include <Kokkos_Core.hpp>
15#include "detail/macros.hpp"
17#include "chunk_traits.hpp"
18#include "discrete_domain.hpp"
23
24
25
26template <
class... QueryDDims,
class ChunkType>
29 static_assert(is_chunk_v<ChunkType>,
"Not a chunk span type");
30 return chunk.
template domain<QueryDDims...>();
33template <
class ElementType,
class SupportType,
class LayoutStridedPolicy>
37 using discrete_domain_type = SupportType;
40 using allocation_mdspan_type = Kokkos::mdspan<
42 Kokkos::dextents<std::size_t, SupportType::rank()>,
45 using const_allocation_mdspan_type = Kokkos::mdspan<
47 Kokkos::dextents<std::size_t, SupportType::rank()>,
50 using discrete_element_type =
typename discrete_domain_type::discrete_element_type;
52 using discrete_vector_type =
typename discrete_domain_type::discrete_vector_type;
54 using extents_type =
typename allocation_mdspan_type::extents_type;
56 using layout_type =
typename allocation_mdspan_type::layout_type;
58 using accessor_type =
typename allocation_mdspan_type::accessor_type;
60 using mapping_type =
typename allocation_mdspan_type::mapping_type;
62 using element_type =
typename allocation_mdspan_type::element_type;
64 using value_type =
typename allocation_mdspan_type::value_type;
66 using size_type =
typename allocation_mdspan_type::size_type;
68 using data_handle_type =
typename allocation_mdspan_type::data_handle_type;
70 using reference =
typename allocation_mdspan_type::reference;
73 template <
class,
class,
class>
76 template <
class,
class,
class,
class>
79 template <
class,
class,
class>
82 static_assert(mapping_type::is_always_strided());
94 return extents_type::rank();
99 return extents_type::rank_dynamic();
104 return extents_type::static_extent(r);
109 return mapping_type::is_always_unique();
114 return mapping_type::is_always_exhaustive();
119 return mapping_type::is_always_strided();
123 template <
class Mapping = mapping_type>
124 static KOKKOS_FUNCTION
constexpr std::
125 enable_if_t<std::is_constructible_v<Mapping, extents_type>, allocation_mdspan_type>
126 make_allocation_mdspan(ElementType* ptr, SupportType
const& domain)
128 return allocation_mdspan_type(ptr, detail::array(domain.extents()));
142 template <
class QueryDDim>
145 return m_domain.
template extent<QueryDDim>();
173 template <
class QueryDDim>
180
181
188
189
190 template <
class... QueryDDims>
201
202
203
205 allocation_mdspan_type allocation_mdspan,
206 SupportType
const& domain)
noexcept
213
214
215
217 class Mapping = mapping_type,
218 std::enable_if_t<std::is_constructible_v<Mapping, extents_type>,
int> = 0>
224 assert(domain.empty() || ((ptr !=
nullptr) && !domain.empty()));
228
229
233
234
240
241
242
246
247
248
253
254
261
262
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.