Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(144)

Side by Side Diff: crosstest/test_icmp_main.cpp

Issue 435353002: Subzero: Fix and clean up some cross tests. (Closed) Base URL: https://gerrit.chromium.org/gerrit/p/native_client/pnacl-subzero.git@master
Patch Set: Fix newlines and filename Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « crosstest/test_icmp.def ('k') | crosstest/test_vector_ops.def » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 //===- subzero/crosstest/test_icmp_main.cpp - Driver for tests. -----------===// 1 //===- subzero/crosstest/test_icmp_main.cpp - Driver for tests. -----------===//
2 // 2 //
3 // The Subzero Code Generator 3 // The Subzero Code Generator
4 // 4 //
5 // This file is distributed under the University of Illinois Open Source 5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details. 6 // License. See LICENSE.TXT for details.
7 // 7 //
8 //===----------------------------------------------------------------------===// 8 //===----------------------------------------------------------------------===//
9 // 9 //
10 // Driver for cross testing the icmp bitcode instruction 10 // Driver for cross testing the icmp bitcode instruction
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 ++TotalTests; 74 ++TotalTests;
75 bool ResultSz = Funcs[f].FuncSz(Value1, Value2); 75 bool ResultSz = Funcs[f].FuncSz(Value1, Value2);
76 bool ResultLlc = Funcs[f].FuncLlc(Value1, Value2); 76 bool ResultLlc = Funcs[f].FuncLlc(Value1, Value2);
77 if (ResultSz == ResultLlc) { 77 if (ResultSz == ResultLlc) {
78 ++Passes; 78 ++Passes;
79 } else { 79 } else {
80 ++Failures; 80 ++Failures;
81 std::cout << "icmp" << Funcs[f].Name 81 std::cout << "icmp" << Funcs[f].Name
82 << (CHAR_BIT * sizeof(TypeUnsigned)) << "(" << Value1 82 << (CHAR_BIT * sizeof(TypeUnsigned)) << "(" << Value1
83 << ", " << Value2 << "): sz=" << ResultSz 83 << ", " << Value2 << "): sz=" << ResultSz
84 << " llc=" << ResultLlc << std::endl; 84 << " llc=" << ResultLlc << "\n";
85 } 85 }
86 } 86 }
87 } 87 }
88 } 88 }
89 } else { 89 } else {
90 // This is the 64-bit version. Test values are synthesized from 90 // This is the 64-bit version. Test values are synthesized from
91 // the 32-bit values in Values[]. 91 // the 32-bit values in Values[].
92 for (size_t f = 0; f < NumFuncs; ++f) { 92 for (size_t f = 0; f < NumFuncs; ++f) {
93 for (size_t iLo = 0; iLo < NumValues; ++iLo) { 93 for (size_t iLo = 0; iLo < NumValues; ++iLo) {
94 for (size_t iHi = 0; iHi < NumValues; ++iHi) { 94 for (size_t iHi = 0; iHi < NumValues; ++iHi) {
95 for (size_t jLo = 0; jLo < NumValues; ++jLo) { 95 for (size_t jLo = 0; jLo < NumValues; ++jLo) {
96 for (size_t jHi = 0; jHi < NumValues; ++jHi) { 96 for (size_t jHi = 0; jHi < NumValues; ++jHi) {
97 TypeUnsigned Value1 = 97 TypeUnsigned Value1 =
98 (((TypeUnsigned)Values[iHi]) << 32) + Values[iLo]; 98 (((TypeUnsigned)Values[iHi]) << 32) + Values[iLo];
99 TypeUnsigned Value2 = 99 TypeUnsigned Value2 =
100 (((TypeUnsigned)Values[jHi]) << 32) + Values[jLo]; 100 (((TypeUnsigned)Values[jHi]) << 32) + Values[jLo];
101 ++TotalTests; 101 ++TotalTests;
102 bool ResultSz = Funcs[f].FuncSz(Value1, Value2); 102 bool ResultSz = Funcs[f].FuncSz(Value1, Value2);
103 bool ResultLlc = Funcs[f].FuncLlc(Value1, Value2); 103 bool ResultLlc = Funcs[f].FuncLlc(Value1, Value2);
104 if (ResultSz == ResultLlc) { 104 if (ResultSz == ResultLlc) {
105 ++Passes; 105 ++Passes;
106 } else { 106 } else {
107 ++Failures; 107 ++Failures;
108 std::cout << "icmp" << Funcs[f].Name 108 std::cout << "icmp" << Funcs[f].Name
109 << (CHAR_BIT * sizeof(TypeUnsigned)) << "(" << Value1 109 << (CHAR_BIT * sizeof(TypeUnsigned)) << "(" << Value1
110 << ", " << Value2 << "): sz=" << ResultSz 110 << ", " << Value2 << "): sz=" << ResultSz
111 << " llc=" << ResultLlc << std::endl; 111 << " llc=" << ResultLlc << "\n";
112 } 112 }
113 } 113 }
114 } 114 }
115 } 115 }
116 } 116 }
117 } 117 }
118 } 118 }
119 } 119 }
120 120
121 const static size_t MaxTestsPerFunc = 100000; 121 const static size_t MaxTestsPerFunc = 100000;
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
167 if (!memcmp(&ResultSz, &ResultLlc, sizeof(ResultSz))) { 167 if (!memcmp(&ResultSz, &ResultLlc, sizeof(ResultSz))) {
168 ++Passes; 168 ++Passes;
169 } else { 169 } else {
170 ++Failures; 170 ++Failures;
171 std::cout << "test" << Funcs[f].Name 171 std::cout << "test" << Funcs[f].Name
172 << Vectors<TypeUnsignedLabel>::TypeName << "(" 172 << Vectors<TypeUnsignedLabel>::TypeName << "("
173 << vectAsString<TypeUnsignedLabel>(Value1) << "," 173 << vectAsString<TypeUnsignedLabel>(Value1) << ","
174 << vectAsString<TypeUnsignedLabel>(Value2) 174 << vectAsString<TypeUnsignedLabel>(Value2)
175 << "): sz=" << vectAsString<TypeUnsignedLabel>(ResultSz) 175 << "): sz=" << vectAsString<TypeUnsignedLabel>(ResultSz)
176 << " llc=" << vectAsString<TypeUnsignedLabel>(ResultLlc) 176 << " llc=" << vectAsString<TypeUnsignedLabel>(ResultLlc)
177 << std::endl; 177 << "\n";
178 } 178 }
179 } 179 }
180 } 180 }
181 } 181 }
182 182
183 // Return true on wraparound 183 // Return true on wraparound
184 template <typename T> bool incrementI1Vector(typename Vectors<T>::Ty &Vect) { 184 template <typename T> bool incrementI1Vector(typename Vectors<T>::Ty &Vect) {
185 size_t Pos = 0; 185 size_t Pos = 0;
186 const static size_t NumElements = Vectors<T>::NumElements; 186 const static size_t NumElements = Vectors<T>::NumElements;
187 for (Pos = 0; Pos < NumElements; ++Pos) { 187 for (Pos = 0; Pos < NumElements; ++Pos) {
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
227 Ty ResultLlc = Funcs[f].FuncLlc(Value1, Value2); 227 Ty ResultLlc = Funcs[f].FuncLlc(Value1, Value2);
228 ++TotalTests; 228 ++TotalTests;
229 if (!memcmp(&ResultSz, &ResultLlc, sizeof(ResultSz))) { 229 if (!memcmp(&ResultSz, &ResultLlc, sizeof(ResultSz))) {
230 ++Passes; 230 ++Passes;
231 } else { 231 } else {
232 ++Failures; 232 ++Failures;
233 std::cout << "test" << Funcs[f].Name << Vectors<T>::TypeName << "(" 233 std::cout << "test" << Funcs[f].Name << Vectors<T>::TypeName << "("
234 << vectAsString<T>(Value1) << "," 234 << vectAsString<T>(Value1) << ","
235 << vectAsString<T>(Value2) 235 << vectAsString<T>(Value2)
236 << "): sz=" << vectAsString<T>(ResultSz) 236 << "): sz=" << vectAsString<T>(ResultSz)
237 << " llc=" << vectAsString<T>(ResultLlc) << std::endl; 237 << " llc=" << vectAsString<T>(ResultLlc) << "\n";
238 } 238 }
239 } 239 }
240 } 240 }
241 } 241 }
242 } else { 242 } else {
243 for (size_t f = 0; f < NumFuncs; ++f) { 243 for (size_t f = 0; f < NumFuncs; ++f) {
244 PRNG Index; 244 PRNG Index;
245 for (size_t i = 0; i < MaxTestsPerFunc; ++i) { 245 for (size_t i = 0; i < MaxTestsPerFunc; ++i) {
246 Ty Value1, Value2; 246 Ty Value1, Value2;
247 // Initialize the test vectors. 247 // Initialize the test vectors.
248 for (size_t j = 0; j < NumElements; ++j) { 248 for (size_t j = 0; j < NumElements; ++j) {
249 Value1[j] = Index() % 2; 249 Value1[j] = Index() % 2;
250 Value2[j] = Index() % 2; 250 Value2[j] = Index() % 2;
251 } 251 }
252 // Perform the test. 252 // Perform the test.
253 Ty ResultSz = Funcs[f].FuncSz(Value1, Value2); 253 Ty ResultSz = Funcs[f].FuncSz(Value1, Value2);
254 Ty ResultLlc = Funcs[f].FuncLlc(Value1, Value2); 254 Ty ResultLlc = Funcs[f].FuncLlc(Value1, Value2);
255 ++TotalTests; 255 ++TotalTests;
256 if (!memcmp(&ResultSz, &ResultLlc, sizeof(ResultSz))) { 256 if (!memcmp(&ResultSz, &ResultLlc, sizeof(ResultSz))) {
257 ++Passes; 257 ++Passes;
258 } else { 258 } else {
259 ++Failures; 259 ++Failures;
260 std::cout << "test" << Funcs[f].Name << Vectors<T>::TypeName << "(" 260 std::cout << "test" << Funcs[f].Name << Vectors<T>::TypeName << "("
261 << vectAsString<T>(Value1) << "," << vectAsString<T>(Value2) 261 << vectAsString<T>(Value1) << "," << vectAsString<T>(Value2)
262 << "): sz=" << vectAsString<T>(ResultSz) 262 << "): sz=" << vectAsString<T>(ResultSz)
263 << " llc=" << vectAsString<T>(ResultLlc) << std::endl; 263 << " llc=" << vectAsString<T>(ResultLlc) << "\n";
264 } 264 }
265 } 265 }
266 } 266 }
267 } 267 }
268 } 268 }
269 269
270 int main(int argc, char **argv) { 270 int main(int argc, char **argv) {
271 size_t TotalTests = 0; 271 size_t TotalTests = 0;
272 size_t Passes = 0; 272 size_t Passes = 0;
273 size_t Failures = 0; 273 size_t Failures = 0;
274 274
275 testsInt<uint8_t, int8_t>(TotalTests, Passes, Failures); 275 testsInt<uint8_t, myint8_t>(TotalTests, Passes, Failures);
276 testsInt<uint16_t, int16_t>(TotalTests, Passes, Failures); 276 testsInt<uint16_t, int16_t>(TotalTests, Passes, Failures);
277 testsInt<uint32_t, int32_t>(TotalTests, Passes, Failures); 277 testsInt<uint32_t, int32_t>(TotalTests, Passes, Failures);
278 testsInt<uint64_t, int64_t>(TotalTests, Passes, Failures); 278 testsInt<uint64_t, int64_t>(TotalTests, Passes, Failures);
279 testsVecInt<v4ui32, v4si32>(TotalTests, Passes, Failures); 279 testsVecInt<v4ui32, v4si32>(TotalTests, Passes, Failures);
280 testsVecInt<v8ui16, v8si16>(TotalTests, Passes, Failures); 280 testsVecInt<v8ui16, v8si16>(TotalTests, Passes, Failures);
281 testsVecInt<v16ui8, v16si8>(TotalTests, Passes, Failures); 281 testsVecInt<v16ui8, v16si8>(TotalTests, Passes, Failures);
282 testsVecI1<v4i1>(TotalTests, Passes, Failures); 282 testsVecI1<v4i1>(TotalTests, Passes, Failures);
283 testsVecI1<v8i1>(TotalTests, Passes, Failures); 283 testsVecI1<v8i1>(TotalTests, Passes, Failures);
284 testsVecI1<v16i1>(TotalTests, Passes, Failures); 284 testsVecI1<v16i1>(TotalTests, Passes, Failures);
285 285
286 std::cout << "TotalTests=" << TotalTests << " Passes=" << Passes 286 std::cout << "TotalTests=" << TotalTests << " Passes=" << Passes
287 << " Failures=" << Failures << "\n"; 287 << " Failures=" << Failures << "\n";
288 return Failures; 288 return Failures;
289 } 289 }
OLDNEW
« no previous file with comments | « crosstest/test_icmp.def ('k') | crosstest/test_vector_ops.def » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698