28 typedef typename Vec::IndexType It;
29 typedef typename Vec::EntryType
T;
39 COMPARE(mem[i],
m[i] ? v[i] :
T(0)) <<
" i = " << i <<
", m = " <<
m;
46 typedef typename Vec::IndexType It;
47 const int count = 31999;
48 typename Vec::EntryType array[count],
out[count];
49 for (
int i = 0; i < count; ++i) {
52 typename It::Mask mask;
54 typename Vec::Mask castedMask(mask);
55 if (castedMask.isFull()) {
60 Vec
a(array, i, castedMask);
62 a.scatter(out, i, castedMask);
65 for (
int i = 0; i < count; ++i) {
69 COMPARE(0, std::memcmp(array, out, count *
sizeof(
typename Vec::EntryType)));
72 template<
typename T>
struct Struct
84 typedef typename Vec::IndexType It;
85 typedef Struct<typename Vec::EntryType>
S;
86 const int count = 3999;
87 S array[count],
out[count];
88 memset(array, 0, count *
sizeof(S));
89 memset(out, 0, count *
sizeof(S));
90 for (
int i = 0; i < count; ++i) {
95 typename It::Mask mask;
97 typename Vec::Mask castedMask(mask);
98 Vec
a(array, &
S::a, i, castedMask);
99 Vec b(array, &S::b, i, castedMask);
100 Vec
c(array, &
S::c, i, castedMask);
101 a.scatter(out, &
S::a, i, castedMask);
102 b.scatter(out, &S::b, i, castedMask);
103 c.scatter(out, &
S::c, i, castedMask);
105 VERIFY(0 == memcmp(array, out, count *
sizeof(S)));
108 template<
typename T>
struct Struct2
117 typedef typename Vec::IndexType It;
118 typedef Struct2<typename Vec::EntryType> S1;
119 typedef Struct<typename Vec::EntryType> S2;
120 const int count = 97;
121 S1 array[count],
out[count];
122 memset(array, 0, count *
sizeof(S1));
123 memset(out, 0, count *
sizeof(S1));
124 for (
int i = 0; i < count; ++i) {
125 array[i].b.a = i + 0;
126 array[i].b.b = i + 1;
127 array[i].b.c = i + 2;
129 typename It::Mask mask;
131 typename Vec::Mask castedMask(mask);
132 Vec
a(array, &S1::b, &
S2::a, i, castedMask);
133 Vec b(array, &S1::b, &S2::b, i, castedMask);
134 Vec
c(array, &S1::b, &
S2::c, i, castedMask);
135 a.scatter(out, &S1::b, &
S2::a, i, castedMask);
136 b.scatter(out, &S1::b, &S2::b, i, castedMask);
137 c.scatter(out, &S1::b, &
S2::c, i, castedMask);
139 VERIFY(0 == memcmp(array, out, count *
sizeof(S1)));
142 int main(
int argc,
char **argv)
148 runTest(scatterArray<float_v>);
149 runTest(scatterArray<double_v>);
150 runTest(scatterArray<sfloat_v>);
151 runTest(scatterArray<short_v>);
152 runTest(scatterArray<ushort_v>);
154 #if defined(VC_CLANG) && VC_CLANG <= 0x030000
159 #warning "Skipping compilation of tests scatterStruct and scatterStruct2 because of clang bug"
162 runTest(scatterStruct<uint_v>);
163 runTest(scatterStruct<float_v>);
164 runTest(scatterStruct<double_v>);
165 runTest(scatterStruct<sfloat_v>);
166 runTest(scatterStruct<short_v>);
167 runTest(scatterStruct<ushort_v>);
void initTest(int argc, char **argv)
void maskedScatterArray()
#define testAllTypes(name)
#define for_all_masks(VecType, _mask_)
int main(int argc, char **argv)