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

Side by Side Diff: crosstest/test_icmp_main.cpp

Issue 1560933002: Subzero: Enable Non-SFI vector cross tests. (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: Created 4 years, 11 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
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 10 matching lines...) Expand all
21 21
22 // Include test_icmp.h twice - once normally, and once within the 22 // Include test_icmp.h twice - once normally, and once within the
23 // Subzero_ namespace, corresponding to the llc and Subzero translated 23 // Subzero_ namespace, corresponding to the llc and Subzero translated
24 // object files, respectively. 24 // object files, respectively.
25 #include "test_icmp.h" 25 #include "test_icmp.h"
26 26
27 namespace Subzero_ { 27 namespace Subzero_ {
28 #include "test_icmp.h" 28 #include "test_icmp.h"
29 } 29 }
30 30
31 #include "insertelement.h"
31 #include "xdefs.h" 32 #include "xdefs.h"
32 33
33 volatile unsigned Values[] = { 34 volatile unsigned Values[] = {
34 0x0, 0x1, 0x7ffffffe, 0x7fffffff, 0x80000000, 0x80000001, 35 0x0, 0x1, 0x7ffffffe, 0x7fffffff, 0x80000000, 0x80000001,
35 0xfffffffe, 0xffffffff, 0x7e, 0x7f, 0x80, 0x81, 36 0xfffffffe, 0xffffffff, 0x7e, 0x7f, 0x80, 0x81,
36 0xfe, 0xff, 0x100, 0x101, 0x7ffe, 0x7fff, 37 0xfe, 0xff, 0x100, 0x101, 0x7ffe, 0x7fff,
37 0x8000, 0x8001, 0xfffe, 0xffff, 0x10000, 0x10001, 38 0x8000, 0x8001, 0xfffe, 0xffff, 0x10000, 0x10001,
38 }; 39 };
39 const static size_t NumValues = sizeof(Values) / sizeof(*Values); 40 const static size_t NumValues = sizeof(Values) / sizeof(*Values);
40 41
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
190 } 191 }
191 } 192 }
192 } 193 }
193 } 194 }
194 } 195 }
195 196
196 const static size_t MaxTestsPerFunc = 100000; 197 const static size_t MaxTestsPerFunc = 100000;
197 198
198 template <typename TypeUnsignedLabel, typename TypeSignedLabel> 199 template <typename TypeUnsignedLabel, typename TypeSignedLabel>
199 void testsVecInt(size_t &TotalTests, size_t &Passes, size_t &Failures) { 200 void testsVecInt(size_t &TotalTests, size_t &Passes, size_t &Failures) {
200 #if !defined(ARM32) && !defined(NONSFI) 201 #if !defined(ARM32)
201 // TODO(jpp): remove this once vector support is implemented. 202 // TODO(jpp): remove this once vector support is implemented.
202 typedef typename Vectors<TypeUnsignedLabel>::Ty TypeUnsigned; 203 typedef typename Vectors<TypeUnsignedLabel>::Ty TypeUnsigned;
203 typedef typename Vectors<TypeSignedLabel>::Ty TypeSigned; 204 typedef typename Vectors<TypeSignedLabel>::Ty TypeSigned;
205 typedef typename Vectors<TypeUnsignedLabel>::ElementTy ElementTypeUnsigned;
206 typedef typename Vectors<TypeSignedLabel>::ElementTy ElementTypeSigned;
204 typedef TypeUnsigned (*FuncTypeUnsigned)(TypeUnsigned, TypeUnsigned); 207 typedef TypeUnsigned (*FuncTypeUnsigned)(TypeUnsigned, TypeUnsigned);
205 typedef TypeSigned (*FuncTypeSigned)(TypeSigned, TypeSigned); 208 typedef TypeSigned (*FuncTypeSigned)(TypeSigned, TypeSigned);
206 static struct { 209 static struct {
207 const char *Name; 210 const char *Name;
208 FuncTypeUnsigned FuncLlc; 211 FuncTypeUnsigned FuncLlc;
209 FuncTypeUnsigned FuncSz; 212 FuncTypeUnsigned FuncSz;
210 } Funcs[] = { 213 } Funcs[] = {
211 #define X(cmp, op) \ 214 #define X(cmp, op) \
212 { \ 215 { \
213 STR(cmp), (FuncTypeUnsigned)icmp##cmp, \ 216 STR(cmp), (FuncTypeUnsigned)icmp##cmp, \
(...skipping 11 matching lines...) Expand all
225 ICMP_S_TABLE 228 ICMP_S_TABLE
226 #undef X 229 #undef X
227 }; 230 };
228 const static size_t NumFuncs = sizeof(Funcs) / sizeof(*Funcs); 231 const static size_t NumFuncs = sizeof(Funcs) / sizeof(*Funcs);
229 const static size_t NumElementsInType = Vectors<TypeUnsigned>::NumElements; 232 const static size_t NumElementsInType = Vectors<TypeUnsigned>::NumElements;
230 for (size_t f = 0; f < NumFuncs; ++f) { 233 for (size_t f = 0; f < NumFuncs; ++f) {
231 PRNG Index; 234 PRNG Index;
232 for (size_t i = 0; i < MaxTestsPerFunc; ++i) { 235 for (size_t i = 0; i < MaxTestsPerFunc; ++i) {
233 // Initialize the test vectors. 236 // Initialize the test vectors.
234 TypeUnsigned Value1, Value2; 237 TypeUnsigned Value1, Value2;
235 for (size_t j = 0; j < NumElementsInType;) { 238 for (size_t j = 0; j < NumElementsInType; ++j) {
236 Value1[j] = Values[Index() % NumValues]; 239 setElement<TypeUnsigned, ElementTypeUnsigned>(
237 Value2[j] = Values[Index() % NumValues]; 240 Value1, j, Values[Index() % NumValues]);
238 ++j; 241 setElement<TypeUnsigned, ElementTypeUnsigned>(
242 Value2, j, Values[Index() % NumValues]);
239 } 243 }
240 // Perform the test. 244 // Perform the test.
241 TypeUnsigned ResultSz = Funcs[f].FuncSz(Value1, Value2); 245 TypeUnsigned ResultSz = Funcs[f].FuncSz(Value1, Value2);
242 TypeUnsigned ResultLlc = Funcs[f].FuncLlc(Value1, Value2); 246 TypeUnsigned ResultLlc = Funcs[f].FuncLlc(Value1, Value2);
243 ++TotalTests; 247 ++TotalTests;
244 if (!memcmp(&ResultSz, &ResultLlc, sizeof(ResultSz))) { 248 if (!memcmp(&ResultSz, &ResultLlc, sizeof(ResultSz))) {
245 ++Passes; 249 ++Passes;
246 } else { 250 } else {
247 ++Failures; 251 ++Failures;
248 std::cout << "test" << Funcs[f].Name 252 std::cout << "test" << Funcs[f].Name
249 << Vectors<TypeUnsignedLabel>::TypeName << "(" 253 << Vectors<TypeUnsignedLabel>::TypeName << "("
250 << vectAsString<TypeUnsignedLabel>(Value1) << "," 254 << vectAsString<TypeUnsignedLabel>(Value1) << ","
251 << vectAsString<TypeUnsignedLabel>(Value2) 255 << vectAsString<TypeUnsignedLabel>(Value2)
252 << "): sz=" << vectAsString<TypeUnsignedLabel>(ResultSz) 256 << "): sz=" << vectAsString<TypeUnsignedLabel>(ResultSz)
253 << " llc=" << vectAsString<TypeUnsignedLabel>(ResultLlc) 257 << " llc=" << vectAsString<TypeUnsignedLabel>(ResultLlc)
254 << "\n"; 258 << "\n";
255 } 259 }
256 } 260 }
257 } 261 }
258 #endif // !ARM32 && !NONSFI 262 #endif // !ARM32
259 } 263 }
260 264
261 // Return true on wraparound 265 // Return true on wraparound
262 template <typename T> bool incrementI1Vector(typename Vectors<T>::Ty &Vect) { 266 template <typename T>
267 bool __attribute__((noinline))
268 incrementI1Vector(typename Vectors<T>::Ty &Vect) {
263 size_t Pos = 0; 269 size_t Pos = 0;
264 const static size_t NumElements = Vectors<T>::NumElements; 270 const static size_t NumElements = Vectors<T>::NumElements;
265 for (Pos = 0; Pos < NumElements; ++Pos) { 271 for (Pos = 0; Pos < NumElements; ++Pos) {
266 if (Vect[Pos] == 0) { 272 if (Vect[Pos] == 0) {
267 Vect[Pos] = 1; 273 Vect[Pos] = 1;
268 break; 274 break;
269 } 275 }
270 Vect[Pos] = 0; 276 Vect[Pos] = 0;
271 } 277 }
272 return (Pos == NumElements); 278 return (Pos == NumElements);
273 } 279 }
274 280
275 template <typename T> 281 template <typename T>
276 void testsVecI1(size_t &TotalTests, size_t &Passes, size_t &Failures) { 282 void testsVecI1(size_t &TotalTests, size_t &Passes, size_t &Failures) {
277 #if !defined(ARM32) && !defined(NONSFI) 283 #if !defined(ARM32)
278 // TODO(jpp): remove this once vector support is implemented. 284 // TODO(jpp): remove this once vector support is implemented.
279 typedef typename Vectors<T>::Ty Ty; 285 typedef typename Vectors<T>::Ty Ty;
280 typedef Ty (*FuncType)(Ty, Ty); 286 typedef Ty (*FuncType)(Ty, Ty);
281 static struct { 287 static struct {
282 const char *Name; 288 const char *Name;
283 FuncType FuncLlc; 289 FuncType FuncLlc;
284 FuncType FuncSz; 290 FuncType FuncSz;
285 } Funcs[] = { 291 } Funcs[] = {
286 #define X(cmp, op) \ 292 #define X(cmp, op) \
287 { STR(cmp), (FuncType)icmpi1##cmp, (FuncType)Subzero_::icmpi1##cmp } \ 293 { STR(cmp), (FuncType)icmpi1##cmp, (FuncType)Subzero_::icmpi1##cmp } \
(...skipping 29 matching lines...) Expand all
317 } 323 }
318 } 324 }
319 } 325 }
320 } else { 326 } else {
321 for (size_t f = 0; f < NumFuncs; ++f) { 327 for (size_t f = 0; f < NumFuncs; ++f) {
322 PRNG Index; 328 PRNG Index;
323 for (size_t i = 0; i < MaxTestsPerFunc; ++i) { 329 for (size_t i = 0; i < MaxTestsPerFunc; ++i) {
324 Ty Value1, Value2; 330 Ty Value1, Value2;
325 // Initialize the test vectors. 331 // Initialize the test vectors.
326 for (size_t j = 0; j < NumElements; ++j) { 332 for (size_t j = 0; j < NumElements; ++j) {
327 Value1[j] = Index() % 2; 333 setElement<Ty, bool>(Value1, j, Index() % 2);
328 Value2[j] = Index() % 2; 334 setElement<Ty, bool>(Value2, j, Index() % 2);
329 } 335 }
330 // Perform the test. 336 // Perform the test.
331 Ty ResultSz = Funcs[f].FuncSz(Value1, Value2); 337 Ty ResultSz = Funcs[f].FuncSz(Value1, Value2);
332 Ty ResultLlc = Funcs[f].FuncLlc(Value1, Value2); 338 Ty ResultLlc = Funcs[f].FuncLlc(Value1, Value2);
333 ++TotalTests; 339 ++TotalTests;
334 if (!memcmp(&ResultSz, &ResultLlc, sizeof(ResultSz))) { 340 if (!memcmp(&ResultSz, &ResultLlc, sizeof(ResultSz))) {
335 ++Passes; 341 ++Passes;
336 } else { 342 } else {
337 ++Failures; 343 ++Failures;
338 std::cout << "test" << Funcs[f].Name << Vectors<T>::TypeName << "(" 344 std::cout << "test" << Funcs[f].Name << Vectors<T>::TypeName << "("
339 << vectAsString<T>(Value1) << "," << vectAsString<T>(Value2) 345 << vectAsString<T>(Value1) << "," << vectAsString<T>(Value2)
340 << "): sz=" << vectAsString<T>(ResultSz) 346 << "): sz=" << vectAsString<T>(ResultSz)
341 << " llc=" << vectAsString<T>(ResultLlc) << "\n"; 347 << " llc=" << vectAsString<T>(ResultLlc) << "\n";
342 } 348 }
343 } 349 }
344 } 350 }
345 } 351 }
346 #endif // !ARM32 && !NONSFI 352 #endif // !ARM32
347 } 353 }
348 354
349 #ifdef X8664_STACK_HACK 355 #ifdef X8664_STACK_HACK
350 extern "C" int wrapped_main(int argc, char *argv[]) { 356 extern "C" int wrapped_main(int argc, char *argv[]) {
351 #else // !defined(X8664_STACK_HACK) 357 #else // !defined(X8664_STACK_HACK)
352 int main(int argc, char *argv[]) { 358 int main(int argc, char *argv[]) {
353 #endif // X8664_STACK_HACK 359 #endif // X8664_STACK_HACK
354 size_t TotalTests = 0; 360 size_t TotalTests = 0;
355 size_t Passes = 0; 361 size_t Passes = 0;
356 size_t Failures = 0; 362 size_t Failures = 0;
(...skipping 10 matching lines...) Expand all
367 testsVecInt<v8ui16, v8si16>(TotalTests, Passes, Failures); 373 testsVecInt<v8ui16, v8si16>(TotalTests, Passes, Failures);
368 testsVecInt<v16ui8, v16si8>(TotalTests, Passes, Failures); 374 testsVecInt<v16ui8, v16si8>(TotalTests, Passes, Failures);
369 testsVecI1<v4i1>(TotalTests, Passes, Failures); 375 testsVecI1<v4i1>(TotalTests, Passes, Failures);
370 testsVecI1<v8i1>(TotalTests, Passes, Failures); 376 testsVecI1<v8i1>(TotalTests, Passes, Failures);
371 testsVecI1<v16i1>(TotalTests, Passes, Failures); 377 testsVecI1<v16i1>(TotalTests, Passes, Failures);
372 378
373 std::cout << "TotalTests=" << TotalTests << " Passes=" << Passes 379 std::cout << "TotalTests=" << TotalTests << " Passes=" << Passes
374 << " Failures=" << Failures << "\n"; 380 << " Failures=" << Failures << "\n";
375 return Failures; 381 return Failures;
376 } 382 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698