|
| Timer () |
| Constructs a timer using the MPI_COMM_WORLD communicator.
|
|
| Timer (CommunicatorType const &comm) |
| Constructs a timer using a given communicator.
|
|
void | synchronize_and_start (std::string const &key) |
| Synchronizes all ranks in the underlying communicator via a barrier and then start the measurement with the given key.
|
|
void | start (std::string const &key) |
| Starts the measurement with the given key.
|
|
void | stop (std::vector< GlobalAggregationMode > const &global_aggregation_modes=std::vector< GlobalAggregationMode >{}) |
| Stops the currently active measurement and stores the result.
|
|
void | stop_and_add (std::vector< GlobalAggregationMode > const &global_aggregation_modes=std::vector< GlobalAggregationMode >{}) |
| Stops the currently active measurement and stores the result. If the key associated with the measurement that is stopped has already been used at the current hierarchy level the duration is added to the last measured duration at this hierarchy level with the same key.
|
|
void | stop_and_append (std::vector< GlobalAggregationMode > const &global_aggregation_modes=std::vector< GlobalAggregationMode >{}) |
| Stops the currently active measurement and stores the result. If the key associated with the measurement that is stopped has already been used at the current hierarchy level the duration is appended to a list of previously measured durations at this hierarchy level with the same key.
|
|
auto | aggregate () |
| Evaluates the time measurements represented by the timer tree for which the current node is the root node globally. The measured durations are aggregated over all participating ranks and the result is stored at the root rank of the given communicator. The used aggregation operations can be specified via TimerTreeNode::data_aggregation_operations(). The durations are aggregated node by node.
|
|
void | clear () |
| Clears all stored measurements.
|
|
void | enable () |
| (Re-)Enable start/stop operations.
|
|
void | disable () |
| Disable start/stop operations, i.e., start()/stop() operations do not have any effect.
|
|
template<typename Printer > |
void | aggregate_and_print (Printer &&printer) |
| Aggregates and outputs the executed measurements. The output is done via the print() method of a given Printer object.
|
|
Distributed timer object.
Timer hierarchy:
The timer is able to execute time measurements in a hierarchical manner. Time measurements are executed with a matching pair of calls to Timer::start() and Timer::stop(). Each call to start() enters a new level in the hierarchy which is left again with the corresponding call to stop(). Time measurements can be nested and the parent time measurement remains active while its child time measurement take place.
See the following pseudocode example:
timer.start(
"algorithm");
timer.start(
"preprocessing");
timer.start(
"core_algorithm");
timer.start(
"subroutine");
timer.start(
"postprocessing");
STL-compatible allocator for requesting memory using the builtin MPI allocator.
Definition allocator.hpp:32
Distributed timer object.
Definition timer.hpp:122
Timer< Communicator<> > & timer()
Gets a reference to a kamping::measurements::BasicTimer.
Definition timer.hpp:280
This corresponds to the following timing hierarchy:
Aggregation operations
There are two types of aggregation operations:
1) Local aggregation operations - It is possible to execute measurements with the same key multiple times. Local aggregation operations specify how these repeated time measurements will be stored. Currently, there are two options - stop_and_add() and stop_and_append(). See the following examples:
The result of this program is one stored duration for the key "foo" which is the sum of the durations for the two measurements with key "foo".
The other option to handle repeated measurements with the same key is stop_and_append():
This program results in a list with two durations for the key "bar". We call the number of durations stored for a key its dimension
.
2) Global (communicator-wide) aggregation operations specify how the stored duration(s) for a specific measurement key shall be aggregated. The default operation (if no operations are specified via the stop() method) is to take the maximum duration over all ranks in the communicator. If there are multiple durations for a certain key, the aggregation operation is applied element-wise and the result remains a list with the same size as the number of input durations. The communicator-wide aggregation operation are applied in the evaluation phase started with calls to aggregate() or aggregate_and_print().
The timer hierarchy that is implicitly created by start() and stop() must be the same on all ranks in the given communicator. The number of time measurements with a specific key may vary as long as the number of stored duration are the same: Consider for example a communicator of size two and rank 0 and 1 both measure the time of a function foo()
each time it is called using the key "computation"
. This is only valid if either each rank calls foo() exactly the same number of times and local aggregation happens using the mode append
, or if the measured time is locally aggregated using add, i.e. the value(s) stored for a single key at the same hierarchy level must have matching dimensions. Furthermore, global communicator-wide duration aggregation operations specified on ranks other than the root rank are ignored.
- See also
- The usage example for Timer provides some more information on how the class can be used.
- Template Parameters
-
CommunicatorType | Communicator in which the time measurements are executed. |