Arcane  v4.1.0.0
Documentation développeur
Chargement...
Recherche...
Aucune correspondance
AbstractArray.h
1// -*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-
2//-----------------------------------------------------------------------------
3// Copyright 2000-2025 CEA (www.cea.fr) IFPEN (www.ifpenergiesnouvelles.com)
4// See the top-level COPYRIGHT file for details.
5// SPDX-License-Identifier: Apache-2.0
6//-----------------------------------------------------------------------------
7/*---------------------------------------------------------------------------*/
8/* AbstractArray.h (C) 2000-2025 */
9/* */
10/* Classe de base des tableaux. */
11/*---------------------------------------------------------------------------*/
12#ifndef ARCCORE_COMMON_ABSTRACTARRAY_H
13#define ARCCORE_COMMON_ABSTRACTARRAY_H
14/*---------------------------------------------------------------------------*/
15/*---------------------------------------------------------------------------*/
16
17#include "arccore/base/Span.h"
18
19#include "arccore/common/ArrayTraits.h"
20#include "arccore/common/ArrayMetaData.h"
21
22/*---------------------------------------------------------------------------*/
23/*---------------------------------------------------------------------------*/
24
25namespace Arcane
26{
27
28/*---------------------------------------------------------------------------*/
29/*---------------------------------------------------------------------------*/
46class ARCCORE_COMMON_EXPORT AbstractArrayBase
47{
48 public:
49
50 AbstractArrayBase()
51 {
52 m_md = &m_meta_data;
53 }
54 virtual ~AbstractArrayBase() = default;
55
56 public:
58 IMemoryAllocator* allocator() const
59 {
60 return m_md->allocation_options.allocator();
61 }
62 MemoryAllocationOptions allocationOptions() const
63 {
64 return m_md->allocation_options;
65 }
70 */
71 void setDebugName(const String& name);
73 String debugName() const;
74
75 protected:
76
77 ArrayMetaData* m_md = nullptr;
78 ArrayMetaData m_meta_data;
79
80 protected:
81
83 static constexpr RunQueue* _nullRunQueue() { return nullptr; }
84
91 virtual bool _isUseOwnMetaData() const
92 {
93 return true;
94 }
95
96 protected:
97
98 void _swapMetaData(AbstractArrayBase& rhs)
99 {
100 std::swap(m_md, rhs.m_md);
101 std::swap(m_meta_data, rhs.m_meta_data);
102 _checkSetUseOwnMetaData();
103 rhs._checkSetUseOwnMetaData();
104 }
105
106 void _copyMetaData(const AbstractArrayBase& rhs)
107 {
108 // Déplace les meta-données
109 // Attention si on utilise m_meta_data alors il
110 // faut positionner m_md pour qu'il pointe vers notre propre m_meta_data.
111 m_meta_data = rhs.m_meta_data;
112 m_md = rhs.m_md;
113 _checkSetUseOwnMetaData();
114 }
115
116 void _allocateMetaData()
117 {
118#ifdef ARCCORE_CHECK
119 if (m_md->is_not_null)
120 ArrayMetaData::throwNullExpected();
121#endif
122 if (_isUseOwnMetaData()) {
123 m_meta_data = ArrayMetaData();
124 m_md = &m_meta_data;
125 }
126 else {
127 m_md = new ArrayMetaData();
128 m_md->is_allocated_by_new = true;
129 }
130 m_md->is_not_null = true;
131 }
132
133 void _deallocateMetaData(ArrayMetaData* md)
134 {
135 if (md->is_allocated_by_new)
136 delete md;
137 else
138 *md = ArrayMetaData();
139 }
140
141 void _checkValidSharedArray()
142 {
143#ifdef ARCCORE_CHECK
144 if (m_md->is_not_null && !m_md->is_allocated_by_new)
145 ArrayMetaData::throwInvalidMetaDataForSharedArray();
146#endif
147 }
148
149 private:
150
151 void _checkSetUseOwnMetaData()
152 {
153 if (!m_md->is_allocated_by_new)
154 m_md = &m_meta_data;
155 }
156};
157
158/*---------------------------------------------------------------------------*/
159/*---------------------------------------------------------------------------*/
167template <typename T>
169: public AbstractArrayBase
170{
171 public:
172
173 typedef typename ArrayTraits<T>::ConstReferenceType ConstReferenceType;
174 typedef typename ArrayTraits<T>::IsPODType IsPODType;
175 typedef AbstractArray<T> ThatClassType;
176 using TrueImpl = T;
177
178 public:
179
181 typedef T value_type;
185 typedef const value_type* const_pointer;
193 typedef ConstReferenceType const_reference;
197 typedef ptrdiff_t difference_type;
198
199 typedef std::reverse_iterator<iterator> reverse_iterator;
200 typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
201
202 protected:
203
206 {
207 }
208
209 AbstractArray(ThatClassType&& rhs) ARCCORE_NOEXCEPT
210 : m_ptr(rhs.m_ptr)
211 {
212 _copyMetaData(rhs);
213 rhs._reset();
214 }
215
216 ~AbstractArray() override
217 {
218 --m_md->nb_ref;
220 }
221
222 public:
223
224 AbstractArray(const AbstractArray<T>& rhs) = delete;
225 AbstractArray<T>& operator=(const AbstractArray<T>& rhs) = delete;
226
227 protected:
228
229 static constexpr Int64 typeSize() { return static_cast<Int64>(sizeof(T)); }
230 AllocatedMemoryInfo _currentMemoryInfo() const
231 {
232 return AllocatedMemoryInfo(m_ptr, m_md->size * typeSize(), m_md->capacity * typeSize());
233 }
234
235 protected:
236
242 void _initFromSpan(const Span<const T>& view)
243 {
244 Int64 asize = view.size();
245 if (asize != 0) {
246 _internalAllocate(asize, _nullRunQueue());
247 _createRange(0, asize, view.data());
248 m_md->size = asize;
249 }
250 }
251
257 // TODO A supprimer. Utiliser la surcharge avec MemoryAllocationOptions à la place.
259 {
261 }
262
273 void* pre_allocated_buffer = nullptr)
274 {
275 _directFirstAllocateWithAllocator(acapacity, o, pre_allocated_buffer);
276 }
277
278 public:
279
281 void dispose()
282 {
283 _destroy();
284 MemoryAllocationOptions options(m_md->allocation_options);
285 _internalDeallocate();
286 _setToSharedNull();
287 // Si on a un allocateur spécifique, il faut allouer un
288 // bloc pour conserver cette information.
289 if (options.allocator() != m_md->_allocator())
292 }
293
294 public:
295
296 operator ConstArrayView<T>() const
297 {
298 return ConstArrayView<T>(ARCCORE_CAST_SMALL_SIZE(size()), m_ptr);
299 }
300 operator Span<const T>() const
301 {
302 return Span<const T>(m_ptr, m_md->size);
303 }
304 operator SmallSpan<const T>() const
305 {
306 return SmallSpan<const T>(m_ptr, ARCCORE_CAST_SMALL_SIZE(size()));
307 }
308
309 public:
310
312 Integer size() const { return ARCCORE_CAST_SMALL_SIZE(m_md->size); }
314 Integer length() const { return ARCCORE_CAST_SMALL_SIZE(m_md->size); }
316 Integer capacity() const { return ARCCORE_CAST_SMALL_SIZE(m_md->capacity); }
318 Int64 largeSize() const { return m_md->size; }
320 Int64 largeLength() const { return m_md->size; }
322 Int64 largeCapacity() const { return m_md->capacity; }
324 bool empty() const { return m_md->size == 0; }
326 bool contains(ConstReferenceType v) const
327 {
328 const T* ptr = m_ptr;
329 for (Int64 i = 0, n = m_md->size; i < n; ++i) {
330 if (ptr[i] == v)
331 return true;
332 }
333 return false;
334 }
335
336 public:
337
339 ConstReferenceType operator[](Int64 i) const
340 {
341 ARCCORE_CHECK_AT(i, m_md->size);
342 return m_ptr[i];
343 }
344
345 ConstReferenceType operator()(Int64 i) const
346 {
347 ARCCORE_CHECK_AT(i, m_md->size);
348 return m_ptr[i];
349 }
350
351 public:
352
355 {
356 m_md->_setMemoryLocationHint(new_hint, m_ptr, sizeof(T));
357 }
358
366 {
367 m_md->_setHostDeviceMemoryLocation(location);
368 }
369
372 {
373 return m_md->allocation_options.hostDeviceMemoryLocation();
374 }
375
376 public:
377
378 friend bool operator==(const AbstractArray<T>& rhs, const AbstractArray<T>& lhs)
379 {
380 return operator==(Span<const T>(rhs), Span<const T>(lhs));
381 }
382
383 friend bool operator!=(const AbstractArray<T>& rhs, const AbstractArray<T>& lhs)
384 {
385 return !(rhs == lhs);
386 }
387
388 friend bool operator==(const AbstractArray<T>& rhs, const Span<const T>& lhs)
389 {
390 return operator==(Span<const T>(rhs), lhs);
391 }
392
393 friend bool operator!=(const AbstractArray<T>& rhs, const Span<const T>& lhs)
394 {
395 return !(rhs == lhs);
396 }
397
398 friend bool operator==(const Span<const T>& rhs, const AbstractArray<T>& lhs)
399 {
400 return operator==(rhs, Span<const T>(lhs));
401 }
402
403 friend bool operator!=(const Span<const T>& rhs, const AbstractArray<T>& lhs)
404 {
405 return !(rhs == lhs);
406 }
407
408 friend std::ostream& operator<<(std::ostream& o, const AbstractArray<T>& val)
409 {
410 o << Span<const T>(val);
411 return o;
412 }
413
414 private:
415
416 using AbstractArrayBase::m_meta_data;
417
418 protected:
419
420 // NOTE: Ces deux champs sont utilisés pour l'affichage TTF de totalview.
421 // Si on modifie leur ordre il faut mettre à jour la partie correspondante
422 // dans l'afficheur totalview de Arcane.
423 T* m_ptr = nullptr;
424
425 protected:
426
428 void _reserve(Int64 new_capacity)
429 {
430 if (new_capacity <= m_md->capacity)
431 return;
432 _internalRealloc(new_capacity, false);
433 }
434
439 template <typename PodType>
440 void _internalRealloc(Int64 new_capacity, bool compute_capacity, PodType pod_type, RunQueue* queue = nullptr)
441 {
442 if (_isSharedNull()) {
443 if (new_capacity != 0)
444 _internalAllocate(new_capacity, queue);
445 return;
446 }
447
448 Int64 acapacity = new_capacity;
449 if (compute_capacity) {
450 acapacity = m_md->capacity;
451 //std::cout << " REALLOC: want=" << wanted_size << " current_capacity=" << capacity << '\n';
452 while (new_capacity > acapacity)
453 acapacity = (acapacity == 0) ? 4 : (acapacity + 1 + acapacity / 2);
454 //std::cout << " REALLOC: want=" << wanted_size << " new_capacity=" << capacity << '\n';
455 }
456 // Si la nouvelle capacité est inférieure à la courante,ne fait rien.
457 if (acapacity <= m_md->capacity)
458 return;
459 _internalReallocate(acapacity, pod_type, queue);
460 }
461
462 void _internalRealloc(Int64 new_capacity, bool compute_capacity)
463 {
464 _internalRealloc(new_capacity, compute_capacity, IsPODType());
465 }
466
468 void _internalReallocate(Int64 new_capacity, TrueType, RunQueue* queue)
469 {
470 T* old_ptr = m_ptr;
471 Int64 old_capacity = m_md->capacity;
472 _directReAllocate(new_capacity, queue);
473 bool update = (new_capacity < old_capacity) || (m_ptr != old_ptr);
474 if (update) {
476 }
477 }
478
480 void _internalReallocate(Int64 new_capacity, FalseType, RunQueue* queue)
481 {
482 T* old_ptr = m_ptr;
483 ArrayMetaData* old_md = m_md;
484 AllocatedMemoryInfo old_mem_info = _currentMemoryInfo();
485 Int64 old_size = m_md->size;
486 _directAllocate(new_capacity, queue);
487 if (m_ptr != old_ptr) {
488 for (Int64 i = 0; i < old_size; ++i) {
489 new (m_ptr + i) T(old_ptr[i]);
490 old_ptr[i].~T();
491 }
492 m_md->nb_ref = old_md->nb_ref;
493 m_md->_deallocate(old_mem_info, queue);
495 }
496 }
497 // Libère la mémoire
498 void _internalDeallocate(RunQueue* queue = nullptr)
499 {
500 if (!_isSharedNull())
501 m_md->_deallocate(_currentMemoryInfo(), queue);
502 if (m_md->is_not_null)
503 _deallocateMetaData(m_md);
504 }
505 void _internalAllocate(Int64 new_capacity, RunQueue* queue)
506 {
507 _directAllocate(new_capacity, queue);
508 m_md->nb_ref = _getNbRef();
510 }
511
512 void _copyFromMemory(const T* source)
513 {
514 m_md->_copyFromMemory(m_ptr, source, sizeof(T), _nullRunQueue());
515 }
516
517 private:
518
528 void* pre_allocated_buffer = nullptr)
529 {
530 IMemoryAllocator* wanted_allocator = options.allocator();
531 if (!wanted_allocator) {
532 wanted_allocator = ArrayMetaData::_defaultAllocator();
533 options.setAllocator(wanted_allocator);
534 }
535 _allocateMetaData();
536 m_md->allocation_options = options;
537 if (new_capacity > 0) {
538 if (!pre_allocated_buffer)
539 _allocateMP(new_capacity, options.runQueue());
540 else
541 _setMPCast(pre_allocated_buffer);
542 }
543 m_md->nb_ref = _getNbRef();
544 m_md->size = 0;
546 }
547
548 void _directAllocate(Int64 new_capacity, RunQueue* queue)
549 {
550 if (!m_md->is_not_null)
551 _allocateMetaData();
552 _allocateMP(new_capacity, queue);
553 }
554
555 void _allocateMP(Int64 new_capacity, RunQueue* queue)
556 {
557 _setMPCast(m_md->_allocate(new_capacity, typeSize(), queue));
558 }
559
560 void _directReAllocate(Int64 new_capacity, RunQueue* queue)
561 {
562 _setMPCast(m_md->_reallocate(_currentMemoryInfo(), new_capacity, typeSize(), queue));
563 }
564
565 public:
566
567 void printInfos(std::ostream& o)
568 {
569 o << " Infos: size=" << m_md->size << " capacity=" << m_md->capacity << '\n';
570 }
571
572 protected:
573
575 virtual void _updateReferences()
576 {
577 }
578
580 {
581 return 1;
582 }
583
584 void _addRange(ConstReferenceType val, Int64 n)
585 {
586 Int64 s = m_md->size;
587 if ((s + n) > m_md->capacity)
588 _internalRealloc(s + n, true);
589 for (Int64 i = 0; i < n; ++i)
590 new (m_ptr + s + i) T(val);
591 m_md->size += n;
592 }
593
596 {
597 Int64 n = val.size();
598 const T* ptr = val.data();
599 Int64 s = m_md->size;
600 if ((s + n) > m_md->capacity)
601 _internalRealloc(s + n, true);
602 _createRange(s, s + n, ptr);
603 m_md->size += n;
604 }
605
608 {
609 if (m_md->nb_ref == 0) {
610 _destroy();
611 _internalDeallocate(_nullRunQueue());
612 }
613 }
614 void _destroy()
615 {
616 _destroyRange(0, m_md->size, IsPODType());
617 }
618 void _destroyRange(Int64, Int64, TrueType)
619 {
620 // Rien à faire pour un type POD.
621 }
622 void _destroyRange(Int64 abegin, Int64 aend, FalseType)
623 {
624 if (abegin < 0)
625 abegin = 0;
626 for (Int64 i = abegin; i < aend; ++i)
627 m_ptr[i].~T();
628 }
629 void _createRangeDefault(Int64, Int64, TrueType)
630 {
631 }
632 void _createRangeDefault(Int64 abegin, Int64 aend, FalseType)
633 {
634 if (abegin < 0)
635 abegin = 0;
636 for (Int64 i = abegin; i < aend; ++i)
637 new (m_ptr + i) T();
638 }
639 void _createRange(Int64 abegin, Int64 aend, ConstReferenceType value, TrueType)
640 {
641 if (abegin < 0)
642 abegin = 0;
643 for (Int64 i = abegin; i < aend; ++i)
644 m_ptr[i] = value;
645 }
646 void _createRange(Int64 abegin, Int64 aend, ConstReferenceType value, FalseType)
647 {
648 if (abegin < 0)
649 abegin = 0;
650 for (Int64 i = abegin; i < aend; ++i)
651 new (m_ptr + i) T(value);
652 }
653 void _createRange(Int64 abegin, Int64 aend, const T* values)
654 {
655 if (abegin < 0)
656 abegin = 0;
657 for (Int64 i = abegin; i < aend; ++i) {
658 new (m_ptr + i) T(*values);
659 ++values;
660 }
661 }
662 void _fill(ConstReferenceType value)
663 {
664 for (Int64 i = 0, n = size(); i < n; ++i)
665 m_ptr[i] = value;
666 }
667 void _clone(const ThatClassType& orig_array)
668 {
669 Int64 that_size = orig_array.size();
670 _internalAllocate(that_size, _nullRunQueue());
671 m_md->size = that_size;
672 m_md->dim1_size = orig_array.m_md->dim1_size;
673 m_md->dim2_size = orig_array.m_md->dim2_size;
674 _createRange(0, that_size, orig_array.m_ptr);
675 }
676 template <typename PodType>
677 void _resizeHelper(Int64 s, PodType pod_type, RunQueue* queue)
678 {
679 if (s < 0)
680 s = 0;
681 if (s > m_md->size) {
682 this->_internalRealloc(s, false, pod_type, queue);
683 this->_createRangeDefault(m_md->size, s, pod_type);
684 }
685 else {
686 this->_destroyRange(s, m_md->size, pod_type);
687 }
688 m_md->size = s;
689 }
690 void _resize(Int64 s)
691 {
692 _resizeHelper(s, IsPODType(), _nullRunQueue());
693 }
695 void _resizeNoInit(Int64 s, RunQueue* queue = nullptr)
696 {
697 _resizeHelper(s, TrueType{}, queue);
698 }
699 void _clear()
700 {
701 this->_destroyRange(0, m_md->size, IsPODType());
702 m_md->size = 0;
703 }
705 void _resize(Int64 s, ConstReferenceType value)
706 {
707 if (s < 0)
708 s = 0;
709 if (s > m_md->size) {
710 this->_internalRealloc(s, false);
711 this->_createRange(m_md->size, s, value, IsPODType());
712 }
713 else {
714 this->_destroyRange(s, m_md->size, IsPODType());
715 }
716 m_md->size = s;
717 }
718 void _copy(const T* rhs_begin, TrueType)
719 {
720 _copyFromMemory(rhs_begin);
721 }
722 void _copy(const T* rhs_begin, FalseType)
723 {
724 for (Int64 i = 0, n = m_md->size; i < n; ++i)
725 m_ptr[i] = rhs_begin[i];
726 }
727 void _copy(const T* rhs_begin)
728 {
729 _copy(rhs_begin, IsPODType());
730 }
731
741 {
742 const T* rhs_begin = rhs.data();
743 Int64 rhs_size = rhs.size();
744 const Int64 current_size = m_md->size;
745 T* abegin = m_ptr;
746 // Vérifie que \a rhs n'est pas un élément à l'intérieur de ce tableau
747 if (abegin >= rhs_begin && abegin < (rhs_begin + rhs_size))
748 ArrayMetaData::overlapError(abegin, m_md->size, rhs_begin, rhs_size);
749
750 if (rhs_size > current_size) {
751 this->_internalRealloc(rhs_size, false);
752 // Crée les nouveaux éléments
753 this->_createRange(m_md->size, rhs_size, rhs_begin + current_size);
754 // Copie les éléments déjà existant
755 _copy(rhs_begin);
756 m_md->size = rhs_size;
757 }
758 else {
759 this->_destroyRange(rhs_size, current_size, IsPODType{});
760 m_md->size = rhs_size;
761 _copy(rhs_begin);
762 }
763 }
764
772 void _move(ThatClassType& rhs) ARCCORE_NOEXCEPT
773 {
774 if (&rhs == this)
775 return;
776
777 // Comme il n'y a qu'une seule référence sur le tableau actuel, on peut
778 // directement libérer la mémoire.
779 _destroy();
780 _internalDeallocate(_nullRunQueue());
781
782 _setMP(rhs.m_ptr);
783
784 _copyMetaData(rhs);
785
786 // Indique que \a rhs est vide.
787 rhs._reset();
788 }
789
796 void _swap(ThatClassType& rhs) ARCCORE_NOEXCEPT
797 {
798 std::swap(m_ptr, rhs.m_ptr);
799 _swapMetaData(rhs);
800 }
801
802 void _shrink()
803 {
804 _shrink(size());
805 }
806
807 // Réalloue la mémoire pour avoir une capacité proche de \a new_capacity
808 void _shrink(Int64 new_capacity)
809 {
810 if (_isSharedNull())
811 return;
812 // On n'augmente pas la capacité avec cette méthode
813 if (new_capacity > this->capacity())
814 return;
815 if (new_capacity < 4)
816 new_capacity = 4;
817 _internalReallocate(new_capacity, IsPODType(), _nullRunQueue());
818 }
819
825 void _reset()
826 {
827 _setToSharedNull();
828 }
829
830 constexpr Integer _clampSizeOffet(Int64 offset, Int32 asize) const
831 {
832 Int64 max_size = m_md->size - offset;
833 if (asize > max_size)
834 // On est certain de ne pas dépasser 32 bits car on est inférieur à asize.
835 asize = static_cast<Integer>(max_size);
836 return asize;
837 }
838
839 // Uniquement pour UniqueArray et UniqueArray2
840 void _assignFromArray(const AbstractArray<T>& rhs)
841 {
842 if (&rhs == this)
843 return;
844 Span<const T> rhs_span(rhs);
845 if (rhs.allocator() == this->allocator()) {
846 _resizeAndCopyView(rhs_span);
847 }
848 else {
849 _destroy();
850 _internalDeallocate(_nullRunQueue());
851 _reset();
852 _initFromAllocator(rhs.allocationOptions(), 0);
853 _initFromSpan(rhs_span);
854 }
855 }
856
857 protected:
858
859 void _setMP(TrueImpl* new_mp)
860 {
861 m_ptr = new_mp;
862 }
863
864 void _setMP2(TrueImpl* new_mp, ArrayMetaData* new_md)
865 {
866 _setMP(new_mp);
867 // Il ne faut garder le nouveau m_md que s'il est alloué
868 // sinon on risque d'avoir des références sur des objets temporaires
869 m_md = new_md;
870 if (!m_md->is_allocated_by_new)
871 m_md = &m_meta_data;
872 }
873
874 bool _isSharedNull()
875 {
876 return m_ptr == nullptr;
877 }
878
879 private:
880
881 void _setToSharedNull()
882 {
883 m_ptr = nullptr;
884 m_meta_data = ArrayMetaData();
885 m_md = &m_meta_data;
886 }
887 void _setMPCast(void* p)
888 {
889 _setMP(reinterpret_cast<TrueImpl*>(p));
890 }
891};
892
893/*---------------------------------------------------------------------------*/
894/*---------------------------------------------------------------------------*/
895
896} // namespace Arcane
897
898/*---------------------------------------------------------------------------*/
899/*---------------------------------------------------------------------------*/
900
901#endif
Classe de base interne pour les tableaux.
static constexpr RunQueue * _nullRunQueue()
Méthode explicite pour une RunQueue nulle.
virtual bool _isUseOwnMetaData() const
Indique si m_md fait référence à m_meta_data.
Classe abstraite de base d'un vecteur.
void _addRange(ConstReferenceType val, Int64 n)
Ajoute n élément de valeur val à la fin du tableau.
Integer capacity() const
Capacité (nombre d'éléments alloués) du vecteur.
void _addRange(Span< const T > val)
Ajoute n élément de valeur val à la fin du tableau.
void _internalSetHostDeviceMemoryLocation(eHostDeviceMemoryLocation location)
Positionne l'emplacement physique de la zone mémoire.
virtual void _updateReferences()
Mise à jour des références.
void _checkFreeMemory()
Détruit l'instance si plus personne ne la référence.
ConstReferenceType operator[](Int64 i) const
Elément d'indice i.
void dispose()
Libère la mémoire utilisée par le tableau.
AbstractArray()
Construit un vecteur vide avec l'allocateur par défaut.
Integer size() const
Nombre d'éléments du vecteur.
void _initFromSpan(const Span< const T > &view)
Initialise le tableau avec la vue view.
void _move(ThatClassType &rhs) ARCCORE_NOEXCEPT
Implémente l'opérateur d'assignement par déplacement.
void _initFromAllocator(IMemoryAllocator *a, Int64 acapacity)
Construit un tableau avec un allocateur spécifique a.
void _initFromAllocator(MemoryAllocationOptions o, Int64 acapacity, void *pre_allocated_buffer=nullptr)
Construit un vecteur vide avec un allocateur spécifique a.
ArrayIterator< pointer > iterator
void _resize(Int64 s, ConstReferenceType value)
Redimensionne et remplit les nouvelles valeurs avec value.
void setMemoryLocationHint(eMemoryLocationHint new_hint)
Modifie les informations sur la localisation mémoire.
void _internalReallocate(Int64 new_capacity, FalseType, RunQueue *queue)
Réallocation pour un type complexe (non POD)
bool empty() const
Capacité (nombre d'éléments alloués) du vecteur.
eHostDeviceMemoryLocation hostDeviceMemoryLocation() const
Positionne l'emplacement physique de la zone mémoire.
Int64 largeSize() const
Nombre d'éléments du vecteur (en 64 bits)
bool contains(ConstReferenceType v) const
Vrai si le tableau contient l'élément de valeur v.
Int64 largeCapacity() const
Capacité (nombre d'éléments alloués) du vecteur (en 64 bits)
Int64 largeLength() const
Nombre d'éléments du vecteur (en 64 bits)
void _directFirstAllocateWithAllocator(Int64 new_capacity, MemoryAllocationOptions options, void *pre_allocated_buffer=nullptr)
Effectue la première allocation.
void _reserve(Int64 new_capacity)
Réserve le mémoire pour new_capacity éléments.
void _resizeAndCopyView(Span< const T > rhs)
Redimensionne l'instance et recopie les valeurs de rhs.
virtual Integer _getNbRef()
Mise à jour des références.
ArrayIterator< const_pointer > const_iterator
void _resizeNoInit(Int64 s, RunQueue *queue=nullptr)
Redimensionne sans initialiser les nouvelles valeurs.
AbstractArray(ThatClassType &&rhs) ARCCORE_NOEXCEPT
Constructeur par déplacement. Ne doit être utilisé que par UniqueArray.
void _internalRealloc(Int64 new_capacity, bool compute_capacity, PodType pod_type, RunQueue *queue=nullptr)
Réalloue le tableau pour une nouvelle capacité égale à new_capacity.
void _swap(ThatClassType &rhs) ARCCORE_NOEXCEPT
Échange les valeurs de l'instance avec celles de rhs.
ConstReferenceType operator()(Int64 i) const
Elément d'indice i.
void _reset()
Réinitialise le tableau à un tableau vide.
void _internalReallocate(Int64 new_capacity, TrueType, RunQueue *queue)
Réallocation pour un type POD.
Integer length() const
Nombre d'éléments du vecteur.
File d'exécution pour un accélérateur.
Informations sur une zone mémoire allouée.
String debugName() const
void setDebugName(const String &name)
Itérateur sur les classes tableau de Arccore.
Meta-Données des tableaux.
bool is_not_null
Indique si cette instance n'est pas l'instance nulle (partagée par tous les SharedArray)
Int64 size
Nombre d'éléments du tableau (pour les tableaux 1D)
Int32 nb_ref
Nombre de références sur l'instance.
bool is_allocated_by_new
Indique is cette instance a été allouée par l'opérateur new.
Vue constante d'un tableau de type T.
Interface d'un allocateur pour la mémoire.
constexpr __host__ __device__ pointer data() const noexcept
Pointeur sur le début de la vue.
Definition Span.h:516
constexpr __host__ __device__ SizeType size() const noexcept
Retourne la taille du tableau.
Definition Span.h:304
Vue d'un tableau d'éléments de type T.
Definition Span.h:612
Chaîne de caractères unicode.
-*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-
std::int64_t Int64
Type entier signé sur 64 bits.
Int32 Integer
Type représentant un entier.
eMemoryLocationHint
Indices sur la localisation mémoire attendue.
eHostDeviceMemoryLocation
Localisation physique d'une adresse mémoire.
std::int32_t Int32
Type entier signé sur 32 bits.
Structure équivalente à la valeur booléenne vrai.
Structure équivalente à la valeur booléenne vrai.