Commit 77c28d57 authored by Jens Korinth's avatar Jens Korinth
Browse files

Fix output bug in tapasco-benchmark

* forgot to output final values, resulting in erroneous readouts
* switched back to high_resolution_clock, since wrong values were
  unrelated to the steadiness of the clock
parent 53d35035
...@@ -64,6 +64,9 @@ public: ...@@ -64,6 +64,9 @@ public:
} while (c == ERR && (fabs(cavg.delta()) > 0.01 || cavg.size() < min_runs)); } while (c == ERR && (fabs(cavg.delta()) > 0.01 || cavg.size() < min_runs));
stop = true; stop = true;
f.get(); f.get();
mvprintw(y, x, "Runtime: %12zu cc, Latency: % 12.1f, Min: % 12.1f, Max: % 12.1f, Count: %zu/%zu",
clock_cycles, cavg(), cavg.min(), cavg.max(), cavg.size(), min_runs);
refresh();
move((y+1) % maxy, 0); move((y+1) % maxy, 0);
if (min) *min = cavg.min(); if (min) *min = cavg.min();
...@@ -75,12 +78,12 @@ private: ...@@ -75,12 +78,12 @@ private:
void trigger(volatile bool& stop, uint32_t const clock_cycles, CumulativeAverage<double>& cavg) { void trigger(volatile bool& stop, uint32_t const clock_cycles, CumulativeAverage<double>& cavg) {
tapasco_res_t res; tapasco_res_t res;
while (! stop) { while (! stop) {
auto tstart = steady_clock::now(); auto tstart = high_resolution_clock::now();
// if 0, use 1us - 100ms interval (clock period is 10ns) // if 0, use 1us - 100ms interval (clock period is 10ns)
uint32_t cc = clock_cycles > 0 ? clock_cycles : (rand() % (10000000 - 100) + 100); uint32_t cc = clock_cycles > 0 ? clock_cycles : (rand() % (10000000 - 100) + 100);
if ((res = tapasco.launch_no_return(COUNTER_ID, cc)) != TAPASCO_SUCCESS) if ((res = tapasco.launch_no_return(COUNTER_ID, cc)) != TAPASCO_SUCCESS)
throw Tapasco::tapasco_error(res); throw Tapasco::tapasco_error(res);
microseconds const d = duration_cast<microseconds>(steady_clock::now() - tstart); microseconds const d = duration_cast<microseconds>(high_resolution_clock::now() - tstart);
cavg.update(d.count() - cc / 100); cavg.update(d.count() - cc / 100);
} }
} }
......
...@@ -36,7 +36,7 @@ public: ...@@ -36,7 +36,7 @@ public:
int x, y; int x, y;
getyx(stdscr, y, x); getyx(stdscr, y, x);
vector<future<void> > threads; vector<future<void> > threads;
auto const t_start = steady_clock::now(); auto const t_start = high_resolution_clock::now();
for (size_t t = 0; t < num_threads; ++t) for (size_t t = 0; t < num_threads; ++t)
threads.push_back(async(launch::async, [&]() { run(stop, jobs); })); threads.push_back(async(launch::async, [&]() { run(stop, jobs); }));
auto c = getch(); auto c = getch();
...@@ -48,7 +48,7 @@ public: ...@@ -48,7 +48,7 @@ public:
refresh(); refresh();
usleep(5000000); usleep(5000000);
auto const j = jobs.load(); auto const j = jobs.load();
auto const t = steady_clock::now(); auto const t = high_resolution_clock::now();
auto const s = duration_cast<seconds>(t - t_start); auto const s = duration_cast<seconds>(t - t_start);
auto const v = s.count() > 0 ? static_cast<double>(j) / static_cast<double>(s.count()) : 0.0; auto const v = s.count() > 0 ? static_cast<double>(j) / static_cast<double>(s.count()) : 0.0;
if (v > 10.0) cavg.update(v); if (v > 10.0) cavg.update(v);
...@@ -59,6 +59,12 @@ public: ...@@ -59,6 +59,12 @@ public:
stop = true; stop = true;
for (auto &f : threads) for (auto &f : threads)
f.get(); f.get();
move(y, 0);
clrtoeol();
mvprintw(y, x, "Num threads: % 2zu, jobs/second: % 12.1f, max: % 12.f, min: % 12.1f",
num_threads, cavg(), cavg.max(), cavg.min());
refresh();
move(y+1, 0); move(y+1, 0);
return cavg(); return cavg();
} }
......
...@@ -39,9 +39,9 @@ public: ...@@ -39,9 +39,9 @@ public:
bytes = 0; bytes = 0;
int x, y; int x, y;
getyx(stdscr, y, x); getyx(stdscr, y, x);
auto tstart = steady_clock::now(); auto tstart = high_resolution_clock::now();
double b = 0.0; double b = 0.0;
duration<double> d = steady_clock::now() - tstart; duration<double> d = high_resolution_clock::now() - tstart;
future<void> f = async(launch::async, [&]() { transfer(stop, chunk_sz, opmask); }); future<void> f = async(launch::async, [&]() { transfer(stop, chunk_sz, opmask); });
auto c = getch(); auto c = getch();
do { do {
...@@ -50,13 +50,17 @@ public: ...@@ -50,13 +50,17 @@ public:
refresh(); refresh();
usleep(1000000); usleep(1000000);
b = bytes.load() / (1024.0 * 1024.0); b = bytes.load() / (1024.0 * 1024.0);
d = steady_clock::now() - tstart; d = high_resolution_clock::now() - tstart;
// exit gracefully on ctrl+c // exit gracefully on ctrl+c
c = getch(); c = getch();
if (c == 3) { endwin(); exit(3); } if (c == 3) { endwin(); exit(3); }
} while (c == ERR && (fabs(cavg.update(b / d.count())) > 0.1 || cavg.size() < 30)); } while (c == ERR && (fabs(cavg.update(b / d.count())) > 0.1 || cavg.size() < 30));
stop = true; stop = true;
f.get(); f.get();
mvprintw(y, x, "Chunk size: %8.2f KiB, Mask: %s, Speed: %8.2f MiB/s",
cs, ms.c_str(), cavg());
refresh();
move(y+1, 0); move(y+1, 0);
return cavg(); return cavg();
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment