From b6e8830c7437250a43da83d0581d73b07aab6221 Mon Sep 17 00:00:00 2001 From: Sebastian Grimberg Date: Mon, 8 Apr 2024 09:46:59 -0700 Subject: [PATCH 1/2] Fix total time value for AMR simulations where reduction is performed more than once --- palace/utils/timer.hpp | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/palace/utils/timer.hpp b/palace/utils/timer.hpp index 1df9a7e11..2863e22e5 100644 --- a/palace/utils/timer.hpp +++ b/palace/utils/timer.hpp @@ -99,18 +99,18 @@ class Timer // Return the time elapsed since timer creation. Duration TimeFromStart() const { return Now() - start_time; } - // Save a timing step by adding a duration, without lapping; optionally, count it. - Duration SaveTime(Index idx, Duration time, bool count_it = true) + // Lap and record a timing step. + Duration MarkTime(Index idx, bool count_it = true) { - data[idx] += time; - counts[idx] += count_it; - return data[idx]; + return MarkTime(idx, Lap(), count_it); } - // Lap and record a timing step. - Duration MarkTime(Index idx, bool count_it = true) + // Record a timing step by adding a duration, without lapping; optionally, count it. + Duration MarkTime(Index idx, Duration time, bool count_it = true) { - return SaveTime(idx, Lap(), count_it); + data[idx] = time + ((idx != Timer::TOTAL) ? data[idx] : 0.0); + counts[idx] += count_it; + return data[idx]; } // Provide map-like read-only access to the timing data. @@ -186,7 +186,7 @@ class BlockTimer timer.MarkTime(stack.top()); stack.pop(); } - timer.SaveTime(Timer::TOTAL, timer.TimeFromStart()); + timer.MarkTime(Timer::TOTAL, timer.TimeFromStart()); // Reduce timing data. std::vector data_min, data_max, data_avg; From 1f50b121976d0e117edfc32802e8ff55fcce3eb7 Mon Sep 17 00:00:00 2001 From: Sebastian Grimberg Date: Mon, 8 Apr 2024 09:58:29 -0700 Subject: [PATCH 2/2] Fix compiler error --- palace/utils/timer.hpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/palace/utils/timer.hpp b/palace/utils/timer.hpp index 2863e22e5..f4cd9fa5f 100644 --- a/palace/utils/timer.hpp +++ b/palace/utils/timer.hpp @@ -108,7 +108,14 @@ class Timer // Record a timing step by adding a duration, without lapping; optionally, count it. Duration MarkTime(Index idx, Duration time, bool count_it = true) { - data[idx] = time + ((idx != Timer::TOTAL) ? data[idx] : 0.0); + if (idx == Timer::TOTAL) + { + data[idx] = time; + } + else + { + data[idx] += time; + } counts[idx] += count_it; return data[idx]; }