Apply .clangformat to all repo source files

Change-Id: I7e79c6058f0303f9a98911e3b7dd2e8596079344
Este commit está contenido en:
Maneesh Gupta
2018-03-12 11:29:03 +05:30
padre 18e70b1e6b
commit 1ba06f63c4
Se han modificado 293 ficheros con 43980 adiciones y 45830 borrados
+98 -171
Ver fichero
@@ -10,96 +10,72 @@ using namespace std;
#define SORT_RETAIN_ATTS_ORDER 1
bool ResultDatabase::Result::operator<(const Result &rhs) const
{
if (test < rhs.test)
return true;
if (test > rhs.test)
return false;
#if (SORT_RETAIN_ATTS_ORDER == 0)
bool ResultDatabase::Result::operator<(const Result& rhs) const {
if (test < rhs.test) return true;
if (test > rhs.test) return false;
#if (SORT_RETAIN_ATTS_ORDER == 0)
// For ties, sort by the value of the attribute:
if (atts < rhs.atts)
return true;
if (atts > rhs.atts)
return false;
if (atts < rhs.atts) return true;
if (atts > rhs.atts) return false;
#endif
return false; // less-operator returns false on equal
return false; // less-operator returns false on equal
}
double ResultDatabase::Result::GetMin() const
{
double ResultDatabase::Result::GetMin() const {
double r = FLT_MAX;
for (int i=0; i<value.size(); i++)
{
for (int i = 0; i < value.size(); i++) {
r = min(r, value[i]);
}
return r;
}
double ResultDatabase::Result::GetMax() const
{
double ResultDatabase::Result::GetMax() const {
double r = -FLT_MAX;
for (int i=0; i<value.size(); i++)
{
for (int i = 0; i < value.size(); i++) {
r = max(r, value[i]);
}
return r;
}
double ResultDatabase::Result::GetMedian() const
{
return GetPercentile(50);
}
double ResultDatabase::Result::GetMedian() const { return GetPercentile(50); }
double ResultDatabase::Result::GetPercentile(double q) const
{
double ResultDatabase::Result::GetPercentile(double q) const {
int n = value.size();
if (n == 0)
return FLT_MAX;
if (n == 1)
return value[0];
if (n == 0) return FLT_MAX;
if (n == 1) return value[0];
if (q <= 0)
return value[0];
if (q >= 100)
return value[n-1];
if (q <= 0) return value[0];
if (q >= 100) return value[n - 1];
double index = ((n + 1.) * q / 100.) - 1;
vector<double> sorted = value;
sort(sorted.begin(), sorted.end());
if (n == 2)
return (sorted[0] * (1 - q/100.) + sorted[1] * (q/100.));
if (n == 2) return (sorted[0] * (1 - q / 100.) + sorted[1] * (q / 100.));
int index_lo = int(index);
double frac = index - index_lo;
if (frac == 0)
return sorted[index_lo];
if (frac == 0) return sorted[index_lo];
double lo = sorted[index_lo];
double hi = sorted[index_lo + 1];
return lo + (hi-lo)*frac;
return lo + (hi - lo) * frac;
}
double ResultDatabase::Result::GetMean() const
{
double ResultDatabase::Result::GetMean() const {
double r = 0;
for (int i=0; i<value.size(); i++)
{
for (int i = 0; i < value.size(); i++) {
r += value[i];
}
return r / double(value.size());
}
double ResultDatabase::Result::GetStdDev() const
{
double ResultDatabase::Result::GetStdDev() const {
double r = 0;
double u = GetMean();
if (u == FLT_MAX)
return FLT_MAX;
for (int i=0; i<value.size(); i++)
{
if (u == FLT_MAX) return FLT_MAX;
for (int i = 0; i < value.size(); i++) {
r += (value[i] - u) * (value[i] - u);
}
r = sqrt(r / value.size());
@@ -107,58 +83,42 @@ double ResultDatabase::Result::GetStdDev() const
}
void ResultDatabase::AddResults(const string &test,
const string &atts,
const string &unit,
const vector<double> &values)
{
for (int i=0; i<values.size(); i++)
{
void ResultDatabase::AddResults(const string& test, const string& atts, const string& unit,
const vector<double>& values) {
for (int i = 0; i < values.size(); i++) {
AddResult(test, atts, unit, values[i]);
}
}
static string RemoveAllButLeadingSpaces(const string &a)
{
static string RemoveAllButLeadingSpaces(const string& a) {
string b;
int n = a.length();
int i = 0;
while (i<n && a[i] == ' ')
{
while (i < n && a[i] == ' ') {
b += a[i];
++i;
}
for (; i<n; i++)
{
if (a[i] != ' ' && a[i] != '\t')
b += a[i];
for (; i < n; i++) {
if (a[i] != ' ' && a[i] != '\t') b += a[i];
}
return b;
}
void ResultDatabase::AddResult(const string &test_orig,
const string &atts_orig,
const string &unit_orig,
double value)
{
void ResultDatabase::AddResult(const string& test_orig, const string& atts_orig,
const string& unit_orig, double value) {
string test = RemoveAllButLeadingSpaces(test_orig);
string atts = RemoveAllButLeadingSpaces(atts_orig);
string unit = RemoveAllButLeadingSpaces(unit_orig);
int index;
for (index = 0; index < results.size(); index++)
{
if (results[index].test == test &&
results[index].atts == atts)
{
if (results[index].unit != unit)
throw "Internal error: mixed units";
for (index = 0; index < results.size(); index++) {
if (results[index].test == test && results[index].atts == atts) {
if (results[index].unit != unit) throw "Internal error: mixed units";
break;
}
}
if (index >= results.size())
{
if (index >= results.size()) {
Result r;
r.test = test;
r.atts = atts;
@@ -192,41 +152,33 @@ void ResultDatabase::AddResult(const string &test_orig,
// Changed note about missing values to be worded a little better.
//
// ****************************************************************************
void ResultDatabase::DumpDetailed(ostream &out)
{
void ResultDatabase::DumpDetailed(ostream& out) {
vector<Result> sorted(results);
stable_sort(sorted.begin(), sorted.end());
const int testNameW = 24 ;
const int testNameW = 24;
const int attW = 12;
const int fieldW = 11;
out << std::fixed << right << std::setprecision(4);
int maxtrials = 1;
for (int i=0; i<sorted.size(); i++)
{
if (sorted[i].value.size() > maxtrials)
maxtrials = sorted[i].value.size();
for (int i = 0; i < sorted.size(); i++) {
if (sorted[i].value.size() > maxtrials) maxtrials = sorted[i].value.size();
}
// TODO: in big parallel runs, the "trials" are the procs
// and we really don't want to print them all out....
out << setw(testNameW) << "test\t"
<< setw(attW) << "atts\t"
<< setw(fieldW)
<< "median\t"
out << setw(testNameW) << "test\t" << setw(attW) << "atts\t" << setw(fieldW) << "median\t"
<< "mean\t"
<< "stddev\t"
<< "min\t"
<< "max\t";
for (int i=0; i<maxtrials; i++)
out << "trial"<<i<<"\t";
for (int i = 0; i < maxtrials; i++) out << "trial" << i << "\t";
out << endl;
for (int i=0; i<sorted.size(); i++)
{
Result &r = sorted[i];
for (int i = 0; i < sorted.size(); i++) {
Result& r = sorted[i];
out << setw(testNameW) << r.test + "\t";
out << setw(attW) << r.atts + "\t";
out << setw(fieldW) << r.unit + "\t";
@@ -237,7 +189,7 @@ void ResultDatabase::DumpDetailed(ostream &out)
if (r.GetMean() == FLT_MAX)
out << "N/A\t";
else
out << r.GetMean() << "\t";
out << r.GetMean() << "\t";
if (r.GetStdDev() == FLT_MAX)
out << "N/A\t";
else
@@ -245,13 +197,12 @@ void ResultDatabase::DumpDetailed(ostream &out)
if (r.GetMin() == FLT_MAX)
out << "N/A\t";
else
out << r.GetMin() << "\t";
out << r.GetMin() << "\t";
if (r.GetMax() == FLT_MAX)
out << "N/A\t";
else
out << r.GetMax() << "\t";
for (int j=0; j<r.value.size(); j++)
{
out << r.GetMax() << "\t";
for (int j = 0; j < r.value.size(); j++) {
if (r.value[j] == FLT_MAX)
out << "N/A\t";
else
@@ -285,23 +236,19 @@ void ResultDatabase::DumpDetailed(ostream &out)
// Added note about (*) missing value tag.
//
// ****************************************************************************
void ResultDatabase::DumpSummary(ostream &out)
{
void ResultDatabase::DumpSummary(ostream& out) {
vector<Result> sorted(results);
stable_sort(sorted.begin(), sorted.end());
const int testNameW = 24 ;
const int testNameW = 24;
const int attW = 12;
const int fieldW = 9;
out << std::fixed << right << std::setprecision(4);
// TODO: in big parallel runs, the "trials" are the procs
// and we really don't want to print them all out....
out << setw(testNameW) << "test\t"
<< setw(attW) << "atts\t"
<< setw(fieldW)
<< "units\t"
out << setw(testNameW) << "test\t" << setw(attW) << "atts\t" << setw(fieldW) << "units\t"
<< "median\t"
<< "mean\t"
<< "stddev\t"
@@ -309,9 +256,8 @@ void ResultDatabase::DumpSummary(ostream &out)
<< "max\t";
out << endl;
for (int i=0; i<sorted.size(); i++)
{
Result &r = sorted[i];
for (int i = 0; i < sorted.size(); i++) {
Result& r = sorted[i];
out << setw(testNameW) << r.test + "\t";
out << setw(attW) << r.atts + "\t";
out << setw(fieldW) << r.unit + "\t";
@@ -322,7 +268,7 @@ void ResultDatabase::DumpSummary(ostream &out)
if (r.GetMean() == FLT_MAX)
out << "N/A\t";
else
out << r.GetMean() << "\t";
out << r.GetMean() << "\t";
if (r.GetStdDev() == FLT_MAX)
out << "N/A\t";
else
@@ -330,11 +276,11 @@ void ResultDatabase::DumpSummary(ostream &out)
if (r.GetMin() == FLT_MAX)
out << "N/A\t";
else
out << r.GetMin() << "\t";
out << r.GetMin() << "\t";
if (r.GetMax() == FLT_MAX)
out << "N/A\t";
else
out << r.GetMax() << "\t";
out << r.GetMax() << "\t";
out << endl;
}
@@ -359,10 +305,7 @@ void ResultDatabase::DumpSummary(ostream &out)
//
//
// ****************************************************************************
void ResultDatabase::ClearAllResults()
{
results.clear();
}
void ResultDatabase::ClearAllResults() { results.clear(); }
// ****************************************************************************
// Method: ResultDatabase::DumpCsv
@@ -380,39 +323,36 @@ void ResultDatabase::ClearAllResults()
// Modifications:
//
// ****************************************************************************
void ResultDatabase::DumpCsv(string fileName)
{
void ResultDatabase::DumpCsv(string fileName) {
bool emptyFile;
vector<Result> sorted(results);
stable_sort(sorted.begin(), sorted.end());
//Check to see if the file is empty - if so, add the headers
// Check to see if the file is empty - if so, add the headers
emptyFile = this->IsFileEmpty(fileName);
//Open file and append by default
// Open file and append by default
ofstream out;
out.open(fileName.c_str(), std::ofstream::out | std::ofstream::app);
out.open(fileName.c_str(), std::ofstream::out | std::ofstream::app);
//Add headers only for empty files
if(emptyFile)
{
// TODO: in big parallel runs, the "trials" are the procs
// and we really don't want to print them all out....
out << "test, "
<< "atts, "
<< "units, "
<< "median, "
<< "mean, "
<< "stddev, "
<< "min, "
<< "max, ";
out << endl;
// Add headers only for empty files
if (emptyFile) {
// TODO: in big parallel runs, the "trials" are the procs
// and we really don't want to print them all out....
out << "test, "
<< "atts, "
<< "units, "
<< "median, "
<< "mean, "
<< "stddev, "
<< "min, "
<< "max, ";
out << endl;
}
for (int i=0; i<sorted.size(); i++)
{
Result &r = sorted[i];
for (int i = 0; i < sorted.size(); i++) {
Result& r = sorted[i];
out << r.test << ", ";
out << r.atts << ", ";
out << r.unit << ", ";
@@ -423,7 +363,7 @@ void ResultDatabase::DumpCsv(string fileName)
if (r.GetMean() == FLT_MAX)
out << "N/A, ";
else
out << r.GetMean() << ", ";
out << r.GetMean() << ", ";
if (r.GetStdDev() == FLT_MAX)
out << "N/A, ";
else
@@ -431,11 +371,11 @@ void ResultDatabase::DumpCsv(string fileName)
if (r.GetMin() == FLT_MAX)
out << "N/A, ";
else
out << r.GetMin() << ", ";
out << r.GetMin() << ", ";
if (r.GetMax() == FLT_MAX)
out << "N/A, ";
else
out << r.GetMax() << ", ";
out << r.GetMax() << ", ";
out << endl;
}
@@ -460,29 +400,24 @@ void ResultDatabase::DumpCsv(string fileName)
//
// ****************************************************************************
bool ResultDatabase::IsFileEmpty(string fileName)
{
bool fileEmpty;
bool ResultDatabase::IsFileEmpty(string fileName) {
bool fileEmpty;
ifstream file(fileName.c_str());
ifstream file(fileName.c_str());
//If the file doesn't exist it is by definition empty
if(!file.good())
{
// If the file doesn't exist it is by definition empty
if (!file.good()) {
return true;
}
else
{
} else {
fileEmpty = (bool)(file.peek() == ifstream::traits_type::eof());
file.close();
return fileEmpty;
}
//Otherwise, return false
return false;
}
return fileEmpty;
}
// Otherwise, return false
return false;
}
// ****************************************************************************
@@ -500,16 +435,12 @@ bool ResultDatabase::IsFileEmpty(string fileName)
// Modifications:
//
// ****************************************************************************
vector<ResultDatabase::Result>
ResultDatabase::GetResultsForTest(const string &test)
{
vector<ResultDatabase::Result> ResultDatabase::GetResultsForTest(const string& test) {
// get only the given test results
vector<Result> retval;
for (int i=0; i<results.size(); i++)
{
Result &r = results[i];
if (r.test == test)
retval.push_back(r);
for (int i = 0; i < results.size(); i++) {
Result& r = results[i];
if (r.test == test) retval.push_back(r);
}
return retval;
}
@@ -528,8 +459,4 @@ ResultDatabase::GetResultsForTest(const string &test)
// Modifications:
//
// ****************************************************************************
const vector<ResultDatabase::Result> &
ResultDatabase::GetResults() const
{
return results;
}
const vector<ResultDatabase::Result>& ResultDatabase::GetResults() const { return results; }
+22 -33
Ver fichero
@@ -6,11 +6,11 @@
#include <iostream>
#include <fstream>
#include <cfloat>
using std::ifstream;
using std::ofstream;
using std::ostream;
using std::string;
using std::vector;
using std::ostream;
using std::ofstream;
using std::ifstream;
// ****************************************************************************
@@ -40,18 +40,16 @@ using std::ifstream;
// Added a GetResults method as well, and made several functions const.
//
// ****************************************************************************
class ResultDatabase
{
public:
class ResultDatabase {
public:
//
// A performance result for a single SHOC benchmark run.
//
struct Result
{
string test; // e.g. "readback"
string atts; // e.g. "pagelocked 4k^2"
string unit; // e.g. "MB/sec"
vector<double> value; // e.g. "837.14"
struct Result {
string test; // e.g. "readback"
string atts; // e.g. "pagelocked 4k^2"
string unit; // e.g. "MB/sec"
vector<double> value; // e.g. "837.14"
double GetMin() const;
double GetMax() const;
double GetMedian() const;
@@ -59,41 +57,32 @@ class ResultDatabase
double GetMean() const;
double GetStdDev() const;
bool operator<(const Result &rhs) const;
bool operator<(const Result& rhs) const;
bool HadAnyFLTMAXValues() const
{
for (int i=0; i<value.size(); ++i)
{
if (value[i] >= FLT_MAX)
return true;
bool HadAnyFLTMAXValues() const {
for (int i = 0; i < value.size(); ++i) {
if (value[i] >= FLT_MAX) return true;
}
return false;
}
};
protected:
protected:
vector<Result> results;
public:
void AddResult(const string &test,
const string &atts,
const string &unit,
double value);
void AddResults(const string &test,
const string &atts,
const string &unit,
const vector<double> &values);
vector<Result> GetResultsForTest(const string &test);
const vector<Result> &GetResults() const;
public:
void AddResult(const string& test, const string& atts, const string& unit, double value);
void AddResults(const string& test, const string& atts, const string& unit,
const vector<double>& values);
vector<Result> GetResultsForTest(const string& test);
const vector<Result>& GetResults() const;
void ClearAllResults();
void DumpDetailed(ostream&);
void DumpSummary(ostream&);
void DumpCsv(string fileName);
private:
private:
bool IsFileEmpty(string fileName);
};
La diferencia del archivo ha sido suprimido porque es demasiado grande Cargar Diff
+97 -170
Ver fichero
@@ -7,93 +7,69 @@
using namespace std;
bool ResultDatabase::Result::operator<(const Result &rhs) const
{
if (test < rhs.test)
return true;
if (test > rhs.test)
return false;
if (atts < rhs.atts)
return true;
if (atts > rhs.atts)
return false;
return false; // less-operator returns false on equal
bool ResultDatabase::Result::operator<(const Result& rhs) const {
if (test < rhs.test) return true;
if (test > rhs.test) return false;
if (atts < rhs.atts) return true;
if (atts > rhs.atts) return false;
return false; // less-operator returns false on equal
}
double ResultDatabase::Result::GetMin() const
{
double ResultDatabase::Result::GetMin() const {
double r = FLT_MAX;
for (int i=0; i<value.size(); i++)
{
for (int i = 0; i < value.size(); i++) {
r = min(r, value[i]);
}
return r;
}
double ResultDatabase::Result::GetMax() const
{
double ResultDatabase::Result::GetMax() const {
double r = -FLT_MAX;
for (int i=0; i<value.size(); i++)
{
for (int i = 0; i < value.size(); i++) {
r = max(r, value[i]);
}
return r;
}
double ResultDatabase::Result::GetMedian() const
{
return GetPercentile(50);
}
double ResultDatabase::Result::GetMedian() const { return GetPercentile(50); }
double ResultDatabase::Result::GetPercentile(double q) const
{
double ResultDatabase::Result::GetPercentile(double q) const {
int n = value.size();
if (n == 0)
return FLT_MAX;
if (n == 1)
return value[0];
if (n == 0) return FLT_MAX;
if (n == 1) return value[0];
if (q <= 0)
return value[0];
if (q >= 100)
return value[n-1];
if (q <= 0) return value[0];
if (q >= 100) return value[n - 1];
double index = ((n + 1.) * q / 100.) - 1;
vector<double> sorted = value;
sort(sorted.begin(), sorted.end());
if (n == 2)
return (sorted[0] * (1 - q/100.) + sorted[1] * (q/100.));
if (n == 2) return (sorted[0] * (1 - q / 100.) + sorted[1] * (q / 100.));
int index_lo = int(index);
double frac = index - index_lo;
if (frac == 0)
return sorted[index_lo];
if (frac == 0) return sorted[index_lo];
double lo = sorted[index_lo];
double hi = sorted[index_lo + 1];
return lo + (hi-lo)*frac;
return lo + (hi - lo) * frac;
}
double ResultDatabase::Result::GetMean() const
{
double ResultDatabase::Result::GetMean() const {
double r = 0;
for (int i=0; i<value.size(); i++)
{
for (int i = 0; i < value.size(); i++) {
r += value[i];
}
return r / double(value.size());
}
double ResultDatabase::Result::GetStdDev() const
{
double ResultDatabase::Result::GetStdDev() const {
double r = 0;
double u = GetMean();
if (u == FLT_MAX)
return FLT_MAX;
for (int i=0; i<value.size(); i++)
{
if (u == FLT_MAX) return FLT_MAX;
for (int i = 0; i < value.size(); i++) {
r += (value[i] - u) * (value[i] - u);
}
r = sqrt(r / value.size());
@@ -101,58 +77,42 @@ double ResultDatabase::Result::GetStdDev() const
}
void ResultDatabase::AddResults(const string &test,
const string &atts,
const string &unit,
const vector<double> &values)
{
for (int i=0; i<values.size(); i++)
{
void ResultDatabase::AddResults(const string& test, const string& atts, const string& unit,
const vector<double>& values) {
for (int i = 0; i < values.size(); i++) {
AddResult(test, atts, unit, values[i]);
}
}
static string RemoveAllButLeadingSpaces(const string &a)
{
static string RemoveAllButLeadingSpaces(const string& a) {
string b;
int n = a.length();
int i = 0;
while (i<n && a[i] == ' ')
{
while (i < n && a[i] == ' ') {
b += a[i];
++i;
}
for (; i<n; i++)
{
if (a[i] != ' ' && a[i] != '\t')
b += a[i];
for (; i < n; i++) {
if (a[i] != ' ' && a[i] != '\t') b += a[i];
}
return b;
}
void ResultDatabase::AddResult(const string &test_orig,
const string &atts_orig,
const string &unit_orig,
double value)
{
void ResultDatabase::AddResult(const string& test_orig, const string& atts_orig,
const string& unit_orig, double value) {
string test = RemoveAllButLeadingSpaces(test_orig);
string atts = RemoveAllButLeadingSpaces(atts_orig);
string unit = RemoveAllButLeadingSpaces(unit_orig);
int index;
for (index = 0; index < results.size(); index++)
{
if (results[index].test == test &&
results[index].atts == atts)
{
if (results[index].unit != unit)
throw "Internal error: mixed units";
for (index = 0; index < results.size(); index++) {
if (results[index].test == test && results[index].atts == atts) {
if (results[index].unit != unit) throw "Internal error: mixed units";
break;
}
}
if (index >= results.size())
{
if (index >= results.size()) {
Result r;
r.test = test;
r.atts = atts;
@@ -186,40 +146,32 @@ void ResultDatabase::AddResult(const string &test_orig,
// Changed note about missing values to be worded a little better.
//
// ****************************************************************************
void ResultDatabase::DumpDetailed(ostream &out)
{
void ResultDatabase::DumpDetailed(ostream& out) {
vector<Result> sorted(results);
sort(sorted.begin(), sorted.end());
const int testNameW = 24 ;
const int testNameW = 24;
const int attW = 12;
const int fieldW = 11;
out << std::fixed << right << std::setprecision(4);
int maxtrials = 1;
for (int i=0; i<sorted.size(); i++)
{
if (sorted[i].value.size() > maxtrials)
maxtrials = sorted[i].value.size();
for (int i = 0; i < sorted.size(); i++) {
if (sorted[i].value.size() > maxtrials) maxtrials = sorted[i].value.size();
}
// TODO: in big parallel runs, the "trials" are the procs
// and we really don't want to print them all out....
out << setw(testNameW) << "test\t"
<< setw(attW) << "atts\t"
<< setw(fieldW)
<< "median\t"
out << setw(testNameW) << "test\t" << setw(attW) << "atts\t" << setw(fieldW) << "median\t"
<< "mean\t"
<< "stddev\t"
<< "min\t"
<< "max\t";
for (int i=0; i<maxtrials; i++)
out << "trial"<<i<<"\t";
for (int i = 0; i < maxtrials; i++) out << "trial" << i << "\t";
out << endl;
for (int i=0; i<sorted.size(); i++)
{
Result &r = sorted[i];
for (int i = 0; i < sorted.size(); i++) {
Result& r = sorted[i];
out << setw(testNameW) << r.test + "\t";
out << setw(attW) << r.atts + "\t";
out << setw(fieldW) << r.unit + "\t";
@@ -230,7 +182,7 @@ void ResultDatabase::DumpDetailed(ostream &out)
if (r.GetMean() == FLT_MAX)
out << "N/A\t";
else
out << r.GetMean() << "\t";
out << r.GetMean() << "\t";
if (r.GetStdDev() == FLT_MAX)
out << "N/A\t";
else
@@ -238,13 +190,12 @@ void ResultDatabase::DumpDetailed(ostream &out)
if (r.GetMin() == FLT_MAX)
out << "N/A\t";
else
out << r.GetMin() << "\t";
out << r.GetMin() << "\t";
if (r.GetMax() == FLT_MAX)
out << "N/A\t";
else
out << r.GetMax() << "\t";
for (int j=0; j<r.value.size(); j++)
{
out << r.GetMax() << "\t";
for (int j = 0; j < r.value.size(); j++) {
if (r.value[j] == FLT_MAX)
out << "N/A\t";
else
@@ -278,22 +229,18 @@ void ResultDatabase::DumpDetailed(ostream &out)
// Added note about (*) missing value tag.
//
// ****************************************************************************
void ResultDatabase::DumpSummary(ostream &out)
{
void ResultDatabase::DumpSummary(ostream& out) {
vector<Result> sorted(results);
sort(sorted.begin(), sorted.end());
const int testNameW = 24 ;
const int testNameW = 24;
const int attW = 12;
const int fieldW = 9;
out << std::fixed << right << std::setprecision(4);
// TODO: in big parallel runs, the "trials" are the procs
// and we really don't want to print them all out....
out << setw(testNameW) << "test\t"
<< setw(attW) << "atts\t"
<< setw(fieldW)
<< "units\t"
out << setw(testNameW) << "test\t" << setw(attW) << "atts\t" << setw(fieldW) << "units\t"
<< "median\t"
<< "mean\t"
<< "stddev\t"
@@ -301,9 +248,8 @@ void ResultDatabase::DumpSummary(ostream &out)
<< "max\t";
out << endl;
for (int i=0; i<sorted.size(); i++)
{
Result &r = sorted[i];
for (int i = 0; i < sorted.size(); i++) {
Result& r = sorted[i];
out << setw(testNameW) << r.test + "\t";
out << setw(attW) << r.atts + "\t";
out << setw(fieldW) << r.unit + "\t";
@@ -314,7 +260,7 @@ void ResultDatabase::DumpSummary(ostream &out)
if (r.GetMean() == FLT_MAX)
out << "N/A\t";
else
out << r.GetMean() << "\t";
out << r.GetMean() << "\t";
if (r.GetStdDev() == FLT_MAX)
out << "N/A\t";
else
@@ -322,11 +268,11 @@ void ResultDatabase::DumpSummary(ostream &out)
if (r.GetMin() == FLT_MAX)
out << "N/A\t";
else
out << r.GetMin() << "\t";
out << r.GetMin() << "\t";
if (r.GetMax() == FLT_MAX)
out << "N/A\t";
else
out << r.GetMax() << "\t";
out << r.GetMax() << "\t";
out << endl;
}
@@ -351,10 +297,7 @@ void ResultDatabase::DumpSummary(ostream &out)
//
//
// ****************************************************************************
void ResultDatabase::ClearAllResults()
{
results.clear();
}
void ResultDatabase::ClearAllResults() { results.clear(); }
// ****************************************************************************
// Method: ResultDatabase::DumpCsv
@@ -372,39 +315,36 @@ void ResultDatabase::ClearAllResults()
// Modifications:
//
// ****************************************************************************
void ResultDatabase::DumpCsv(string fileName)
{
void ResultDatabase::DumpCsv(string fileName) {
bool emptyFile;
vector<Result> sorted(results);
sort(sorted.begin(), sorted.end());
//Check to see if the file is empty - if so, add the headers
// Check to see if the file is empty - if so, add the headers
emptyFile = this->IsFileEmpty(fileName);
//Open file and append by default
// Open file and append by default
ofstream out;
out.open(fileName.c_str(), std::ofstream::out | std::ofstream::app);
out.open(fileName.c_str(), std::ofstream::out | std::ofstream::app);
//Add headers only for empty files
if(emptyFile)
{
// TODO: in big parallel runs, the "trials" are the procs
// and we really don't want to print them all out....
out << "test, "
<< "atts, "
<< "units, "
<< "median, "
<< "mean, "
<< "stddev, "
<< "min, "
<< "max, ";
out << endl;
// Add headers only for empty files
if (emptyFile) {
// TODO: in big parallel runs, the "trials" are the procs
// and we really don't want to print them all out....
out << "test, "
<< "atts, "
<< "units, "
<< "median, "
<< "mean, "
<< "stddev, "
<< "min, "
<< "max, ";
out << endl;
}
for (int i=0; i<sorted.size(); i++)
{
Result &r = sorted[i];
for (int i = 0; i < sorted.size(); i++) {
Result& r = sorted[i];
out << r.test << ", ";
out << r.atts << ", ";
out << r.unit << ", ";
@@ -415,7 +355,7 @@ void ResultDatabase::DumpCsv(string fileName)
if (r.GetMean() == FLT_MAX)
out << "N/A, ";
else
out << r.GetMean() << ", ";
out << r.GetMean() << ", ";
if (r.GetStdDev() == FLT_MAX)
out << "N/A, ";
else
@@ -423,11 +363,11 @@ void ResultDatabase::DumpCsv(string fileName)
if (r.GetMin() == FLT_MAX)
out << "N/A, ";
else
out << r.GetMin() << ", ";
out << r.GetMin() << ", ";
if (r.GetMax() == FLT_MAX)
out << "N/A, ";
else
out << r.GetMax() << ", ";
out << r.GetMax() << ", ";
out << endl;
}
@@ -452,29 +392,24 @@ void ResultDatabase::DumpCsv(string fileName)
//
// ****************************************************************************
bool ResultDatabase::IsFileEmpty(string fileName)
{
bool fileEmpty;
bool ResultDatabase::IsFileEmpty(string fileName) {
bool fileEmpty;
ifstream file(fileName.c_str());
ifstream file(fileName.c_str());
//If the file doesn't exist it is by definition empty
if(!file.good())
{
// If the file doesn't exist it is by definition empty
if (!file.good()) {
return true;
}
else
{
} else {
fileEmpty = (bool)(file.peek() == ifstream::traits_type::eof());
file.close();
return fileEmpty;
}
//Otherwise, return false
return false;
}
return fileEmpty;
}
// Otherwise, return false
return false;
}
// ****************************************************************************
@@ -492,16 +427,12 @@ bool ResultDatabase::IsFileEmpty(string fileName)
// Modifications:
//
// ****************************************************************************
vector<ResultDatabase::Result>
ResultDatabase::GetResultsForTest(const string &test)
{
vector<ResultDatabase::Result> ResultDatabase::GetResultsForTest(const string& test) {
// get only the given test results
vector<Result> retval;
for (int i=0; i<results.size(); i++)
{
Result &r = results[i];
if (r.test == test)
retval.push_back(r);
for (int i = 0; i < results.size(); i++) {
Result& r = results[i];
if (r.test == test) retval.push_back(r);
}
return retval;
}
@@ -520,8 +451,4 @@ ResultDatabase::GetResultsForTest(const string &test)
// Modifications:
//
// ****************************************************************************
const vector<ResultDatabase::Result> &
ResultDatabase::GetResults() const
{
return results;
}
const vector<ResultDatabase::Result>& ResultDatabase::GetResults() const { return results; }
+22 -33
Ver fichero
@@ -6,11 +6,11 @@
#include <iostream>
#include <fstream>
#include <cfloat>
using std::ifstream;
using std::ofstream;
using std::ostream;
using std::string;
using std::vector;
using std::ostream;
using std::ofstream;
using std::ifstream;
// ****************************************************************************
@@ -40,18 +40,16 @@ using std::ifstream;
// Added a GetResults method as well, and made several functions const.
//
// ****************************************************************************
class ResultDatabase
{
public:
class ResultDatabase {
public:
//
// A performance result for a single SHOC benchmark run.
//
struct Result
{
string test; // e.g. "readback"
string atts; // e.g. "pagelocked 4k^2"
string unit; // e.g. "MB/sec"
vector<double> value; // e.g. "837.14"
struct Result {
string test; // e.g. "readback"
string atts; // e.g. "pagelocked 4k^2"
string unit; // e.g. "MB/sec"
vector<double> value; // e.g. "837.14"
double GetMin() const;
double GetMax() const;
double GetMedian() const;
@@ -59,41 +57,32 @@ class ResultDatabase
double GetMean() const;
double GetStdDev() const;
bool operator<(const Result &rhs) const;
bool operator<(const Result& rhs) const;
bool HadAnyFLTMAXValues() const
{
for (int i=0; i<value.size(); ++i)
{
if (value[i] >= FLT_MAX)
return true;
bool HadAnyFLTMAXValues() const {
for (int i = 0; i < value.size(); ++i) {
if (value[i] >= FLT_MAX) return true;
}
return false;
}
};
protected:
protected:
vector<Result> results;
public:
void AddResult(const string &test,
const string &atts,
const string &unit,
double value);
void AddResults(const string &test,
const string &atts,
const string &unit,
const vector<double> &values);
vector<Result> GetResultsForTest(const string &test);
const vector<Result> &GetResults() const;
public:
void AddResult(const string& test, const string& atts, const string& unit, double value);
void AddResults(const string& test, const string& atts, const string& unit,
const vector<double>& values);
vector<Result> GetResultsForTest(const string& test);
const vector<Result>& GetResults() const;
void ClearAllResults();
void DumpDetailed(ostream&);
void DumpSummary(ostream&);
void DumpCsv(string fileName);
private:
private:
bool IsFileEmpty(string fileName);
};
La diferencia del archivo ha sido suprimido porque es demasiado grande Cargar Diff
+1 -1
Ver fichero
@@ -1,6 +1,6 @@
#include "hip/hip_runtime.h"
extern "C" __global__ void NullKernel(hipLaunchParm lp, float* Ad){
extern "C" __global__ void NullKernel(hipLaunchParm lp, float* Ad) {
if (Ad) {
Ad[0] = 42;
}
+8 -11
Ver fichero
@@ -1,20 +1,17 @@
#include <hip/hip_runtime.h>
static const int BLOCKSIZEX=32;
static const int BLOCKSIZEY=16;
static const int BLOCKSIZEX = 32;
static const int BLOCKSIZEY = 16;
__global__ void fails(hipLaunchParm lp, float* pErrorI)
{
if(pErrorI!=0)
{
pErrorI[0]=1;
__global__ void fails(hipLaunchParm lp, float* pErrorI) {
if (pErrorI != 0) {
pErrorI[0] = 1;
}
}
int main()
{
dim3 blocks(1,1);
dim3 threads(BLOCKSIZEX,BLOCKSIZEY);
int main() {
dim3 blocks(1, 1);
dim3 threads(BLOCKSIZEX, BLOCKSIZEY);
float error;
hipLaunchKernel(HIP_KERNEL_NAME(fails), blocks, threads, 0, 0, &error);
@@ -11,96 +11,72 @@ using namespace std;
#define SORT_RETAIN_ATTS_ORDER 1
bool ResultDatabase::Result::operator<(const Result &rhs) const
{
if (test < rhs.test)
return true;
if (test > rhs.test)
return false;
#if (SORT_RETAIN_ATTS_ORDER == 0)
bool ResultDatabase::Result::operator<(const Result& rhs) const {
if (test < rhs.test) return true;
if (test > rhs.test) return false;
#if (SORT_RETAIN_ATTS_ORDER == 0)
// For ties, sort by the value of the attribute:
if (atts < rhs.atts)
return true;
if (atts > rhs.atts)
return false;
if (atts < rhs.atts) return true;
if (atts > rhs.atts) return false;
#endif
return false; // less-operator returns false on equal
return false; // less-operator returns false on equal
}
double ResultDatabase::Result::GetMin() const
{
double ResultDatabase::Result::GetMin() const {
double r = FLT_MAX;
for (int i=0; i<value.size(); i++)
{
for (int i = 0; i < value.size(); i++) {
r = min(r, value[i]);
}
return r;
}
double ResultDatabase::Result::GetMax() const
{
double ResultDatabase::Result::GetMax() const {
double r = -FLT_MAX;
for (int i=0; i<value.size(); i++)
{
for (int i = 0; i < value.size(); i++) {
r = max(r, value[i]);
}
return r;
}
double ResultDatabase::Result::GetMedian() const
{
return GetPercentile(50);
}
double ResultDatabase::Result::GetMedian() const { return GetPercentile(50); }
double ResultDatabase::Result::GetPercentile(double q) const
{
double ResultDatabase::Result::GetPercentile(double q) const {
int n = value.size();
if (n == 0)
return FLT_MAX;
if (n == 1)
return value[0];
if (n == 0) return FLT_MAX;
if (n == 1) return value[0];
if (q <= 0)
return value[0];
if (q >= 100)
return value[n-1];
if (q <= 0) return value[0];
if (q >= 100) return value[n - 1];
double index = ((n + 1.) * q / 100.) - 1;
vector<double> sorted = value;
sort(sorted.begin(), sorted.end());
if (n == 2)
return (sorted[0] * (1 - q/100.) + sorted[1] * (q/100.));
if (n == 2) return (sorted[0] * (1 - q / 100.) + sorted[1] * (q / 100.));
int index_lo = int(index);
double frac = index - index_lo;
if (frac == 0)
return sorted[index_lo];
if (frac == 0) return sorted[index_lo];
double lo = sorted[index_lo];
double hi = sorted[index_lo + 1];
return lo + (hi-lo)*frac;
return lo + (hi - lo) * frac;
}
double ResultDatabase::Result::GetMean() const
{
double ResultDatabase::Result::GetMean() const {
double r = 0;
for (int i=0; i<value.size(); i++)
{
for (int i = 0; i < value.size(); i++) {
r += value[i];
}
return r / double(value.size());
}
double ResultDatabase::Result::GetStdDev() const
{
double ResultDatabase::Result::GetStdDev() const {
double r = 0;
double u = GetMean();
if (u == FLT_MAX)
return FLT_MAX;
for (int i=0; i<value.size(); i++)
{
if (u == FLT_MAX) return FLT_MAX;
for (int i = 0; i < value.size(); i++) {
r += (value[i] - u) * (value[i] - u);
}
r = sqrt(r / value.size());
@@ -108,58 +84,42 @@ double ResultDatabase::Result::GetStdDev() const
}
void ResultDatabase::AddResults(const string &test,
const string &atts,
const string &unit,
const vector<double> &values)
{
for (int i=0; i<values.size(); i++)
{
void ResultDatabase::AddResults(const string& test, const string& atts, const string& unit,
const vector<double>& values) {
for (int i = 0; i < values.size(); i++) {
AddResult(test, atts, unit, values[i]);
}
}
static string RemoveAllButLeadingSpaces(const string &a)
{
static string RemoveAllButLeadingSpaces(const string& a) {
string b;
int n = a.length();
int i = 0;
while (i<n && a[i] == ' ')
{
while (i < n && a[i] == ' ') {
b += a[i];
++i;
}
for (; i<n; i++)
{
if (a[i] != ' ' && a[i] != '\t')
b += a[i];
for (; i < n; i++) {
if (a[i] != ' ' && a[i] != '\t') b += a[i];
}
return b;
}
void ResultDatabase::AddResult(const string &test_orig,
const string &atts_orig,
const string &unit_orig,
double value)
{
void ResultDatabase::AddResult(const string& test_orig, const string& atts_orig,
const string& unit_orig, double value) {
string test = RemoveAllButLeadingSpaces(test_orig);
string atts = RemoveAllButLeadingSpaces(atts_orig);
string unit = RemoveAllButLeadingSpaces(unit_orig);
int index;
for (index = 0; index < results.size(); index++)
{
if (results[index].test == test &&
results[index].atts == atts)
{
if (results[index].unit != unit)
throw "Internal error: mixed units";
for (index = 0; index < results.size(); index++) {
if (results[index].test == test && results[index].atts == atts) {
if (results[index].unit != unit) throw "Internal error: mixed units";
break;
}
}
if (index >= results.size())
{
if (index >= results.size()) {
Result r;
r.test = test;
r.atts = atts;
@@ -193,43 +153,35 @@ void ResultDatabase::AddResult(const string &test_orig,
// Changed note about missing values to be worded a little better.
//
// ****************************************************************************
void ResultDatabase::DumpDetailed(ostream &out)
{
void ResultDatabase::DumpDetailed(ostream& out) {
vector<Result> sorted(results);
#if SORT_BY_NAME
stable_sort(sorted.begin(), sorted.end());
#endif
const int testNameW = 24 ;
const int testNameW = 24;
const int attW = 12;
const int fieldW = 11;
out << std::fixed << right << std::setprecision(4);
int maxtrials = 1;
for (int i=0; i<sorted.size(); i++)
{
if (sorted[i].value.size() > maxtrials)
maxtrials = sorted[i].value.size();
for (int i = 0; i < sorted.size(); i++) {
if (sorted[i].value.size() > maxtrials) maxtrials = sorted[i].value.size();
}
// TODO: in big parallel runs, the "trials" are the procs
// and we really don't want to print them all out....
out << setw(testNameW) << "test\t"
<< setw(attW) << "atts\t"
<< setw(fieldW)
<< "median\t"
out << setw(testNameW) << "test\t" << setw(attW) << "atts\t" << setw(fieldW) << "median\t"
<< "mean\t"
<< "stddev\t"
<< "min\t"
<< "max\t";
for (int i=0; i<maxtrials; i++)
out << "trial"<<i<<"\t";
for (int i = 0; i < maxtrials; i++) out << "trial" << i << "\t";
out << endl;
for (int i=0; i<sorted.size(); i++)
{
Result &r = sorted[i];
for (int i = 0; i < sorted.size(); i++) {
Result& r = sorted[i];
out << setw(testNameW) << r.test + "\t";
out << setw(attW) << r.atts + "\t";
out << setw(fieldW) << r.unit + "\t";
@@ -240,7 +192,7 @@ void ResultDatabase::DumpDetailed(ostream &out)
if (r.GetMean() == FLT_MAX)
out << "N/A\t";
else
out << r.GetMean() << "\t";
out << r.GetMean() << "\t";
if (r.GetStdDev() == FLT_MAX)
out << "N/A\t";
else
@@ -248,13 +200,12 @@ void ResultDatabase::DumpDetailed(ostream &out)
if (r.GetMin() == FLT_MAX)
out << "N/A\t";
else
out << r.GetMin() << "\t";
out << r.GetMin() << "\t";
if (r.GetMax() == FLT_MAX)
out << "N/A\t";
else
out << r.GetMax() << "\t";
for (int j=0; j<r.value.size(); j++)
{
out << r.GetMax() << "\t";
for (int j = 0; j < r.value.size(); j++) {
if (r.value[j] == FLT_MAX)
out << "N/A\t";
else
@@ -290,25 +241,21 @@ void ResultDatabase::DumpDetailed(ostream &out)
// Added note about (*) missing value tag.
//
// ****************************************************************************
void ResultDatabase::DumpSummary(ostream &out)
{
void ResultDatabase::DumpSummary(ostream& out) {
vector<Result> sorted(results);
#if SORT_BY_NAME
stable_sort(sorted.begin(), sorted.end());
#endif
const int testNameW = 32 ;
const int testNameW = 32;
const int attW = 12;
const int fieldW = 9;
out << std::fixed << right << std::setprecision(2);
// TODO: in big parallel runs, the "trials" are the procs
// and we really don't want to print them all out....
out << setw(testNameW) << "test\t"
<< setw(attW) << "atts\t"
<< setw(fieldW)
<< "units\t"
out << setw(testNameW) << "test\t" << setw(attW) << "atts\t" << setw(fieldW) << "units\t"
<< "median\t"
<< "mean\t"
<< "stddev\t"
@@ -316,9 +263,8 @@ void ResultDatabase::DumpSummary(ostream &out)
<< "max\t";
out << endl;
for (int i=0; i<sorted.size(); i++)
{
Result &r = sorted[i];
for (int i = 0; i < sorted.size(); i++) {
Result& r = sorted[i];
out << setw(testNameW) << r.test + "\t";
out << setw(attW) << r.atts + "\t";
out << setw(fieldW) << r.unit + "\t";
@@ -329,7 +275,7 @@ void ResultDatabase::DumpSummary(ostream &out)
if (r.GetMean() == FLT_MAX)
out << "N/A\t";
else
out << r.GetMean() << "\t";
out << r.GetMean() << "\t";
if (r.GetStdDev() == FLT_MAX)
out << "N/A\t";
else
@@ -337,11 +283,11 @@ void ResultDatabase::DumpSummary(ostream &out)
if (r.GetMin() == FLT_MAX)
out << "N/A\t";
else
out << r.GetMin() << "\t";
out << r.GetMin() << "\t";
if (r.GetMax() == FLT_MAX)
out << "N/A\t";
else
out << r.GetMax() << "\t";
out << r.GetMax() << "\t";
out << endl;
}
@@ -368,10 +314,7 @@ void ResultDatabase::DumpSummary(ostream &out)
//
//
// ****************************************************************************
void ResultDatabase::ClearAllResults()
{
results.clear();
}
void ResultDatabase::ClearAllResults() { results.clear(); }
// ****************************************************************************
// Method: ResultDatabase::DumpCsv
@@ -389,8 +332,7 @@ void ResultDatabase::ClearAllResults()
// Modifications:
//
// ****************************************************************************
void ResultDatabase::DumpCsv(string fileName)
{
void ResultDatabase::DumpCsv(string fileName) {
bool emptyFile;
vector<Result> sorted(results);
@@ -398,32 +340,30 @@ void ResultDatabase::DumpCsv(string fileName)
stable_sort(sorted.begin(), sorted.end());
#endif
//Check to see if the file is empty - if so, add the headers
// Check to see if the file is empty - if so, add the headers
emptyFile = this->IsFileEmpty(fileName);
//Open file and append by default
// Open file and append by default
ofstream out;
out.open(fileName.c_str(), std::ofstream::out | std::ofstream::app);
out.open(fileName.c_str(), std::ofstream::out | std::ofstream::app);
//Add headers only for empty files
if(emptyFile)
{
// TODO: in big parallel runs, the "trials" are the procs
// and we really don't want to print them all out....
out << "test, "
<< "atts, "
<< "units, "
<< "median, "
<< "mean, "
<< "stddev, "
<< "min, "
<< "max, ";
out << endl;
// Add headers only for empty files
if (emptyFile) {
// TODO: in big parallel runs, the "trials" are the procs
// and we really don't want to print them all out....
out << "test, "
<< "atts, "
<< "units, "
<< "median, "
<< "mean, "
<< "stddev, "
<< "min, "
<< "max, ";
out << endl;
}
for (int i=0; i<sorted.size(); i++)
{
Result &r = sorted[i];
for (int i = 0; i < sorted.size(); i++) {
Result& r = sorted[i];
out << r.test << ", ";
out << r.atts << ", ";
out << r.unit << ", ";
@@ -434,7 +374,7 @@ void ResultDatabase::DumpCsv(string fileName)
if (r.GetMean() == FLT_MAX)
out << "N/A, ";
else
out << r.GetMean() << ", ";
out << r.GetMean() << ", ";
if (r.GetStdDev() == FLT_MAX)
out << "N/A, ";
else
@@ -442,11 +382,11 @@ void ResultDatabase::DumpCsv(string fileName)
if (r.GetMin() == FLT_MAX)
out << "N/A, ";
else
out << r.GetMin() << ", ";
out << r.GetMin() << ", ";
if (r.GetMax() == FLT_MAX)
out << "N/A, ";
else
out << r.GetMax() << ", ";
out << r.GetMax() << ", ";
out << endl;
}
@@ -471,29 +411,24 @@ void ResultDatabase::DumpCsv(string fileName)
//
// ****************************************************************************
bool ResultDatabase::IsFileEmpty(string fileName)
{
bool fileEmpty;
bool ResultDatabase::IsFileEmpty(string fileName) {
bool fileEmpty;
ifstream file(fileName.c_str());
ifstream file(fileName.c_str());
//If the file doesn't exist it is by definition empty
if(!file.good())
{
// If the file doesn't exist it is by definition empty
if (!file.good()) {
return true;
}
else
{
} else {
fileEmpty = (bool)(file.peek() == ifstream::traits_type::eof());
file.close();
return fileEmpty;
}
//Otherwise, return false
return false;
}
return fileEmpty;
}
// Otherwise, return false
return false;
}
// ****************************************************************************
@@ -511,16 +446,12 @@ bool ResultDatabase::IsFileEmpty(string fileName)
// Modifications:
//
// ****************************************************************************
vector<ResultDatabase::Result>
ResultDatabase::GetResultsForTest(const string &test)
{
vector<ResultDatabase::Result> ResultDatabase::GetResultsForTest(const string& test) {
// get only the given test results
vector<Result> retval;
for (int i=0; i<results.size(); i++)
{
Result &r = results[i];
if (r.test == test)
retval.push_back(r);
for (int i = 0; i < results.size(); i++) {
Result& r = results[i];
if (r.test == test) retval.push_back(r);
}
return retval;
}
@@ -539,8 +470,4 @@ ResultDatabase::GetResultsForTest(const string &test)
// Modifications:
//
// ****************************************************************************
const vector<ResultDatabase::Result> &
ResultDatabase::GetResults() const
{
return results;
}
const vector<ResultDatabase::Result>& ResultDatabase::GetResults() const { return results; }
@@ -6,11 +6,11 @@
#include <iostream>
#include <fstream>
#include <cfloat>
using std::ifstream;
using std::ofstream;
using std::ostream;
using std::string;
using std::vector;
using std::ostream;
using std::ofstream;
using std::ifstream;
// ****************************************************************************
@@ -40,18 +40,16 @@ using std::ifstream;
// Added a GetResults method as well, and made several functions const.
//
// ****************************************************************************
class ResultDatabase
{
public:
class ResultDatabase {
public:
//
// A performance result for a single SHOC benchmark run.
//
struct Result
{
string test; // e.g. "readback"
string atts; // e.g. "pagelocked 4k^2"
string unit; // e.g. "MB/sec"
vector<double> value; // e.g. "837.14"
struct Result {
string test; // e.g. "readback"
string atts; // e.g. "pagelocked 4k^2"
string unit; // e.g. "MB/sec"
vector<double> value; // e.g. "837.14"
double GetMin() const;
double GetMax() const;
double GetMedian() const;
@@ -59,41 +57,32 @@ class ResultDatabase
double GetMean() const;
double GetStdDev() const;
bool operator<(const Result &rhs) const;
bool operator<(const Result& rhs) const;
bool HadAnyFLTMAXValues() const
{
for (int i=0; i<value.size(); ++i)
{
if (value[i] >= FLT_MAX)
return true;
bool HadAnyFLTMAXValues() const {
for (int i = 0; i < value.size(); ++i) {
if (value[i] >= FLT_MAX) return true;
}
return false;
}
};
protected:
protected:
vector<Result> results;
public:
void AddResult(const string &test,
const string &atts,
const string &unit,
double value);
void AddResults(const string &test,
const string &atts,
const string &unit,
const vector<double> &values);
vector<Result> GetResultsForTest(const string &test);
const vector<Result> &GetResults() const;
public:
void AddResult(const string& test, const string& atts, const string& unit, double value);
void AddResults(const string& test, const string& atts, const string& unit,
const vector<double>& values);
vector<Result> GetResultsForTest(const string& test);
const vector<Result>& GetResults() const;
void ClearAllResults();
void DumpDetailed(ostream&);
void DumpSummary(ostream&);
void DumpCsv(string fileName);
private:
private:
bool IsFileEmpty(string fileName);
};
@@ -21,35 +21,34 @@ THE SOFTWARE.
*/
#include "hip/hip_runtime.h"
#include<iostream>
#include<time.h>
#include"ResultDatabase.h"
#include <iostream>
#include <time.h>
#include "ResultDatabase.h"
#define PRINT_PROGRESS 0
#define check(cmd) \
{\
hipError_t status = cmd;\
if(status != hipSuccess){ \
printf("error: '%s'(%d) from %s at %s:%d\n", \
hipGetErrorString(status), status, #cmd,\
__FILE__, __LINE__); \
abort(); \
}\
}
#define check(cmd) \
{ \
hipError_t status = cmd; \
if (status != hipSuccess) { \
printf("error: '%s'(%d) from %s at %s:%d\n", hipGetErrorString(status), status, #cmd, \
__FILE__, __LINE__); \
abort(); \
} \
}
#define LEN 1024*1024
#define LEN 1024 * 1024
#define NUM_GROUPS 1
#define GROUP_SIZE 64
#define TEST_ITERS 20
#define TEST_ITERS 20
#define DISPATCHES_PER_TEST 100
const unsigned p_tests = 0xfffffff;
// HCC optimizes away fully NULL kernel calls, so run one that is nearly null:
__global__ void NearlyNull(hipLaunchParm lp, float* Ad){
__global__ void NearlyNull(hipLaunchParm lp, float* Ad) {
if (Ad) {
Ad[0] = 42;
}
@@ -59,38 +58,35 @@ __global__ void NearlyNull(hipLaunchParm lp, float* Ad){
ResultDatabase resultDB;
void stopTest(hipEvent_t start, hipEvent_t stop, const char *msg, int iters)
{
float mS = 0;
void stopTest(hipEvent_t start, hipEvent_t stop, const char* msg, int iters) {
float mS = 0;
check(hipEventRecord(stop));
check(hipDeviceSynchronize());
check(hipEventElapsedTime(&mS, start, stop));
resultDB.AddResult(std::string(msg), "", "uS", mS*1000/iters);
if (PRINT_PROGRESS & 0x1 ) {
std::cout<< msg <<"\t\t"<<mS*1000/iters<<" uS"<<std::endl;
resultDB.AddResult(std::string(msg), "", "uS", mS * 1000 / iters);
if (PRINT_PROGRESS & 0x1) {
std::cout << msg << "\t\t" << mS * 1000 / iters << " uS" << std::endl;
}
if (PRINT_PROGRESS & 0x2 ) {
if (PRINT_PROGRESS & 0x2) {
resultDB.DumpSummary(std::cout);
}
}
int main(){
hipError_t err;
float *Ad;
int main() {
hipError_t err;
float* Ad;
check(hipMalloc(&Ad, 4));
hipStream_t stream;
check(hipStreamCreate(&stream));
hipStream_t stream;
check(hipStreamCreate(&stream));
hipEvent_t start, sync, stop;
check(hipEventCreate(&start));
check(hipEventCreateWithFlags(&sync, hipEventBlockingSync));
check(hipEventCreate(&stop));
hipEvent_t start, sync, stop;
check(hipEventCreate(&start));
check(hipEventCreateWithFlags(&sync, hipEventBlockingSync));
check(hipEventCreate(&stop));
hipStream_t stream0 = 0;
@@ -103,7 +99,6 @@ int main(){
}
if (p_tests & 0x2) {
hipEventRecord(start);
hipLaunchKernel(NearlyNull, dim3(NUM_GROUPS), dim3(GROUP_SIZE), 0, stream0, Ad);
@@ -112,9 +107,9 @@ int main(){
if (p_tests & 0x4) {
for (int t=0; t<TEST_ITERS; t++) {
for (int t = 0; t < TEST_ITERS; t++) {
hipEventRecord(start);
for(int i=0;i<DISPATCHES_PER_TEST;i++){
for (int i = 0; i < DISPATCHES_PER_TEST; i++) {
hipLaunchKernel(NearlyNull, dim3(NUM_GROUPS), dim3(GROUP_SIZE), 0, stream0, Ad);
hipEventRecord(sync);
hipEventSynchronize(sync);
@@ -125,9 +120,9 @@ int main(){
if (p_tests & 0x10) {
for (int t=0; t<TEST_ITERS; t++) {
for (int t = 0; t < TEST_ITERS; t++) {
hipEventRecord(start);
for(int i=0;i<DISPATCHES_PER_TEST;i++){
for (int i = 0; i < DISPATCHES_PER_TEST; i++) {
hipLaunchKernel(NearlyNull, dim3(NUM_GROUPS), dim3(GROUP_SIZE), 0, stream, Ad);
hipEventRecord(sync);
hipEventSynchronize(sync);
@@ -139,9 +134,9 @@ int main(){
#if 1
if (p_tests & 0x40) {
for (int t=0; t<TEST_ITERS; t++) {
for (int t = 0; t < TEST_ITERS; t++) {
hipEventRecord(start);
for(int i=0;i<DISPATCHES_PER_TEST;i++){
for (int i = 0; i < DISPATCHES_PER_TEST; i++) {
hipLaunchKernel(NearlyNull, dim3(NUM_GROUPS), dim3(GROUP_SIZE), 0, stream0, Ad);
}
stopTest(start, stop, "NullStreamASyncDispatchNoWait", DISPATCHES_PER_TEST);
@@ -149,9 +144,9 @@ int main(){
}
if (p_tests & 0x80) {
for (int t=0; t<TEST_ITERS; t++) {
for (int t = 0; t < TEST_ITERS; t++) {
hipEventRecord(start);
for(int i=0;i<DISPATCHES_PER_TEST;i++){
for (int i = 0; i < DISPATCHES_PER_TEST; i++) {
hipLaunchKernel(NearlyNull, dim3(NUM_GROUPS), dim3(GROUP_SIZE), 0, stream, Ad);
}
stopTest(start, stop, "StreamASyncDispatchNoWait", DISPATCHES_PER_TEST);
@@ -161,7 +156,7 @@ int main(){
resultDB.DumpSummary(std::cout);
check(hipEventDestroy(start));
check(hipEventDestroy(sync));
check(hipEventDestroy(stop));
check(hipEventDestroy(start));
check(hipEventDestroy(sync));
check(hipEventDestroy(stop));
}
+70 -68
Ver fichero
@@ -24,61 +24,57 @@ THE SOFTWARE.
#include <iomanip>
#include "hip/hip_runtime.h"
#define KNRM "\x1B[0m"
#define KRED "\x1B[31m"
#define KGRN "\x1B[32m"
#define KYEL "\x1B[33m"
#define KBLU "\x1B[34m"
#define KMAG "\x1B[35m"
#define KCYN "\x1B[36m"
#define KWHT "\x1B[37m"
#define KNRM "\x1B[0m"
#define KRED "\x1B[31m"
#define KGRN "\x1B[32m"
#define KYEL "\x1B[33m"
#define KBLU "\x1B[34m"
#define KMAG "\x1B[35m"
#define KCYN "\x1B[36m"
#define KWHT "\x1B[37m"
#define failed(...) \
printf ("%serror: ", KRED);\
printf (__VA_ARGS__);\
printf ("\n");\
printf ("error: TEST FAILED\n%s", KNRM );\
#define failed(...) \
printf("%serror: ", KRED); \
printf(__VA_ARGS__); \
printf("\n"); \
printf("error: TEST FAILED\n%s", KNRM); \
exit(EXIT_FAILURE);
#define HIPCHECK(error) \
if (error != hipSuccess) { \
printf("%serror: '%s'(%d) at %s:%d%s\n", \
KRED, hipGetErrorString(error), error,\
__FILE__, __LINE__,KNRM);\
failed("API returned error code.");\
#define HIPCHECK(error) \
if (error != hipSuccess) { \
printf("%serror: '%s'(%d) at %s:%d%s\n", KRED, hipGetErrorString(error), error, __FILE__, \
__LINE__, KNRM); \
failed("API returned error code."); \
}
void printCompilerInfo ()
{
void printCompilerInfo() {
#ifdef __HCC__
printf ("compiler: hcc version=%s, workweek (YYWWD) = %u\n", __hcc_version__, __hcc_workweek__);
printf("compiler: hcc version=%s, workweek (YYWWD) = %u\n", __hcc_version__, __hcc_workweek__);
#endif
#ifdef __NVCC__
printf ("compiler: nvcc\n");
printf("compiler: nvcc\n");
#endif
}
double bytesToGB(size_t s)
{
return (double)s / (1024.0*1024.0*1024.0);
}
double bytesToGB(size_t s) { return (double)s / (1024.0 * 1024.0 * 1024.0); }
#define printLimit(w1, limit, units) \
{\
size_t val;\
cudaDeviceGetLimit(&val, limit);\
std::cout << setw(w1) << #limit": " << val << " " << units << std::endl;\
}
#define printLimit(w1, limit, units) \
{ \
size_t val; \
cudaDeviceGetLimit(&val, limit); \
std::cout << setw(w1) << #limit ": " << val << " " << units << std::endl; \
}
void printDeviceProp (int deviceId)
{
void printDeviceProp(int deviceId) {
using namespace std;
const int w1 = 34;
cout << left;
cout << setw(w1) << "--------------------------------------------------------------------------------" << endl;
cout << setw(w1)
<< "--------------------------------------------------------------------------------"
<< endl;
cout << setw(w1) << "device#" << deviceId << endl;
hipDeviceProp_t props;
@@ -88,16 +84,22 @@ void printDeviceProp (int deviceId)
cout << setw(w1) << "pciBusID: " << props.pciBusID << endl;
cout << setw(w1) << "pciDeviceID: " << props.pciDeviceID << endl;
cout << setw(w1) << "multiProcessorCount: " << props.multiProcessorCount << endl;
cout << setw(w1) << "maxThreadsPerMultiProcessor: " << props.maxThreadsPerMultiProcessor << endl;
cout << setw(w1) << "maxThreadsPerMultiProcessor: " << props.maxThreadsPerMultiProcessor
<< endl;
cout << setw(w1) << "isMultiGpuBoard: " << props.isMultiGpuBoard << endl;
cout << setw(w1) << "clockRate: " << (float)props.clockRate / 1000.0 << " Mhz" << endl;
cout << setw(w1) << "memoryClockRate: " << (float)props.memoryClockRate / 1000.0 << " Mhz" << endl;
cout << setw(w1) << "memoryClockRate: " << (float)props.memoryClockRate / 1000.0 << " Mhz"
<< endl;
cout << setw(w1) << "memoryBusWidth: " << props.memoryBusWidth << endl;
cout << setw(w1) << "clockInstructionRate: " << (float)props.clockInstructionRate / 1000.0 << " Mhz" << endl;
cout << setw(w1) << "totalGlobalMem: " << fixed << setprecision(2) << bytesToGB(props.totalGlobalMem) << " GB" << endl;
cout << setw(w1) << "maxSharedMemoryPerMultiProcessor: " << fixed << setprecision(2) << bytesToGB(props.maxSharedMemoryPerMultiProcessor) << " GB" << endl;
cout << setw(w1) << "clockInstructionRate: " << (float)props.clockInstructionRate / 1000.0
<< " Mhz" << endl;
cout << setw(w1) << "totalGlobalMem: " << fixed << setprecision(2)
<< bytesToGB(props.totalGlobalMem) << " GB" << endl;
cout << setw(w1) << "maxSharedMemoryPerMultiProcessor: " << fixed << setprecision(2)
<< bytesToGB(props.maxSharedMemoryPerMultiProcessor) << " GB" << endl;
cout << setw(w1) << "totalConstMem: " << props.totalConstMem << endl;
cout << setw(w1) << "sharedMemPerBlock: " << (float)props.sharedMemPerBlock / 1024.0 << " KB" << endl;
cout << setw(w1) << "sharedMemPerBlock: " << (float)props.sharedMemPerBlock / 1024.0 << " KB"
<< endl;
cout << setw(w1) << "regsPerBlock: " << props.regsPerBlock << endl;
cout << setw(w1) << "warpSize: " << props.warpSize << endl;
cout << setw(w1) << "l2CacheSize: " << props.l2CacheSize << endl;
@@ -112,29 +114,31 @@ void printDeviceProp (int deviceId)
cout << setw(w1) << "major: " << props.major << endl;
cout << setw(w1) << "minor: " << props.minor << endl;
cout << setw(w1) << "concurrentKernels: " << props.concurrentKernels << endl;
cout << setw(w1) << "arch.hasGlobalInt32Atomics: " << props.arch.hasGlobalInt32Atomics << endl;
cout << setw(w1) << "arch.hasGlobalFloatAtomicExch: " << props.arch.hasGlobalFloatAtomicExch << endl;
cout << setw(w1) << "arch.hasSharedInt32Atomics: " << props.arch.hasSharedInt32Atomics << endl;
cout << setw(w1) << "arch.hasSharedFloatAtomicExch: " << props.arch.hasSharedFloatAtomicExch << endl;
cout << setw(w1) << "arch.hasFloatAtomicAdd: " << props.arch.hasFloatAtomicAdd << endl;
cout << setw(w1) << "arch.hasGlobalInt64Atomics: " << props.arch.hasGlobalInt64Atomics << endl;
cout << setw(w1) << "arch.hasSharedInt64Atomics: " << props.arch.hasSharedInt64Atomics << endl;
cout << setw(w1) << "arch.hasDoubles: " << props.arch.hasDoubles << endl;
cout << setw(w1) << "arch.hasWarpVote: " << props.arch.hasWarpVote << endl;
cout << setw(w1) << "arch.hasWarpBallot: " << props.arch.hasWarpBallot << endl;
cout << setw(w1) << "arch.hasWarpShuffle: " << props.arch.hasWarpShuffle << endl;
cout << setw(w1) << "arch.hasFunnelShift: " << props.arch.hasFunnelShift << endl;
cout << setw(w1) << "arch.hasThreadFenceSystem: " << props.arch.hasThreadFenceSystem << endl;
cout << setw(w1) << "arch.hasSyncThreadsExt: " << props.arch.hasSyncThreadsExt << endl;
cout << setw(w1) << "arch.hasSurfaceFuncs: " << props.arch.hasSurfaceFuncs << endl;
cout << setw(w1) << "arch.has3dGrid: " << props.arch.has3dGrid << endl;
cout << setw(w1) << "arch.hasDynamicParallelism: " << props.arch.hasDynamicParallelism << endl;
cout << setw(w1) << "gcnArch: " << props.gcnArch << endl;
cout << setw(w1) << "arch.hasGlobalInt32Atomics: " << props.arch.hasGlobalInt32Atomics << endl;
cout << setw(w1) << "arch.hasGlobalFloatAtomicExch: " << props.arch.hasGlobalFloatAtomicExch
<< endl;
cout << setw(w1) << "arch.hasSharedInt32Atomics: " << props.arch.hasSharedInt32Atomics << endl;
cout << setw(w1) << "arch.hasSharedFloatAtomicExch: " << props.arch.hasSharedFloatAtomicExch
<< endl;
cout << setw(w1) << "arch.hasFloatAtomicAdd: " << props.arch.hasFloatAtomicAdd << endl;
cout << setw(w1) << "arch.hasGlobalInt64Atomics: " << props.arch.hasGlobalInt64Atomics << endl;
cout << setw(w1) << "arch.hasSharedInt64Atomics: " << props.arch.hasSharedInt64Atomics << endl;
cout << setw(w1) << "arch.hasDoubles: " << props.arch.hasDoubles << endl;
cout << setw(w1) << "arch.hasWarpVote: " << props.arch.hasWarpVote << endl;
cout << setw(w1) << "arch.hasWarpBallot: " << props.arch.hasWarpBallot << endl;
cout << setw(w1) << "arch.hasWarpShuffle: " << props.arch.hasWarpShuffle << endl;
cout << setw(w1) << "arch.hasFunnelShift: " << props.arch.hasFunnelShift << endl;
cout << setw(w1) << "arch.hasThreadFenceSystem: " << props.arch.hasThreadFenceSystem << endl;
cout << setw(w1) << "arch.hasSyncThreadsExt: " << props.arch.hasSyncThreadsExt << endl;
cout << setw(w1) << "arch.hasSurfaceFuncs: " << props.arch.hasSurfaceFuncs << endl;
cout << setw(w1) << "arch.has3dGrid: " << props.arch.has3dGrid << endl;
cout << setw(w1) << "arch.hasDynamicParallelism: " << props.arch.hasDynamicParallelism << endl;
cout << setw(w1) << "gcnArch: " << props.gcnArch << endl;
int deviceCnt;
hipGetDeviceCount(&deviceCnt);
cout << setw(w1) << "peers: ";
for (int i=0; i<deviceCnt; i++) {
for (int i = 0; i < deviceCnt; i++) {
int isPeer;
hipDeviceCanAccessPeer(&isPeer, i, deviceId);
if (isPeer) {
@@ -143,7 +147,7 @@ void printDeviceProp (int deviceId)
}
cout << endl;
cout << setw(w1) << "non-peers: ";
for (int i=0; i<deviceCnt; i++) {
for (int i = 0; i < deviceCnt; i++) {
int isPeer;
hipDeviceCanAccessPeer(&isPeer, i, deviceId);
if (!isPeer) {
@@ -164,8 +168,6 @@ void printDeviceProp (int deviceId)
#endif
cout << endl;
@@ -174,11 +176,11 @@ void printDeviceProp (int deviceId)
cout << fixed << setprecision(2);
cout << setw(w1) << "memInfo.total: " << bytesToGB(total) << " GB" << endl;
cout << setw(w1) << "memInfo.free: " << bytesToGB(free) << " GB (" << setprecision(0) << (float)free/total * 100.0 << "%)" << endl;
cout << setw(w1) << "memInfo.free: " << bytesToGB(free) << " GB (" << setprecision(0)
<< (float)free / total * 100.0 << "%)" << endl;
}
int main(int argc, char *argv[])
{
int main(int argc, char* argv[]) {
using namespace std;
cout << endl;
@@ -189,7 +191,7 @@ int main(int argc, char *argv[])
HIPCHECK(hipGetDeviceCount(&deviceCnt));
for (int i=0; i< deviceCnt; i++) {
for (int i = 0; i < deviceCnt; i++) {
printDeviceProp(i);
}