Skip to content
This repository was archived by the owner on Mar 28, 2023. It is now read-only.

Commit 01fd37f

Browse files
committed
Reorganize the tests
1 parent f43b38f commit 01fd37f

File tree

2 files changed

+28
-18
lines changed

2 files changed

+28
-18
lines changed

SYCL/ESIMD/lsc/lsc_predicate.cpp

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ template <unsigned SIMDSize> int testAccessor(queue q) {
3131
auto vec_3 = std::vector<int>(size);
3232

3333
std::iota(vec_0.begin(), vec_0.end(), 0);
34-
std::iota(vec_1.begin(), vec_1.end(), 0);
3534
std::iota(vec_2.begin(), vec_2.end(), 0);
3635
std::iota(vec_3.begin(), vec_3.end(), 0);
3736
auto buf_0 = buffer{vec_0};
@@ -81,18 +80,16 @@ template <unsigned SIMDSize> int testAccessor(queue q) {
8180
}
8281

8382
auto error = 0;
83+
int acc = 0;
8484
for (auto i = 0; i != size; ++i) {
8585
if (vec_0[i] != 2 * i) {
8686
++error;
8787
std::cout << " Accessor Test 1 out[" << i << "] = 0x" << std::hex
8888
<< vec_0[i] << " vs etalon = 0x" << 2 * i << std::dec
8989
<< std::endl;
9090
}
91-
if (vec_1[i] > 0) {
92-
++error;
93-
std::cout << " Accessor Test 2 out[" << i << "] = 0x" << std::hex
94-
<< vec_1[i] << " vs etalon = 0x" << 0 << std::dec << std::endl;
95-
}
91+
acc += vec_1[i];
92+
9693
if (vec_2[i] != i) {
9794
++error;
9895
std::cout << " Accessor Test 3 out[" << i << "] = 0x" << std::hex
@@ -105,6 +102,11 @@ template <unsigned SIMDSize> int testAccessor(queue q) {
105102
<< vec_3[i] << " vs etalon = 0x" << i << std::dec << std::endl;
106103
}
107104
}
105+
if (acc == 0) {
106+
++error;
107+
std::cout << " Accessor Test 2 out = 0"
108+
<< " vs etalon non 0" << std::endl;
109+
}
108110
std::cout << "Accessor lsc predicate test ";
109111
std::cout << (error != 0 ? "FAILED" : "passed") << std::endl;
110112
return error;
@@ -118,10 +120,13 @@ template <unsigned SIMDSize> int testUSM(queue q) {
118120
auto *vec_2 = malloc_shared<int>(size, q);
119121
auto *vec_3 = malloc_shared<int>(size, q);
120122
std::iota(vec_0, vec_0 + size, 0);
121-
std::iota(vec_1, vec_1 + size, 0);
122123
std::iota(vec_2, vec_2 + size, 0);
123124
std::iota(vec_3, vec_3 + size, 0);
124125

126+
for (int i = 0; i < size; ++i) {
127+
vec_1[i] = 0;
128+
}
129+
125130
try {
126131
q.submit([&](handler &h) {
127132
h.parallel_for(
@@ -162,17 +167,15 @@ template <unsigned SIMDSize> int testUSM(queue q) {
162167
}
163168

164169
int error = 0;
170+
int acc = 0;
165171
for (auto i = 0; i != size; ++i) {
166172
if (vec_0[i] != 2 * i) {
167173
++error;
168174
std::cout << " USM Test 1 out[" << i << "] = 0x" << std::hex << vec_0[i]
169175
<< " vs etalon = 0x" << 2 * i << std::dec << std::endl;
170176
}
171-
if (vec_1[i] > 0) {
172-
++error;
173-
std::cout << " USM Test 2 out[" << i << "] = 0x" << std::hex << vec_1[i]
174-
<< " vs etalon = 0x" << 0 << std::dec << std::endl;
175-
}
177+
acc += vec_1[i];
178+
176179
if (vec_2[i] != i) {
177180
++error;
178181
std::cout << " USM Test 3 out[" << i << "] = 0x" << std::hex << vec_2[i]
@@ -185,6 +188,11 @@ template <unsigned SIMDSize> int testUSM(queue q) {
185188
<< " vs etalon = 0x" << i << std::dec << std::endl;
186189
}
187190
}
191+
if (acc == 0) {
192+
++error;
193+
std::cout << " USM Test 2 out = 0"
194+
<< " vs etalon non 0" << std::endl;
195+
}
188196
sycl::free(vec_0, q);
189197
sycl::free(vec_1, q);
190198
sycl::free(vec_2, q);

SYCL/ESIMD/lsc/lsc_predicate_stateless.cpp

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ template <unsigned SIMDSize> int testAccessor(queue q) {
3333
auto vec_3 = std::vector<int>(size);
3434

3535
std::iota(vec_0.begin(), vec_0.end(), 0);
36-
std::iota(vec_1.begin(), vec_1.end(), 0);
3736
std::iota(vec_2.begin(), vec_2.end(), 0);
3837
std::iota(vec_3.begin(), vec_3.end(), 0);
3938
auto buf_0 = buffer{vec_0};
@@ -83,6 +82,7 @@ template <unsigned SIMDSize> int testAccessor(queue q) {
8382
return 1;
8483
}
8584

85+
int acc = 0;
8686
auto error = 0;
8787
for (auto i = 0; i != size; ++i) {
8888
if (vec_0[i] != 2 * i) {
@@ -91,11 +91,8 @@ template <unsigned SIMDSize> int testAccessor(queue q) {
9191
<< vec_0[i] << " vs etalon = 0x" << 2 * i << std::dec
9292
<< std::endl;
9393
}
94-
if (vec_1[i] > 0) {
95-
++error;
96-
std::cout << " Accessor Test 2 out[" << i << "] = 0x" << std::hex
97-
<< vec_1[i] << " vs etalon = 0x" << 0 << std::dec << std::endl;
98-
}
94+
acc += vec_1[i];
95+
9996
if (vec_2[i] != i) {
10097
++error;
10198
std::cout << " Accessor Test 3 out[" << i << "] = 0x" << std::hex
@@ -108,6 +105,11 @@ template <unsigned SIMDSize> int testAccessor(queue q) {
108105
<< vec_3[i] << " vs etalon = 0x" << i << std::dec << std::endl;
109106
}
110107
}
108+
if (acc == 0) {
109+
++error;
110+
std::cout << " Accessor Test 2 out = 0"
111+
<< " vs etalon is non zero." << std::endl;
112+
}
111113
std::cout << "Accessor lsc predicate test ";
112114
std::cout << (error != 0 ? "FAILED" : "passed") << std::endl;
113115
return error;

0 commit comments

Comments
 (0)