aboutsummaryrefslogtreecommitdiff
path: root/Carpet/LoopControl
diff options
context:
space:
mode:
authorErik Schnetter <schnetter@gmail.com>2013-02-08 12:20:31 -0500
committerErik Schnetter <schnetter@gmail.com>2013-02-08 12:20:31 -0500
commit5c504a42ef7218c2a075d4e44bc09435139ef02e (patch)
tree3e2bf6f67a9f377ce54707ebe7fef952b9e81219 /Carpet/LoopControl
parentdf79d5403ee5a410d0b8ee9a54b99d0434029c9a (diff)
LoopControl: Output statistics to a file instead of stdout
Diffstat (limited to 'Carpet/LoopControl')
-rw-r--r--Carpet/LoopControl/param.ccl12
-rw-r--r--Carpet/LoopControl/src/loopcontrol.cc19
2 files changed, 26 insertions, 5 deletions
diff --git a/Carpet/LoopControl/param.ccl b/Carpet/LoopControl/param.ccl
index 2a2ddefe8..42246a6af 100644
--- a/Carpet/LoopControl/param.ccl
+++ b/Carpet/LoopControl/param.ccl
@@ -12,6 +12,18 @@ BOOLEAN selftest "Run a self test with every loop (expensive)" STEERABLE=always
{
} "no"
+STRING statistics_filename "File name for LoopControl statistics" STEERABLE=always
+{
+ "" :: "disable statistics output"
+ ".+" :: "file name"
+} "LoopControl-statistics.txt"
+
+SHARES: IO
+
+USES STRING out_dir
+
+PRIVATE:
+
KEYWORD initial_setup "Initial configuration" STEERABLE=always
diff --git a/Carpet/LoopControl/src/loopcontrol.cc b/Carpet/LoopControl/src/loopcontrol.cc
index 298dc868e..50672cded 100644
--- a/Carpet/LoopControl/src/loopcontrol.cc
+++ b/Carpet/LoopControl/src/loopcontrol.cc
@@ -802,23 +802,32 @@ void lc_statistics(CCTK_ARGUMENTS)
DECLARE_CCTK_ARGUMENTS;
DECLARE_CCTK_PARAMETERS;
- CCTK_INFO("LoopControl statistics:");
+ if (strlen(statistics_filename) == 0) return;
+
+ string const filename = string(out_dir) + "/" + statistics_filename;
+ FILE *const statsfile = fopen(filename.c_str(), "a");
+
+ fprintf(statsfile, "\n");
+ fprintf(statsfile, "LoopControl statistics:\n");
for (all_stats_t::const_iterator
istats = all_stats.begin(); istats != all_stats.end(); ++istats)
{
- lc_stats_t const* const stats = *istats;
+ lc_stats_t const *const stats = *istats;
if (stats->count == 0.0) {
- printf(" Loop %s (%s:%d):\n",
- stats->name.c_str(), stats->file.c_str(), stats->line);
+ fprintf(statsfile,
+ " Loop %s (%s:%d):\n",
+ stats->name.c_str(), stats->file.c_str(), stats->line);
} else {
double const avg_thread = stats->sum / stats->count;
double const avg_point =
stats->sum * stats->threads / (stats->count * stats->points);
- printf(" Loop %s (%s:%d): count=%g, avg/thread=%g s, avg/point=%g s\n",
+ fprintf(statsfile,
+ " Loop %s (%s:%d): count=%g, avg/thread=%g s, avg/point=%g s\n",
stats->name.c_str(), stats->file.c_str(), stats->line,
stats->count, avg_thread, avg_point);
}
}
+ fclose(statsfile);
}
void lc_statistics_maybe(CCTK_ARGUMENTS)