7#include <gtest/gtest.h>
9#include "arccore/collections/Array.h"
10#include "arccore/collections/IMemoryAllocator.h"
12#include "arccore/base/FatalErrorException.h"
13#include "arccore/base/Iterator.h"
15#include "TestArrayCommon.h"
18using namespace TestArccore;
22void _testArraySwap(
bool use_own_swap)
24 std::cout <<
"** TestArraySwap is_own=" << use_own_swap <<
"\n";
28 c1.setDebugName(c1_name);
30 std::cout <<
"** C1_this = " << &c1 <<
"\n";
31 std::cout <<
"** C1_BASE = " << x1 <<
"\n";
34 std::cout <<
"** C2_this = " << &c2 <<
"\n";
35 std::cout <<
"** C2_BASE = " << x2 <<
"\n";
37 ASSERT_EQ(c1.debugName(), c1_name);
38 ASSERT_EQ(c2.debugName(),
String{});
46 ASSERT_EQ(c2.debugName(), c1_name);
47 ASSERT_EQ(c1.debugName(),
String{});
51 std::cout <<
"** C1_BASE_AFTER = " << after_x1 <<
" size=" << c1.size() <<
"\n";
52 std::cout <<
"** C2_BASE_AFTER = " << after_x2 <<
" size=" << c2.size() <<
"\n";
54 ASSERT_TRUE(x1 == after_x2) <<
"Bad value after swap [1]";
55 ASSERT_TRUE(x2 == after_x1) <<
"Bad value after swap [2]";
66 _testArraySwap(
false);
72Integer IntPtrSubClass::count = 0;
77template <
typename Container,
typename SubClass>
89 ARCCORE_UT_CHECK((c.size() == 3),
"Bad size (3)");
90 ARCCORE_UT_CHECK((c[0] == 1),
"Bad value [0]");
91 ARCCORE_UT_CHECK((c[1] == 2),
"Bad value [1]");
92 ARCCORE_UT_CHECK((c[2] == 3),
"Bad value [2]");
94 ARCCORE_UT_CHECK((c.size() == 0),
"Bad size (0)");
96 ARCCORE_UT_CHECK((c.size() == 5),
"Bad size");
98 ARCCORE_UT_CHECK((c.size() == 6),
"Bad size");
99 ARCCORE_UT_CHECK((c[5] == 6),
"Bad value [5]");
101 ASSERT_EQ(c.size(), c.capacity()) <<
"Bad capacity (test 1)";
104 ASSERT_EQ(c.size(), c.capacity()) <<
"Bad capacity (test 2)";
109 ASSERT_EQ(c.capacity(), 0) <<
"Bad capacity (test 3)";
114 for (
Integer i = 0; i < nb; ++i)
117 Int64 current_capacity = c.capacity();
118 ASSERT_EQ(current_capacity, (nb * 2)) <<
"Bad capacity (test 4)";
119 c.shrink(c.capacity() + 5);
120 ASSERT_EQ(c.capacity(), current_capacity) <<
"Bad capacity (test 5)";
122 ASSERT_EQ(c.capacity(), 32) <<
"Bad capacity (test 6)";
124 ASSERT_EQ(c.capacity(), c.size()) <<
"Bad capacity (test 7)";
130 for (Container& c : uc) {
137 for (
Integer i = 0; i < 50; ++i)
138 c.add(SubClass(i + 2));
141 for (
Integer i = 50; i < 100; ++i) {
142 c2.add(SubClass(i + 2));
150 for (
Integer i = 100; i < 150; ++i) {
151 c4.add(SubClass(i + 2));
154 ARCCORE_UT_CHECK((c.size() == 150),
"Bad size (150)");
156 ARCCORE_UT_CHECK((c.capacity() == 300),
"Bad capacity (300)");
157 for (
Integer i = 0; i < 50; ++i) {
160 ARCCORE_UT_CHECK((c.size() == 100),
"Bad size (100)");
161 for (
Integer i = 0; i < 50; ++i) {
163 ARCCORE_UT_CHECK((c[i] == ((i * 2) + 3)),
"Bad value");
165 for (
Integer i = 50; i < 100; ++i) {
167 ARCCORE_UT_CHECK((c[i] == (i + 52)),
"Bad value");
175void _testArrayNewInternal()
178 std::cout <<
"** TEST VECTOR NEW\n";
187 std::cout <<
"** TEST VECTOR NEW 2\n";
191 std::cout <<
"** COUNT = " << IntPtrSubClass::count <<
"\n";
193 std::cout <<
"** TEST VECTOR NEW 3\n";
197 std::cout <<
"** COUNT = " << IntPtrSubClass::count <<
"\n";
205 ARCCORE_UT_CHECK((c2.size() == 3),
"Bad value [3]");
206 ARCCORE_UT_CHECK((c.
size() == 2),
"Bad value [2]");
207 ARCCORE_UT_CHECK((c[0] == 5),
"Bad value [5]");
208 ARCCORE_UT_CHECK((c[1] == 7),
"Bad value [7]");
209 ARCCORE_UT_CHECK((c2[0] == 5),
"Bad value [5]");
210 ARCCORE_UT_CHECK((c2[1] == 7),
"Bad value [7]");
211 ARCCORE_UT_CHECK((c2[2] == 3),
"Bad value [7]");
219 ARCCORE_UT_CHECK((c2.size() == 3),
"Bad value [3]");
220 ARCCORE_UT_CHECK((c.
size() == 2),
"Bad value [2]");
221 ARCCORE_UT_CHECK((c[0] == 5),
"Bad value [5]");
222 ARCCORE_UT_CHECK((c[1] == 7),
"Bad value [7]");
223 ARCCORE_UT_CHECK((c2[0] == 5),
"Bad value [5]");
224 ARCCORE_UT_CHECK((c2[1] == 7),
"Bad value [7]");
225 ARCCORE_UT_CHECK((c2[2] == 3),
"Bad value [7]");
231 ARCCORE_UT_CHECK((c2.size() == 3),
"Bad value [3]");
232 ARCCORE_UT_CHECK((c.
size() == 2),
"Bad value [2]");
233 ARCCORE_UT_CHECK((c[0] == 5),
"Bad value [5]");
234 ARCCORE_UT_CHECK((c[1] == 7),
"Bad value [7]");
235 ARCCORE_UT_CHECK((c2[0] == 5),
"Bad value [5]");
236 ARCCORE_UT_CHECK((c2[1] == 7),
"Bad value [7]");
237 ARCCORE_UT_CHECK((c2[2] == 3),
"Bad value [7]");
241 ARCCORE_UT_CHECK((c.
size() == 2),
"Bad value [2]");
242 ARCCORE_UT_CHECK((c[0] == 5),
"Bad value [5]");
243 ARCCORE_UT_CHECK((c[1] == 7),
"Bad value [7]");
247 ARCCORE_UT_CHECK((c.
size() == 2),
"Bad value [2]");
248 ARCCORE_UT_CHECK((c[0] == 5),
"Bad value [5]");
249 ARCCORE_UT_CHECK((c[1] == 7),
"Bad value [7]");
255 ARCCORE_UT_CHECK((cx.size() == 5),
"Bad value [5]");
260 ARCCORE_UT_CHECK((c2.size() == 3),
"Bad value [3]");
261 ARCCORE_UT_CHECK((c.
size() == 2),
"Bad value [2]");
262 ARCCORE_UT_CHECK((c[0] == 5),
"Bad value [5]");
263 ARCCORE_UT_CHECK((c[1] == 7),
"Bad value [7]");
264 ARCCORE_UT_CHECK((c2[0] == 5),
"Bad value [5]");
265 ARCCORE_UT_CHECK((c2[1] == 7),
"Bad value [7]");
266 ARCCORE_UT_CHECK((c2[2] == 3),
"Bad value [7]");
267 for (
Integer i = 0; i < 50; ++i)
277 ASSERT_EQ(c22.size(), 33);
287 ASSERT_EQ(c2.
size(), c3.size());
288 ASSERT_EQ(c2.
size(), c4.size());
290 ASSERT_EQ(c2.
size(), c3.size());
291 ASSERT_EQ(c2.
size(), c4.size());
296 ARCCORE_UT_CHECK((c2.
size() == 33),
"Bad value [3]");
297 ARCCORE_UT_CHECK((c2[0] == 5),
"Bad value [5]");
298 ARCCORE_UT_CHECK((c2[1] == 7),
"Bad value [7]");
299 ARCCORE_UT_CHECK((c2[32] == 3),
"Bad value [7]");
301 ASSERT_EQ(c2.
size(), 1293);
302 ASSERT_EQ(c22.size(), 2);
306 ASSERT_EQ(values1.
size(), 3);
307 ASSERT_EQ(values1[0], -7);
308 ASSERT_EQ(values1[1], 3);
309 ASSERT_EQ(values1[2], 4);
310 values1 = { 2, -1, 9, 13 };
311 ASSERT_EQ(values1.
size(), 4);
312 ASSERT_EQ(values1[0], 2);
313 ASSERT_EQ(values1[1], -1);
314 ASSERT_EQ(values1[2], 9);
315 ASSERT_EQ(values1[3], 13);
317 ASSERT_EQ(values2, values1);
320 ASSERT_EQ(values1.
size(), 0);
321 ASSERT_EQ(values2.
size(), 0);
328 std::copy(std::begin(values2), std::end(values2), std::back_inserter(values1));
329 std::cout <<
"** VALUES1 = " << values1 <<
"\n";
330 ARCCORE_UT_CHECK((values1.size() == 5),
"BI: Bad size");
331 ARCCORE_UT_CHECK((values1[0] == 2),
"BI: Bad value [0]");
332 ARCCORE_UT_CHECK((values1[1] == 5),
"BI: Bad value [1]");
333 ARCCORE_UT_CHECK((values1[2] == 4),
"BI: Bad value [2]");
334 ARCCORE_UT_CHECK((values1[3] == 9),
"BI: Bad value [3]");
335 ARCCORE_UT_CHECK((values1[4] == 7),
"BI: Bad value [4]");
341 std::cout <<
"V=" << i->m_v <<
" " << ci->m_v <<
'\n';
344 ASSERT_EQ(values1.size(), 2);
345 ASSERT_EQ(values1[0], -7);
346 ASSERT_EQ(values1[1], 3);
349 ASSERT_EQ(values1.size(), 0);
355 values1.
copy(values2);
356 std::cout <<
"** VALUES1 = " << values1 <<
"\n";
357 ARCCORE_UT_CHECK((values1.size() == 5),
"BI: Bad size");
358 ARCCORE_UT_CHECK((values1[0] == 4),
"BI2: Bad value [0]");
359 ARCCORE_UT_CHECK((values1[1] == 9),
"BI2: Bad value [1]");
360 ARCCORE_UT_CHECK((values1[2] == 7),
"BI2: Bad value [2]");
361 ARCCORE_UT_CHECK((values1[3] == 6),
"BI2: Bad value [3]");
362 ARCCORE_UT_CHECK((values1[4] == 3),
"BI2: Bad value [4]");
368 std::cout <<
"V=" << i->m_v <<
" " << ci->m_v <<
'\n';
375 std::cout <<
"V=" << i->m_v <<
" " << ci->m_v <<
'\n';
378 std::cout <<
"V=" << cicvx->m_v <<
'\n';
386 std::cout <<
"V=" << i->m_v <<
" " << ci->m_v <<
" " << (iend - i) <<
'\n';
389 std::cout <<
"V=" << cicvx->m_v <<
'\n';
390 std::copy(std::begin(vx), std::end(vx), std::begin(vx));
395 std::cout << *i <<
'\n';
398 std::cout << *i <<
'\n';
400 for (
auto i : values.
range()) {
401 std::cout << i <<
'\n';
403 for (
auto i : values.
constView().range()) {
404 std::cout << i <<
'\n';
408 auto r1 = std::make_reverse_iterator(values.
end());
409 auto r2 = std::make_reverse_iterator(values.
begin());
410 for (; r1 != r2; ++r1) {
411 std::cout <<
"RVALUE = " << *r1 <<
'\n';
415 auto r1 = values.
rbegin();
428 ARCCORE_UT_CHECK((c2.
size() == 3),
"Bad value [3]");
429 ARCCORE_UT_CHECK((c.
size() == 2),
"Bad value [2]");
430 ARCCORE_UT_CHECK((c[0] == 5),
"Bad value [5]");
431 ARCCORE_UT_CHECK((c[1] == 7),
"Bad value [7]");
432 ARCCORE_UT_CHECK((c2[0] == 5),
"Bad value [5]");
433 ARCCORE_UT_CHECK((c2[1] == 7),
"Bad value [7]");
434 ARCCORE_UT_CHECK((c2[2] == 3),
"Bad value [7]");
451 _testArrayNewInternal();
454 std::cerr <<
"Exception ex=" << ex <<
"\n";
482 ASSERT_EQ(v[0], 1.2);
483 ASSERT_EQ(v[1], -1.3);
484 ASSERT_EQ(v.
at(2), 7.6);
488 std::cout <<
" Value: " << x <<
'\n';
490 v.printInfos(std::cout);
497 v.printInfos(std::cout);
501 v.printInfos(std::cout);
503 v.printInfos(std::cout);
508 v.printInfos(std::cout);
510 std::cout <<
" Value: " << v[i] <<
'\n';
516 for (
int i = 0; i < 10; ++i)
519 std::cout <<
" Value: " << v[i] <<
'\n';
525 for (
int i = 0; i < 27500; ++i) {
529 for (
int i = 0; i < 5000; ++i) {
533 for (
int i = 0; i < 27500; ++i) {
537 std::cout <<
" ValueSize= " << v.
size() <<
" values=" << v <<
'\n';
539 for (
Integer i = 0; i < 100; ++i) {
548 std::cout <<
" Size: " << v.
size() <<
'\n';
549 ASSERT_EQ(v.
size(), 230000);
564 for (Int32 i = 0, n = v.
size(); i < n; ++i)
567 auto sub_view1 = v.
subView(50, 5);
568 ASSERT_EQ(sub_view1.data(),
nullptr);
569 ASSERT_EQ(sub_view1.size(), 0);
571 auto sub_view2 = v.
subView(2, 8);
572 ASSERT_EQ(sub_view2.size(), 8);
573 for (Int32 i = 0, n = sub_view2.size(); i < n; ++i)
574 ASSERT_EQ(sub_view2[i], v[2 + i]);
576 auto sub_view3 = v.
subView(20, 8);
577 ASSERT_EQ(sub_view3.size(), 3);
578 for (Int32 i = 0, n = sub_view3.size(); i < n; ++i)
579 ASSERT_EQ(sub_view3[i], v[20 + i]);
582 ASSERT_EQ(sub_const_view1.data(),
nullptr);
583 ASSERT_EQ(sub_const_view1.size(), 0);
586 ASSERT_EQ(sub_const_view2.size(), 8);
587 for (Int32 i = 0, n = sub_const_view2.size(); i < n; ++i)
588 ASSERT_EQ(sub_const_view2[i], v[2 + i]);
591 ASSERT_EQ(sub_const_view3.size(), 3);
592 for (Int32 i = 0, n = sub_const_view3.size(); i < n; ++i)
593 ASSERT_EQ(sub_const_view3[i], v[20 + i]);
604 NoCopyData(
const NoCopyData& x) =
delete;
607template <
typename DataType>
625 const Int32 ref_value1 = 12;
626 const Int32 ref_value2 = 7;
629 std::cout <<
"C1=" << c <<
"\n";
631 ASSERT_EQ(x, ref_value1);
634 ASSERT_EQ(c.size(), 21);
635 std::cout <<
"C2=" << c <<
"\n";
640 std::cout <<
"C4=" << c <<
"\n";
641 for (Int32 i = 9, s = c.size(); i < s; ++i)
642 ASSERT_EQ(c[i], ref_value2);
643 for (Int32 i = 9, s = c.size(); i < s; ++i)
645 for (Int32 i = 9, s = c.size(); i < s; ++i)
646 ASSERT_EQ(c[i], (i + 2));
657template <
typename ArrayType>
662 static void doTestBase()
671 std::cout <<
"Array a\n";
672 ArrayType a(allocator1);
673 ASSERT_EQ(a.allocator(), allocator1);
679 std::cout <<
"Array b\n";
680 ArrayType b(allocator2);
681 ASSERT_EQ(b.capacity(), 0);
682 ASSERT_EQ(b.size(), 0);
683 ASSERT_EQ(b.allocator(), allocator2);
686 ASSERT_EQ(b.size(), a.size());
687 ASSERT_EQ(b.allocator(), a.allocator());
689 std::cout <<
"Array c\n";
690 ArrayType c(a.clone());
691 ASSERT_EQ(c.allocator(), a.allocator());
692 ASSERT_EQ(c.size(), a.size());
693 ASSERT_EQ(c.constSpan(), a.constSpan());
695 std::cout <<
"Array d\n";
696 ArrayType d(allocator2, a);
697 ASSERT_EQ(d.allocator(), allocator2);
698 ASSERT_EQ(d.size(), a.size());
699 ASSERT_EQ(d.constSpan(), a.constSpan());
701 std::cout <<
"Array e\n";
702 ArrayType e(allocator2, 25);
703 ASSERT_EQ(e.allocator(), allocator2);
704 ASSERT_EQ(e.size(), 25);
706 ArrayType f(allocator2);
708 ASSERT_EQ(f.allocator(), e.allocator());
709 ASSERT_EQ(f.size(), e.size());
712 ASSERT_EQ(f.allocator(), e.allocator());
713 ASSERT_EQ(f.size(), e.size());
735 std::cout <<
"Sizeof(ArrayMetaData)=" <<
sizeof(
ArrayMetaData) <<
"\n";
744 std::cout <<
"Array a1\n";
746 ASSERT_EQ(a1.allocator(), allocator2);
747 ASSERT_EQ(a1.size(), 0);
748 ASSERT_EQ(a1.capacity(), 0);
749 ASSERT_EQ(a1.data(),
nullptr);
751 std::cout <<
"Array a2\n";
753 ASSERT_EQ(a1.allocator(), a2.allocator());
754 ASSERT_EQ(a2.capacity(), 0);
755 ASSERT_EQ(a2.data(),
nullptr);
762 ASSERT_EQ(a1.size(), 5);
764 std::cout <<
"Array a3\n";
769 ASSERT_EQ(a3.size(), 3);
771 ASSERT_EQ(a3.allocator(), a1.allocator());
772 ASSERT_EQ(a3.size(), a1.size());
773 ASSERT_EQ(a3.constSpan(), a1.constSpan());
775 std::cout <<
"Array a4\n";
780 ASSERT_EQ(a4.size(), 3);
782 ASSERT_EQ(a4.allocator(), allocator1);
788 for (
Integer i = 0; i < 2; ++i) {
791 ASSERT_EQ(array[0].allocator(), allocator3);
792 ASSERT_EQ(array[1].allocator(), allocator3);
803 std::cout <<
"Sizeof(ArrayMetaData)=" <<
sizeof(
ArrayMetaData) <<
"\n";
812 std::cout <<
"Array a1\n";
814 ASSERT_EQ(a1.allocator(), allocator2);
815 ASSERT_EQ(a1.size(), 0);
816 ASSERT_EQ(a1.capacity(), 0);
817 ASSERT_EQ(a1.data(),
nullptr);
819 std::cout <<
"Array a2\n";
821 ASSERT_EQ(a1.allocator(), a2.allocator());
822 ASSERT_EQ(a2.capacity(), 0);
823 ASSERT_EQ(a2.data(),
nullptr);
830 ASSERT_EQ(a1.size(), 5);
832 std::cout <<
"Array a3\n";
837 ASSERT_EQ(a3.size(), 3);
839 ASSERT_EQ(a3.allocator(), a1.allocator());
840 ASSERT_EQ(a3.size(), a1.size());
841 ASSERT_EQ(a3.constSpan(), a1.constSpan());
843 std::cout <<
"Array a4\n";
845 ASSERT_EQ(a4.size(), 2);
849 ASSERT_EQ(a4.size(), 5);
855 ASSERT_EQ(a4.allocator(), allocator1);
861 for (
Integer i = 0; i < 2; ++i) {
864 ASSERT_EQ(array[0].allocator(), allocator3);
865 ASSERT_EQ(array[1].allocator(), allocator3);
877:
public IMemoryAllocator3
884 return m_default_allocator.hasRealloc(args);
889 return m_default_allocator.allocate(args, new_size);
894 return m_default_allocator.reallocate(args, current_ptr, new_size);
899 m_default_allocator.deallocate(args, ptr);
901 Int64 adjustedCapacity(
MemoryAllocationArgs args, Int64 wanted_capacity, Int64 element_size)
const override
904 return m_default_allocator.adjustedCapacity(args, wanted_capacity, element_size);
909 return m_default_allocator.guaranteedAlignment(args);
917 ASSERT_EQ(ptr.
size(), 8);
918 m_default_allocator.notifyMemoryArgsChanged(old_args, new_args, ptr);
923 DefaultMemoryAllocator3 m_default_allocator;
932 bool is_valid = v1 || v2 || v3;
937#define ASSERT_SAME_ARRAY_INFOS(a, b) \
938 ASSERT_EQ(a.allocationOptions(), b.allocationOptions()); \
939 ASSERT_EQ(a.size(), b.size()); \
940 ASSERT_EQ(a.capacity(), b.capacity())
942TEST(
Array, AllocatorV2)
952 ASSERT_EQ(opt3, allocate_options1);
955 std::cout <<
"Array a1\n";
957 ASSERT_EQ(a1.allocationOptions(), allocate_options2);
958 ASSERT_EQ(a1.size(), 0);
959 ASSERT_EQ(a1.capacity(), 0);
960 ASSERT_EQ(a1.data(),
nullptr);
962 std::cout <<
"Array a2\n";
964 ASSERT_SAME_ARRAY_INFOS(a2, a1);
965 ASSERT_EQ(a2.data(),
nullptr);
972 ASSERT_EQ(a1.size(), 5);
978 std::cout <<
"Array a3\n";
983 ASSERT_EQ(a3.size(), 3);
985 ASSERT_EQ(a3.allocator(), a1.allocator());
986 ASSERT_EQ(a3.size(), a1.size());
987 ASSERT_EQ(a3.constSpan(), a1.constSpan());
989 std::cout <<
"Array a4\n";
994 ASSERT_EQ(a4.size(), 3);
996 ASSERT_EQ(a4.allocationOptions(), allocate_options1);
1002 for (
Integer i = 0; i < 2; ++i) {
1005 ASSERT_EQ(array[0].allocationOptions(), allocator3);
1006 ASSERT_EQ(array[1].allocationOptions(), allocator3);
1013TEST(
Array, DebugInfo)
1016 DefaultMemoryAllocator3 m_default_allocator;
1019 String a1_name(
"Array1");
1020 String sa1_name(
"SharedArray1");
1023 std::cout <<
"Array a1\n";
1025 a1.setDebugName(a1_name);
1026 ASSERT_EQ(a1.allocationOptions(), allocate_options2);
1027 ASSERT_EQ(a1.size(), 0);
1028 ASSERT_EQ(a1.capacity(), 0);
1029 ASSERT_EQ(a1.data(),
nullptr);
1030 ASSERT_EQ(a1.debugName(), a1_name);
1032 std::cout <<
"SharedArray sa1\n";
1034 sa1.setDebugName(sa1_name);
1035 ASSERT_EQ(sa1.allocationOptions(), allocate_options2);
1036 ASSERT_EQ(sa1.size(), 0);
1037 ASSERT_EQ(sa1.capacity(), 0);
1038 ASSERT_EQ(sa1.data(),
nullptr);
1039 ASSERT_EQ(sa1.debugName(), sa1_name);
1041 ASSERT_EQ(a1.debugName(), a1_name);
1043 std::cout <<
"Array a2\n";
1045 ASSERT_SAME_ARRAY_INFOS(a2, a1);
1046 ASSERT_EQ(a2.data(),
nullptr);
1047 ASSERT_EQ(a2.debugName(), a1_name);
1054 ASSERT_EQ(a1.size(), 5);
1057 ASSERT_EQ(a2.debugName(), a1_name);
1058 ASSERT_EQ(a2.size(), 2);
1063 ASSERT_EQ(a3.
size(), 2);
1069TEST(Collections, Memory)
#define ASSERT_TRUE(condition)
Checks that condition is true.
String debugName() const
Debug name (null if no name specified).
Abstract base class for a vector.
void _internalSetHostDeviceMemoryLocation(eHostDeviceMemoryLocation location)
Sets the physical location of the memory region.
Integer size() const
Number of elements in the vector.
ArrayIterator< pointer > iterator
Type of the iterator over an array element.
eHostDeviceMemoryLocation hostDeviceMemoryLocation() const
Sets the physical location of the memory region.
ArrayIterator< const_pointer > const_iterator
Type of the constant iterator over an array element.
static constexpr Integer simdAlignment()
Alignment for structures using vectorization.
static AlignedMemoryAllocator * Simd()
Allocator guaranteeing alignment to use vectorization on the target platform.
Information about an allocated memory region.
Int64 size() const
Size in bytes of the used memory region. (-1) if unknown.
ConstIterT< ArrayView< T > > const_iter
Type of a constant iterator over the entire array.
Base class for 1D data vectors.
SmallSpan< const T > smallSpan() const
Immutable view of this array.
reverse_iterator rbegin()
Reverse iterator over the first element of the array.
T & at(Int64 i)
Element at index i. Always checks for overflows.
void resizeNoInit(Int64 s)
Resizes without initializing new values.
Span< const T > span() const
Immutable view of this array.
void resize(Int64 s)
Changes the number of elements in the array to s.
ConstArrayView< T > subConstView(Int64 abegin, Int32 asize) const
Sub-view starting from element abegin and containing asize elements.
void copy(Span< const T > rhs)
Copies the values from rhs into the instance.
SmallSpan< const T > constSmallSpan() const
Immutable view of this array.
iterator begin()
Iterator over the first element of the array.
void add(ConstReferenceType val)
Adds element val to the end of the array.
ConstArrayView< T > constView() const
Constant view of this array.
ArrayRange< pointer > range()
Iteration range from the first to the last element.
void remove(Int64 index)
Removes the entity at index index.
Span< const T > constSpan() const
Constant view of this array.
void reserve(Int64 new_capacity)
Reserves memory for new_capacity elements.
reverse_iterator rend()
Reverse iterator over the first element after the end of the array.
ArrayView< T > subView(Int64 abegin, Integer asize)
Sub-view starting from element abegin and containing asize elements.
iterator end()
Iterator over the first element after the end of the array.
ArrayView< T > view() const
Mutable view of this array.
ConstIterT< ConstArrayView< T > > const_iter
Type of a constant iterator over the entire array.
Base class for an exception.
Interface for a memory allocator.
Class containing information to specialize allocations.
Options to configure allocations.
Memory allocator via malloc/realloc/free with listing output.
1D vector of data with reference semantics.
SharedArray< T > clone() const
Clones the array.
View of an array of elements of type T.
Unicode character string.
1D data vector with value semantics (STL style).
Allocator for testing arguments.
Concept for allocating, resizing and freeing memory block.
-- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature --
void swap(UniqueArray2< T > &v1, UniqueArray2< T > &v2)
Swaps the values of v1 and v2.
Int32 Integer
Type representing an integer.
@ MainlyHost
Indicates that the data will primarily be used on the CPU.
@ HostAndDeviceMostlyRead
Indicates that the data will be used both on the accelerator and on the CPU and will not be frequentl...
@ Unknown
Unknown location.
@ ManagedMemoryDevice
The memory is managed memory on the accelerator.
@ Host
The memory is on the host.
@ ManagedMemoryHost
The memory is managed memory on the host.
@ Device
The memory is on the accelerator.
@ HostPinned
Allocates on the host.
@ Unknown
Unknown or uninitialized value.
@ Host
Allocates on the host.
@ UnifiedMemory
Allocates using unified memory.
@ Device
Allocates on the device.