5
5
// source code
6
6
7
7
#include < algorithm>
8
+ #include < array>
8
9
#include < chrono>
9
10
#include < cmath>
10
11
#include < cstring>
@@ -29,6 +30,7 @@ unsigned int deviceIndex = 0;
29
30
bool use_float = false ;
30
31
bool output_as_csv = false ;
31
32
Unit unit = MegaByte;
33
+ bool silence_errors = false ;
32
34
string csv_separator = " ," ;
33
35
34
36
// Benchmarks:
@@ -308,25 +310,37 @@ void check_solution(const unsigned int ntimes, vector<T>& a, vector<T>& b, vecto
308
310
309
311
long double epsi = numeric_limits<T>::epsilon () * 100.0 ;
310
312
311
- if (errA > epsi)
313
+ bool failed = false ;
314
+ if (errA > epsi) {
315
+ failed = true ;
312
316
cerr
313
317
<< " Validation failed on a[]. Average error " << errA
314
318
<< endl;
315
- if (errB > epsi)
319
+ }
320
+ if (errB > epsi) {
321
+ failed =true ;
316
322
cerr
317
323
<< " Validation failed on b[]. Average error " << errB
318
324
<< endl;
319
- if (errC > epsi)
325
+ }
326
+ if (errC > epsi) {
327
+ failed =true ;
320
328
cerr
321
329
<< " Validation failed on c[]. Average error " << errC
322
330
<< endl;
331
+ }
323
332
// Check sum to 8 decimal places
324
- if (selection == Benchmark::All && errSum > 1.0E-8 )
333
+ if (selection == Benchmark::All && errSum > 1.0E-8 ) {
334
+ failed = true ;
325
335
cerr
326
336
<< " Validation failed on sum. Error " << errSum
327
337
<< endl << setprecision (15 )
328
338
<< " Sum was " << sum << " but should be " << goldSum
329
339
<< endl;
340
+ }
341
+
342
+ if (failed && !silence_errors)
343
+ exit (1 );
330
344
331
345
}
332
346
@@ -446,6 +460,10 @@ void parseArguments(int argc, char *argv[])
446
460
{
447
461
unit = Unit (GigaByte);
448
462
}
463
+ else if (!string (" --silence-errors" ).compare (argv[i]))
464
+ {
465
+ silence_errors = true ;
466
+ }
449
467
else if (!string (" --help" ).compare (argv[i]) ||
450
468
!string (" -h" ).compare (argv[i]))
451
469
{
@@ -465,6 +483,7 @@ void parseArguments(int argc, char *argv[])
465
483
cout << " --mibibytes Use MiB=2^20 for bandwidth calculation (default MB=10^6)" << endl;
466
484
cout << " --gigibytes Use GiB=2^30 for bandwidth calculation (default MB=10^6)" << endl;
467
485
cout << " --gigabytes Use GB=10^9 for bandwidth calculation (default MB=10^6)" << endl;
486
+ cout << " --silence-errors Ignores validation errors." << endl;
468
487
cout << endl;
469
488
exit (EXIT_SUCCESS);
470
489
}
0 commit comments