From 5ee832f7386b44a8ce8d15747c04dd0e1fc9d7c4 Mon Sep 17 00:00:00 2001 From: Antonin Portelli Date: Wed, 7 Oct 2020 15:31:51 +0100 Subject: [PATCH] I/O benchmark code cleaning --- benchmarks/Benchmark_IO.cc | 31 ++++++++-------- benchmarks/Benchmark_IO.hpp | 4 +-- benchmarks/Benchmark_IO_vs_dir.cc | 59 +++++++++++++++++-------------- 3 files changed, 50 insertions(+), 44 deletions(-) diff --git a/benchmarks/Benchmark_IO.cc b/benchmarks/Benchmark_IO.cc index b59e4741..5e4cef9f 100644 --- a/benchmarks/Benchmark_IO.cc +++ b/benchmarks/Benchmark_IO.cc @@ -14,61 +14,62 @@ std::string filestem(const int l) int main (int argc, char ** argv) { -#ifdef HAVE_LIME Grid_init(&argc,&argv); - int64_t threads = GridThread::GetThreads(); + int64_t threads = GridThread::GetThreads(); + auto mpi = GridDefaultMpi(); + std::vector latt; + MSG << "Grid is setup to use " << threads << " threads" << std::endl; + MSG << "MPI partition " << mpi << std::endl; MSG << SEP << std::endl; - MSG << "Benchmark std C++ write" << std::endl; + MSG << "Benchmark std write" << std::endl; MSG << SEP << std::endl; for (int l = 4; l <= BENCH_IO_LMAX; l += 2) { - auto mpi = GridDefaultMpi(); - std::vector latt = {l*mpi[0], l*mpi[1], l*mpi[2], l*mpi[3]}; + latt = {l*mpi[0], l*mpi[1], l*mpi[2], l*mpi[3]}; MSG << "-- Local volume " << l << "^4" << std::endl; writeBenchmark(latt, filestem(l), stdWrite); } MSG << SEP << std::endl; - MSG << "Benchmark std C++ read" << std::endl; + MSG << "Benchmark std read" << std::endl; MSG << SEP << std::endl; for (int l = 4; l <= BENCH_IO_LMAX; l += 2) { - auto mpi = GridDefaultMpi(); - std::vector latt = {l*mpi[0], l*mpi[1], l*mpi[2], l*mpi[3]}; + latt = {l*mpi[0], l*mpi[1], l*mpi[2], l*mpi[3]}; MSG << "-- Local volume " << l << "^4" << std::endl; readBenchmark(latt, filestem(l), stdRead); } +#ifdef HAVE_LIME MSG << SEP << std::endl; - MSG << "Benchmark Lime write" << std::endl; + MSG << "Benchmark Grid C-Lime write" << std::endl; MSG << SEP << std::endl; for (int l = 4; l <= BENCH_IO_LMAX; l += 2) { - auto mpi = GridDefaultMpi(); - std::vector latt = {l*mpi[0], l*mpi[1], l*mpi[2], l*mpi[3]}; + latt = {l*mpi[0], l*mpi[1], l*mpi[2], l*mpi[3]}; MSG << "-- Local volume " << l << "^4" << std::endl; writeBenchmark(latt, filestem(l), limeWrite); } MSG << SEP << std::endl; - MSG << "Benchmark Lime read" << std::endl; + MSG << "Benchmark Grid C-Lime read" << std::endl; MSG << SEP << std::endl; for (int l = 4; l <= BENCH_IO_LMAX; l += 2) { - auto mpi = GridDefaultMpi(); - std::vector latt = {l*mpi[0], l*mpi[1], l*mpi[2], l*mpi[3]}; + latt = {l*mpi[0], l*mpi[1], l*mpi[2], l*mpi[3]}; MSG << "-- Local volume " << l << "^4" << std::endl; readBenchmark(latt, filestem(l), limeRead); } +#endif Grid_finalize(); -#endif + return EXIT_SUCCESS; } diff --git a/benchmarks/Benchmark_IO.hpp b/benchmarks/Benchmark_IO.hpp index 73c198dc..39af14ba 100644 --- a/benchmarks/Benchmark_IO.hpp +++ b/benchmarks/Benchmark_IO.hpp @@ -101,7 +101,7 @@ void stdWrite(const std::string filestem, Field &vec) ioWatch.Stop(); size *= vec.Grid()->ProcessorCount(); MSG << "Std I/O write: Wrote " << size << " bytes in " << ioWatch.Elapsed() - << ", performance " << size/1024./1024./(ioWatch.useconds()/1.e6) + << ", " << size/1024./1024./(ioWatch.useconds()/1.e6) << " MB/s" << std::endl; MSG << "Std I/O write: checksum overhead " << crcWatch.Elapsed() << std::endl; } @@ -136,7 +136,7 @@ void stdRead(Field &vec, const std::string filestem) assert(crcData == crcRead); size *= vec.Grid()->ProcessorCount(); MSG << "Std I/O read: Read " << size << " bytes in " << ioWatch.Elapsed() - << ", performance " << size/1024./1024./(ioWatch.useconds()/1.e6) + << ", " << size/1024./1024./(ioWatch.useconds()/1.e6) << " MB/s" << std::endl; MSG << "Std I/O read: checksum overhead " << crcWatch.Elapsed() << std::endl; } diff --git a/benchmarks/Benchmark_IO_vs_dir.cc b/benchmarks/Benchmark_IO_vs_dir.cc index 6e6c9ae0..9c254e27 100644 --- a/benchmarks/Benchmark_IO_vs_dir.cc +++ b/benchmarks/Benchmark_IO_vs_dir.cc @@ -34,46 +34,51 @@ int main (int argc, char ** argv) } Grid_init(&argc,&argv); - int64_t threads = GridThread::GetThreads(); + auto mpi = GridDefaultMpi(); + MSG << "Grid is setup to use " << threads << " threads" << std::endl; - MSG << SEP << std::endl; - MSG << "Benchmark double precision Lime write" << std::endl; - MSG << SEP << std::endl; - for (auto &d: dir) - { - MSG << "-- Directory " << d << std::endl; - writeBenchmark(GridDefaultLatt(), d + "/ioBench", limeWrite, Ls, rb); - } + MSG << "MPI partition " << mpi << std::endl; MSG << SEP << std::endl; - MSG << "Benchmark double precision Lime read" << std::endl; + MSG << "Benchmark Grid C-Lime write" << std::endl; MSG << SEP << std::endl; for (auto &d: dir) { MSG << "-- Directory " << d << std::endl; - readBenchmark(GridDefaultLatt(), d + "/ioBench", limeRead, Ls, rb); + writeBenchmark(GridDefaultLatt(), d + "/ioBench", + limeWrite, Ls, rb); + } + MSG << SEP << std::endl; + MSG << "Benchmark Grid C-Lime read" << std::endl; + MSG << SEP << std::endl; + for (auto &d: dir) + { + MSG << "-- Directory " << d << std::endl; + readBenchmark(GridDefaultLatt(), d + "/ioBench", + limeRead, Ls, rb); } - MSG << SEP << std::endl; - MSG << "Benchmark single precision Lime write" << std::endl; - MSG << SEP << std::endl; - for (auto &d: dir) - { - MSG << "-- Directory " << d << std::endl; - writeBenchmark(GridDefaultLatt(), d + "/ioBench", limeWrite, Ls, rb); - } + // MSG << SEP << std::endl; + // MSG << "Benchmark single precision Lime write" << std::endl; + // MSG << SEP << std::endl; + // for (auto &d: dir) + // { + // MSG << "-- Directory " << d << std::endl; + // writeBenchmark(GridDefaultLatt(), d + "/ioBench", limeWrite, Ls, rb); + // } - MSG << SEP << std::endl; - MSG << "Benchmark single precision Lime read" << std::endl; - MSG << SEP << std::endl; - for (auto &d: dir) - { - MSG << "-- Directory " << d << std::endl; - readBenchmark(GridDefaultLatt(), d + "/ioBench", limeRead, Ls, rb); - } + // MSG << SEP << std::endl; + // MSG << "Benchmark single precision Lime read" << std::endl; + // MSG << SEP << std::endl; + // for (auto &d: dir) + // { + // MSG << "-- Directory " << d << std::endl; + // readBenchmark(GridDefaultLatt(), d + "/ioBench", limeRead, Ls, rb); + // } Grid_finalize(); + #endif return EXIT_SUCCESS; }