aboutsummaryrefslogtreecommitdiff
path: root/Carpet/CarpetLib/src/timestat.cc
diff options
context:
space:
mode:
authorErik Schnetter <schnetter@cct.lsu.edu>2006-09-11 02:56:00 +0000
committerErik Schnetter <schnetter@cct.lsu.edu>2006-09-11 02:56:00 +0000
commitcd889c022b928f5a8b3a51099e106f617c23a236 (patch)
tree74e838af2fd320b02a61dca65837fa994115c157 /Carpet/CarpetLib/src/timestat.cc
parent849721b9597d95c2d4de6bf047eb5636b587e662 (diff)
CarpetLib: Write timer output to files
Write the CarpetLib timer output to files instead of to screen; the output is lengthy, difficult to interpret, and output from all processors is needed. darcs-hash:20060911025609-dae7b-c1d812ae44dfdb3f8e8daae09f06a8ed3476e73f.gz
Diffstat (limited to 'Carpet/CarpetLib/src/timestat.cc')
-rw-r--r--Carpet/CarpetLib/src/timestat.cc44
1 files changed, 43 insertions, 1 deletions
diff --git a/Carpet/CarpetLib/src/timestat.cc b/Carpet/CarpetLib/src/timestat.cc
index 88987742f..9ee2bebb0 100644
--- a/Carpet/CarpetLib/src/timestat.cc
+++ b/Carpet/CarpetLib/src/timestat.cc
@@ -1,7 +1,10 @@
#include <algorithm>
#include <cassert>
#include <cmath>
+#include <fstream>
+#include <iomanip>
#include <iostream>
+#include <sstream>
#include <mpi.h>
@@ -9,6 +12,7 @@
#include "cctk_Arguments.h"
#include "cctk_Parameters.h"
+#include "dist.hh"
#include "timestat.hh"
@@ -136,7 +140,45 @@ void CarpetLib_printtimestats (CCTK_ARGUMENTS)
(print_timestats_every and
cctk_iteration % print_timestats_every == 0))
{
- cout << "Timing statistics from CarpetLib:" << endl
+ ostringstream filenamebuf;
+ filenamebuf << out_dir << "/" << timestat_file
+ << "." << setw(4) << setfill('0') << dist::rank()
+ << ".txt";
+ string const filename = filenamebuf.str();
+
+ ofstream file;
+ static bool do_truncate = true;
+ if (do_truncate) {
+ if (not IO_TruncateOutputFiles (cctkGH)) {
+ do_truncate = false;
+ }
+ }
+ if (do_truncate) {
+ do_truncate = false;
+ file.open (filename.c_str(), ios::out | ios::trunc);
+ } else {
+ file.open (filename.c_str(), ios::out | ios::app);
+ }
+
+ static bool do_print_info = true;
+ if (do_print_info) {
+ do_print_info = false;
+ if (CCTK_IsFunctionAliased ("UniqueBuildID")) {
+ char const * const build_id
+ = static_cast<char const *> (UniqueBuildID (cctkGH));
+ file << "Build ID: " << build_id << endl;
+ }
+ if (CCTK_IsFunctionAliased ("UniqueSimulationID")) {
+ char const * const job_id
+ = static_cast<char const *> (UniqueSimulationID (cctkGH));
+ file << "Simulation ID: " << job_id << endl;
+ }
+ file << "Running on " << dist::size() << " processors" << endl;
+ }
+
+ file << endl
+ << "********************************************************************************" << endl
+ << "Timing statistics from CarpetLib at iteration " << cctkGH->cctk_iteration << " time " << cctkGH->cctk_time << ":" << endl
<< " wtime_copyfrom_recv: " << wtime_copyfrom_recv << endl
<< " wtime_copyfrom_send: " << wtime_copyfrom_send << endl
<< " wtime_copyfrom_wait: " << wtime_copyfrom_wait << endl