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 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
157 } | 157 } |
158 } | 158 } |
159 } | 159 } |
160 } | 160 } |
161 } | 161 } |
162 | 162 |
163 const static size_t MaxTestsPerFunc = 100000; | 163 const static size_t MaxTestsPerFunc = 100000; |
164 | 164 |
165 template <typename TypeUnsignedLabel, typename TypeSignedLabel> | 165 template <typename TypeUnsignedLabel, typename TypeSignedLabel> |
166 void testsVecInt(size_t &TotalTests, size_t &Passes, size_t &Failures) { | 166 void testsVecInt(size_t &TotalTests, size_t &Passes, size_t &Failures) { |
167 #if !defined(ARM32) | |
168 // TODO(jpp): remove this once vector support is implemented. | |
169 typedef typename Vectors<TypeUnsignedLabel>::Ty TypeUnsigned; | 167 typedef typename Vectors<TypeUnsignedLabel>::Ty TypeUnsigned; |
170 typedef typename Vectors<TypeSignedLabel>::Ty TypeSigned; | 168 typedef typename Vectors<TypeSignedLabel>::Ty TypeSigned; |
171 typedef typename Vectors<TypeUnsignedLabel>::ElementTy ElementTypeUnsigned; | 169 typedef typename Vectors<TypeUnsignedLabel>::ElementTy ElementTypeUnsigned; |
172 typedef typename Vectors<TypeSignedLabel>::ElementTy ElementTypeSigned; | 170 typedef typename Vectors<TypeSignedLabel>::ElementTy ElementTypeSigned; |
173 | 171 |
174 typedef TypeUnsigned (*FuncTypeUnsigned)(TypeUnsigned, TypeUnsigned); | 172 typedef TypeUnsigned (*FuncTypeUnsigned)(TypeUnsigned, TypeUnsigned); |
175 typedef TypeSigned (*FuncTypeSigned)(TypeSigned, TypeSigned); | 173 typedef TypeSigned (*FuncTypeSigned)(TypeSigned, TypeSigned); |
176 volatile unsigned Values[] = INT_VALUE_ARRAY; | 174 volatile unsigned Values[] = INT_VALUE_ARRAY; |
177 const static size_t NumValues = sizeof(Values) / sizeof(*Values); | 175 const static size_t NumValues = sizeof(Values) / sizeof(*Values); |
178 static struct { | 176 static struct { |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
234 std::cout << "test" << Funcs[f].Name << "v" << NumElementsInType << "i" | 232 std::cout << "test" << Funcs[f].Name << "v" << NumElementsInType << "i" |
235 << (CHAR_BIT * sizeof(ElementTypeUnsigned)) << "(" | 233 << (CHAR_BIT * sizeof(ElementTypeUnsigned)) << "(" |
236 << vectAsString<TypeUnsignedLabel>(Value1) << "," | 234 << vectAsString<TypeUnsignedLabel>(Value1) << "," |
237 << vectAsString<TypeUnsignedLabel>(Value2) | 235 << vectAsString<TypeUnsignedLabel>(Value2) |
238 << "): sz=" << vectAsString<TypeUnsignedLabel>(ResultSz) | 236 << "): sz=" << vectAsString<TypeUnsignedLabel>(ResultSz) |
239 << " llc=" << vectAsString<TypeUnsignedLabel>(ResultLlc) | 237 << " llc=" << vectAsString<TypeUnsignedLabel>(ResultLlc) |
240 << "\n"; | 238 << "\n"; |
241 } | 239 } |
242 } | 240 } |
243 } | 241 } |
244 #endif // !ARM32 | |
245 } | 242 } |
246 | 243 |
247 template <typename Type> | 244 template <typename Type> |
248 void testsFp(size_t &TotalTests, size_t &Passes, size_t &Failures) { | 245 void testsFp(size_t &TotalTests, size_t &Passes, size_t &Failures) { |
249 static const Type NegInf = -1.0 / 0.0; | 246 static const Type NegInf = -1.0 / 0.0; |
250 static const Type PosInf = 1.0 / 0.0; | 247 static const Type PosInf = 1.0 / 0.0; |
251 static const Type Nan = 0.0 / 0.0; | 248 static const Type Nan = 0.0 / 0.0; |
252 static const Type NegNan = -0.0 / 0.0; | 249 static const Type NegNan = -0.0 / 0.0; |
253 volatile Type Values[] = FP_VALUE_ARRAY(NegInf, PosInf, NegNan, Nan); | 250 volatile Type Values[] = FP_VALUE_ARRAY(NegInf, PosInf, NegNan, Nan); |
254 const static size_t NumValues = sizeof(Values) / sizeof(*Values); | 251 const static size_t NumValues = sizeof(Values) / sizeof(*Values); |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
310 } else { | 307 } else { |
311 ++Failures; | 308 ++Failures; |
312 std::cout << std::fixed << "test_fabs" << (CHAR_BIT * sizeof(Type)) << "(" | 309 std::cout << std::fixed << "test_fabs" << (CHAR_BIT * sizeof(Type)) << "(" |
313 << Value << "): sz=" << ResultSz << " llc=" << ResultLlc | 310 << Value << "): sz=" << ResultSz << " llc=" << ResultLlc |
314 << "\n"; | 311 << "\n"; |
315 } | 312 } |
316 } | 313 } |
317 } | 314 } |
318 | 315 |
319 void testsVecFp(size_t &TotalTests, size_t &Passes, size_t &Failures) { | 316 void testsVecFp(size_t &TotalTests, size_t &Passes, size_t &Failures) { |
320 #if !defined(ARM32) | |
321 // TODO(jpp): remove this once vector support is implemented. | |
322 static const float NegInf = -1.0 / 0.0; | 317 static const float NegInf = -1.0 / 0.0; |
323 static const float PosInf = 1.0 / 0.0; | 318 static const float PosInf = 1.0 / 0.0; |
324 static const float Nan = 0.0 / 0.0; | 319 static const float Nan = 0.0 / 0.0; |
325 static const float NegNan = -0.0 / 0.0; | 320 static const float NegNan = -0.0 / 0.0; |
326 volatile float Values[] = FP_VALUE_ARRAY(NegInf, PosInf, NegNan, Nan); | 321 volatile float Values[] = FP_VALUE_ARRAY(NegInf, PosInf, NegNan, Nan); |
327 const static size_t NumValues = sizeof(Values) / sizeof(*Values); | 322 const static size_t NumValues = sizeof(Values) / sizeof(*Values); |
328 typedef v4f32 (*FuncType)(v4f32, v4f32); | 323 typedef v4f32 (*FuncType)(v4f32, v4f32); |
329 static struct { | 324 static struct { |
330 const char *Name; | 325 const char *Name; |
331 FuncType FuncLlc; | 326 FuncType FuncLlc; |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
370 ++Passes; | 365 ++Passes; |
371 } else { | 366 } else { |
372 ++Failures; | 367 ++Failures; |
373 std::cout << "test_fabs_v4f32" | 368 std::cout << "test_fabs_v4f32" |
374 << "(" << vectAsString<v4f32>(Value1) | 369 << "(" << vectAsString<v4f32>(Value1) |
375 << "): sz=" << vectAsString<v4f32>(ResultSz) << " llc" | 370 << "): sz=" << vectAsString<v4f32>(ResultSz) << " llc" |
376 << vectAsString<v4f32>(ResultLlc) << "\n"; | 371 << vectAsString<v4f32>(ResultLlc) << "\n"; |
377 } | 372 } |
378 } | 373 } |
379 } | 374 } |
380 #endif // !ARM32 | |
381 } | 375 } |
382 | 376 |
383 int main(int argc, char *argv[]) { | 377 int main(int argc, char *argv[]) { |
384 size_t TotalTests = 0; | 378 size_t TotalTests = 0; |
385 size_t Passes = 0; | 379 size_t Passes = 0; |
386 size_t Failures = 0; | 380 size_t Failures = 0; |
387 | 381 |
388 testsInt<bool, bool>(TotalTests, Passes, Failures); | 382 testsInt<bool, bool>(TotalTests, Passes, Failures); |
389 testsInt<uint8_t, myint8_t>(TotalTests, Passes, Failures); | 383 testsInt<uint8_t, myint8_t>(TotalTests, Passes, Failures); |
390 testsInt<uint16_t, int16_t>(TotalTests, Passes, Failures); | 384 testsInt<uint16_t, int16_t>(TotalTests, Passes, Failures); |
391 testsInt<uint32_t, int32_t>(TotalTests, Passes, Failures); | 385 testsInt<uint32_t, int32_t>(TotalTests, Passes, Failures); |
392 testsInt<uint64, int64>(TotalTests, Passes, Failures); | 386 testsInt<uint64, int64>(TotalTests, Passes, Failures); |
393 testsVecInt<v4ui32, v4si32>(TotalTests, Passes, Failures); | 387 testsVecInt<v4ui32, v4si32>(TotalTests, Passes, Failures); |
394 testsVecInt<v8ui16, v8si16>(TotalTests, Passes, Failures); | 388 testsVecInt<v8ui16, v8si16>(TotalTests, Passes, Failures); |
395 testsVecInt<v16ui8, v16si8>(TotalTests, Passes, Failures); | 389 testsVecInt<v16ui8, v16si8>(TotalTests, Passes, Failures); |
396 testsFp<float>(TotalTests, Passes, Failures); | 390 testsFp<float>(TotalTests, Passes, Failures); |
397 testsFp<double>(TotalTests, Passes, Failures); | 391 testsFp<double>(TotalTests, Passes, Failures); |
398 testsVecFp(TotalTests, Passes, Failures); | 392 testsVecFp(TotalTests, Passes, Failures); |
399 | 393 |
400 std::cout << "TotalTests=" << TotalTests << " Passes=" << Passes | 394 std::cout << "TotalTests=" << TotalTests << " Passes=" << Passes |
401 << " Failures=" << Failures << "\n"; | 395 << " Failures=" << Failures << "\n"; |
402 return Failures; | 396 return Failures; |
403 } | 397 } |
OLD | NEW |