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"
20using namespace TestArccore;
24void _testArraySwap(
bool use_own_swap)
26 std::cout <<
"** TestArraySwap is_own=" << use_own_swap <<
"\n";
30 c1.setDebugName(c1_name);
32 std::cout <<
"** C1_this = " << &c1 <<
"\n";
33 std::cout <<
"** C1_BASE = " << x1 <<
"\n";
36 std::cout <<
"** C2_this = " << &c2 <<
"\n";
37 std::cout <<
"** C2_BASE = " << x2 <<
"\n";
39 ASSERT_EQ(c1.debugName(), c1_name);
40 ASSERT_EQ(c2.debugName(),
String{});
48 ASSERT_EQ(c2.debugName(), c1_name);
49 ASSERT_EQ(c1.debugName(),
String{});
53 std::cout <<
"** C1_BASE_AFTER = " << after_x1 <<
" size=" << c1.size() <<
"\n";
54 std::cout <<
"** C2_BASE_AFTER = " << after_x2 <<
" size=" << c2.size() <<
"\n";
56 ASSERT_TRUE(x1 == after_x2) <<
"Bad value after swap [1]";
57 ASSERT_TRUE(x2 == after_x1) <<
"Bad value after swap [2]";
68 _testArraySwap(
false);
74Integer IntPtrSubClass::count = 0;
79template <
typename Container,
typename SubClass>
91 ARCCORE_UT_CHECK((c.size() == 3),
"Bad size (3)");
92 ARCCORE_UT_CHECK((c[0] == 1),
"Bad value [0]");
93 ARCCORE_UT_CHECK((c[1] == 2),
"Bad value [1]");
94 ARCCORE_UT_CHECK((c[2] == 3),
"Bad value [2]");
96 ARCCORE_UT_CHECK((c.size() == 0),
"Bad size (0)");
98 ARCCORE_UT_CHECK((c.size() == 5),
"Bad size");
100 ARCCORE_UT_CHECK((c.size() == 6),
"Bad size");
101 ARCCORE_UT_CHECK((c[5] == 6),
"Bad value [5]");
103 ASSERT_EQ(c.size(), c.capacity()) <<
"Bad capacity (test 1)";
106 ASSERT_EQ(c.size(), c.capacity()) <<
"Bad capacity (test 2)";
111 ASSERT_EQ(c.capacity(), 0) <<
"Bad capacity (test 3)";
116 for (
Integer i = 0; i < nb; ++i)
119 Int64 current_capacity = c.capacity();
120 ASSERT_EQ(current_capacity, (nb * 2)) <<
"Bad capacity (test 4)";
121 c.shrink(c.capacity() + 5);
122 ASSERT_EQ(c.capacity(), current_capacity) <<
"Bad capacity (test 5)";
124 ASSERT_EQ(c.capacity(), 32) <<
"Bad capacity (test 6)";
126 ASSERT_EQ(c.capacity(), c.size()) <<
"Bad capacity (test 7)";
132 for (Container& c : uc) {
139 for (
Integer i = 0; i < 50; ++i)
140 c.add(SubClass(i + 2));
143 for (
Integer i = 50; i < 100; ++i) {
144 c2.add(SubClass(i + 2));
152 for (
Integer i = 100; i < 150; ++i) {
153 c4.add(SubClass(i + 2));
156 ARCCORE_UT_CHECK((c.size() == 150),
"Bad size (150)");
158 ARCCORE_UT_CHECK((c.capacity() == 300),
"Bad capacity (300)");
159 for (
Integer i = 0; i < 50; ++i) {
162 ARCCORE_UT_CHECK((c.size() == 100),
"Bad size (100)");
163 for (
Integer i = 0; i < 50; ++i) {
165 ARCCORE_UT_CHECK((c[i] == ((i * 2) + 3)),
"Bad value");
167 for (
Integer i = 50; i < 100; ++i) {
169 ARCCORE_UT_CHECK((c[i] == (i + 52)),
"Bad value");
177void _testArrayNewInternal()
180 std::cout <<
"** TEST VECTOR NEW\n";
189 std::cout <<
"** TEST VECTOR NEW 2\n";
193 std::cout <<
"** COUNT = " << IntPtrSubClass::count <<
"\n";
195 std::cout <<
"** TEST VECTOR NEW 3\n";
199 std::cout <<
"** COUNT = " << IntPtrSubClass::count <<
"\n";
207 ARCCORE_UT_CHECK((c2.size() == 3),
"Bad value [3]");
208 ARCCORE_UT_CHECK((c.
size() == 2),
"Bad value [2]");
209 ARCCORE_UT_CHECK((c[0] == 5),
"Bad value [5]");
210 ARCCORE_UT_CHECK((c[1] == 7),
"Bad value [7]");
211 ARCCORE_UT_CHECK((c2[0] == 5),
"Bad value [5]");
212 ARCCORE_UT_CHECK((c2[1] == 7),
"Bad value [7]");
213 ARCCORE_UT_CHECK((c2[2] == 3),
"Bad value [7]");
221 ARCCORE_UT_CHECK((c2.size() == 3),
"Bad value [3]");
222 ARCCORE_UT_CHECK((c.
size() == 2),
"Bad value [2]");
223 ARCCORE_UT_CHECK((c[0] == 5),
"Bad value [5]");
224 ARCCORE_UT_CHECK((c[1] == 7),
"Bad value [7]");
225 ARCCORE_UT_CHECK((c2[0] == 5),
"Bad value [5]");
226 ARCCORE_UT_CHECK((c2[1] == 7),
"Bad value [7]");
227 ARCCORE_UT_CHECK((c2[2] == 3),
"Bad value [7]");
233 ARCCORE_UT_CHECK((c2.size() == 3),
"Bad value [3]");
234 ARCCORE_UT_CHECK((c.
size() == 2),
"Bad value [2]");
235 ARCCORE_UT_CHECK((c[0] == 5),
"Bad value [5]");
236 ARCCORE_UT_CHECK((c[1] == 7),
"Bad value [7]");
237 ARCCORE_UT_CHECK((c2[0] == 5),
"Bad value [5]");
238 ARCCORE_UT_CHECK((c2[1] == 7),
"Bad value [7]");
239 ARCCORE_UT_CHECK((c2[2] == 3),
"Bad value [7]");
243 ARCCORE_UT_CHECK((c.
size() == 2),
"Bad value [2]");
244 ARCCORE_UT_CHECK((c[0] == 5),
"Bad value [5]");
245 ARCCORE_UT_CHECK((c[1] == 7),
"Bad value [7]");
249 ARCCORE_UT_CHECK((c.
size() == 2),
"Bad value [2]");
250 ARCCORE_UT_CHECK((c[0] == 5),
"Bad value [5]");
251 ARCCORE_UT_CHECK((c[1] == 7),
"Bad value [7]");
257 ARCCORE_UT_CHECK((cx.size() == 5),
"Bad value [5]");
262 ARCCORE_UT_CHECK((c2.size() == 3),
"Bad value [3]");
263 ARCCORE_UT_CHECK((c.
size() == 2),
"Bad value [2]");
264 ARCCORE_UT_CHECK((c[0] == 5),
"Bad value [5]");
265 ARCCORE_UT_CHECK((c[1] == 7),
"Bad value [7]");
266 ARCCORE_UT_CHECK((c2[0] == 5),
"Bad value [5]");
267 ARCCORE_UT_CHECK((c2[1] == 7),
"Bad value [7]");
268 ARCCORE_UT_CHECK((c2[2] == 3),
"Bad value [7]");
269 for (
Integer i = 0; i < 50; ++i)
279 ASSERT_EQ(c22.size(), 33);
289 ASSERT_EQ(c2.
size(), c3.size());
290 ASSERT_EQ(c2.
size(), c4.size());
292 ASSERT_EQ(c2.
size(), c3.size());
293 ASSERT_EQ(c2.
size(), c4.size());
298 ARCCORE_UT_CHECK((c2.
size() == 33),
"Bad value [3]");
299 ARCCORE_UT_CHECK((c2[0] == 5),
"Bad value [5]");
300 ARCCORE_UT_CHECK((c2[1] == 7),
"Bad value [7]");
301 ARCCORE_UT_CHECK((c2[32] == 3),
"Bad value [7]");
303 ASSERT_EQ(c2.
size(), 1293);
304 ASSERT_EQ(c22.size(), 2);
308 ASSERT_EQ(values1.
size(), 3);
309 ASSERT_EQ(values1[0], -7);
310 ASSERT_EQ(values1[1], 3);
311 ASSERT_EQ(values1[2], 4);
312 values1 = { 2, -1, 9, 13 };
313 ASSERT_EQ(values1.
size(), 4);
314 ASSERT_EQ(values1[0], 2);
315 ASSERT_EQ(values1[1], -1);
316 ASSERT_EQ(values1[2], 9);
317 ASSERT_EQ(values1[3], 13);
319 ASSERT_EQ(values2, values1);
322 ASSERT_EQ(values1.
size(), 0);
323 ASSERT_EQ(values2.
size(), 0);
330 std::copy(std::begin(values2), std::end(values2), std::back_inserter(values1));
331 std::cout <<
"** VALUES1 = " << values1 <<
"\n";
332 ARCCORE_UT_CHECK((values1.size() == 5),
"BI: Bad size");
333 ARCCORE_UT_CHECK((values1[0] == 2),
"BI: Bad value [0]");
334 ARCCORE_UT_CHECK((values1[1] == 5),
"BI: Bad value [1]");
335 ARCCORE_UT_CHECK((values1[2] == 4),
"BI: Bad value [2]");
336 ARCCORE_UT_CHECK((values1[3] == 9),
"BI: Bad value [3]");
337 ARCCORE_UT_CHECK((values1[4] == 7),
"BI: Bad value [4]");
343 std::cout <<
"V=" << i->m_v <<
" " << ci->m_v <<
'\n';
346 ASSERT_EQ(values1.size(), 2);
347 ASSERT_EQ(values1[0], -7);
348 ASSERT_EQ(values1[1], 3);
351 ASSERT_EQ(values1.size(), 0);
357 values1.
copy(values2);
358 std::cout <<
"** VALUES1 = " << values1 <<
"\n";
359 ARCCORE_UT_CHECK((values1.size() == 5),
"BI: Bad size");
360 ARCCORE_UT_CHECK((values1[0] == 4),
"BI2: Bad value [0]");
361 ARCCORE_UT_CHECK((values1[1] == 9),
"BI2: Bad value [1]");
362 ARCCORE_UT_CHECK((values1[2] == 7),
"BI2: Bad value [2]");
363 ARCCORE_UT_CHECK((values1[3] == 6),
"BI2: Bad value [3]");
364 ARCCORE_UT_CHECK((values1[4] == 3),
"BI2: Bad value [4]");
370 std::cout <<
"V=" << i->m_v <<
" " << ci->m_v <<
'\n';
377 std::cout <<
"V=" << i->m_v <<
" " << ci->m_v <<
'\n';
380 std::cout <<
"V=" << cicvx->m_v <<
'\n';
388 std::cout <<
"V=" << i->m_v <<
" " << ci->m_v <<
" " << (iend - i) <<
'\n';
391 std::cout <<
"V=" << cicvx->m_v <<
'\n';
392 std::copy(std::begin(vx), std::end(vx), std::begin(vx));
397 std::cout << *i <<
'\n';
400 std::cout << *i <<
'\n';
402 for (
auto i : values.
range()) {
403 std::cout << i <<
'\n';
405 for (
auto i : values.
constView().range()) {
406 std::cout << i <<
'\n';
410 auto r1 = std::make_reverse_iterator(values.
end());
411 auto r2 = std::make_reverse_iterator(values.
begin());
412 for (; r1 != r2; ++r1) {
413 std::cout <<
"RVALUE = " << *r1 <<
'\n';
417 auto r1 = values.
rbegin();
430 ARCCORE_UT_CHECK((c2.
size() == 3),
"Bad value [3]");
431 ARCCORE_UT_CHECK((c.
size() == 2),
"Bad value [2]");
432 ARCCORE_UT_CHECK((c[0] == 5),
"Bad value [5]");
433 ARCCORE_UT_CHECK((c[1] == 7),
"Bad value [7]");
434 ARCCORE_UT_CHECK((c2[0] == 5),
"Bad value [5]");
435 ARCCORE_UT_CHECK((c2[1] == 7),
"Bad value [7]");
436 ARCCORE_UT_CHECK((c2[2] == 3),
"Bad value [7]");
453 _testArrayNewInternal();
456 std::cerr <<
"Exception ex=" << ex <<
"\n";
484 ASSERT_EQ(v[0], 1.2);
485 ASSERT_EQ(v[1], -1.3);
486 ASSERT_EQ(v.
at(2), 7.6);
490 std::cout <<
" Value: " << x <<
'\n';
492 v.printInfos(std::cout);
499 v.printInfos(std::cout);
503 v.printInfos(std::cout);
505 v.printInfos(std::cout);
510 v.printInfos(std::cout);
512 std::cout <<
" Value: " << v[i] <<
'\n';
518 for (
int i = 0; i < 10; ++i)
521 std::cout <<
" Value: " << v[i] <<
'\n';
527 for (
int i = 0; i < 27500; ++i) {
531 for (
int i = 0; i < 5000; ++i) {
535 for (
int i = 0; i < 27500; ++i) {
539 std::cout <<
" ValueSize= " << v.
size() <<
" values=" << v <<
'\n';
541 for (
Integer i = 0; i < 100; ++i) {
550 std::cout <<
" Size: " << v.
size() <<
'\n';
551 ASSERT_EQ(v.
size(), 230000);
566 for (Int32 i = 0, n = v.
size(); i < n; ++i)
569 auto sub_view1 = v.
subView(50, 5);
570 ASSERT_EQ(sub_view1.data(),
nullptr);
571 ASSERT_EQ(sub_view1.size(), 0);
573 auto sub_view2 = v.
subView(2, 8);
574 ASSERT_EQ(sub_view2.size(), 8);
575 for (Int32 i = 0, n = sub_view2.size(); i < n; ++i)
576 ASSERT_EQ(sub_view2[i], v[2 + i]);
578 auto sub_view3 = v.
subView(20, 8);
579 ASSERT_EQ(sub_view3.size(), 3);
580 for (Int32 i = 0, n = sub_view3.size(); i < n; ++i)
581 ASSERT_EQ(sub_view3[i], v[20 + i]);
584 ASSERT_EQ(sub_const_view1.data(),
nullptr);
585 ASSERT_EQ(sub_const_view1.size(), 0);
588 ASSERT_EQ(sub_const_view2.size(), 8);
589 for (Int32 i = 0, n = sub_const_view2.size(); i < n; ++i)
590 ASSERT_EQ(sub_const_view2[i], v[2 + i]);
593 ASSERT_EQ(sub_const_view3.size(), 3);
594 for (Int32 i = 0, n = sub_const_view3.size(); i < n; ++i)
595 ASSERT_EQ(sub_const_view3[i], v[20 + i]);
606 NoCopyData(
const NoCopyData& x) =
delete;
609template <
typename DataType>
627 const Int32 ref_value1 = 12;
628 const Int32 ref_value2 = 7;
631 std::cout <<
"C1=" << c <<
"\n";
633 ASSERT_EQ(x, ref_value1);
636 ASSERT_EQ(c.size(), 21);
637 std::cout <<
"C2=" << c <<
"\n";
642 std::cout <<
"C4=" << c <<
"\n";
643 for (Int32 i = 9, s = c.size(); i < s; ++i)
644 ASSERT_EQ(c[i], ref_value2);
645 for (Int32 i = 9, s = c.size(); i < s; ++i)
647 for (Int32 i = 9, s = c.size(); i < s; ++i)
648 ASSERT_EQ(c[i], (i + 2));
659template <
typename ArrayType>
664 static void doTestBase()
673 std::cout <<
"Array a\n";
674 ArrayType a(allocator1);
675 ASSERT_EQ(a.allocator(), allocator1);
681 std::cout <<
"Array b\n";
682 ArrayType b(allocator2);
683 ASSERT_EQ(b.capacity(), 0);
684 ASSERT_EQ(b.size(), 0);
685 ASSERT_EQ(b.allocator(), allocator2);
688 ASSERT_EQ(b.size(), a.size());
689 ASSERT_EQ(b.allocator(), a.allocator());
691 std::cout <<
"Array c\n";
692 ArrayType c(a.clone());
693 ASSERT_EQ(c.allocator(), a.allocator());
694 ASSERT_EQ(c.size(), a.size());
695 ASSERT_EQ(c.constSpan(), a.constSpan());
697 std::cout <<
"Array d\n";
698 ArrayType d(allocator2, a);
699 ASSERT_EQ(d.allocator(), allocator2);
700 ASSERT_EQ(d.size(), a.size());
701 ASSERT_EQ(d.constSpan(), a.constSpan());
703 std::cout <<
"Array e\n";
704 ArrayType e(allocator2, 25);
705 ASSERT_EQ(e.allocator(), allocator2);
706 ASSERT_EQ(e.size(), 25);
708 ArrayType f(allocator2);
710 ASSERT_EQ(f.allocator(), e.allocator());
711 ASSERT_EQ(f.size(), e.size());
714 ASSERT_EQ(f.allocator(), e.allocator());
715 ASSERT_EQ(f.size(), e.size());
737 std::cout <<
"Sizeof(ArrayMetaData)=" <<
sizeof(
ArrayMetaData) <<
"\n";
746 std::cout <<
"Array a1\n";
748 ASSERT_EQ(a1.allocator(), allocator2);
749 ASSERT_EQ(a1.size(), 0);
750 ASSERT_EQ(a1.capacity(), 0);
751 ASSERT_EQ(a1.data(),
nullptr);
753 std::cout <<
"Array a2\n";
755 ASSERT_EQ(a1.allocator(), a2.allocator());
756 ASSERT_EQ(a2.capacity(), 0);
757 ASSERT_EQ(a2.data(),
nullptr);
764 ASSERT_EQ(a1.size(), 5);
766 std::cout <<
"Array a3\n";
771 ASSERT_EQ(a3.size(), 3);
773 ASSERT_EQ(a3.allocator(), a1.allocator());
774 ASSERT_EQ(a3.size(), a1.size());
775 ASSERT_EQ(a3.constSpan(), a1.constSpan());
777 std::cout <<
"Array a4\n";
782 ASSERT_EQ(a4.size(), 3);
784 ASSERT_EQ(a4.allocator(), allocator1);
790 for (
Integer i = 0; i < 2; ++i) {
793 ASSERT_EQ(array[0].allocator(), allocator3);
794 ASSERT_EQ(array[1].allocator(), allocator3);
805 std::cout <<
"Sizeof(ArrayMetaData)=" <<
sizeof(
ArrayMetaData) <<
"\n";
814 std::cout <<
"Array a1\n";
816 ASSERT_EQ(a1.allocator(), allocator2);
817 ASSERT_EQ(a1.size(), 0);
818 ASSERT_EQ(a1.capacity(), 0);
819 ASSERT_EQ(a1.data(),
nullptr);
821 std::cout <<
"Array a2\n";
823 ASSERT_EQ(a1.allocator(), a2.allocator());
824 ASSERT_EQ(a2.capacity(), 0);
825 ASSERT_EQ(a2.data(),
nullptr);
832 ASSERT_EQ(a1.size(), 5);
834 std::cout <<
"Array a3\n";
839 ASSERT_EQ(a3.size(), 3);
841 ASSERT_EQ(a3.allocator(), a1.allocator());
842 ASSERT_EQ(a3.size(), a1.size());
843 ASSERT_EQ(a3.constSpan(), a1.constSpan());
845 std::cout <<
"Array a4\n";
847 ASSERT_EQ(a4.size(), 2);
851 ASSERT_EQ(a4.size(), 5);
857 ASSERT_EQ(a4.allocator(), allocator1);
863 for (
Integer i = 0; i < 2; ++i) {
866 ASSERT_EQ(array[0].allocator(), allocator3);
867 ASSERT_EQ(array[1].allocator(), allocator3);
879:
public IMemoryAllocator3
886 return m_default_allocator.hasRealloc(args);
891 return m_default_allocator.allocate(args, new_size);
896 return m_default_allocator.reallocate(args, current_ptr, new_size);
901 m_default_allocator.deallocate(args, ptr);
903 Int64 adjustedCapacity(
MemoryAllocationArgs args, Int64 wanted_capacity, Int64 element_size)
const override
906 return m_default_allocator.adjustedCapacity(args, wanted_capacity, element_size);
911 return m_default_allocator.guaranteedAlignment(args);
919 ASSERT_EQ(ptr.
size(), 8);
920 m_default_allocator.notifyMemoryArgsChanged(old_args, new_args, ptr);
925 DefaultMemoryAllocator3 m_default_allocator;
934 bool is_valid = v1 || v2 || v3;
939#define ASSERT_SAME_ARRAY_INFOS(a, b) \
940 ASSERT_EQ(a.allocationOptions(), b.allocationOptions()); \
941 ASSERT_EQ(a.size(), b.size()); \
942 ASSERT_EQ(a.capacity(), b.capacity())
944TEST(
Array, AllocatorV2)
954 ASSERT_EQ(opt3, allocate_options1);
957 std::cout <<
"Array a1\n";
959 ASSERT_EQ(a1.allocationOptions(), allocate_options2);
960 ASSERT_EQ(a1.size(), 0);
961 ASSERT_EQ(a1.capacity(), 0);
962 ASSERT_EQ(a1.data(),
nullptr);
964 std::cout <<
"Array a2\n";
966 ASSERT_SAME_ARRAY_INFOS(a2, a1);
967 ASSERT_EQ(a2.data(),
nullptr);
974 ASSERT_EQ(a1.size(), 5);
980 std::cout <<
"Array a3\n";
985 ASSERT_EQ(a3.size(), 3);
987 ASSERT_EQ(a3.allocator(), a1.allocator());
988 ASSERT_EQ(a3.size(), a1.size());
989 ASSERT_EQ(a3.constSpan(), a1.constSpan());
991 std::cout <<
"Array a4\n";
996 ASSERT_EQ(a4.size(), 3);
998 ASSERT_EQ(a4.allocationOptions(), allocate_options1);
1004 for (
Integer i = 0; i < 2; ++i) {
1007 ASSERT_EQ(array[0].allocationOptions(), allocator3);
1008 ASSERT_EQ(array[1].allocationOptions(), allocator3);
1015TEST(
Array, DebugInfo)
1018 DefaultMemoryAllocator3 m_default_allocator;
1021 String a1_name(
"Array1");
1022 String sa1_name(
"SharedArray1");
1025 std::cout <<
"Array a1\n";
1027 a1.setDebugName(a1_name);
1028 ASSERT_EQ(a1.allocationOptions(), allocate_options2);
1029 ASSERT_EQ(a1.size(), 0);
1030 ASSERT_EQ(a1.capacity(), 0);
1031 ASSERT_EQ(a1.data(),
nullptr);
1032 ASSERT_EQ(a1.debugName(), a1_name);
1034 std::cout <<
"SharedArray sa1\n";
1036 sa1.setDebugName(sa1_name);
1037 ASSERT_EQ(sa1.allocationOptions(), allocate_options2);
1038 ASSERT_EQ(sa1.size(), 0);
1039 ASSERT_EQ(sa1.capacity(), 0);
1040 ASSERT_EQ(sa1.data(),
nullptr);
1041 ASSERT_EQ(sa1.debugName(), sa1_name);
1043 ASSERT_EQ(a1.debugName(), a1_name);
1045 std::cout <<
"Array a2\n";
1047 ASSERT_SAME_ARRAY_INFOS(a2, a1);
1048 ASSERT_EQ(a2.data(),
nullptr);
1049 ASSERT_EQ(a2.debugName(), a1_name);
1056 ASSERT_EQ(a1.size(), 5);
1059 ASSERT_EQ(a2.debugName(), a1_name);
1060 ASSERT_EQ(a2.size(), 2);
1065 ASSERT_EQ(a3.
size(), 2);
1071TEST(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.