diff options
author | Erik Schnetter <schnetter@gmail.com> | 2013-10-28 11:01:39 -0400 |
---|---|---|
committer | Erik Schnetter <schnetter@gmail.com> | 2013-10-28 11:11:36 -0400 |
commit | 5de40cab297db3f809e1ee97f7c3d32bf736df0d (patch) | |
tree | adeddcb94a08174316b4ebcf331b86a394785a12 | |
parent | 3b0a847e8d5844efb3a4b52ad016764aa8bfcdab (diff) |
LoopControl: Avoid nans in statistics output
-rw-r--r-- | Carpet/LoopControl/src/loopcontrol.cc | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/Carpet/LoopControl/src/loopcontrol.cc b/Carpet/LoopControl/src/loopcontrol.cc index ec1d0e019..6135c007a 100644 --- a/Carpet/LoopControl/src/loopcontrol.cc +++ b/Carpet/LoopControl/src/loopcontrol.cc @@ -1226,6 +1226,14 @@ void lc_statistics(CCTK_ARGUMENTS) time_actual += setup_count * setup.stats.avg_point(); } } + const double ratio_unopt = + time_default == 0.0 && time_actual == 0.0 ? + 0.0 : + time_default / time_actual - 1.0; + const double ratio_ideal = + time_default == 0.0 && time_actual == 0.0 ? + 0.0 : + time_best / time_actual - 1.0; const size_t nbytes = (nloops * (sizeof(lc_descr_t*) + sizeof(lc_descr_t))) + @@ -1241,10 +1249,10 @@ void lc_statistics(CCTK_ARGUMENTS) time_actual); CCTK_VInfo(CCTK_THORNSTRING, " Unoptimized time would have been: %g s (%+.1f%%)", - time_default, 100.0 * (time_default / time_actual - 1.0)); + time_default, 100.0 * ratio_unopt); CCTK_VInfo(CCTK_THORNSTRING, " Ideal time could have been: %g s (%+.1f%%)", - time_best, 100.0 * (time_best / time_actual - 1.0)); + time_best, 100.0 * ratio_ideal); CCTK_VInfo(CCTK_THORNSTRING, " Memory allocated: %g MB", nbytes / 1.0e+6); } |