make Latency benchmark proper one-way and increase statistics

This commit is contained in:
Simon Bürger 2024-09-26 09:31:22 +01:00
parent f7e607eae4
commit 4cd67805b9

View File

@ -266,8 +266,8 @@ class Benchmark
static void Latency(void) static void Latency(void)
{ {
int Nwarmup = 100; int Nwarmup = 1000;
int Nloop = 1000; int Nloop = 10000;
Coordinate simd_layout = GridDefaultSimd(Nd, vComplexD::Nsimd()); Coordinate simd_layout = GridDefaultSimd(Nd, vComplexD::Nsimd());
Coordinate mpi_layout = GridDefaultMpi(); Coordinate mpi_layout = GridDefaultMpi();
@ -310,26 +310,22 @@ class Benchmark
{ {
auto err = MPI_Send(buf_from, bytes, MPI_CHAR, to, 0, Grid.communicator); auto err = MPI_Send(buf_from, bytes, MPI_CHAR, to, 0, Grid.communicator);
assert(err == MPI_SUCCESS); assert(err == MPI_SUCCESS);
err = MPI_Recv(buf_to, bytes, MPI_CHAR, to, 0, Grid.communicator, &status);
assert(err == MPI_SUCCESS);
} }
if (to == me) if (to == me)
{ {
auto err = auto err =
MPI_Recv(buf_to, bytes, MPI_CHAR, from, 0, Grid.communicator, &status); MPI_Recv(buf_to, bytes, MPI_CHAR, from, 0, Grid.communicator, &status);
assert(err == MPI_SUCCESS); assert(err == MPI_SUCCESS);
err = MPI_Send(buf_from, bytes, MPI_CHAR, from, 0, Grid.communicator);
assert(err == MPI_SUCCESS);
} }
double stop = usecond(); double stop = usecond();
if (i >= 0) if (i >= 0)
t_time[i] = stop - start; t_time[i] = stop - start;
} }
// important: only the 'from' rank has a trustworthy time // important: only 'from' and 'to' have meaningful timings. we use 'from's.
MPI_Bcast(t_time.data(), Nloop, MPI_DOUBLE, from, Grid.communicator); MPI_Bcast(t_time.data(), Nloop, MPI_DOUBLE, from, Grid.communicator);
timestat.statistics(t_time); timestat.statistics(t_time);
grid_printf("%2d %2d %15.2f %15.1f %15.2f\n", from, to, timestat.mean, grid_printf("%2d %2d %15.4f %15.3f %15.4f\n", from, to, timestat.mean,
timestat.err, timestat.min); timestat.err, timestat.min);
nlohmann::json tmp; nlohmann::json tmp;
tmp["from"] = from; tmp["from"] = from;