Skip to content

Allow access to logged timer data #3487

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 35 commits into from
Oct 31, 2024
Merged
Show file tree
Hide file tree
Changes from 30 commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
a1378ef
Remove resume functionality
schnellerhase Oct 22, 2024
739846f
Move to chrono timings
schnellerhase Oct 22, 2024
9b6301c
Return duration instead of scalar
schnellerhase Oct 23, 2024
58c68c5
Remove boost timer dependency
schnellerhase Oct 23, 2024
9299575
Switch to microseconds as default
schnellerhase Oct 24, 2024
cd85255
Fix with cast
schnellerhase Oct 24, 2024
27a5c95
Addapt logging to new std::chrono clocks
schnellerhase Oct 24, 2024
3956eff
Remove missed boost timer dependencies
schnellerhase Oct 24, 2024
3978e02
Partially revert boost dependency removal
schnellerhase Oct 24, 2024
83058e5
Merge branch 'main' into timer
schnellerhase Oct 24, 2024
bc6308f
Remove list_timings from python wrapper
schnellerhase Oct 24, 2024
e15c469
Readd elapsed for pyhton testing
schnellerhase Oct 24, 2024
5c370ae
Ruff
schnellerhase Oct 24, 2024
3264892
Ruff 2
schnellerhase Oct 24, 2024
8e840e5
Doc
schnellerhase Oct 24, 2024
a8a5d02
Some simplifications
garth-wells Oct 25, 2024
8243c7a
Try removing cast
garth-wells Oct 25, 2024
2af6b41
Simplification
garth-wells Oct 25, 2024
1d09f2f
Doc improvement
garth-wells Oct 25, 2024
c19ae91
Fixes for timer
garth-wells Oct 26, 2024
f976e30
Dox updates
garth-wells Oct 26, 2024
3b18880
Updates
garth-wells Oct 26, 2024
ef58698
Various fixes
garth-wells Oct 26, 2024
2c9b529
Doc improvements
garth-wells Oct 27, 2024
73acde6
Remove debug
garth-wells Oct 27, 2024
4ed1391
Merge branch 'main' into garth/timer
garth-wells Oct 28, 2024
f04c8b0
Return raw timer data
garth-wells Oct 28, 2024
fa65df4
Return timer data
garth-wells Oct 29, 2024
d39dc91
Merge fix
garth-wells Oct 29, 2024
c9adad9
Merge remote-tracking branch 'origin/main' into garth/timer-data
garth-wells Oct 29, 2024
c70529e
Type fixes
garth-wells Oct 30, 2024
573ad00
Merge remote-tracking branch 'origin/main' into garth/timer-data
garth-wells Oct 31, 2024
e5a1bb1
Doc improvements and add test
garth-wells Oct 31, 2024
6a7e8b0
Store time delta
garth-wells Oct 31, 2024
9171116
Test updates
garth-wells Oct 31, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions cpp/dolfinx/common/TimeLogger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ void TimeLogger::register_timing(std::string task, double time)
void TimeLogger::list_timings(MPI_Comm comm, Table::Reduction reduction) const
{
// Format and reduce to rank 0
Table timings = this->timings();
Table timings = this->timing_table();
timings = timings.reduce(comm, reduction);
const std::string str = "\n" + timings.str();

Expand All @@ -44,7 +44,7 @@ void TimeLogger::list_timings(MPI_Comm comm, Table::Reduction reduction) const
std::cout << str << std::endl;
}
//-----------------------------------------------------------------------------
Table TimeLogger::timings() const
Table TimeLogger::timing_table() const
{
// Generate log::timing table
Table table("Summary of timings");
Expand Down Expand Up @@ -73,3 +73,8 @@ std::pair<int, double> TimeLogger::timing(std::string task) const
return it->second;
}
//-----------------------------------------------------------------------------
std::map<std::string, std::pair<int, double>> TimeLogger::timings() const
{
return _timings;
}
//-----------------------------------------------------------------------------
9 changes: 6 additions & 3 deletions cpp/dolfinx/common/TimeLogger.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class TimeLogger
void register_timing(std::string task, double wall);

