Grid IO benchmark cleanup

This commit is contained in:
Antonin Portelli 2023-01-29 14:56:37 +00:00
parent ce890a8fc2
commit 51eae5723e
2 changed files with 64 additions and 76 deletions

View File

@ -32,7 +32,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#ifdef HAVE_LIME #ifdef HAVE_LIME
using namespace Grid; using namespace Grid;
std::string filestem(const int l) { return "iobench_l" + std::to_string(l); } std::string filestem(const int l) { return "io/iobench_l" + std::to_string(l); }
int vol(const int i) { return BENCH_IO_LMIN + 2 * i; } int vol(const int i) { return BENCH_IO_LMIN + 2 * i; }
@ -56,13 +56,6 @@ template <typename Mat> void stats(Mat &mean, Mat &stdDev, const std::vector<Mat
mean /= n; mean /= n;
} }
#define grid_printf(...) \
{ \
char _buf[1024]; \
sprintf(_buf, __VA_ARGS__); \
MSG << _buf; \
}
enum enum
{ {
sRead = 0, sRead = 0,
@ -83,58 +76,58 @@ int main(int argc, char **argv)
std::vector<Eigen::VectorXd> avPerf(BENCH_IO_NPASS, Eigen::VectorXd::Zero(4)); std::vector<Eigen::VectorXd> avPerf(BENCH_IO_NPASS, Eigen::VectorXd::Zero(4));
std::vector<int> latt; std::vector<int> latt;
MSG << "Grid is setup to use " << threads << " threads" << std::endl; GRID_MSG << "Grid is setup to use " << threads << " threads" << std::endl;
MSG << "MPI partition " << mpi << std::endl; GRID_MSG << "MPI partition " << mpi << std::endl;
for (unsigned int i = 0; i < BENCH_IO_NPASS; ++i) for (unsigned int i = 0; i < BENCH_IO_NPASS; ++i)
{ {
MSG << BIGSEP << std::endl; grid_big_sep();
MSG << "Pass " << i + 1 << "/" << BENCH_IO_NPASS << std::endl; GRID_MSG << "Pass " << i + 1 << "/" << BENCH_IO_NPASS << std::endl;
MSG << BIGSEP << std::endl; grid_big_sep();
MSG << SEP << std::endl; grid_small_sep();
MSG << "Benchmark std write" << std::endl; GRID_MSG << "Benchmark std write" << std::endl;
MSG << SEP << std::endl; grid_small_sep();
for (int l = BENCH_IO_LMIN; l <= BENCH_IO_LMAX; l += 2) for (int l = BENCH_IO_LMIN; l <= BENCH_IO_LMAX; l += 2)
{ {
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; GRID_MSG << "-- Local volume " << l << "^4" << std::endl;
writeBenchmark<LatticeFermion>(latt, filestem(l), stdWrite<LatticeFermion>); writeBenchmark<LatticeFermion>(latt, filestem(l), stdWrite<LatticeFermion>);
perf[i](volInd(l), sWrite) = BinaryIO::lastPerf.mbytesPerSecond; perf[i](volInd(l), sWrite) = BinaryIO::lastPerf.mbytesPerSecond;
} }
MSG << SEP << std::endl; grid_small_sep();
MSG << "Benchmark std read" << std::endl; GRID_MSG << "Benchmark std read" << std::endl;
MSG << SEP << std::endl; grid_small_sep();
for (int l = BENCH_IO_LMIN; l <= BENCH_IO_LMAX; l += 2) for (int l = BENCH_IO_LMIN; l <= BENCH_IO_LMAX; l += 2)
{ {
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; GRID_MSG << "-- Local volume " << l << "^4" << std::endl;
readBenchmark<LatticeFermion>(latt, filestem(l), stdRead<LatticeFermion>); readBenchmark<LatticeFermion>(latt, filestem(l), stdRead<LatticeFermion>);
perf[i](volInd(l), sRead) = BinaryIO::lastPerf.mbytesPerSecond; perf[i](volInd(l), sRead) = BinaryIO::lastPerf.mbytesPerSecond;
} }
#ifdef HAVE_LIME #ifdef HAVE_LIME
MSG << SEP << std::endl; grid_small_sep();
MSG << "Benchmark Grid C-Lime write" << std::endl; GRID_MSG << "Benchmark Grid C-Lime write" << std::endl;
MSG << SEP << std::endl; grid_small_sep();
for (int l = BENCH_IO_LMIN; l <= BENCH_IO_LMAX; l += 2) for (int l = BENCH_IO_LMIN; l <= BENCH_IO_LMAX; l += 2)
{ {
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; GRID_MSG << "-- Local volume " << l << "^4" << std::endl;
writeBenchmark<LatticeFermion>(latt, filestem(l), limeWrite<LatticeFermion>); writeBenchmark<LatticeFermion>(latt, filestem(l), limeWrite<LatticeFermion>);
perf[i](volInd(l), gWrite) = BinaryIO::lastPerf.mbytesPerSecond; perf[i](volInd(l), gWrite) = BinaryIO::lastPerf.mbytesPerSecond;
} }
MSG << SEP << std::endl; grid_small_sep();
MSG << "Benchmark Grid C-Lime read" << std::endl; GRID_MSG << "Benchmark Grid C-Lime read" << std::endl;
MSG << SEP << std::endl; grid_small_sep();
for (int l = BENCH_IO_LMIN; l <= BENCH_IO_LMAX; l += 2) for (int l = BENCH_IO_LMIN; l <= BENCH_IO_LMAX; l += 2)
{ {
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; GRID_MSG << "-- Local volume " << l << "^4" << std::endl;
readBenchmark<LatticeFermion>(latt, filestem(l), limeRead<LatticeFermion>); readBenchmark<LatticeFermion>(latt, filestem(l), limeRead<LatticeFermion>);
perf[i](volInd(l), gRead) = BinaryIO::lastPerf.mbytesPerSecond; perf[i](volInd(l), gRead) = BinaryIO::lastPerf.mbytesPerSecond;
} }
@ -159,13 +152,13 @@ int main(int argc, char **argv)
avRob.fill(100.); avRob.fill(100.);
avRob -= 100. * avStdDev.cwiseQuotient(avMean.cwiseAbs()); avRob -= 100. * avStdDev.cwiseQuotient(avMean.cwiseAbs());
MSG << BIGSEP << std::endl; grid_big_sep();
MSG << "SUMMARY" << std::endl; GRID_MSG << "SUMMARY" << std::endl;
MSG << BIGSEP << std::endl; grid_big_sep();
MSG << "Summary of individual results (all results in MB/s)." << std::endl; GRID_MSG << "Summary of individual results (all results in MB/s)." << std::endl;
MSG << "Every second colum gives the standard deviation of the previous column." GRID_MSG << "Every second colum gives the standard deviation of the previous column."
<< std::endl; << std::endl;
MSG << std::endl; GRID_MSG << std::endl;
grid_printf("%4s %12s %12s %12s %12s %12s %12s %12s %12s\n", "L", "std read", "std dev", grid_printf("%4s %12s %12s %12s %12s %12s %12s %12s %12s\n", "L", "std read", "std dev",
"std write", "std dev", "Grid read", "std dev", "Grid write", "std dev"); "std write", "std dev", "Grid read", "std dev", "Grid write", "std dev");
for (int l = BENCH_IO_LMIN; l <= BENCH_IO_LMAX; l += 2) for (int l = BENCH_IO_LMIN; l <= BENCH_IO_LMAX; l += 2)
@ -176,10 +169,10 @@ int main(int argc, char **argv)
stdDev(volInd(l), gRead), mean(volInd(l), gWrite), stdDev(volInd(l), gRead), mean(volInd(l), gWrite),
stdDev(volInd(l), gWrite)); stdDev(volInd(l), gWrite));
} }
MSG << std::endl; GRID_MSG << std::endl;
MSG << "Robustness of individual results, in %. (rob = 100% - std dev / mean)" GRID_MSG << "Robustness of individual results, in %. (rob = 100% - std dev / mean)"
<< std::endl; << std::endl;
MSG << std::endl; GRID_MSG << std::endl;
grid_printf("%4s %12s %12s %12s %12s\n", "L", "std read", "std write", "Grid read", grid_printf("%4s %12s %12s %12s %12s\n", "L", "std read", "std write", "Grid read",
"Grid write"); "Grid write");
for (int l = BENCH_IO_LMIN; l <= BENCH_IO_LMAX; l += 2) for (int l = BENCH_IO_LMIN; l <= BENCH_IO_LMAX; l += 2)
@ -187,21 +180,21 @@ int main(int argc, char **argv)
grid_printf("%4d %12.1f %12.1f %12.1f %12.1f\n", l, rob(volInd(l), sRead), grid_printf("%4d %12.1f %12.1f %12.1f %12.1f\n", l, rob(volInd(l), sRead),
rob(volInd(l), sWrite), rob(volInd(l), gRead), rob(volInd(l), gWrite)); rob(volInd(l), sWrite), rob(volInd(l), gRead), rob(volInd(l), gWrite));
} }
MSG << std::endl; GRID_MSG << std::endl;
MSG << "Summary of results averaged over local volumes 24^4-" << BENCH_IO_LMAX GRID_MSG << "Summary of results averaged over local volumes 24^4-" << BENCH_IO_LMAX
<< "^4 (all results in MB/s)." << std::endl; << "^4 (all results in MB/s)." << std::endl;
MSG << "Every second colum gives the standard deviation of the previous column." GRID_MSG << "Every second colum gives the standard deviation of the previous column."
<< std::endl; << std::endl;
MSG << std::endl; GRID_MSG << std::endl;
grid_printf("%12s %12s %12s %12s %12s %12s %12s %12s\n", "std read", "std dev", grid_printf("%12s %12s %12s %12s %12s %12s %12s %12s\n", "std read", "std dev",
"std write", "std dev", "Grid read", "std dev", "Grid write", "std dev"); "std write", "std dev", "Grid read", "std dev", "Grid write", "std dev");
grid_printf("%12.1f %12.1f %12.1f %12.1f %12.1f %12.1f %12.1f %12.1f\n", avMean(sRead), grid_printf("%12.1f %12.1f %12.1f %12.1f %12.1f %12.1f %12.1f %12.1f\n", avMean(sRead),
avStdDev(sRead), avMean(sWrite), avStdDev(sWrite), avMean(gRead), avStdDev(sRead), avMean(sWrite), avStdDev(sWrite), avMean(gRead),
avStdDev(gRead), avMean(gWrite), avStdDev(gWrite)); avStdDev(gRead), avMean(gWrite), avStdDev(gWrite));
MSG << std::endl; GRID_MSG << std::endl;
MSG << "Robustness of volume-averaged results, in %. (rob = 100% - std dev / mean)" GRID_MSG << "Robustness of volume-averaged results, in %. (rob = 100% - std dev / mean)"
<< std::endl; << std::endl;
MSG << std::endl; GRID_MSG << std::endl;
grid_printf("%12s %12s %12s %12s\n", "std read", "std write", "Grid read", grid_printf("%12s %12s %12s %12s\n", "std read", "std write", "Grid read",
"Grid write"); "Grid write");
grid_printf("%12.1f %12.1f %12.1f %12.1f\n", avRob(sRead), avRob(sWrite), avRob(gRead), grid_printf("%12.1f %12.1f %12.1f %12.1f\n", avRob(sRead), avRob(sWrite), avRob(gRead),

View File

@ -18,12 +18,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#ifndef Benchmark_IO_hpp_ #ifndef Benchmark_IO_hpp_
#define Benchmark_IO_hpp_ #define Benchmark_IO_hpp_
#include "Common.hpp"
#include <Grid/Grid.h> #include <Grid/Grid.h>
#define MSG std::cout << GridLogMessage
#define SEP \
"-----------------------------------------------------------------------------"
#define BIGSEP \
"============================================================================="
#ifdef HAVE_LIME #ifdef HAVE_LIME
namespace Grid namespace Grid
@ -50,9 +46,9 @@ namespace Grid
// crc = GridChecksum::crc32(vec_v.cpu_ptr, size); // crc = GridChecksum::crc32(vec_v.cpu_ptr, size);
// std::fwrite(&crc, sizeof(uint32_t), 1, file); // std::fwrite(&crc, sizeof(uint32_t), 1, file);
// crcWatch.Stop(); // crcWatch.Stop();
// MSG << "Std I/O write: Data CRC32 " << std::hex << crc << std::dec << std::endl; // GRID_MSG << "Std I/O write: Data CRC32 " << std::hex << crc << std::dec <<
// ioWatch.Start(); // std::endl; ioWatch.Start(); std::fwrite(vec_v.cpu_ptr, sizeof(typename
// std::fwrite(vec_v.cpu_ptr, sizeof(typename Field::scalar_object), // Field::scalar_object),
// vec.Grid()->lSites(), file); // vec.Grid()->lSites(), file);
// ioWatch.Stop(); // ioWatch.Stop();
// std::fclose(file); // std::fclose(file);
@ -61,11 +57,11 @@ namespace Grid
// p.size = size; // p.size = size;
// p.time = ioWatch.useconds(); // p.time = ioWatch.useconds();
// p.mbytesPerSecond = size / 1024. / 1024. / (ioWatch.useconds() / 1.e6); // p.mbytesPerSecond = size / 1024. / 1024. / (ioWatch.useconds() / 1.e6);
// MSG << "Std I/O write: Wrote " << p.size << " bytes in " << ioWatch.Elapsed() // GRID_MSG << "Std I/O write: Wrote " << p.size << " bytes in " << ioWatch.Elapsed()
// << ", // << ",
// " // "
// << p.mbytesPerSecond << " MB/s" << std::endl; // << p.mbytesPerSecond << " MB/s" << std::endl;
// MSG << "Std I/O write: checksum overhead " << crcWatch.Elapsed() << std::endl; // GRID_MSG << "Std I/O write: checksum overhead " << crcWatch.Elapsed() << std::endl;
// } // }
// template <typename Field> void stdRead(Field &vec, const std::string filestem) // template <typename Field> void stdRead(Field &vec, const std::string filestem)
@ -94,16 +90,14 @@ namespace Grid
// crcData = GridChecksum::crc32(vec_v.cpu_ptr, size); // crcData = GridChecksum::crc32(vec_v.cpu_ptr, size);
// crcWatch.Stop(); // crcWatch.Stop();
// } // }
// MSG << "Std I/O read: Data CRC32 " << std::hex << crcData << std::dec << std::endl; // GRID_MSG << "Std I/O read: Data CRC32 " << std::hex << crcData << std::dec <<
// assert(crcData == crcRead); // std::endl; assert(crcData == crcRead); size *= vec.Grid()->ProcessorCount(); auto
// size *= vec.Grid()->ProcessorCount(); // &p = BinaryIO::lastPerf; p.size = size; p.time = ioWatch.useconds();
// auto &p = BinaryIO::lastPerf;
// p.size = size;
// p.time = ioWatch.useconds();
// p.mbytesPerSecond = size / 1024. / 1024. / (ioWatch.useconds() / 1.e6); // p.mbytesPerSecond = size / 1024. / 1024. / (ioWatch.useconds() / 1.e6);
// MSG << "Std I/O read: Read " << p.size << " bytes in " << ioWatch.Elapsed() << ", " // GRID_MSG << "Std I/O read: Read " << p.size << " bytes in " << ioWatch.Elapsed() <<
// ", "
// << p.mbytesPerSecond << " MB/s" << std::endl; // << p.mbytesPerSecond << " MB/s" << std::endl;
// MSG << "Std I/O read: checksum overhead " << crcWatch.Elapsed() << std::endl; // GRID_MSG << "Std I/O read: checksum overhead " << crcWatch.Elapsed() << std::endl;
// } // }
template <typename Field> void stdWrite(const std::string filestem, Field &vec) template <typename Field> void stdWrite(const std::string filestem, Field &vec)
@ -122,7 +116,7 @@ namespace Grid
crc = GridChecksum::crc32(vec_v.cpu_ptr, size); crc = GridChecksum::crc32(vec_v.cpu_ptr, size);
file.write(reinterpret_cast<char *>(&crc), sizeof(uint32_t) / sizeof(char)); file.write(reinterpret_cast<char *>(&crc), sizeof(uint32_t) / sizeof(char));
crcWatch.Stop(); crcWatch.Stop();
MSG << "Std I/O write: Data CRC32 " << std::hex << crc << std::dec << std::endl; GRID_MSG << "Std I/O write: Data CRC32 " << std::hex << crc << std::dec << std::endl;
ioWatch.Start(); ioWatch.Start();
file.write(reinterpret_cast<char *>(vec_v.cpu_ptr), sizec); file.write(reinterpret_cast<char *>(vec_v.cpu_ptr), sizec);
file.flush(); file.flush();
@ -132,9 +126,9 @@ namespace Grid
p.size = size; p.size = size;
p.time = ioWatch.useconds(); p.time = ioWatch.useconds();
p.mbytesPerSecond = size / 1024. / 1024. / (ioWatch.useconds() / 1.e6); p.mbytesPerSecond = size / 1024. / 1024. / (ioWatch.useconds() / 1.e6);
MSG << "Std I/O write: Wrote " << p.size << " bytes in " << ioWatch.Elapsed() << ", " GRID_MSG << "Std I/O write: Wrote " << p.size << " bytes in " << ioWatch.Elapsed()
<< p.mbytesPerSecond << " MB/s" << std::endl; << ", " << p.mbytesPerSecond << " MB/s" << std::endl;
MSG << "Std I/O write: checksum overhead " << crcWatch.Elapsed() << std::endl; GRID_MSG << "Std I/O write: checksum overhead " << crcWatch.Elapsed() << std::endl;
} }
template <typename Field> void stdRead(Field &vec, const std::string filestem) template <typename Field> void stdRead(Field &vec, const std::string filestem)
@ -163,16 +157,17 @@ namespace Grid
crcData = GridChecksum::crc32(vec_v.cpu_ptr, size); crcData = GridChecksum::crc32(vec_v.cpu_ptr, size);
crcWatch.Stop(); crcWatch.Stop();
} }
MSG << "Std I/O read: Data CRC32 " << std::hex << crcData << std::dec << std::endl; GRID_MSG << "Std I/O read: Data CRC32 " << std::hex << crcData << std::dec
<< std::endl;
assert(crcData == crcRead); assert(crcData == crcRead);
size *= vec.Grid()->ProcessorCount(); size *= vec.Grid()->ProcessorCount();
auto &p = BinaryIO::lastPerf; auto &p = BinaryIO::lastPerf;
p.size = size; p.size = size;
p.time = ioWatch.useconds(); p.time = ioWatch.useconds();
p.mbytesPerSecond = size / 1024. / 1024. / (ioWatch.useconds() / 1.e6); p.mbytesPerSecond = size / 1024. / 1024. / (ioWatch.useconds() / 1.e6);
MSG << "Std I/O read: Read " << p.size << " bytes in " << ioWatch.Elapsed() << ", " GRID_MSG << "Std I/O read: Read " << p.size << " bytes in " << ioWatch.Elapsed()
<< p.mbytesPerSecond << " MB/s" << std::endl; << ", " << p.mbytesPerSecond << " MB/s" << std::endl;
MSG << "Std I/O read: checksum overhead " << crcWatch.Elapsed() << std::endl; GRID_MSG << "Std I/O read: checksum overhead " << crcWatch.Elapsed() << std::endl;
} }
template <typename Field> void limeWrite(const std::string filestem, Field &vec) template <typename Field> void limeWrite(const std::string filestem, Field &vec)