OLD | NEW |
1 //===- subzero/crosstest/test_arith_main.cpp - Driver for tests -----------===// | 1 //===- subzero/crosstest/test_arith_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 crosstesting arithmetic operations | 10 // Driver for crosstesting arithmetic operations |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
57 const char *Name; | 57 const char *Name; |
58 FuncTypeUnsigned FuncLlcUnsigned; | 58 FuncTypeUnsigned FuncLlcUnsigned; |
59 FuncTypeUnsigned FuncSzUnsigned; | 59 FuncTypeUnsigned FuncSzUnsigned; |
60 FuncTypeSigned FuncLlcSigned; | 60 FuncTypeSigned FuncLlcSigned; |
61 FuncTypeSigned FuncSzSigned; | 61 FuncTypeSigned FuncSzSigned; |
62 bool ExcludeDivExceptions; // for divide related tests | 62 bool ExcludeDivExceptions; // for divide related tests |
63 } Funcs[] = { | 63 } Funcs[] = { |
64 #define X(inst, op, isdiv, isshift) \ | 64 #define X(inst, op, isdiv, isshift) \ |
65 { STR(inst), test##inst, Subzero_::test##inst, NULL, NULL, isdiv } \ | 65 { STR(inst), test##inst, Subzero_::test##inst, NULL, NULL, isdiv } \ |
66 , | 66 , |
67 UINTOP_TABLE | 67 UINTOP_TABLE |
68 #undef X | 68 #undef X |
69 #define X(inst, op, isdiv, isshift) \ | 69 #define X(inst, op, isdiv, isshift) \ |
70 { STR(inst), NULL, NULL, test##inst, Subzero_::test##inst, isdiv } \ | 70 { STR(inst), NULL, NULL, test##inst, Subzero_::test##inst, isdiv } \ |
71 , | 71 , |
72 SINTOP_TABLE | 72 SINTOP_TABLE |
73 #undef X | 73 #undef X |
74 }; | 74 }; |
75 const static size_t NumFuncs = sizeof(Funcs) / sizeof(*Funcs); | 75 const static size_t NumFuncs = sizeof(Funcs) / sizeof(*Funcs); |
76 | 76 |
77 if (sizeof(TypeUnsigned) <= sizeof(uint32_t)) { | 77 if (sizeof(TypeUnsigned) <= sizeof(uint32_t)) { |
78 // This is the "normal" version of the loop nest, for 32-bit or | 78 // This is the "normal" version of the loop nest, for 32-bit or |
79 // narrower types. | 79 // narrower types. |
80 for (size_t f = 0; f < NumFuncs; ++f) { | 80 for (size_t f = 0; f < NumFuncs; ++f) { |
81 for (size_t i = 0; i < NumValues; ++i) { | 81 for (size_t i = 0; i < NumValues; ++i) { |
82 for (size_t j = 0; j < NumValues; ++j) { | 82 for (size_t j = 0; j < NumValues; ++j) { |
83 TypeUnsigned Value1 = Values[i]; | 83 TypeUnsigned Value1 = Values[i]; |
84 TypeUnsigned Value2 = Values[j]; | 84 TypeUnsigned Value2 = Values[j]; |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
170 FuncTypeUnsigned FuncLlcUnsigned; | 170 FuncTypeUnsigned FuncLlcUnsigned; |
171 FuncTypeUnsigned FuncSzUnsigned; | 171 FuncTypeUnsigned FuncSzUnsigned; |
172 FuncTypeSigned FuncLlcSigned; | 172 FuncTypeSigned FuncLlcSigned; |
173 FuncTypeSigned FuncSzSigned; | 173 FuncTypeSigned FuncSzSigned; |
174 bool ExcludeDivExceptions; // for divide related tests | 174 bool ExcludeDivExceptions; // for divide related tests |
175 bool MaskShiftOperations; // for shift related tests | 175 bool MaskShiftOperations; // for shift related tests |
176 } Funcs[] = { | 176 } Funcs[] = { |
177 #define X(inst, op, isdiv, isshift) \ | 177 #define X(inst, op, isdiv, isshift) \ |
178 { STR(inst), test##inst, Subzero_::test##inst, NULL, NULL, isdiv, isshift } \ | 178 { STR(inst), test##inst, Subzero_::test##inst, NULL, NULL, isdiv, isshift } \ |
179 , | 179 , |
180 UINTOP_TABLE | 180 UINTOP_TABLE |
181 #undef X | 181 #undef X |
182 #define X(inst, op, isdiv, isshift) \ | 182 #define X(inst, op, isdiv, isshift) \ |
183 { STR(inst), NULL, NULL, test##inst, Subzero_::test##inst, isdiv, isshift } \ | 183 { STR(inst), NULL, NULL, test##inst, Subzero_::test##inst, isdiv, isshift } \ |
184 , | 184 , |
185 SINTOP_TABLE | 185 SINTOP_TABLE |
186 #undef X | 186 #undef X |
187 }; | 187 }; |
188 const static size_t NumFuncs = sizeof(Funcs) / sizeof(*Funcs); | 188 const static size_t NumFuncs = sizeof(Funcs) / sizeof(*Funcs); |
189 const static size_t NumElementsInType = Vectors<TypeUnsigned>::NumElements; | 189 const static size_t NumElementsInType = Vectors<TypeUnsigned>::NumElements; |
190 for (size_t f = 0; f < NumFuncs; ++f) { | 190 for (size_t f = 0; f < NumFuncs; ++f) { |
191 PRNG Index; | 191 PRNG Index; |
192 for (size_t i = 0; i < MaxTestsPerFunc; ++i) { | 192 for (size_t i = 0; i < MaxTestsPerFunc; ++i) { |
193 // Initialize the test vectors. | 193 // Initialize the test vectors. |
194 TypeUnsigned Value1, Value2; | 194 TypeUnsigned Value1, Value2; |
195 for (size_t j = 0; j < NumElementsInType;) { | 195 for (size_t j = 0; j < NumElementsInType;) { |
196 ElementTypeUnsigned Element1 = Values[Index() % NumValues]; | 196 ElementTypeUnsigned Element1 = Values[Index() % NumValues]; |
197 ElementTypeUnsigned Element2 = Values[Index() % NumValues]; | 197 ElementTypeUnsigned Element2 = Values[Index() % NumValues]; |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
240 const static size_t NumValues = sizeof(Values) / sizeof(*Values); | 240 const static size_t NumValues = sizeof(Values) / sizeof(*Values); |
241 typedef Type (*FuncType)(Type, Type); | 241 typedef Type (*FuncType)(Type, Type); |
242 static struct { | 242 static struct { |
243 const char *Name; | 243 const char *Name; |
244 FuncType FuncLlc; | 244 FuncType FuncLlc; |
245 FuncType FuncSz; | 245 FuncType FuncSz; |
246 } Funcs[] = { | 246 } Funcs[] = { |
247 #define X(inst, op, func) \ | 247 #define X(inst, op, func) \ |
248 { STR(inst), (FuncType)test##inst, (FuncType)Subzero_::test##inst } \ | 248 { STR(inst), (FuncType)test##inst, (FuncType)Subzero_::test##inst } \ |
249 , | 249 , |
250 FPOP_TABLE | 250 FPOP_TABLE |
251 #undef X | 251 #undef X |
252 }; | 252 }; |
253 const static size_t NumFuncs = sizeof(Funcs) / sizeof(*Funcs); | 253 const static size_t NumFuncs = sizeof(Funcs) / sizeof(*Funcs); |
254 | 254 |
255 for (size_t f = 0; f < NumFuncs; ++f) { | 255 for (size_t f = 0; f < NumFuncs; ++f) { |
256 for (size_t i = 0; i < NumValues; ++i) { | 256 for (size_t i = 0; i < NumValues; ++i) { |
257 for (size_t j = 0; j < NumValues; ++j) { | 257 for (size_t j = 0; j < NumValues; ++j) { |
258 Type Value1 = Values[i]; | 258 Type Value1 = Values[i]; |
259 Type Value2 = Values[j]; | 259 Type Value2 = Values[j]; |
260 ++TotalTests; | 260 ++TotalTests; |
261 Type ResultSz = Funcs[f].FuncSz(Value1, Value2); | 261 Type ResultSz = Funcs[f].FuncSz(Value1, Value2); |
262 Type ResultLlc = Funcs[f].FuncLlc(Value1, Value2); | 262 Type ResultLlc = Funcs[f].FuncLlc(Value1, Value2); |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
299 const static size_t NumValues = sizeof(Values) / sizeof(*Values); | 299 const static size_t NumValues = sizeof(Values) / sizeof(*Values); |
300 typedef v4f32 (*FuncType)(v4f32, v4f32); | 300 typedef v4f32 (*FuncType)(v4f32, v4f32); |
301 static struct { | 301 static struct { |
302 const char *Name; | 302 const char *Name; |
303 FuncType FuncLlc; | 303 FuncType FuncLlc; |
304 FuncType FuncSz; | 304 FuncType FuncSz; |
305 } Funcs[] = { | 305 } Funcs[] = { |
306 #define X(inst, op, func) \ | 306 #define X(inst, op, func) \ |
307 { STR(inst), (FuncType)test##inst, (FuncType)Subzero_::test##inst } \ | 307 { STR(inst), (FuncType)test##inst, (FuncType)Subzero_::test##inst } \ |
308 , | 308 , |
309 FPOP_TABLE | 309 FPOP_TABLE |
310 #undef X | 310 #undef X |
311 }; | 311 }; |
312 const static size_t NumFuncs = sizeof(Funcs) / sizeof(*Funcs); | 312 const static size_t NumFuncs = sizeof(Funcs) / sizeof(*Funcs); |
313 const static size_t NumElementsInType = 4; | 313 const static size_t NumElementsInType = 4; |
314 for (size_t f = 0; f < NumFuncs; ++f) { | 314 for (size_t f = 0; f < NumFuncs; ++f) { |
315 PRNG Index; | 315 PRNG Index; |
316 for (size_t i = 0; i < MaxTestsPerFunc; ++i) { | 316 for (size_t i = 0; i < MaxTestsPerFunc; ++i) { |
317 // Initialize the test vectors. | 317 // Initialize the test vectors. |
318 v4f32 Value1, Value2; | 318 v4f32 Value1, Value2; |
319 for (size_t j = 0; j < NumElementsInType; ++j) { | 319 for (size_t j = 0; j < NumElementsInType; ++j) { |
320 Value1[j] = Values[Index() % NumValues]; | 320 Value1[j] = Values[Index() % NumValues]; |
321 Value2[j] = Values[Index() % NumValues]; | 321 Value2[j] = Values[Index() % NumValues]; |
(...skipping 30 matching lines...) Expand all Loading... |
352 testsVecInt<v8ui16, v8si16>(TotalTests, Passes, Failures); | 352 testsVecInt<v8ui16, v8si16>(TotalTests, Passes, Failures); |
353 testsVecInt<v16ui8, v16si8>(TotalTests, Passes, Failures); | 353 testsVecInt<v16ui8, v16si8>(TotalTests, Passes, Failures); |
354 testsFp<float>(TotalTests, Passes, Failures); | 354 testsFp<float>(TotalTests, Passes, Failures); |
355 testsFp<double>(TotalTests, Passes, Failures); | 355 testsFp<double>(TotalTests, Passes, Failures); |
356 testsVecFp(TotalTests, Passes, Failures); | 356 testsVecFp(TotalTests, Passes, Failures); |
357 | 357 |
358 std::cout << "TotalTests=" << TotalTests << " Passes=" << Passes | 358 std::cout << "TotalTests=" << TotalTests << " Passes=" << Passes |
359 << " Failures=" << Failures << "\n"; | 359 << " Failures=" << Failures << "\n"; |
360 return Failures; | 360 return Failures; |
361 } | 361 } |
OLD | NEW |