From 5c504a42ef7218c2a075d4e44bc09435139ef02e Mon Sep 17 00:00:00 2001 From: Erik Schnetter Date: Fri, 8 Feb 2013 12:20:31 -0500 Subject: LoopControl: Output statistics to a file instead of stdout --- Carpet/LoopControl/param.ccl | 12 ++++++++++++ Carpet/LoopControl/src/loopcontrol.cc | 19 ++++++++++++++----- 2 files changed, 26 insertions(+), 5 deletions(-) (limited to 'Carpet/LoopControl') 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) -- cgit v1.2.3