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

Side by Side Diff: crosstest/test_arith_main.cpp

Issue 1022573004: Subzero: Add fabs intrinsic support. (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: Code review changes Created 5 years, 9 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_arith_fabs.ll ('k') | src/IceInstX8632.h » ('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_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 269 matching lines...) Expand 10 before | Expand all | Expand 10 after
280 Type ResultLlc = mySqrt(Value); 280 Type ResultLlc = mySqrt(Value);
281 // Compare results using memcmp() in case they are both NaN. 281 // Compare results using memcmp() in case they are both NaN.
282 if (!memcmp(&ResultSz, &ResultLlc, sizeof(Type))) { 282 if (!memcmp(&ResultSz, &ResultLlc, sizeof(Type))) {
283 ++Passes; 283 ++Passes;
284 } else { 284 } else {
285 ++Failures; 285 ++Failures;
286 std::cout << std::fixed << "test_sqrt" << (CHAR_BIT * sizeof(Type)) << "(" 286 std::cout << std::fixed << "test_sqrt" << (CHAR_BIT * sizeof(Type)) << "("
287 << Value << "): sz=" << ResultSz << " llc=" << ResultLlc 287 << Value << "): sz=" << ResultSz << " llc=" << ResultLlc
288 << "\n"; 288 << "\n";
289 } 289 }
290 ++TotalTests;
291 ResultSz = Subzero_::myFabs(Value);
292 ResultLlc = myFabs(Value);
293 // Compare results using memcmp() in case they are both NaN.
294 if (!memcmp(&ResultSz, &ResultLlc, sizeof(Type))) {
295 ++Passes;
296 } else {
297 ++Failures;
298 std::cout << std::fixed << "test_fabs" << (CHAR_BIT * sizeof(Type)) << "("
299 << Value << "): sz=" << ResultSz << " llc=" << ResultLlc
300 << "\n";
301 }
290 } 302 }
291 } 303 }
292 304
293 void testsVecFp(size_t &TotalTests, size_t &Passes, size_t &Failures) { 305 void testsVecFp(size_t &TotalTests, size_t &Passes, size_t &Failures) {
294 static const float NegInf = -1.0 / 0.0; 306 static const float NegInf = -1.0 / 0.0;
295 static const float PosInf = 1.0 / 0.0; 307 static const float PosInf = 1.0 / 0.0;
296 static const float Nan = 0.0 / 0.0; 308 static const float Nan = 0.0 / 0.0;
297 static const float NegNan = -0.0 / 0.0; 309 static const float NegNan = -0.0 / 0.0;
298 volatile float Values[] = FP_VALUE_ARRAY(NegInf, PosInf, NegNan, Nan); 310 volatile float Values[] = FP_VALUE_ARRAY(NegInf, PosInf, NegNan, Nan);
299 const static size_t NumValues = sizeof(Values) / sizeof(*Values); 311 const static size_t NumValues = sizeof(Values) / sizeof(*Values);
(...skipping 27 matching lines...) Expand all
327 if (!memcmp(&ResultSz, &ResultLlc, sizeof(ResultSz))) { 339 if (!memcmp(&ResultSz, &ResultLlc, sizeof(ResultSz))) {
328 ++Passes; 340 ++Passes;
329 } else { 341 } else {
330 ++Failures; 342 ++Failures;
331 std::cout << "test" << Funcs[f].Name << "v4f32" 343 std::cout << "test" << Funcs[f].Name << "v4f32"
332 << "(" << vectAsString<v4f32>(Value1) << "," 344 << "(" << vectAsString<v4f32>(Value1) << ","
333 << vectAsString<v4f32>(Value2) 345 << vectAsString<v4f32>(Value2)
334 << "): sz=" << vectAsString<v4f32>(ResultSz) << " llc" 346 << "): sz=" << vectAsString<v4f32>(ResultSz) << " llc"
335 << vectAsString<v4f32>(ResultLlc) << "\n"; 347 << vectAsString<v4f32>(ResultLlc) << "\n";
336 } 348 }
349 // Special case for unary fabs operation. Use Value1, ignore Value2.
350 ResultSz = Subzero_::myFabs(Value1);
351 ResultLlc = myFabs(Value1);
352 ++TotalTests;
353 if (!memcmp(&ResultSz, &ResultLlc, sizeof(ResultSz))) {
354 ++Passes;
355 } else {
356 ++Failures;
357 std::cout << "test_fabs_v4f32"
358 << "(" << vectAsString<v4f32>(Value1)
359 << "): sz=" << vectAsString<v4f32>(ResultSz) << " llc"
360 << vectAsString<v4f32>(ResultLlc) << "\n";
361 }
337 } 362 }
338 } 363 }
339 } 364 }
340 365
341 int main(int argc, char **argv) { 366 int main(int argc, char **argv) {
342 size_t TotalTests = 0; 367 size_t TotalTests = 0;
343 size_t Passes = 0; 368 size_t Passes = 0;
344 size_t Failures = 0; 369 size_t Failures = 0;
345 370
346 testsInt<bool, bool>(TotalTests, Passes, Failures); 371 testsInt<bool, bool>(TotalTests, Passes, Failures);
347 testsInt<uint8_t, myint8_t>(TotalTests, Passes, Failures); 372 testsInt<uint8_t, myint8_t>(TotalTests, Passes, Failures);
348 testsInt<uint16_t, int16_t>(TotalTests, Passes, Failures); 373 testsInt<uint16_t, int16_t>(TotalTests, Passes, Failures);
349 testsInt<uint32_t, int32_t>(TotalTests, Passes, Failures); 374 testsInt<uint32_t, int32_t>(TotalTests, Passes, Failures);
350 testsInt<uint64_t, int64_t>(TotalTests, Passes, Failures); 375 testsInt<uint64_t, int64_t>(TotalTests, Passes, Failures);
351 testsVecInt<v4ui32, v4si32>(TotalTests, Passes, Failures); 376 testsVecInt<v4ui32, v4si32>(TotalTests, Passes, Failures);
352 testsVecInt<v8ui16, v8si16>(TotalTests, Passes, Failures); 377 testsVecInt<v8ui16, v8si16>(TotalTests, Passes, Failures);
353 testsVecInt<v16ui8, v16si8>(TotalTests, Passes, Failures); 378 testsVecInt<v16ui8, v16si8>(TotalTests, Passes, Failures);
354 testsFp<float>(TotalTests, Passes, Failures); 379 testsFp<float>(TotalTests, Passes, Failures);
355 testsFp<double>(TotalTests, Passes, Failures); 380 testsFp<double>(TotalTests, Passes, Failures);
356 testsVecFp(TotalTests, Passes, Failures); 381 testsVecFp(TotalTests, Passes, Failures);
357 382
358 std::cout << "TotalTests=" << TotalTests << " Passes=" << Passes 383 std::cout << "TotalTests=" << TotalTests << " Passes=" << Passes
359 << " Failures=" << Failures << "\n"; 384 << " Failures=" << Failures << "\n";
360 return Failures; 385 return Failures;
361 } 386 }
OLDNEW
« no previous file with comments | « crosstest/test_arith_fabs.ll ('k') | src/IceInstX8632.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698