KaMPIng 0.1.1
Flexible and (near) zero-overhead C++ bindings for MPI
Loading...
Searching...
No Matches
measurement_aggregation_definitions.hpp
Go to the documentation of this file.
1// This file is part of KaMPIng.
2//
3// Copyright 2023 The KaMPIng Authors
4//
5// KaMPIng is free software : you can redistribute it and/or modify it under the terms of the GNU Lesser General Public
6// License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later
7// version. KaMPIng is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the
8// implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
9// for more details.
10//
11// You should have received a copy of the GNU Lesser General Public License along with KaMPIng. If not, see
12// <https://www.gnu.org/licenses/>.
13
14/// @file
15/// This file contains functionality that is related to measurement aggregation.
16
17#pragma once
18
19#include <string>
20#include <unordered_map>
21#include <variant>
22#include <vector>
23
24namespace kamping::measurements {
25///@brief Either a scalar or vector of type \c T.
26///@tparam T Type.
27template <typename T>
28using ScalarOrContainer = std::variant<T, std::vector<T>>;
29
30/// @brief Enum to specify how time measurements with same key shall be aggregated locally.
32 accumulate, ///< Tag used to indicate that data associated with identical keys will be accumulated into a scalar.
33 append ///< Tag used to indicate that data with identical keys will not be accumulated and stored in a list.
34};
35
36/// @brief Enum to specify how time durations with same key shall be aggregated across the participating ranks.
38 min, ///< The minimum of the measurement data on the participating ranks will be computed.
39 max, ///< The maximum of the measurement data on the participating ranks will be computed.
40 sum, ///< The sum of the measurement data on the participating ranks will be computed.
41 gather ///< The measurement data on the participating ranks will be collected in a container.
42};
43
44/// @brief Returns name of given GlobalAggregationMode.
45/// @param mode Given mode for which a name as a string is requested.
46/// @return Name of mode as a string.
48 switch (mode) {
49 case GlobalAggregationMode::min:
50 return "min";
51 case GlobalAggregationMode::max:
52 return "max";
53 case GlobalAggregationMode::sum:
54 return "sum";
55 case GlobalAggregationMode::gather:
56 return "gather";
57 }
58 return "No name string is specified for given mode.";
59}
60
61} // namespace kamping::measurements
STL-compatible allocator for requesting memory using the builtin MPI allocator.
Definition allocator.hpp:32
std::string get_string(GlobalAggregationMode mode)
Returns name of given GlobalAggregationMode.
Definition measurement_aggregation_definitions.hpp:47
std::variant< T, std::vector< T > > ScalarOrContainer
Either a scalar or vector of type T.
Definition measurement_aggregation_definitions.hpp:28
GlobalAggregationMode
Enum to specify how time durations with same key shall be aggregated across the participating ranks.
Definition measurement_aggregation_definitions.hpp:37
@ sum
The sum of the measurement data on the participating ranks will be computed.
@ gather
The measurement data on the participating ranks will be collected in a container.
LocalAggregationMode
Enum to specify how time measurements with same key shall be aggregated locally.
Definition measurement_aggregation_definitions.hpp:31
@ accumulate
Tag used to indicate that data associated with identical keys will be accumulated into a scalar.
@ append
Tag used to indicate that data with identical keys will not be accumulated and stored in a list.