22#include <kassert/kassert.hpp>
25#include "kamping/collectives/bcast.hpp"
26#include "kamping/collectives/gather.hpp"
27#include "kamping/communicator.hpp"
30namespace kamping::measurements::internal {
38 template <
typename Container>
40 using T =
typename Container::value_type;
42 return std::optional<T>{};
45 return std::make_optional(*
it);
56 template <
typename Container>
58 using T =
typename Container::value_type;
60 return std::optional<T>{};
63 return std::make_optional(*
it);
74 template <
typename Container>
76 using T =
typename Container::value_type;
78 return std::optional<T>{};
81 return std::make_optional(
sum);
91 template <
typename Container>
93 return std::forward<Container>(
container);
107template <
typename DerivedNode>
127 auto it = _children_map.find(
name);
128 if (
it != _children_map.end()) {
134 _children_storage.push_back(std::move(
new_child));
148 return _children_storage;
160 std::unordered_map<std::string, DerivedNode*>
162 std::vector<std::unique_ptr<DerivedNode>> _children_storage;
169template <
typename T, GlobalAggregationMode default_global_aggregation_mode>
180 case LocalAggregationMode::accumulate:
181 if (_datapoints.empty()) {
187 case LocalAggregationMode::append:
201 return _datapoint_aggregation_operations;
207 return _datapoint_aggregation_operations;
211 std::vector<T> _datapoints;
212 std::vector<GlobalAggregationMode> _datapoint_aggregation_operations{
223template <
typename TimePo
int,
typename Duration>
255 bool _is_active{
false};
264template <
typename DataType>
277template <
typename NodeType>
299template <
typename Communicator>
309 if (
comm.is_root()) {
312 auto end = begin +
static_cast<int>(
str.size());
Wrapper for MPI communicator providing access to rank() and size() of the communicator....
Definition communicator.hpp:49
STL-compatible allocator for requesting memory using the builtin MPI allocator.
Definition allocator.hpp:32
Class representing a node in the counter tree. Each node represents a measurement (or multiple with t...
Definition measurement_utils.hpp:266
Class to store measurement data points associated with a node in a measurement tree,...
Definition measurement_utils.hpp:170
void aggregate_measurements_locally(T const &datapoint, LocalAggregationMode const &mode)
Add the result of a time measurement (i.e. a duration) to the node.
Definition measurement_utils.hpp:178
auto const & measurements_aggregation_operations() const
Access to the data aggregation operations (used during the evaluation).
Definition measurement_utils.hpp:206
auto const & measurements() const
Access to stored duration(s).
Definition measurement_utils.hpp:194
auto & measurements_aggregation_operations()
Access to the data aggregation operations (used during the evaluation).
Definition measurement_utils.hpp:200
Class representing a node in the timer tree. Each node represents a time measurement (or multiple wit...
Definition measurement_utils.hpp:225
void is_active(bool is_active)
Sets the activity status of this node (i.e. is there a currently active measurement).
Definition measurement_utils.hpp:243
void startpoint(TimePoint start)
Sets the point in time at which the currently active measurement has been started.
Definition measurement_utils.hpp:237
TimePoint startpoint() const
Returns the point in time at which the currently active measurement has been started.
Definition measurement_utils.hpp:231
bool is_active() const
Getter for activity status.
Definition measurement_utils.hpp:249
Object representing a node in a tree. The class is not meant to be used on its own but to encapsulate...
Definition measurement_utils.hpp:108
auto const & children() const
Access to the node's children.
Definition measurement_utils.hpp:147
auto const & name() const
Access to the node's children.
Definition measurement_utils.hpp:153
TreeNode(std::string const &name, DerivedNode *parent)
Constructs node pointer to parent.
Definition measurement_utils.hpp:120
TreeNode()
Constructs node without pointer to parent and empty name.
Definition measurement_utils.hpp:111
auto & find_or_insert(std::string const &name)
Searches the node's children for a node with the given name. If there is no such child a new node is ...
Definition measurement_utils.hpp:126
auto & parent_ptr()
Access to the parent pointer.
Definition measurement_utils.hpp:141
TreeNode(std::string const &name)
Constructs node without pointer to parent.
Definition measurement_utils.hpp:115
auto recv_buf(Container &&container)
Passes a container, into which the received elements will be written, to the underlying call....
Definition named_parameters.hpp:859
auto send_buf(internal::ignore_t< Data > ignore)
Generates a dummy send buf that wraps a nullptr.
Definition named_parameters.hpp:51
auto send_recv_buf(Data &&data)
Passes a container/single value as a send or receive buffer to the underlying MPI call.
Definition named_parameters.hpp:137
@ sum
The sum of the measurement data on the participating ranks will be computed.
LocalAggregationMode
Enum to specify how time measurements with same key shall be aggregated locally.
Definition measurement_aggregation_definitions.hpp:31
bool is_string_same_on_all_ranks(std::string const &str, Communicator const &comm)
Checks that the given string is equal on all ranks in the given communicator.
Definition measurement_utils.hpp:300
Object encapsulating a gather operation on a given range of objects.
Definition measurement_utils.hpp:86
static std::string operation_name()
Returns operation's name.
Definition measurement_utils.hpp:98
static decltype(auto) compute(Container &&container)
Forwards input container.
Definition measurement_utils.hpp:92
Object encapsulating a maximum operation on a given range of objects.
Definition measurement_utils.hpp:32
static auto compute(Container const &container)
Apply a maximum computation of the given range of objects.
Definition measurement_utils.hpp:39
Object encapsulating a minimum operation on a given range of objects.
Definition measurement_utils.hpp:50
static auto compute(Container const &container)
Apply a minimum computation of the given range of objects.
Definition measurement_utils.hpp:57
Object encapsulating a summation operation on a given range of objects.
Definition measurement_utils.hpp:68
static auto compute(Container const &container)
Apply a summation computation of the given range of objects.
Definition measurement_utils.hpp:75
Tree consisting of objects of type NodeType. The tree constitutes a hierarchy of measurements such th...
Definition measurement_utils.hpp:278
NodeType root
Root node of the tree.
Definition measurement_utils.hpp:288
Tree()
Construct a TimerTree consisting only of a root node.
Definition measurement_utils.hpp:280
NodeType * current_node
Pointer to the currently active node of the tree.
Definition measurement_utils.hpp:289
void reset()
Resets the root node (i.e. deletes and assigns a new empty node).
Definition measurement_utils.hpp:284