/// Return a summary of timings and tasks in a Table
Table timings() const;
Table timing_table() const;

/// List a summary of timings and tasks. Reduction type is
/// printed.
Expand All @@ -46,10 +46,13 @@ class TimeLogger

/// @brief Return timing.
/// @param[in] task The task name to retrieve the timing for
/// @returns Values (count, total wall time, total user time, total
/// system time) for given task.
/// @return Values (count, total wall time) for given task.
std::pair<int, double> timing(std::string task) const;

/// @brief Logged elapsed times.
/// @return Elapsed [task id: (count, total wall time)].
std::map<std::string, std::pair<int, double>> timings() const;

private:
// List of timings for tasks, map from string to (num_timings,
// total_wall_time)
Expand Down
9 changes: 7 additions & 2 deletions cpp/dolfinx/common/timing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@
#include "Timer.h"

//-----------------------------------------------------------------------
dolfinx::Table dolfinx::timings()
dolfinx::Table dolfinx::timing_table()
{
return dolfinx::common::TimeLogManager::logger().timings();
return dolfinx::common::TimeLogManager::logger().timing_table();
}
//-----------------------------------------------------------------------------
void dolfinx::list_timings(MPI_Comm comm, Table::Reduction reduction)
Expand All @@ -26,3 +26,8 @@ std::pair<std::size_t, double> dolfinx::timing(std::string task)
return dolfinx::common::TimeLogManager::logger().timing(task);
}
//-----------------------------------------------------------------------------
std::map<std::string, std::pair<int, double>> dolfinx::timings()
{
return dolfinx::common::TimeLogManager::logger().timings();
}
//-----------------------------------------------------------------------------
11 changes: 7 additions & 4 deletions cpp/dolfinx/common/timing.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,16 @@
#pragma once

#include "Table.h"
#include <map>
#include <mpi.h>
#include <string>
#include <utility>

namespace dolfinx
{

/// @brief Return a summary of timings and tasks in a Table.
/// @return Table with timings.
Table timings();
Table timing_table();

/// @brief List a summary of timings and tasks.
///
Expand All @@ -27,10 +27,13 @@ Table timings();
void list_timings(MPI_Comm comm,
Table::Reduction reduction = Table::Reduction::max);

/// @brief Return timing (count, total wall time, total user time, total
/// system time) for given task.
/// @brief Return timing (count, total wall time) for given task.
/// @param[in] task Name of a task
/// @return The (count, total wall time) for the task.
std::pair<std::size_t, double> timing(std::string task);

/// @brief Logged elapsed times.
/// @return Elapsed [task id: (count, total wall time)].
std::map<std::string, std::pair<int, double>> timings();

} // namespace dolfinx
4 changes: 3 additions & 1 deletion python/dolfinx/wrappers/common.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#include <nanobind/ndarray.h>
#include <nanobind/stl/array.h>
#include <nanobind/stl/chrono.h>
#include <nanobind/stl/map.h>
#include <nanobind/stl/optional.h>
#include <nanobind/stl/pair.h>
#include <nanobind/stl/string.h>
Expand Down Expand Up @@ -161,6 +162,7 @@ void common(nb::module_& m)
return dolfinx_wrappers::as_nbarray(std::move(local));
},
nb::arg("global"));

// dolfinx::common::Timer
nb::class_<dolfinx::common::Timer<std::chrono::high_resolution_clock>>(
m, "Timer", "Timer class")
Expand All @@ -176,8 +178,8 @@ void common(nb::module_& m)
&dolfinx::common::Timer<std::chrono::high_resolution_clock>::stop<>,
"Stop timer");

// dolfinx::common::Timer enum
m.def("timing", &dolfinx::timing);
m.def("timings", &dolfinx::timings);

m.def(
"list_timings",
Expand Down
Loading