Compare commits

...

2 Commits

Author SHA1 Message Date
f7e607eae4 proper warmup loop for latency 2024-05-09 23:33:04 +01:00
a267986800 naming consitency 2024-05-09 23:25:06 +01:00

View File

@ -264,16 +264,17 @@ class Benchmark
return; return;
} }
static void PointToPoint(void) static void Latency(void)
{ {
int Nloop = 200; int Nwarmup = 100;
int Nloop = 1000;
Coordinate simd_layout = GridDefaultSimd(Nd, vComplexD::Nsimd()); Coordinate simd_layout = GridDefaultSimd(Nd, vComplexD::Nsimd());
Coordinate mpi_layout = GridDefaultMpi(); Coordinate mpi_layout = GridDefaultMpi();
std::cout << GridLogMessage << "Benchmarking point-to-point latency" << std::endl; std::cout << GridLogMessage << "Benchmarking point-to-point latency" << std::endl;
grid_small_sep(); grid_small_sep();
grid_printf("from to mean(usec) err min\n"); grid_printf("from to mean(usec) err min\n");
int lat = 8; // dummy lattice size. Not actually used. int lat = 8; // dummy lattice size. Not actually used.
Coordinate latt_size({lat * mpi_layout[0], lat * mpi_layout[1], lat * mpi_layout[2], Coordinate latt_size({lat * mpi_layout[0], lat * mpi_layout[1], lat * mpi_layout[2],
@ -291,7 +292,7 @@ class Benchmark
int bytes = 8; int bytes = 8;
void *buf_from = acceleratorAllocDevice(bytes); void *buf_from = acceleratorAllocDevice(bytes);
void *buf_to = acceleratorAllocDevice(bytes); void *buf_to = acceleratorAllocDevice(bytes);
nlohmann::json json_p2p; nlohmann::json json_latency;
for (int from = 0; from < ranks; ++from) for (int from = 0; from < ranks; ++from)
for (int to = 0; to < ranks; ++to) for (int to = 0; to < ranks; ++to)
{ {
@ -302,7 +303,7 @@ class Benchmark
time_statistics timestat; time_statistics timestat;
MPI_Status status; MPI_Status status;
for (int i = 0; i < Nloop; ++i) for (int i = -Nwarmup; i < Nloop; ++i)
{ {
double start = usecond(); double start = usecond();
if (from == me) if (from == me)
@ -321,7 +322,8 @@ class Benchmark
assert(err == MPI_SUCCESS); assert(err == MPI_SUCCESS);
} }
double stop = usecond(); double stop = usecond();
t_time[i] = stop - start; if (i >= 0)
t_time[i] = stop - start;
} }
// important: only the 'from' rank has a trustworthy time // important: only the 'from' rank has a trustworthy time
MPI_Bcast(t_time.data(), Nloop, MPI_DOUBLE, from, Grid.communicator); MPI_Bcast(t_time.data(), Nloop, MPI_DOUBLE, from, Grid.communicator);
@ -335,9 +337,9 @@ class Benchmark
tmp["time_usec"] = timestat.mean; tmp["time_usec"] = timestat.mean;
tmp["time_usec_error"] = timestat.err; tmp["time_usec_error"] = timestat.err;
tmp["time_usec_max"] = timestat.min; tmp["time_usec_max"] = timestat.min;
json_p2p.push_back(tmp); json_latency.push_back(tmp);
} }
json_results["latency"] = json_p2p; json_results["latency"] = json_latency;
acceleratorFreeDevice(buf_from); acceleratorFreeDevice(buf_from);
acceleratorFreeDevice(buf_to); acceleratorFreeDevice(buf_to);
@ -884,7 +886,7 @@ int main(int argc, char **argv)
int do_su4 = 1; int do_su4 = 1;
int do_memory = 1; int do_memory = 1;
int do_comms = 1; int do_comms = 1;
int do_p2p = 1; int do_latency = 1;
int do_flops = 1; int do_flops = 1;
int Ls = 1; int Ls = 1;
@ -920,12 +922,12 @@ int main(int argc, char **argv)
Benchmark::Comms(); Benchmark::Comms();
} }
if (do_p2p) if (do_latency)
{ {
grid_big_sep(); grid_big_sep();
std::cout << GridLogMessage << " Point-to-Point benchmark " << std::endl; std::cout << GridLogMessage << " Latency benchmark " << std::endl;
grid_big_sep(); grid_big_sep();
Benchmark::PointToPoint(); Benchmark::Latency();
} }
if (do_flops) if (do_flops)