From 5de40cab297db3f809e1ee97f7c3d32bf736df0d Mon Sep 17 00:00:00 2001 From: Erik Schnetter Date: Mon, 28 Oct 2013 11:01:39 -0400 Subject: LoopControl: Avoid nans in statistics output --- Carpet/LoopControl/src/loopcontrol.cc | 12 ++++++++++-- 1 file 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); } -- cgit v1.2.3