From d4eb3e0d35194baa40d826c4084e3228b4c149e2 Mon Sep 17 00:00:00 2001 From: jpekkila Date: Mon, 30 Mar 2020 17:41:42 +0300 Subject: [PATCH] Benchmarks are now written into a csv-file --- samples/benchmark/main.cc | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/samples/benchmark/main.cc b/samples/benchmark/main.cc index 0bd798f..d343bc9 100644 --- a/samples/benchmark/main.cc +++ b/samples/benchmark/main.cc @@ -22,6 +22,7 @@ #include "astaroth.h" #include "astaroth_utils.h" +#include "errchk.h" #include "timer_hires.h" #if AC_MPI_ENABLED @@ -99,12 +100,24 @@ main(void) results.push_back(timer_diff_nsec(t) / 1e6); } - std::sort(results.begin(), results.end(), - [](const double& a, const double& b) { return a < b; }); - fprintf(stdout, - "Integration step time %g ms (%gth percentile)--------------------------------------\n", - results[nth_percentile * num_iters], 100 * nth_percentile); - acGridSynchronizeStream(STREAM_ALL); + // Write benchmark to file + if (!pid) { + std::sort(results.begin(), results.end(), + [](const double& a, const double& b) { return a < b; }); + fprintf(stdout, + "Integration step time %g ms (%gth " + "percentile)--------------------------------------\n", + results[nth_percentile * num_iters], 100 * nth_percentile); + + const char* path = "strong_scaling.csv"; + FILE* fp = fopen(path, "a"); + ERRCHK_ALWAYS(fp); + // Format + // nprocs, measured (ms) + fprintf(fp, "%d, %g\n", nprocs, results[nth_percentile * num_iters]); + + fclose(fp); + } acGridQuit(); MPI_Finalize();