From ed1e94edaee8fb70e5c234b289242a6077656b17 Mon Sep 17 00:00:00 2001 From: Alejandro Gallo Date: Tue, 30 Nov 2021 12:05:22 +0100 Subject: [PATCH] Add printing mechanism test for bench --- bench/test_main.cxx | 35 ++++++++++++++++++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) diff --git a/bench/test_main.cxx b/bench/test_main.cxx index 65219b7..2861538 100644 --- a/bench/test_main.cxx +++ b/bench/test_main.cxx @@ -6,6 +6,7 @@ #include #include +#include #include #define _print_size(what, size) \ @@ -20,7 +21,7 @@ int main(int argc, char** argv) { MPI_Init(&argc, &argv); - int no(10), nv(10), itMod(100); + int no(10), nv(10), itMod(-1), percentageMod(10); bool nochrono(false), barrier(false), rankRoundRobin(false); std::string tuplesDistributionString = "naive"; @@ -32,6 +33,7 @@ int main(int argc, char** argv) { app.add_flag("--rank-round-robin", rankRoundRobin, "Do rank round robin"); app.add_flag("--barrier", barrier, "Use the first barrier"); app.add_option("--dist", tuplesDistributionString, "Which distribution"); + app.add_option("-%", percentageMod, "Percentage to be printed"); CLI11_PARSE(app, argc, argv); @@ -40,6 +42,36 @@ int main(int argc, char** argv) { MPI_Comm_rank(world.comm, &rank); constexpr double elem_to_gb = 8.0 / 1024.0 / 1024.0 / 1024.0; + const double doublesFlops + = double(no) + * double(no) + * double(no) + * (double(no) + double(nv)) + * 2 + * 6 + / 1e9 + ; + + bool firstHeader = true; + + atrip::registerIterationDescriptor + ([doublesFlops, &firstHeader, rank](atrip::IterationDescription const& d) { + const char + *fmt_header = "%-13s%-10s%-13s", + *fmt_nums = "%-13.0f%-10.0f%-13.3f"; + char out[256]; + if (firstHeader) { + sprintf(out, fmt_header, "Progress(%)", "time(s)", "GLFOP/s"); + firstHeader = false; + if (rank == 0) std::cout << out << "\n"; + } + sprintf(out, fmt_nums, + double(d.currentIteration) / double(d.totalIterations) * 100, + d.currentElapsedTime, + doublesFlops / d.currentElapsedTime); + if (rank == 0) std::cout << out << "\n"; + }); + atrip::Atrip::Input::TuplesDistribution tuplesDistribution; { using atrip::Atrip; @@ -97,6 +129,7 @@ int main(int argc, char** argv) { .with_chrono(!nochrono) .with_rankRoundRobin(rankRoundRobin) .with_iterationMod(itMod) + .with_percentageMod(percentageMod) .with_tuplesDistribution(tuplesDistribution) ;