From 49ac81ecea3f2eaf425e9924c528fe8dfb4e9c8a Mon Sep 17 00:00:00 2001 From: Erik Schnetter Date: Wed, 3 Oct 2007 19:50:00 +0000 Subject: CarpetIOScalar: Record time spent in I/O darcs-hash:20071003195015-dae7b-cc7705056e55d76a20ad0277588b57329886032a.gz --- Carpet/CarpetIOScalar/src/ioscalar.cc | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'Carpet/CarpetIOScalar') diff --git a/Carpet/CarpetIOScalar/src/ioscalar.cc b/Carpet/CarpetIOScalar/src/ioscalar.cc index d92bb7e66..0e26646be 100644 --- a/Carpet/CarpetIOScalar/src/ioscalar.cc +++ b/Carpet/CarpetIOScalar/src/ioscalar.cc @@ -263,7 +263,10 @@ namespace CarpetIOScalar { { string const reduction = ireduction->reduction; - ofstream file; + fstream file; + BeginTimingIO (cctkGH); + long long io_files = 0; + long long io_bytes_begin = 0, io_bytes_end = 0; if (CCTK_MyProc(cctkGH)==0) { // Invent a file name @@ -277,6 +280,8 @@ namespace CarpetIOScalar { // If this is the first time, then write a nice header if (do_truncate.at(n) and IO_TruncateOutputFiles (cctkGH)) { file.open (filename, ios::out | ios::trunc); + io_files += 1; + io_bytes_begin = file.tellg(); { bool want_labels = false; bool want_date = false; @@ -353,6 +358,8 @@ namespace CarpetIOScalar { } } else { file.open (filename, ios::out | ios::app); + io_files += 1; + io_bytes_begin = file.tellg(); } if (! file.good()) { CCTK_VWarn (0, __LINE__, __FILE__, CCTK_THORNSTRING, @@ -420,12 +427,19 @@ namespace CarpetIOScalar { } if (CCTK_MyProc(cctkGH)==0) { + io_bytes_end = file.tellg(); file.close(); assert (file.good()); } assert (! file.is_open()); + long long io_bytes = io_bytes_end - io_bytes_begin; + // Broadcast I/O size and synchronise processes + MPI_Bcast (& io_files, 1, MPI_LONG_LONG, 0, dist::comm()); + MPI_Bcast (& io_bytes, 1, MPI_LONG_LONG, 0, dist::comm()); + EndTimingIO (cctkGH, io_files, io_bytes, false); + } // for reductions } END_GLOBAL_MODE; -- cgit v1.2.3