Skip to content

Commit

Permalink
Add option to silence errors
Browse files Browse the repository at this point in the history
  • Loading branch information
gonzalobg committed Mar 8, 2024
1 parent cba455d commit bbea0e9
Showing 1 changed file with 23 additions and 4 deletions.
27 changes: 23 additions & 4 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
// source code

#include <algorithm>
#include <array>
#include <chrono>
#include <cmath>
#include <cstring>
Expand All @@ -29,6 +30,7 @@ unsigned int deviceIndex = 0;
bool use_float = false;
bool output_as_csv = false;
Unit unit = MegaByte;
bool silence_errors = false;
string csv_separator = ",";

// Benchmarks:
Expand Down Expand Up @@ -308,25 +310,37 @@ void check_solution(const unsigned int ntimes, vector<T>& a, vector<T>& b, vecto

long double epsi = numeric_limits<T>::epsilon() * 100.0;

if (errA > epsi)
bool failed = false;
if (errA > epsi) {
failed = true;
cerr
<< "Validation failed on a[]. Average error " << errA
<< endl;
if (errB > epsi)
}
if (errB > epsi) {
failed =true;
cerr
<< "Validation failed on b[]. Average error " << errB
<< endl;
if (errC > epsi)
}
if (errC > epsi) {
failed =true;
cerr
<< "Validation failed on c[]. Average error " << errC
<< endl;
}
// Check sum to 8 decimal places
if (selection == Benchmark::All && errSum > 1.0E-8)
if (selection == Benchmark::All && errSum > 1.0E-8) {
failed = true;
cerr
<< "Validation failed on sum. Error " << errSum
<< endl << setprecision(15)
<< "Sum was " << sum << " but should be " << goldSum
<< endl;
}

if (failed && !silence_errors)
exit(1);

}

Expand Down Expand Up @@ -446,6 +460,10 @@ void parseArguments(int argc, char *argv[])
{
unit = Unit(GigaByte);
}
else if (!string("--silence-errors").compare(argv[i]))
{
silence_errors = true;
}
else if (!string("--help").compare(argv[i]) ||
!string("-h").compare(argv[i]))
{
Expand All @@ -465,6 +483,7 @@ void parseArguments(int argc, char *argv[])
cout << " --mibibytes Use MiB=2^20 for bandwidth calculation (default MB=10^6)" << endl;
cout << " --gigibytes Use GiB=2^30 for bandwidth calculation (default MB=10^6)" << endl;
cout << " --gigabytes Use GB=10^9 for bandwidth calculation (default MB=10^6)" << endl;
cout << " --silence-errors Ignores validation errors." << endl;
cout << endl;
exit(EXIT_SUCCESS);
}
Expand Down

0 comments on commit bbea0e9

Please sign in to comment.