DDC 0.6.0
Loading...
Searching...
No Matches
chunk.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 <cassert>
8#include <string>
9#include <type_traits>
10#include <utility>
11
12#include <Kokkos_Core.hpp>
13
14#include "ddc/chunk_common.hpp"
15#include "ddc/chunk_span.hpp"
16#include "ddc/chunk_traits.hpp"
17#include "ddc/detail/kokkos.hpp"
18#include "ddc/detail/type_traits.hpp"
19#include "ddc/kokkos_allocator.hpp"
20
21namespace ddc {
22
23template <class ElementType, class, class Allocator = HostAllocator<ElementType>>
24class Chunk;
25
26template <class ElementType, class SupportType, class Allocator>
27inline constexpr bool enable_chunk<Chunk<ElementType, SupportType, Allocator>> = true;
28
29template <class ElementType, class... DDims, class Allocator>
30class Chunk<ElementType, DiscreteDomain<DDims...>, Allocator>
31 : public ChunkCommon<ElementType, DiscreteDomain<DDims...>, Kokkos::layout_right>
32{
33protected:
34 using base_type = ChunkCommon<ElementType, DiscreteDomain<DDims...>, Kokkos::layout_right>;
35
36 /// ND memory view
37 using internal_mdspan_type = typename base_type::internal_mdspan_type;
38
39public:
40 /// type of a span of this full chunk
41 using span_type = ChunkSpan<
42 ElementType,
43 DiscreteDomain<DDims...>,
44 Kokkos::layout_right,
45 typename Allocator::memory_space>;
46
47 /// type of a view of this full chunk
48 using view_type = ChunkSpan<
49 ElementType const,
50 DiscreteDomain<DDims...>,
51 Kokkos::layout_right,
52 typename Allocator::memory_space>;
53
54 /// The dereferenceable part of the co-domain but with indexing starting at 0
55 using allocation_mdspan_type = typename base_type::allocation_mdspan_type;
56
57 using const_allocation_mdspan_type = typename base_type::const_allocation_mdspan_type;
58
59 using discrete_domain_type = typename base_type::discrete_domain_type;
60
61 using memory_space = typename Allocator::memory_space;
62
63 using discrete_element_type = typename base_type::discrete_element_type;
64
65 using discrete_vector_type = typename base_type::discrete_vector_type;
66
67 using extents_type = typename base_type::extents_type;
68
69 using layout_type = typename base_type::layout_type;
70
71 using mapping_type = typename base_type::mapping_type;
72
73 using element_type = typename base_type::element_type;
74
75 using value_type = typename base_type::value_type;
76
77 using size_type = typename base_type::size_type;
78
79 using data_handle_type = typename base_type::data_handle_type;
80
81 using reference = typename base_type::reference;
82
83 template <class, class, class>
84 friend class Chunk;
85
86private:
87 Allocator m_allocator;
88
89 std::string m_label;
90
91public:
92 /// Empty Chunk
93 Chunk() = default;
94
95 /// Construct a labeled Chunk on a domain with uninitialized values
96 explicit Chunk(
97 std::string const& label,
98 discrete_domain_type const& domain,
99 Allocator allocator = Allocator())
100 : base_type(allocator.allocate(label, domain.size()), domain)
101 , m_allocator(std::move(allocator))
102 , m_label(label)
103 {
104 }
105
106 /// Construct a Chunk on a domain with uninitialized values
107 explicit Chunk(discrete_domain_type const& domain, Allocator allocator = Allocator())
108 : Chunk("no-label", domain, std::move(allocator))
109 {
110 }
111
112 /// Deleted: use deepcopy instead
113 Chunk(Chunk const& other) = delete;
114
115 /** Constructs a new Chunk by move
116 * @param other the Chunk to move
117 */
118 Chunk(Chunk&& other) noexcept
119 : base_type(std::move(static_cast<base_type&>(other)))
120 , m_allocator(std::move(other.m_allocator))
121 , m_label(std::move(other.m_label))
122 {
123 other.m_internal_mdspan = internal_mdspan_type(nullptr, other.m_internal_mdspan.mapping());
124 }
125
126 ~Chunk() noexcept
127 {
128 if (this->m_internal_mdspan.data_handle()) {
129 m_allocator.deallocate(this->data_handle(), this->size());
130 }
131 }
132
133 /// Deleted: use deepcopy instead
134 Chunk& operator=(Chunk const& other) = delete;
135
136 /** Move-assigns a new value to this field
137 * @param other the Chunk to move
138 * @return *this
139 */
140 Chunk& operator=(Chunk&& other) noexcept
141 {
142 if (this == &other) {
143 return *this;
144 }
145 if (this->m_internal_mdspan.data_handle()) {
146 m_allocator.deallocate(this->data_handle(), this->size());
147 }
148 static_cast<base_type&>(*this) = std::move(static_cast<base_type&>(other));
149 m_allocator = std::move(other.m_allocator);
150 m_label = std::move(other.m_label);
151 other.m_internal_mdspan = internal_mdspan_type(nullptr, other.m_internal_mdspan.mapping());
152
153 return *this;
154 }
155
156 /// Slice out some dimensions
157 template <class... QueryDDims>
158 auto operator[](DiscreteElement<QueryDDims...> const& slice_spec) const
159 {
160 return view_type(*this)[slice_spec];
161 }
162
163 /// Slice out some dimensions
164 template <class... QueryDDims>
165 auto operator[](DiscreteElement<QueryDDims...> const& slice_spec)
166 {
167 return span_view()[slice_spec];
168 }
169
170 /// Slice out some dimensions
171 template <class... QueryDDims>
172 auto operator[](DiscreteDomain<QueryDDims...> const& odomain) const
173 {
174 return span_view()[odomain];
175 }
176
177 /// Slice out some dimensions
178 template <class... QueryDDims>
179 auto operator[](DiscreteDomain<QueryDDims...> const& odomain)
180 {
181 return span_view()[odomain];
182 }
183
184 /** Element access using a list of DiscreteElement
185 * @param delems discrete coordinates
186 * @return const-reference to this element
187 */
188 template <
189 class... DElems,
190 std::enable_if_t<detail::all_of_v<is_discrete_element_v<DElems>...>, int> = 0>
191 element_type const& operator()(DElems const&... delems) const noexcept
192 {
193 static_assert(
194 sizeof...(DDims) == (0 + ... + DElems::size()),
195 "Invalid number of dimensions");
196 static_assert((is_discrete_element_v<DElems> && ...), "Expected DiscreteElements");
197 assert(this->m_domain.contains(delems...));
198 return DDC_MDSPAN_ACCESS_OP(this->m_internal_mdspan, uid<DDims>(take<DDims>(delems...))...);
199 }
200
201 /** Element access using a list of DiscreteVector
202 * @param dvects discrete vectors
203 * @return reference to this element
204 */
205 template <
206 class... DVects,
207 std::enable_if_t<detail::all_of_v<is_discrete_vector_v<DVects>...>, int> = 0,
208 std::enable_if_t<sizeof...(DVects) != 0, int> = 0>
209 element_type const& operator()(DVects const&... dvects) const noexcept
210 {
211 static_assert(
212 sizeof...(DDims) == (0 + ... + DVects::size()),
213 "Invalid number of dimensions");
214 discrete_element_type const delem
215 = this->m_domain.front() + discrete_vector_type(dvects...);
216 return DDC_MDSPAN_ACCESS_OP(this->m_internal_mdspan, uid<DDims>(delem)...);
217 }
218
219 /** Element access using a list of DiscreteElement
220 * @param delems discrete coordinates
221 * @return reference to this element
222 */
223 template <
224 class... DElems,
225 std::enable_if_t<detail::all_of_v<is_discrete_element_v<DElems>...>, int> = 0>
226 element_type& operator()(DElems const&... delems) noexcept
227 {
228 static_assert(
229 sizeof...(DDims) == (0 + ... + DElems::size()),
230 "Invalid number of dimensions");
231 static_assert((is_discrete_element_v<DElems> && ...), "Expected DiscreteElements");
232 assert(this->m_domain.contains(delems...));
233 return DDC_MDSPAN_ACCESS_OP(this->m_internal_mdspan, uid<DDims>(take<DDims>(delems...))...);
234 }
235
236 /** Element access using a list of DiscreteVector
237 * @param dvects discrete vectors
238 * @return reference to this element
239 */
240 template <
241 class... DVects,
242 std::enable_if_t<detail::all_of_v<is_discrete_vector_v<DVects>...>, int> = 0,
243 std::enable_if_t<sizeof...(DVects) != 0, int> = 0>
244 element_type& operator()(DVects const&... dvects) noexcept
245 {
246 static_assert(
247 sizeof...(DDims) == (0 + ... + DVects::size()),
248 "Invalid number of dimensions");
249 discrete_element_type const delem
250 = this->m_domain.front() + discrete_vector_type(dvects...);
251 return DDC_MDSPAN_ACCESS_OP(this->m_internal_mdspan, uid<DDims>(delem)...);
252 }
253
254 /** Returns the label of the Chunk
255 * @return c-string
256 */
257 char const* label() const
258 {
259 return m_label.c_str();
260 }
261
262 /** Access to the underlying allocation pointer
263 * @return read-only allocation pointer
264 */
265 ElementType const* data_handle() const
266 {
267 return base_type::data_handle();
268 }
269
270 /** Access to the underlying allocation pointer
271 * @return allocation pointer
272 */
273 ElementType* data_handle()
274 {
275 return base_type::data_handle();
276 }
277
278 /** Provide a mdspan on the memory allocation
279 * @return read-only allocation mdspan
280 */
281 const_allocation_mdspan_type allocation_mdspan() const
282 {
283 return base_type::allocation_mdspan();
284 }
285
286 /** Provide a mdspan on the memory allocation
287 * @return allocation mdspan
288 */
289 allocation_mdspan_type allocation_mdspan()
290 {
291 return base_type::allocation_mdspan();
292 }
293
294 /** Provide an unmanaged `Kokkos::View` on the memory allocation
295 * @return allocation `Kokkos::View`
296 */
298 {
299 auto s = this->allocation_mdspan();
300 auto kokkos_layout = detail::build_kokkos_layout(
301 s.extents(),
302 s.mapping(),
303 std::make_index_sequence<sizeof...(DDims)> {});
304 return Kokkos::View<
305 detail::mdspan_to_kokkos_element_t<ElementType, sizeof...(DDims)>,
306 decltype(kokkos_layout),
307 typename Allocator::memory_space>(s.data_handle(), kokkos_layout);
308 }
309
310 /** Provide an unmanaged `Kokkos::View` on the memory allocation
311 * @return read-only allocation `Kokkos::View`
312 */
313 auto allocation_kokkos_view() const
314 {
315 auto s = this->allocation_mdspan();
316 auto kokkos_layout = detail::build_kokkos_layout(
317 s.extents(),
318 s.mapping(),
319 std::make_index_sequence<sizeof...(DDims)> {});
320 return Kokkos::View<
321 detail::mdspan_to_kokkos_element_t<ElementType const, sizeof...(DDims)>,
322 decltype(kokkos_layout),
323 typename Allocator::memory_space>(s.data_handle(), kokkos_layout);
324 }
325
326 view_type span_cview() const
327 {
328 return view_type(*this);
329 }
330
331 view_type span_view() const
332 {
333 return view_type(*this);
334 }
335
336 span_type span_view()
337 {
338 return span_type(*this);
339 }
340};
341
342template <class ElementType, class SupportType, class Allocator>
343class Chunk : public ChunkCommon<ElementType, SupportType, Kokkos::layout_right>
344{
345protected:
346 using base_type = ChunkCommon<ElementType, SupportType, Kokkos::layout_right>;
347
348public:
349 /// type of a span of this full chunk
350 using span_type = ChunkSpan<
351 ElementType,
352 SupportType,
353 Kokkos::layout_right,
354 typename Allocator::memory_space>;
355
356 /// type of a view of this full chunk
357 using view_type = ChunkSpan<
358 ElementType const,
359 SupportType,
360 Kokkos::layout_right,
361 typename Allocator::memory_space>;
362
363 /// The dereferenceable part of the co-domain but with indexing starting at 0
364 using allocation_mdspan_type = typename base_type::allocation_mdspan_type;
365
366 using const_allocation_mdspan_type = typename base_type::const_allocation_mdspan_type;
367
368 using discrete_domain_type = typename base_type::discrete_domain_type;
369
370 using memory_space = typename Allocator::memory_space;
371
372 using discrete_element_type = typename base_type::discrete_element_type;
373
374 using discrete_vector_type = typename base_type::discrete_vector_type;
375
376 using extents_type = typename base_type::extents_type;
377
378 using layout_type = typename base_type::layout_type;
379
380 using mapping_type = typename base_type::mapping_type;
381
382 using element_type = typename base_type::element_type;
383
384 using value_type = typename base_type::value_type;
385
386 using size_type = typename base_type::size_type;
387
388 using data_handle_type = typename base_type::data_handle_type;
389
390 using reference = typename base_type::reference;
391
392 template <class, class, class>
393 friend class Chunk;
394
395private:
396 Allocator m_allocator;
397
398 std::string m_label;
399
400public:
401 /// Empty Chunk
402 Chunk() = default;
403
404 /// Construct a labeled Chunk on a domain with uninitialized values
405 explicit Chunk(
406 std::string const& label,
407 SupportType const& domain,
408 Allocator allocator = Allocator())
409 : base_type(allocator.allocate(label, domain.size()), domain)
410 , m_allocator(std::move(allocator))
411 , m_label(label)
412 {
413 }
414
415 /// Construct a Chunk on a domain with uninitialized values
416 explicit Chunk(SupportType const& domain, Allocator allocator = Allocator())
417 : Chunk("no-label", domain, std::move(allocator))
418 {
419 }
420
421 /// Deleted: use deepcopy instead
422 Chunk(Chunk const& other) = delete;
423
424 /** Constructs a new Chunk by move
425 * @param other the Chunk to move
426 */
427 Chunk(Chunk&& other) noexcept
428 : base_type(std::move(static_cast<base_type&>(other)))
429 , m_allocator(std::move(other.m_allocator))
430 , m_label(std::move(other.m_label))
431 {
432 other.m_allocation_mdspan
433 = allocation_mdspan_type(nullptr, other.m_allocation_mdspan.mapping());
434 }
435
436 ~Chunk() noexcept
437 {
438 if (this->m_allocation_mdspan.data_handle()) {
439 m_allocator.deallocate(this->data_handle(), this->size());
440 }
441 }
442
443 /// Deleted: use deepcopy instead
444 Chunk& operator=(Chunk const& other) = delete;
445
446 /** Move-assigns a new value to this field
447 * @param other the Chunk to move
448 * @return *this
449 */
450 Chunk& operator=(Chunk&& other) noexcept
451 {
452 if (this == &other) {
453 return *this;
454 }
455 if (this->m_allocation_mdspan.data_handle()) {
456 m_allocator.deallocate(this->data_handle(), this->size());
457 }
458 static_cast<base_type&>(*this) = std::move(static_cast<base_type&>(other));
459 m_allocator = std::move(other.m_allocator);
460 m_label = std::move(other.m_label);
461 other.m_allocation_mdspan
462 = allocation_mdspan_type(nullptr, other.m_allocation_mdspan.mapping());
463
464 return *this;
465 }
466
467 /// Slice out some dimensions
468 template <class... QueryDDims>
469 auto operator[](DiscreteElement<QueryDDims...> const& slice_spec) const
470 {
471 return view_type(*this)[slice_spec];
472 }
473
474 /// Slice out some dimensions
475 template <class... QueryDDims>
476 auto operator[](DiscreteElement<QueryDDims...> const& slice_spec)
477 {
478 return span_view()[slice_spec];
479 }
480
481 /** Element access using a list of DiscreteElement
482 * @param delems discrete coordinates
483 * @return const-reference to this element
484 */
485 template <
486 class... DElems,
487 std::enable_if_t<detail::all_of_v<is_discrete_element_v<DElems>...>, int> = 0>
488 element_type const& operator()(DElems const&... delems) const noexcept
489 {
490 static_assert(
491 SupportType::rank() == (0 + ... + DElems::size()),
492 "Invalid number of dimensions");
493 assert(this->m_domain.contains(delems...));
494 return DDC_MDSPAN_ACCESS_OP(
495 this->m_allocation_mdspan,
496 detail::array(this->m_domain.distance_from_front(delems...)));
497 }
498
499 /** Element access using a list of DiscreteVector
500 * @param dvects discrete vectors
501 * @return reference to this element
502 */
503 template <
504 class... DVects,
505 std::enable_if_t<detail::all_of_v<is_discrete_vector_v<DVects>...>, int> = 0,
506 std::enable_if_t<sizeof...(DVects) != 0, int> = 0>
507 element_type const& operator()(DVects const&... dvects) const noexcept
508 {
509 static_assert(
510 SupportType::rank() == (0 + ... + DVects::size()),
511 "Invalid number of dimensions");
512 return DDC_MDSPAN_ACCESS_OP(
513 this->m_allocation_mdspan,
514 detail::array(discrete_vector_type(dvects...)));
515 }
516
517 /** Element access using a list of DiscreteElement
518 * @param delems discrete coordinates
519 * @return reference to this element
520 */
521 template <
522 class... DElems,
523 std::enable_if_t<detail::all_of_v<is_discrete_element_v<DElems>...>, int> = 0>
524 element_type& operator()(DElems const&... delems) noexcept
525 {
526 static_assert(
527 SupportType::rank() == (0 + ... + DElems::size()),
528 "Invalid number of dimensions");
529 assert(this->m_domain.contains(delems...));
530 return DDC_MDSPAN_ACCESS_OP(
531 this->m_allocation_mdspan,
532 detail::array(this->m_domain.distance_from_front(delems...)));
533 }
534
535 /** Element access using a list of DiscreteVector
536 * @param dvects discrete vectors
537 * @return reference to this element
538 */
539 template <
540 class... DVects,
541 std::enable_if_t<detail::all_of_v<is_discrete_vector_v<DVects>...>, int> = 0,
542 std::enable_if_t<sizeof...(DVects) != 0, int> = 0>
543 element_type& operator()(DVects const&... dvects) noexcept
544 {
545 static_assert(
546 SupportType::rank() == (0 + ... + DVects::size()),
547 "Invalid number of dimensions");
548 return DDC_MDSPAN_ACCESS_OP(
549 this->m_allocation_mdspan,
550 detail::array(discrete_vector_type(dvects...)));
551 }
552
553 /** Returns the label of the Chunk
554 * @return c-string
555 */
556 char const* label() const
557 {
558 return m_label.c_str();
559 }
560
561 /** Access to the underlying allocation pointer
562 * @return read-only allocation pointer
563 */
564 ElementType const* data_handle() const
565 {
566 return base_type::data_handle();
567 }
568
569 /** Access to the underlying allocation pointer
570 * @return allocation pointer
571 */
572 ElementType* data_handle()
573 {
574 return base_type::data_handle();
575 }
576
577 /** Provide a mdspan on the memory allocation
578 * @return read-only allocation mdspan
579 */
580 const_allocation_mdspan_type allocation_mdspan() const
581 {
582 return base_type::allocation_mdspan();
583 }
584
585 /** Provide a mdspan on the memory allocation
586 * @return allocation mdspan
587 */
588 allocation_mdspan_type allocation_mdspan()
589 {
590 return base_type::allocation_mdspan();
591 }
592
593 /** Provide an unmanaged `Kokkos::View` on the memory allocation
594 * @return allocation `Kokkos::View`
595 */
597 {
598 auto s = this->allocation_mdspan();
599 auto kokkos_layout = detail::build_kokkos_layout(
600 s.extents(),
601 s.mapping(),
602 std::make_index_sequence<SupportType::rank()> {});
603 return Kokkos::View<
604 detail::mdspan_to_kokkos_element_t<ElementType, SupportType::rank()>,
605 decltype(kokkos_layout),
606 typename Allocator::memory_space>(s.data_handle(), kokkos_layout);
607 }
608
609 /** Provide an unmanaged `Kokkos::View` on the memory allocation
610 * @return read-only allocation `Kokkos::View`
611 */
612 auto allocation_kokkos_view() const
613 {
614 auto s = this->allocation_mdspan();
615 auto kokkos_layout = detail::build_kokkos_layout(
616 s.extents(),
617 s.mapping(),
618 std::make_index_sequence<SupportType::rank()> {});
619 return Kokkos::View<
620 detail::mdspan_to_kokkos_element_t<ElementType const, SupportType::rank()>,
621 decltype(kokkos_layout),
622 typename Allocator::memory_space>(s.data_handle(), kokkos_layout);
623 }
624
625 view_type span_cview() const
626 {
627 return view_type(*this);
628 }
629
630 view_type span_view() const
631 {
632 return view_type(*this);
633 }
634
635 span_type span_view()
636 {
637 return span_type(*this);
638 }
639};
640
641template <class SupportType, class Allocator>
642Chunk(std::string const&, SupportType const&, Allocator)
643 -> Chunk<typename Allocator::value_type, SupportType, Allocator>;
644
645template <class SupportType, class Allocator>
646Chunk(SupportType const&, Allocator)
647 -> Chunk<typename Allocator::value_type, SupportType, Allocator>;
648
649} // namespace ddc
auto operator[](DiscreteDomain< QueryDDims... > const &odomain)
Slice out some dimensions.
Definition chunk.hpp:179
auto operator[](DiscreteDomain< QueryDDims... > const &odomain) const
Slice out some dimensions.
Definition chunk.hpp:172
Chunk(discrete_domain_type const &domain, Allocator allocator=Allocator())
Construct a Chunk on a domain with uninitialized values.
Definition chunk.hpp:107
Chunk(Chunk &&other) noexcept
Constructs a new Chunk by move.
Definition chunk.hpp:118
allocation_mdspan_type allocation_mdspan()
Provide a mdspan on the memory allocation.
Definition chunk.hpp:289
ElementType * data_handle()
Access to the underlying allocation pointer.
Definition chunk.hpp:273
auto operator[](DiscreteElement< QueryDDims... > const &slice_spec) const
Slice out some dimensions.
Definition chunk.hpp:158
Chunk & operator=(Chunk const &other)=delete
Deleted: use deepcopy instead.
element_type & operator()(DVects const &... dvects) noexcept
Element access using a list of DiscreteVector.
Definition chunk.hpp:244
const_allocation_mdspan_type allocation_mdspan() const
Provide a mdspan on the memory allocation.
Definition chunk.hpp:281
Chunk & operator=(Chunk &&other) noexcept
Move-assigns a new value to this field.
Definition chunk.hpp:140
element_type & operator()(DElems const &... delems) noexcept
Element access using a list of DiscreteElement.
Definition chunk.hpp:226
auto allocation_kokkos_view() const
Provide an unmanaged Kokkos::View on the memory allocation.
Definition chunk.hpp:313
ElementType const * data_handle() const
Access to the underlying allocation pointer.
Definition chunk.hpp:265
auto allocation_kokkos_view()
Provide an unmanaged Kokkos::View on the memory allocation.
Definition chunk.hpp:297
element_type const & operator()(DVects const &... dvects) const noexcept
Element access using a list of DiscreteVector.
Definition chunk.hpp:209
Chunk(Chunk const &other)=delete
Deleted: use deepcopy instead.
Chunk(std::string const &label, discrete_domain_type const &domain, Allocator allocator=Allocator())
Construct a labeled Chunk on a domain with uninitialized values.
Definition chunk.hpp:96
char const * label() const
Returns the label of the Chunk.
Definition chunk.hpp:257
element_type const & operator()(DElems const &... delems) const noexcept
Element access using a list of DiscreteElement.
Definition chunk.hpp:191
auto operator[](DiscreteElement< QueryDDims... > const &slice_spec)
Slice out some dimensions.
Definition chunk.hpp:165
auto operator[](DiscreteElement< QueryDDims... > const &slice_spec) const
Slice out some dimensions.
Definition chunk.hpp:469
char const * label() const
Returns the label of the Chunk.
Definition chunk.hpp:556
const_allocation_mdspan_type allocation_mdspan() const
Provide a mdspan on the memory allocation.
Definition chunk.hpp:580
element_type & operator()(DVects const &... dvects) noexcept
Element access using a list of DiscreteVector.
Definition chunk.hpp:543
ElementType const * data_handle() const
Access to the underlying allocation pointer.
Definition chunk.hpp:564
auto allocation_kokkos_view()
Provide an unmanaged Kokkos::View on the memory allocation.
Definition chunk.hpp:596
auto allocation_kokkos_view() const
Provide an unmanaged Kokkos::View on the memory allocation.
Definition chunk.hpp:612
Chunk(SupportType const &domain, Allocator allocator=Allocator())
Construct a Chunk on a domain with uninitialized values.
Definition chunk.hpp:416
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:588
ElementType * data_handle()
Access to the underlying allocation pointer.
Definition chunk.hpp:572
element_type const & operator()(DVects const &... dvects) const noexcept
Element access using a list of DiscreteVector.
Definition chunk.hpp:507
view_type span_cview() const
Definition chunk.hpp:625
Chunk(Chunk const &other)=delete
Deleted: use deepcopy instead.
~Chunk() noexcept
Definition chunk.hpp:436
Chunk(std::string const &label, SupportType const &domain, Allocator allocator=Allocator())
Construct a labeled Chunk on a domain with uninitialized values.
Definition chunk.hpp:405
element_type & operator()(DElems const &... delems) noexcept
Element access using a list of DiscreteElement.
Definition chunk.hpp:524
Chunk()=default
Empty Chunk.
Chunk & operator=(Chunk &&other) noexcept
Move-assigns a new value to this field.
Definition chunk.hpp:450
Chunk(Chunk &&other) noexcept
Constructs a new Chunk by move.
Definition chunk.hpp:427
span_type span_view()
Definition chunk.hpp:635
view_type span_view() const
Definition chunk.hpp:630
element_type const & operator()(DElems const &... delems) const noexcept
Element access using a list of DiscreteElement.
Definition chunk.hpp:488
auto operator[](DiscreteElement< QueryDDims... > const &slice_spec)
Slice out some dimensions.
Definition chunk.hpp:476
friend class DiscreteDomain
The top-level namespace of DDC.
constexpr bool enable_chunk< Chunk< ElementType, SupportType, Allocator > >
Definition chunk.hpp:27
Chunk(SupportType const &, Allocator) -> Chunk< typename Allocator::value_type, SupportType, Allocator >
Chunk(std::string const &, SupportType const &, Allocator) -> Chunk< typename Allocator::value_type, SupportType, Allocator >