169 std::lock_guard< std::mutex > lock( mtx );
177 std::lock_guard< std::mutex > lock( mtx );
178 if ( !current->children.contains( name ) )
180 current->children[name] = std::make_shared< TimerNode >( name, current );
182 current = current->children[name].get();
188 std::lock_guard< std::mutex > lock( mtx );
189 current->total_time += elapsed;
191 if ( current->parent )
193 current = current->parent;
218 void aggregate_node(
TimerNode* node, MPI_Comm comm )
220 double local_time = node->total_time;
221 double root_time, min_time, max_time, sum_time;
223 root_time = local_time;
224 MPI_Bcast( &root_time, 1, MPI_DOUBLE, 0, MPI_COMM_WORLD );
225 MPI_Allreduce( &local_time, &min_time, 1, MPI_DOUBLE, MPI_MIN, comm );
226 MPI_Allreduce( &local_time, &max_time, 1, MPI_DOUBLE, MPI_MAX, comm );
227 MPI_Allreduce( &local_time, &sum_time, 1, MPI_DOUBLE, MPI_SUM, comm );
230 MPI_Comm_size( comm, &size );
231 node->root_time = root_time;
232 node->sum_time = sum_time;
233 node->min_time = min_time;
234 node->max_time = max_time;
235 node->avg_time = sum_time / size;
237 for (
auto& child : node->children | std::ranges::views::values )
239 aggregate_node( child.get(), comm );