DDC 0.15.1
Loading...
Searching...
No Matches
chunk_span.hpp
1// Copyright (C) The DDC development team, see COPYRIGHT.md file
2//
3// SPDX-License-Identifier: MIT
4
5#pragma once
6
7#include <concepts>
8#include <cstddef>
9#include <type_traits>
10#include <utility>
11
12#include <Kokkos_Core.hpp>
13
14#include "detail/kokkos.hpp"
15#include "detail/macros.hpp"
16#include "detail/type_seq.hpp"
17
18#include "chunk_common.hpp"
22
23namespace ddc {
24
25template <class, class, class>
26class Chunk;
27
28template <
29 class ElementType,
30 class SupportType,
31 class LayoutStridedPolicy = Kokkos::layout_right,
32 class MemorySpace = Kokkos::DefaultHostExecutionSpace::memory_space>
33class ChunkSpan;
34
35template <class ElementType, class SupportType, class LayoutStridedPolicy, class MemorySpace>
36inline constexpr bool
38 = true;
39
40template <class ElementType, class SupportType, class LayoutStridedPolicy, class MemorySpace>
41inline constexpr bool
43 = true;
44
45template <class ElementType, class SupportType, class LayoutStridedPolicy, class MemorySpace>
46class ChunkSpan : public ChunkCommon<ElementType, SupportType, LayoutStridedPolicy>
47{
48 static_assert(
49 std::is_same_v<LayoutStridedPolicy, Kokkos::layout_left>
50 || std::is_same_v<LayoutStridedPolicy, Kokkos::layout_right>
51 || std::is_same_v<LayoutStridedPolicy, Kokkos::layout_stride>,
52 "ChunkSpan only supports layout_left, layout_right or layout_stride");
53 static_assert(
54 Kokkos::is_memory_space_v<MemorySpace>,
55 "ChunkSpan requires a valid Kokkos memory space");
56
57protected:
58 using base_type = ChunkCommon<ElementType, SupportType, LayoutStridedPolicy>;
59
60public:
61 /// type of a span of this full chunk
62 using span_type = ChunkSpan<ElementType, SupportType, LayoutStridedPolicy, MemorySpace>;
63
64 /// type of a view of this full chunk
65 using view_type = ChunkSpan<ElementType const, SupportType, LayoutStridedPolicy, MemorySpace>;
66
67 using discrete_domain_type = base_type::discrete_domain_type;
68
69 using memory_space = MemorySpace;
70
71 /// The dereferenceable part of the co-domain but with a different domain, starting at 0
72 using allocation_mdspan_type = base_type::allocation_mdspan_type;
73
74 using const_allocation_mdspan_type = base_type::const_allocation_mdspan_type;
75
76 using discrete_element_type = discrete_domain_type::discrete_element_type;
77
78 using discrete_vector_type = discrete_domain_type::discrete_vector_type;
79
80 using extents_type = base_type::extents_type;
81
82 using layout_type = base_type::layout_type;
83
84 using accessor_type = base_type::accessor_type;
85
86 using mapping_type = base_type::mapping_type;
87
88 using element_type = base_type::element_type;
89
90 using value_type = base_type::value_type;
91
92 using size_type = base_type::size_type;
93
94 using data_handle_type = base_type::data_handle_type;
95
96 using reference = base_type::reference;
97
98 template <class, class, class, class>
99 friend class ChunkSpan;
100
101protected:
102 template <class QueryDDim, class... ODDims>
103 KOKKOS_FUNCTION static constexpr auto get_slicer_for(DiscreteVector<ODDims...> const& c)
104 {
105 DDC_IF_NVCC_THEN_PUSH_AND_SUPPRESS(implicit_return_from_non_void_function)
106 if constexpr (in_tags_v<QueryDDim, detail::TypeSeq<ODDims...>>) {
107 return c.template get<QueryDDim>();
108 } else {
109 return Kokkos::full_extent;
110 }
111 DDC_IF_NVCC_THEN_POP
112 }
113
114 template <class QueryDDim, class... ODDims, class... OODDims>
115 KOKKOS_FUNCTION static constexpr auto get_slicer_for(
116 DiscreteDomain<ODDims...> const& c,
117 DiscreteDomain<OODDims...> const& origin)
118 {
119 DDC_IF_NVCC_THEN_PUSH_AND_SUPPRESS(implicit_return_from_non_void_function)
120 if constexpr (in_tags_v<QueryDDim, detail::TypeSeq<ODDims...>>) {
121 DiscreteDomain<QueryDDim> const c_slice(c);
122 DiscreteDomain<QueryDDim> const origin_slice(origin);
123 return std::pair<std::size_t, std::size_t>(
124 c_slice.front() - origin_slice.front(),
125 c_slice.back() + 1 - origin_slice.front());
126 } else {
127 return Kokkos::full_extent;
128 }
129 DDC_IF_NVCC_THEN_POP
130 }
131
132 template <class TypeSeq>
133 struct Slicer
134 {
135 };
136
137 template <class... DDims>
138 struct Slicer<detail::TypeSeq<DDims...>>
139 {
140 template <class... ODDims>
141 KOKKOS_FUNCTION constexpr auto operator()(
142 allocation_mdspan_type const& span,
143 DiscreteVector<ODDims...> const& c) const
144 {
145 return Kokkos::submdspan(span, get_slicer_for<DDims>(c)...);
146 }
147
148 template <class... ODDims, class... OODDims>
149 KOKKOS_FUNCTION constexpr auto operator()(
150 allocation_mdspan_type const& span,
151 DiscreteDomain<ODDims...> const& c,
152 DiscreteDomain<OODDims...> const& origin) const
153 {
154 return Kokkos::submdspan(span, get_slicer_for<DDims>(c, origin)...);
155 }
156 };
157
158public:
159 /// Empty ChunkSpan
160 KOKKOS_DEFAULTED_FUNCTION constexpr ChunkSpan() = default;
161
162 /** Constructs a new ChunkSpan by copy, yields a new view to the same data
163 * @param other the ChunkSpan to copy
164 */
165 KOKKOS_DEFAULTED_FUNCTION constexpr ChunkSpan(ChunkSpan const& other) = default;
166
167 /** Constructs a new ChunkSpan by move
168 * @param other the ChunkSpan to move
169 */
170 KOKKOS_DEFAULTED_FUNCTION constexpr ChunkSpan(ChunkSpan&& other) noexcept = default;
171
172 /** Forbids to construct a ChunkSpan from a rvalue of type Chunk.
173 */
174 template <class OElementType, class Allocator>
175 ChunkSpan(Chunk<OElementType, SupportType, Allocator>&& other) noexcept
176 requires(std::is_same_v<typename Allocator::memory_space, MemorySpace>)
177 = delete;
178
179 /** Constructs a new ChunkSpan from a Chunk, yields a new view to the same data
180 * @param other the Chunk to view
181 */
182 template <class OElementType, class Allocator>
183 KOKKOS_FUNCTION constexpr explicit ChunkSpan(
184 Chunk<OElementType, SupportType, Allocator>& other) noexcept
185 requires(std::is_same_v<typename Allocator::memory_space, MemorySpace>)
186 : base_type(other.m_allocation_mdspan, other.m_domain)
187 {
188 }
189
190 /** Constructs a new ChunkSpan from a Chunk, yields a new view to the same data
191 * @param other the Chunk to view
192 */
193 // Disabled in the case of `ElementType` is not `const` to avoid write access
194 template <class OElementType, class Allocator>
195 KOKKOS_FUNCTION constexpr explicit ChunkSpan(
196 Chunk<OElementType, SupportType, Allocator> const& other) noexcept
197 requires(
198 std::is_const_v<ElementType>
199 && std::is_same_v<typename Allocator::memory_space, MemorySpace>)
200 : base_type(other.m_allocation_mdspan, other.m_domain)
201 {
202 }
203
204 /** Constructs a new ChunkSpan by copy of a chunk, yields a new view to the same data
205 * @param other the ChunkSpan to move
206 */
207 template <class OElementType, class OLayout>
208 KOKKOS_FUNCTION constexpr explicit ChunkSpan(
209 ChunkSpan<OElementType, SupportType, OLayout, MemorySpace> const& other) noexcept
210 requires(std::constructible_from<
211 allocation_mdspan_type,
212 Kokkos::mdspan<OElementType, extents_type, OLayout>>)
213 : base_type(other.m_allocation_mdspan, other.m_domain)
214 {
215 }
216
217 /** Constructs a new ChunkSpan from scratch
218 * @param ptr the allocation pointer to the data
219 * @param domain the domain that sustains the view
220 */
221 KOKKOS_FUNCTION constexpr ChunkSpan(ElementType* const ptr, SupportType const& domain)
222 requires(std::is_constructible_v<mapping_type, extents_type>)
223 : base_type(ptr, domain)
224 {
225 }
226
227 /** Constructs a new ChunkSpan from scratch
228 * @param allocation_mdspan the allocation mdspan to the data
229 * @param domain the domain that sustains the view
230 */
231 KOKKOS_FUNCTION constexpr ChunkSpan(
232 allocation_mdspan_type allocation_mdspan,
233 SupportType const& domain)
234 : base_type(allocation_mdspan, domain)
235 {
236 if constexpr (SupportType::rank() > 0) {
237 for (std::size_t i = 0; i < SupportType::rank(); ++i) {
238 KOKKOS_ASSERT(
239 allocation_mdspan.extent(i)
240 == static_cast<std::size_t>(detail::array(domain.extents())[i]))
241 }
242 }
243 }
244
245 /** Constructs a new ChunkSpan from scratch
246 * @param view the Kokkos view
247 * @param domain the domain that sustains the view
248 */
249 template <class KokkosView>
250 KOKKOS_FUNCTION constexpr ChunkSpan(KokkosView const& view, SupportType const& domain) noexcept
251 requires(Kokkos::is_view_v<KokkosView>)
252 : ChunkSpan(
253 detail::build_mdspan(view, std::make_index_sequence<SupportType::rank()> {}),
254 domain)
255 {
256 }
257
258 KOKKOS_DEFAULTED_FUNCTION ~ChunkSpan() noexcept = default;
259
260 /** Copy-assigns a new value to this ChunkSpan, yields a new view to the same data
261 * @param other the ChunkSpan to copy
262 * @return *this
263 */
264 KOKKOS_DEFAULTED_FUNCTION constexpr ChunkSpan& operator=(ChunkSpan const& other) = default;
265
266 /** Move-assigns a new value to this ChunkSpan
267 * @param other the ChunkSpan to move
268 * @return *this
269 */
270 KOKKOS_DEFAULTED_FUNCTION constexpr ChunkSpan& operator=(ChunkSpan&& other) noexcept = default;
271
272 /** Slice out some dimensions
273 */
274 template <class... QueryDDims>
275 KOKKOS_FUNCTION constexpr auto operator[](DiscreteVector<QueryDDims...> const& slice_spec) const
276 {
277 using detail::TypeSeq;
278 KOKKOS_ASSERT(
279 ((DiscreteVector<QueryDDims>(slice_spec)
280 < DiscreteVector<QueryDDims>(this->m_domain.extents()))
281 && ...))
282 Slicer<to_type_seq_t<SupportType>> const slicer;
283 auto subview = slicer(this->allocation_mdspan(), slice_spec);
284 using layout_type = decltype(subview)::layout_type;
285 using extents_type = decltype(subview)::extents_type;
286 using OutTypeSeqDDims
287 = type_seq_remove_t<to_type_seq_t<SupportType>, TypeSeq<QueryDDims...>>;
288 using OutDDom = detail::Rebind<SupportType, OutTypeSeqDDims>::type;
289 if constexpr (
290 std::is_same_v<layout_type, Kokkos::Experimental::layout_left_padded<>>
291 || std::is_same_v<layout_type, Kokkos::Experimental::layout_right_padded<>>) {
292 Kokkos::layout_stride::mapping<extents_type> const mapping_stride(subview.mapping());
293 Kokkos::mdspan<ElementType, extents_type, Kokkos::layout_stride> const
294 a(subview.data_handle(), mapping_stride);
295 return ChunkSpan<
296 ElementType,
297 OutDDom,
298 Kokkos::layout_stride,
299 memory_space>(a, OutDDom(this->m_domain));
300 } else {
301 return ChunkSpan<
302 ElementType,
303 OutDDom,
304 layout_type,
305 memory_space>(subview, OutDDom(this->m_domain));
306 }
307 }
308
309 /** Slice out some dimensions
310 */
311 template <class... QueryDDims>
312 KOKKOS_FUNCTION constexpr auto operator[](
313 DiscreteElement<QueryDDims...> const& slice_spec) const
314 {
315 using QueryDDom = detail::Rebind<SupportType, detail::TypeSeq<QueryDDims...>>::type;
316 KOKKOS_ASSERT(QueryDDom(this->m_domain).contains(slice_spec))
317 return (*this)[QueryDDom(this->m_domain).distance_from_front(slice_spec)];
318 }
319
320 /** Restrict to a subdomain, only valid when SupportType is a DiscreteDomain
321 */
322 template <class... QueryDDims>
323 KOKKOS_FUNCTION constexpr auto operator[](DiscreteDomain<QueryDDims...> const& odomain) const
324 requires(is_discrete_domain_v<SupportType>)
325 {
326 KOKKOS_ASSERT(
327 odomain.empty()
328 || (DiscreteDomain<QueryDDims...>(this->m_domain).contains(odomain.front())
329 && DiscreteDomain<QueryDDims...>(this->m_domain).contains(odomain.back())))
330 Slicer<to_type_seq_t<SupportType>> const slicer;
331 auto subview = slicer(this->allocation_mdspan(), odomain, this->m_domain);
332 using layout_type = decltype(subview)::layout_type;
333 using extents_type = decltype(subview)::extents_type;
334 if constexpr (
335 std::is_same_v<layout_type, Kokkos::Experimental::layout_left_padded<>>
336 || std::is_same_v<layout_type, Kokkos::Experimental::layout_right_padded<>>) {
337 Kokkos::layout_stride::mapping<extents_type> const mapping_stride(subview.mapping());
338 Kokkos::mdspan<ElementType, extents_type, Kokkos::layout_stride> const
339 a(subview.data_handle(), mapping_stride);
340 return ChunkSpan<
341 ElementType,
342 decltype(this->m_domain.restrict_with(odomain)),
343 Kokkos::layout_stride,
344 memory_space>(a, this->m_domain.restrict_with(odomain));
345 } else {
346 return ChunkSpan<
347 ElementType,
348 decltype(this->m_domain.restrict_with(odomain)),
349 layout_type,
350 memory_space>(subview, this->m_domain.restrict_with(odomain));
351 }
352 }
353
354 /** Element access using a list of DiscreteElement
355 * @param delems discrete elements
356 * @return reference to this element
357 */
358 template <concepts::discrete_element... DElems>
359 KOKKOS_FUNCTION constexpr reference operator()(DElems const&... delems) const noexcept
360 {
361 static_assert(
362 SupportType::rank() == (0 + ... + DElems::size()),
363 "Invalid number of dimensions");
364 KOKKOS_ASSERT(this->m_domain.contains(delems...))
365 return DDC_MDSPAN_ACCESS_OP(
366 this->m_allocation_mdspan,
367 detail::array(this->m_domain.distance_from_front(delems...)));
368 }
369
370 /** Element access using a list of DiscreteVector
371 * @param dvects discrete vectors
372 * @return reference to this element
373 */
374 template <concepts::discrete_vector... DVects>
375 KOKKOS_FUNCTION constexpr reference operator()(DVects const&... dvects) const noexcept
376 requires(sizeof...(DVects) != 0)
377 {
378 static_assert(
379 SupportType::rank() == (0 + ... + DVects::size()),
380 "Invalid number of dimensions");
381 return DDC_MDSPAN_ACCESS_OP(
382 this->m_allocation_mdspan,
383 detail::array(discrete_vector_type(dvects...)));
384 }
385
386 /** Access to the underlying allocation pointer
387 * @return allocation pointer
388 */
389 KOKKOS_FUNCTION constexpr ElementType* data_handle() const
390 {
391 return base_type::data_handle();
392 }
393
394 /** Provide a mdspan on the memory allocation
395 * @return allocation mdspan
396 */
397 KOKKOS_FUNCTION constexpr allocation_mdspan_type allocation_mdspan() const
398 {
399 return base_type::allocation_mdspan();
400 }
401
402 /** Provide a mdspan on the memory allocation
403 * @return allocation mdspan
404 */
405 KOKKOS_FUNCTION constexpr auto allocation_kokkos_view() const
406 {
407 auto s = this->allocation_mdspan();
408 auto kokkos_layout = detail::build_kokkos_layout(
409 s.extents(),
410 s.mapping(),
411 std::make_index_sequence<SupportType::rank()> {});
412 return Kokkos::View<
413 detail::mdspan_to_kokkos_element_t<ElementType, SupportType::rank()>,
414 decltype(kokkos_layout),
415 MemorySpace>(s.data_handle(), kokkos_layout);
416 }
417
418 KOKKOS_FUNCTION constexpr view_type span_cview() const
419 {
420 return view_type(*this);
421 }
422
423 KOKKOS_FUNCTION constexpr span_type span_view() const
424 {
425 return *this;
426 }
427};
428
429template <class DataType, class... Properties, class SupportType>
430KOKKOS_DEDUCTION_GUIDE ChunkSpan(
431 Kokkos::View<DataType, Properties...> const& view,
432 SupportType domain)
433 -> ChunkSpan<
434 detail::kokkos_to_mdspan_element_t<
435 typename Kokkos::View<DataType, Properties...>::data_type>,
436 SupportType,
437 detail::kokkos_to_mdspan_layout_t<
438 typename Kokkos::View<DataType, Properties...>::array_layout>,
439 typename Kokkos::View<DataType, Properties...>::memory_space>;
440
441template <class ElementType, class SupportType, class Allocator>
442ChunkSpan(Chunk<ElementType, SupportType, Allocator>& other) -> ChunkSpan<
443 ElementType,
444 SupportType,
445 Kokkos::layout_right,
446 typename Allocator::memory_space>;
447
448template <class ElementType, class SupportType, class Allocator>
449ChunkSpan(Chunk<ElementType, SupportType, Allocator> const& other) -> ChunkSpan<
450 ElementType const,
451 SupportType,
452 Kokkos::layout_right,
453 typename Allocator::memory_space>;
454
455template <
456 class ElementType,
457 class SupportType,
458 class LayoutStridedPolicy = Kokkos::layout_right,
459 class MemorySpace = Kokkos::HostSpace>
460using ChunkView = ChunkSpan<ElementType const, SupportType, LayoutStridedPolicy, MemorySpace>;
461
462} // namespace ddc
friend class ChunkSpan
KOKKOS_FUNCTION constexpr ChunkCommon(ElementType *ptr, SupportType const &domain)
Constructs a new ChunkCommon from scratch.
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_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
KOKKOS_DEFAULTED_FUNCTION constexpr ChunkSpan(ChunkSpan &&other) noexcept=default
Constructs a new ChunkSpan by move.
KOKKOS_FUNCTION constexpr view_type span_cview() const
KOKKOS_FUNCTION constexpr ChunkSpan(allocation_mdspan_type allocation_mdspan, SupportType const &domain)
Constructs a new ChunkSpan from scratch.
KOKKOS_FUNCTION constexpr auto operator[](DiscreteElement< QueryDDims... > const &slice_spec) const
Slice out some dimensions.
ChunkSpan(Chunk< OElementType, SupportType, Allocator > &&other) noexcept=delete
Forbids to construct a ChunkSpan from a rvalue of type Chunk.
KOKKOS_FUNCTION constexpr ChunkSpan(ChunkSpan< OElementType, SupportType, OLayout, MemorySpace > const &other) noexcept
Constructs a new ChunkSpan by copy of a chunk, yields a new view to the same data.
KOKKOS_DEFAULTED_FUNCTION constexpr ChunkSpan(ChunkSpan const &other)=default
Constructs a new ChunkSpan by copy, yields a new view to the same data.
static KOKKOS_FUNCTION constexpr auto get_slicer_for(DiscreteDomain< ODDims... > const &c, DiscreteDomain< OODDims... > const &origin)
static KOKKOS_FUNCTION constexpr auto get_slicer_for(DiscreteVector< ODDims... > const &c)
KOKKOS_FUNCTION constexpr ChunkSpan(Chunk< OElementType, SupportType, Allocator > const &other) noexcept
Constructs a new ChunkSpan from a Chunk, yields a new view to the same data.
KOKKOS_FUNCTION constexpr reference operator()(DElems const &... delems) const noexcept
Element access using a list of DiscreteElement.
KOKKOS_DEFAULTED_FUNCTION constexpr ChunkSpan()=default
Empty ChunkSpan.
KOKKOS_FUNCTION constexpr allocation_mdspan_type allocation_mdspan() const
Provide a mdspan on the memory allocation.
KOKKOS_FUNCTION constexpr ElementType * data_handle() const
Access to the underlying allocation pointer.
KOKKOS_FUNCTION constexpr auto allocation_kokkos_view() const
Provide a mdspan on the memory allocation.
KOKKOS_FUNCTION constexpr ChunkSpan(Chunk< OElementType, SupportType, Allocator > &other) noexcept
Constructs a new ChunkSpan from a Chunk, yields a new view to the same data.
KOKKOS_DEFAULTED_FUNCTION constexpr ChunkSpan & operator=(ChunkSpan const &other)=default
Copy-assigns a new value to this ChunkSpan, yields a new view to the same data.
KOKKOS_FUNCTION constexpr ChunkSpan(KokkosView const &view, SupportType const &domain) noexcept
Constructs a new ChunkSpan from scratch.
KOKKOS_FUNCTION constexpr auto operator[](DiscreteVector< QueryDDims... > const &slice_spec) const
Slice out some dimensions.
KOKKOS_DEFAULTED_FUNCTION ~ChunkSpan() noexcept=default
KOKKOS_FUNCTION constexpr auto operator[](DiscreteDomain< QueryDDims... > const &odomain) const
Restrict to a subdomain, only valid when SupportType is a DiscreteDomain.
KOKKOS_FUNCTION constexpr span_type span_view() const
KOKKOS_FUNCTION constexpr ChunkSpan(ElementType *const ptr, SupportType const &domain)
Constructs a new ChunkSpan from scratch.
KOKKOS_DEFAULTED_FUNCTION constexpr ChunkSpan & operator=(ChunkSpan &&other) noexcept=default
Move-assigns a new value to this ChunkSpan.
auto operator[](DiscreteElement< QueryDDims... > const &slice_spec) const
Slice out some dimensions.
Definition chunk.hpp:168
auto operator[](DiscreteVector< QueryDDims... > const &slice_spec) const
Slice out some dimensions.
Definition chunk.hpp:154
char const * label() const
Returns the label of the Chunk.
Definition chunk.hpp:263
const_allocation_mdspan_type allocation_mdspan() const
Provide a mdspan on the memory allocation.
Definition chunk.hpp:287
ElementType const * data_handle() const
Access to the underlying allocation pointer.
Definition chunk.hpp:271
auto allocation_kokkos_view()
Provide an unmanaged Kokkos::View on the memory allocation.
Definition chunk.hpp:303
auto operator[](DiscreteDomain< QueryDDims... > const &odomain)
Slice out some dimensions.
Definition chunk.hpp:190
auto allocation_kokkos_view() const
Provide an unmanaged Kokkos::View on the memory allocation.
Definition chunk.hpp:319
Chunk(SupportType const &domain, Allocator allocator=Allocator())
Construct a Chunk on a domain with uninitialized values.
Definition chunk.hpp:104
Chunk & operator=(Chunk const &other)=delete
Deleted: use deepcopy instead.
allocation_mdspan_type allocation_mdspan()
Provide a mdspan on the memory allocation.
Definition chunk.hpp:295
ElementType * data_handle()
Access to the underlying allocation pointer.
Definition chunk.hpp:279
view_type span_cview() const
Definition chunk.hpp:332
Chunk(Chunk const &other)=delete
Deleted: use deepcopy instead.
~Chunk() noexcept
Definition chunk.hpp:124
Chunk(std::string const &label, SupportType const &domain, Allocator allocator=Allocator())
Construct a labeled Chunk on a domain with uninitialized values.
Definition chunk.hpp:93
element_type & operator()(DElems const &... delems) noexcept
Element access using a list of DiscreteElement.
Definition chunk.hpp:233
Chunk()=default
Empty Chunk.
Chunk & operator=(Chunk &&other) noexcept
Move-assigns a new value to this field.
Definition chunk.hpp:138
Chunk(Chunk &&other) noexcept
Constructs a new Chunk by move.
Definition chunk.hpp:115
friend class Chunk
Definition chunk.hpp:81
span_type span_view()
Definition chunk.hpp:342
view_type span_view() const
Definition chunk.hpp:337
auto operator[](DiscreteDomain< QueryDDims... > const &odomain) const
Slice out some dimensions.
Definition chunk.hpp:182
element_type const & operator()(DElems const &... delems) const noexcept
Element access using a list of DiscreteElement.
Definition chunk.hpp:201
auto operator[](DiscreteVector< QueryDDims... > const &slice_spec)
Slice out some dimensions.
Definition chunk.hpp:161
auto operator[](DiscreteElement< QueryDDims... > const &slice_spec)
Slice out some dimensions.
Definition chunk.hpp:175
static KOKKOS_FUNCTION constexpr discrete_vector_type extents() noexcept
KOKKOS_DEFAULTED_FUNCTION ~DiscreteDomain()=default
KOKKOS_FUNCTION constexpr DiscreteDomain(discrete_element_type const &element_begin, discrete_vector_type const &size)
Construct a DiscreteDomain starting from element_begin with size points.
KOKKOS_FUNCTION constexpr DiscreteDomain(DDoms const &...)
Construct a DiscreteDomain by copies and merge of domains.
KOKKOS_FUNCTION constexpr DiscreteDomain take_last(discrete_vector_type) const
KOKKOS_FUNCTION constexpr bool operator==(DiscreteDomain const &) const
KOKKOS_FUNCTION constexpr DiscreteDomain remove(discrete_vector_type, discrete_vector_type) const
static KOKKOS_FUNCTION constexpr std::size_t rank()
KOKKOS_FUNCTION constexpr DiscreteDomain remove_last(discrete_vector_type) const
KOKKOS_DEFAULTED_FUNCTION DiscreteDomain(DiscreteDomain const &x)=default
static KOKKOS_FUNCTION bool contains() noexcept
KOKKOS_DEFAULTED_FUNCTION constexpr DiscreteDomain()=default
KOKKOS_DEFAULTED_FUNCTION DiscreteDomain & operator=(DiscreteDomain &&x)=default
KOKKOS_FUNCTION constexpr operator bool()
static KOKKOS_FUNCTION constexpr std::size_t size()
static KOKKOS_FUNCTION constexpr bool empty() noexcept
static KOKKOS_FUNCTION bool contains(DiscreteElement<>) noexcept
static KOKKOS_FUNCTION constexpr discrete_element_type back() noexcept
static KOKKOS_FUNCTION DiscreteVector distance_from_front(DiscreteElement<>) noexcept
KOKKOS_FUNCTION constexpr DiscreteDomain remove_first(discrete_vector_type) const
static KOKKOS_FUNCTION constexpr discrete_element_type front() noexcept
KOKKOS_DEFAULTED_FUNCTION DiscreteDomain & operator=(DiscreteDomain const &x)=default
KOKKOS_FUNCTION constexpr DiscreteDomain take_first(discrete_vector_type) const
KOKKOS_FUNCTION constexpr DiscreteDomain restrict_with(DiscreteDomain< ODims... > const &) const
KOKKOS_FUNCTION constexpr DiscreteElement operator()(DiscreteVector<> const &) const noexcept
KOKKOS_DEFAULTED_FUNCTION DiscreteDomain(DiscreteDomain &&x)=default
static KOKKOS_FUNCTION DiscreteVector distance_from_front() noexcept
KOKKOS_DEFAULTED_FUNCTION DiscreteDomain(DiscreteDomain const &x)=default
KOKKOS_DEFAULTED_FUNCTION DiscreteDomain(DiscreteDomain &&x)=default
KOKKOS_FUNCTION constexpr DiscreteDomain remove_last(discrete_vector_type n) const
KOKKOS_FUNCTION bool contains(DElems const &... delems) const noexcept
KOKKOS_FUNCTION constexpr DiscreteDomain take_last(discrete_vector_type n) const
KOKKOS_FUNCTION constexpr DiscreteDomain(DDoms const &... domains)
Construct a DiscreteDomain by copies and merge of domains.
KOKKOS_FUNCTION constexpr decltype(auto) operator[](std::size_t n)
KOKKOS_FUNCTION constexpr DiscreteDomain remove(discrete_vector_type n1, discrete_vector_type n2) const
KOKKOS_FUNCTION constexpr decltype(auto) operator[](std::size_t n) const
KOKKOS_FUNCTION constexpr auto restrict_with(DiscreteDomain< ODDims... > const &odomain) const
static KOKKOS_FUNCTION constexpr std::size_t rank()
KOKKOS_FUNCTION constexpr bool empty() const noexcept
KOKKOS_FUNCTION constexpr std::size_t size() const
friend class DiscreteDomain
KOKKOS_FUNCTION constexpr discrete_vector_type extents() const noexcept
KOKKOS_FUNCTION constexpr DiscreteVector< QueryDDim > extent() const noexcept
KOKKOS_FUNCTION constexpr discrete_element_type front() const noexcept
KOKKOS_DEFAULTED_FUNCTION DiscreteDomain & operator=(DiscreteDomain &&x)=default
KOKKOS_FUNCTION constexpr DiscreteDomain remove_first(discrete_vector_type n) const
KOKKOS_FUNCTION constexpr bool operator==(DiscreteDomain< ODims... > const &other) const
KOKKOS_FUNCTION constexpr DiscreteDomain take_first(discrete_vector_type n) const
KOKKOS_DEFAULTED_FUNCTION ~DiscreteDomain()=default
KOKKOS_FUNCTION DiscreteVector< DDims... > distance_from_front(DElems const &... delems) const noexcept
KOKKOS_FUNCTION constexpr discrete_element_type back() const noexcept
KOKKOS_DEFAULTED_FUNCTION DiscreteDomain & operator=(DiscreteDomain const &x)=default
KOKKOS_FUNCTION constexpr DiscreteElement< DDims... > operator()(DiscreteVector< DDims... > const &dvect) const noexcept
KOKKOS_DEFAULTED_FUNCTION DiscreteDomain()=default
KOKKOS_FUNCTION constexpr operator bool()
KOKKOS_FUNCTION constexpr DiscreteDomain(discrete_element_type const &element_begin, discrete_vector_type const &size)
Construct a DiscreteDomain starting from element_begin with size points.
KOKKOS_FUNCTION constexpr DiscreteElement & operator+=(DiscreteVector< OTags... > const &rhs)
KOKKOS_FUNCTION constexpr value_type const & uid() const noexcept
KOKKOS_FUNCTION constexpr value_type & uid() noexcept
KOKKOS_DEFAULTED_FUNCTION ~DiscreteElement()=default
KOKKOS_FUNCTION constexpr DiscreteElement(DElems const &... delems) noexcept
KOKKOS_FUNCTION constexpr DiscreteElement & operator+=(IntegralType const &rhs)
KOKKOS_DEFAULTED_FUNCTION constexpr DiscreteElement(DiscreteElement const &)=default
KOKKOS_FUNCTION constexpr DiscreteElement operator--(int)
KOKKOS_FUNCTION constexpr DiscreteElement & operator-=(IntegralType const &rhs)
KOKKOS_FUNCTION constexpr DiscreteElement & operator-=(DiscreteVector< OTags... > const &rhs)
KOKKOS_DEFAULTED_FUNCTION constexpr DiscreteElement()=default
KOKKOS_FUNCTION constexpr DiscreteElement operator++(int)
KOKKOS_DEFAULTED_FUNCTION DiscreteElement & operator=(DiscreteElement const &other)=default
static KOKKOS_FUNCTION constexpr std::size_t size() noexcept
KOKKOS_FUNCTION constexpr DiscreteElement(std::array< IntegerType, sizeof...(Tags)> const &values) noexcept
KOKKOS_DEFAULTED_FUNCTION DiscreteElement & operator=(DiscreteElement &&other)=default
KOKKOS_DEFAULTED_FUNCTION constexpr DiscreteElement(DiscreteElement &&)=default
KOKKOS_FUNCTION constexpr DiscreteVectorElement const & get_or(DiscreteVectorElement const &default_value) const &
KOKKOS_FUNCTION constexpr DiscreteVector operator--(int)
KOKKOS_DEFAULTED_FUNCTION ~DiscreteVector()=default
KOKKOS_FUNCTION constexpr DiscreteVectorElement const & get() const noexcept
KOKKOS_FUNCTION constexpr DiscreteVector & operator+=(IntegralType const &rhs)
KOKKOS_FUNCTION constexpr DiscreteVector & operator-=(DiscreteVector< OTags... > const &rhs)
KOKKOS_FUNCTION constexpr DiscreteVector & operator-=(IntegralType const &rhs)
KOKKOS_FUNCTION constexpr DiscreteVector(DVects const &... delems) noexcept
KOKKOS_FUNCTION constexpr bool operator!=(DiscreteVector< OTags... > const &rhs) const noexcept
KOKKOS_DEFAULTED_FUNCTION constexpr DiscreteVector & operator=(DiscreteVector &&other)=default
static KOKKOS_FUNCTION constexpr std::size_t size() noexcept
KOKKOS_DEFAULTED_FUNCTION constexpr DiscreteVector()=default
KOKKOS_DEFAULTED_FUNCTION constexpr DiscreteVector(DiscreteVector const &)=default
KOKKOS_FUNCTION constexpr DiscreteVectorElement & get() noexcept
KOKKOS_FUNCTION constexpr bool operator==(DiscreteVector< OTags... > const &rhs) const noexcept
KOKKOS_FUNCTION constexpr DiscreteVector(std::array< IntegerType, sizeof...(Tags)> const &values) noexcept
KOKKOS_FUNCTION constexpr DiscreteVector & operator*=(DiscreteVector< OTags... > const &rhs)
KOKKOS_DEFAULTED_FUNCTION constexpr DiscreteVector(DiscreteVector &&)=default
KOKKOS_DEFAULTED_FUNCTION constexpr DiscreteVector & operator=(DiscreteVector const &other)=default
KOKKOS_FUNCTION constexpr DiscreteVector operator++(int)
KOKKOS_FUNCTION constexpr DiscreteVector & operator+=(DiscreteVector< OTags... > const &rhs)
The top-level namespace of DDC.
constexpr bool is_borrowed_chunk_v
KOKKOS_FUNCTION constexpr bool operator<(DiscreteElement< Tag > const &lhs, DiscreteElement< Tag > const &rhs)
KOKKOS_FUNCTION auto get_domain(ChunkType const &chunk) noexcept
Access the domain (or subdomain) of a view.
constexpr bool enable_chunk< Chunk< ElementType, SupportType, Allocator > >
Definition chunk.hpp:28
KOKKOS_FUNCTION constexpr DiscreteElement< Tag > operator+(DiscreteElement< Tag > const &lhs, IntegralType const &rhs)
KOKKOS_FUNCTION constexpr DiscreteElement< QueryDDims... > back(DiscreteDomain< DDims... > const &domain) noexcept
constexpr bool enable_borrowed_chunk
constexpr bool enable_chunk
KOKKOS_FUNCTION constexpr bool operator==(DiscreteElement< Tags... > const &lhs, DiscreteElement< OTags... > const &rhs) noexcept
constexpr bool enable_borrowed_chunk< ChunkSpan< ElementType, SupportType, LayoutStridedPolicy, MemorySpace > >
KOKKOS_FUNCTION constexpr DiscreteVector< Tags... > operator+(DiscreteVector< Tags... > const &x)
Unary operators: +, -.
KOKKOS_FUNCTION constexpr DiscreteElement< QueryTags... > select(DiscreteElement< Tags... > &&arr) noexcept
constexpr DiscreteElement< DDim > create_reference_discrete_element() noexcept
constexpr bool is_chunk_v
KOKKOS_FUNCTION constexpr DiscreteElement< QueryTags... > select(DiscreteElement< Tags... > const &arr) noexcept
KOKKOS_FUNCTION constexpr auto const & take(HeadDElem const &head, TailDElems const &... tail)
Returns a reference towards the DiscreteElement that contains the QueryTag.
KOKKOS_FUNCTION constexpr DiscreteVector< Tag > operator-(IntegralType const &lhs, DiscreteVector< Tag > const &rhs)
KOKKOS_FUNCTION constexpr auto remove_dims_of(DiscreteDomain< DDimsA... > const &DDom_a, DiscreteDomain< DDimsB... > const &) noexcept
KOKKOS_FUNCTION constexpr bool operator<(DiscreteVector< Tag > const &lhs, IntegralType const &rhs)
KOKKOS_FUNCTION constexpr DiscreteVectorElement const & get_or(DiscreteVector< Tags... > const &tuple, DiscreteVectorElement const &default_value) noexcept
KOKKOS_FUNCTION constexpr auto operator-(DiscreteVector< Tags... > const &lhs, DiscreteVector< OTags... > const &rhs)
KOKKOS_FUNCTION constexpr auto remove_dims_of(DiscreteDomain< DDimsA... > const &DDom_a) noexcept
Remove the dimensions DDimsB from DDom_a.
KOKKOS_FUNCTION constexpr DiscreteVector< Tags... > operator-(DiscreteElement< Tags... > const &lhs, DiscreteElement< OTags... > const &rhs)
binary operator: -
KOKKOS_FUNCTION constexpr DiscreteElement< QueryDDims... > front(DiscreteDomain< DDims... > const &domain) noexcept
KOKKOS_FUNCTION constexpr DiscreteVectorElement & get(DiscreteVector< Tags... > &tuple) noexcept
KOKKOS_FUNCTION constexpr DiscreteElement< QueryTag > select_or(DiscreteElement< Tags... > const &arr, DiscreteElement< QueryTag > const &default_value) noexcept
constexpr bool is_writable_chunk_v
KOKKOS_FUNCTION constexpr DiscreteVector< Tag > operator+(IntegralType const &lhs, DiscreteVector< Tag > const &rhs)
constexpr bool is_discrete_vector_v
KOKKOS_FUNCTION constexpr DiscreteElementType const & uid(DiscreteElement< Tag > const &tuple) noexcept
KOKKOS_FUNCTION constexpr DiscreteElement< Tags... > operator+(DiscreteElement< Tags... > const &lhs, DiscreteVector< OTags... > const &rhs)
right external binary operators: +, -
ChunkSpan(Chunk< ElementType, SupportType, Allocator > const &other) -> ChunkSpan< ElementType const, SupportType, Kokkos::layout_right, typename Allocator::memory_space >
KOKKOS_FUNCTION constexpr DiscreteVectorElement const & get(DiscreteVector< Tags... > const &tuple) noexcept
KOKKOS_FUNCTION constexpr DiscreteVector< Tags... > operator-(DiscreteVector< Tags... > const &x)
constexpr bool is_discrete_element_v
KOKKOS_FUNCTION constexpr DiscreteVector< QueryTags... > select(DiscreteVector< Tags... > const &arr) noexcept
KOKKOS_FUNCTION constexpr DiscreteVector< QueryDDims... > extents(DiscreteDomain< DDims... > const &domain) noexcept
Chunk(SupportType const &, Allocator) -> Chunk< typename Allocator::value_type, SupportType, Allocator >
KOKKOS_FUNCTION constexpr bool operator>=(DiscreteElement< Tag > const &lhs, DiscreteElement< Tag > const &rhs)
KOKKOS_FUNCTION constexpr auto operator+(DiscreteVector< Tags... > const &lhs, DiscreteVector< OTags... > const &rhs)
Internal binary operators: +, -.
KOKKOS_FUNCTION constexpr auto replace_dim_of(DiscreteDomain< DDimsA... > const &DDom_a, DiscreteDomain< DDimsB... > const &DDom_b) noexcept
ChunkSpan(Chunk< ElementType, SupportType, Allocator > &other) -> ChunkSpan< ElementType, SupportType, Kokkos::layout_right, typename Allocator::memory_space >
constexpr bool enable_chunk< ChunkSpan< ElementType, SupportType, LayoutStridedPolicy, MemorySpace > >
KOKKOS_FUNCTION constexpr bool operator<=(DiscreteElement< Tag > const &lhs, DiscreteElement< Tag > const &rhs)
KOKKOS_FUNCTION constexpr bool operator<(DiscreteVector< Tag > const &lhs, DiscreteVector< Tag > const &rhs)
KOKKOS_FUNCTION constexpr DiscreteElementType & uid(DiscreteElement< Tags... > &tuple) noexcept
Chunk(std::string const &, SupportType const &, Allocator) -> Chunk< typename Allocator::value_type, SupportType, Allocator >
KOKKOS_FUNCTION constexpr DiscreteVector< QueryTag > select_or(DiscreteVector< Tags... > const &arr, DiscreteVector< QueryTag > const &default_value) noexcept
KOKKOS_FUNCTION constexpr bool operator>(DiscreteElement< Tag > const &lhs, DiscreteElement< Tag > const &rhs)
KOKKOS_FUNCTION constexpr DiscreteElementType & uid(DiscreteElement< Tag > &tuple) noexcept
constexpr bool is_discrete_domain_v
KOKKOS_FUNCTION constexpr DiscreteVector< QueryTags... > select(DiscreteVector< Tags... > &&arr) noexcept
KOKKOS_FUNCTION constexpr DiscreteElement< Tag > operator-(DiscreteElement< Tag > const &lhs, IntegralType const &rhs)
KOKKOS_FUNCTION constexpr DiscreteElement< Tags... > operator-(DiscreteElement< Tags... > const &lhs, DiscreteVector< OTags... > const &rhs)
KOKKOS_FUNCTION constexpr DiscreteElementType const & uid(DiscreteElement< Tags... > const &tuple) noexcept
KOKKOS_FUNCTION constexpr auto operator*(IntegralType const &lhs, DiscreteVector< Tags... > const &rhs)
external left binary operator: *
KOKKOS_FUNCTION constexpr DiscreteDomain< QueryDDims... > select(DiscreteDomain< DDims... > const &domain)
KOKKOS_FUNCTION constexpr DiscreteVector< Tag > operator-(DiscreteVector< Tag > const &lhs, IntegralType const &rhs)
KOKKOS_DEDUCTION_GUIDE ChunkSpan(Kokkos::View< DataType, Properties... > const &view, SupportType domain) -> ChunkSpan< detail::kokkos_to_mdspan_element_t< typename Kokkos::View< DataType, Properties... >::data_type >, SupportType, detail::kokkos_to_mdspan_layout_t< typename Kokkos::View< DataType, Properties... >::array_layout >, typename Kokkos::View< DataType, Properties... >::memory_space >
KOKKOS_FUNCTION constexpr DiscreteVector< Tag > operator+(DiscreteVector< Tag > const &lhs, IntegralType const &rhs)
KOKKOS_FUNCTION constexpr DiscreteDomainIterator operator--(int)
friend KOKKOS_FUNCTION constexpr bool operator<=(DiscreteDomainIterator const &xx, DiscreteDomainIterator const &yy)
KOKKOS_FUNCTION constexpr DiscreteElement< DDim > operator*() const noexcept
friend KOKKOS_FUNCTION constexpr bool operator>=(DiscreteDomainIterator const &xx, DiscreteDomainIterator const &yy)
KOKKOS_DEFAULTED_FUNCTION DiscreteDomainIterator()=default
KOKKOS_FUNCTION constexpr DiscreteElement< DDim > operator[](difference_type n) const
KOKKOS_FUNCTION constexpr DiscreteDomainIterator & operator--()
KOKKOS_FUNCTION constexpr DiscreteDomainIterator operator++(int)
friend KOKKOS_FUNCTION constexpr DiscreteDomainIterator operator-(DiscreteDomainIterator i, difference_type n)
friend KOKKOS_FUNCTION constexpr DiscreteDomainIterator operator+(DiscreteDomainIterator i, difference_type n)
friend KOKKOS_FUNCTION constexpr bool operator>(DiscreteDomainIterator const &xx, DiscreteDomainIterator const &yy)
friend KOKKOS_FUNCTION constexpr bool operator!=(DiscreteDomainIterator const &xx, DiscreteDomainIterator const &yy)
friend KOKKOS_FUNCTION constexpr bool operator<(DiscreteDomainIterator const &xx, DiscreteDomainIterator const &yy)
KOKKOS_FUNCTION constexpr DiscreteDomainIterator & operator+=(difference_type n)
KOKKOS_FUNCTION constexpr DiscreteDomainIterator & operator++()
friend KOKKOS_FUNCTION constexpr DiscreteDomainIterator operator+(difference_type n, DiscreteDomainIterator i)
friend KOKKOS_FUNCTION constexpr bool operator==(DiscreteDomainIterator const &xx, DiscreteDomainIterator const &yy)
KOKKOS_FUNCTION constexpr DiscreteDomainIterator(DiscreteElement< DDim > value)
KOKKOS_FUNCTION constexpr DiscreteDomainIterator & operator-=(difference_type n)
friend KOKKOS_FUNCTION constexpr difference_type operator-(DiscreteDomainIterator const &xx, DiscreteDomainIterator const &yy)