diff --git a/samples/1_Utils/hipDispatchLatency/ResultDatabase.cpp b/samples/1_Utils/hipDispatchLatency/ResultDatabase.cpp index d207154e39..f6f2fab709 100644 --- a/samples/1_Utils/hipDispatchLatency/ResultDatabase.cpp +++ b/samples/1_Utils/hipDispatchLatency/ResultDatabase.cpp @@ -7,16 +7,23 @@ using namespace std; +#define SORT_BY_NAME 0 +#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) + // For ties, sort by the value of the attribute: if (atts < rhs.atts) return true; if (atts > rhs.atts) return false; +#endif return false; // less-operator returns false on equal } @@ -189,7 +196,10 @@ void ResultDatabase::AddResult(const string &test_orig, void ResultDatabase::DumpDetailed(ostream &out) { vector sorted(results); - sort(sorted.begin(), sorted.end()); + +#if SORT_BY_NAME + stable_sort(sorted.begin(), sorted.end()); +#endif const int testNameW = 24 ; const int attW = 12; @@ -283,12 +293,15 @@ void ResultDatabase::DumpDetailed(ostream &out) void ResultDatabase::DumpSummary(ostream &out) { vector sorted(results); - sort(sorted.begin(), sorted.end()); - const int testNameW = 24 ; +#if SORT_BY_NAME + stable_sort(sorted.begin(), sorted.end()); +#endif + + const int testNameW = 32 ; const int attW = 12; const int fieldW = 9; - out << std::fixed << right << std::setprecision(4); + 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.... @@ -334,8 +347,8 @@ void ResultDatabase::DumpSummary(ostream &out) } if (0) { out << endl - << "Note: results marked with (*) had missing values such as" << endl - << "might occur with a mixture of architectural capabilities." << endl; + << "Note: results marked with (*) had missing values such as" << endl + << "might occur with a mixture of architectural capabilities." << endl; } } @@ -381,7 +394,9 @@ void ResultDatabase::DumpCsv(string fileName) bool emptyFile; vector sorted(results); - sort(sorted.begin(), sorted.end()); +#if SORT_BY_NAME + stable_sort(sorted.begin(), sorted.end()); +#endif //Check to see if the file is empty - if so, add the headers emptyFile = this->IsFileEmpty(fileName); diff --git a/samples/1_Utils/hipDispatchLatency/hipDispatchLatency.cpp b/samples/1_Utils/hipDispatchLatency/hipDispatchLatency.cpp index b343386b5c..2a4f6ff649 100644 --- a/samples/1_Utils/hipDispatchLatency/hipDispatchLatency.cpp +++ b/samples/1_Utils/hipDispatchLatency/hipDispatchLatency.cpp @@ -25,15 +25,27 @@ THE SOFTWARE. #include #include"ResultDatabase.h" -#define check(msg, status) \ -if(status != hipSuccess){ \ - printf("%s failed.\n",#msg); \ - exit(1); \ +#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 LEN 1024*1024 -#define SIZE LEN * sizeof(float) -#define ITER 10120 + +#define NUM_GROUPS 1 +#define GROUP_SIZE 64 +#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: @@ -44,115 +56,112 @@ __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; + 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"<