aboutsummaryrefslogtreecommitdiff
path: root/Carpet
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
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')
-rw-r--r--Carpet/CarpetLib/interface.ccl19
-rw-r--r--Carpet/CarpetLib/param.ccl6
-rw-r--r--Carpet/CarpetLib/src/timestat.cc44
3 files changed, 68 insertions, 1 deletions
diff --git a/Carpet/CarpetLib/interface.ccl b/Carpet/CarpetLib/interface.ccl
index 7a507d949..1b3da8365 100644
--- a/Carpet/CarpetLib/interface.ccl
+++ b/Carpet/CarpetLib/interface.ccl
@@ -39,3 +39,22 @@ USES FUNCTION UniqueBuildID
CCTK_POINTER_TO_CONST \
FUNCTION UniqueSimulationID (CCTK_POINTER_TO_CONST IN cctkGH)
USES FUNCTION UniqueSimulationID
+
+
+
+# Check whether existing output files should be truncated
+CCTK_INT \
+FUNCTION IO_TruncateOutputFiles (CCTK_POINTER_TO_CONST IN cctkGH)
+REQUIRES FUNCTION IO_TruncateOutputFiles
+
+
+
+# The location of the boundary points
+CCTK_INT FUNCTION GetBoundarySpecification \
+ (CCTK_INT IN size, \
+ CCTK_INT OUT ARRAY nboundaryzones, \
+ CCTK_INT OUT ARRAY is_internal, \
+ CCTK_INT OUT ARRAY is_staggered, \
+ CCTK_INT OUT ARRAY shiftout)
+USES FUNCTION GetBoundarySpecification
+
diff --git a/Carpet/CarpetLib/param.ccl b/Carpet/CarpetLib/param.ccl
index 1a064d0bb..2292280c6 100644
--- a/Carpet/CarpetLib/param.ccl
+++ b/Carpet/CarpetLib/param.ccl
@@ -54,6 +54,12 @@ INT print_timestats_every "Print timing statistics periodically" STEERABLE=alway
1:* :: "report every so many iterations"
} 0
+STRING timestat_file "File name in which timestat output is collected (because stdout from the root node may not be enough)" STEERABLE=always
+{
+ "^$" :: "empty filename: no file output"
+ "^.+$" :: "file name"
+} "carpetlib-time-statistics"
+
INT print_memstats_every "Report periodically how much memory is used per process" STEERABLE=always
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