Skip to content

Commit

Permalink
Fix total time value for AMR simulations where reduction is performed…
Browse files Browse the repository at this point in the history
… more than once
  • Loading branch information
sebastiangrimberg committed Apr 8, 2024
1 parent f066315 commit b6e8830
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions palace/utils/timer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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<double> data_min, data_max, data_avg;
Expand Down

0 comments on commit b6e8830

Please sign in to comment.