GCC Code Coverage Report


Directory: gridformat/
File: gridformat/parallel/communication.hpp
Date: 2024-11-10 16:24:00
Exec Total Coverage
Lines: 18 18 100.0%
Functions: 29 42 69.0%
Branches: 0 0 -%

Line Branch Exec Source
1 // SPDX-FileCopyrightText: 2022-2023 Dennis Gläser <dennis.glaeser@iws.uni-stuttgart.de>
2 // SPDX-License-Identifier: MIT
3 /*!
4 * \file
5 * \ingroup Parallel
6 * \brief Interface for parallel communication.
7 */
8 #ifndef GRIDFORMAT_PARALLEL_COMMUNICATION_HPP_
9 #define GRIDFORMAT_PARALLEL_COMMUNICATION_HPP_
10
11 #include <gridformat/parallel/traits.hpp>
12 #include <gridformat/parallel/concepts.hpp>
13
14 namespace GridFormat::Parallel {
15
16 //! \addtogroup Parallel
17 //! \{
18
19 //! Return the number of processes in a communication
20 template<Concepts::Communicator C>
21 54974 inline int size(const C& comm) {
22 54974 return ParallelTraits::Size<C>::get(comm);
23 }
24
25 //! Return the rank of a processes in a communication
26 template<Concepts::Communicator C>
27 23597 inline int rank(const C& comm) {
28 23597 return ParallelTraits::Rank<C>::get(comm);
29 }
30
31 //! Return a barrier
32 template<Concepts::Communicator C>
33 12680 inline int barrier(const C& comm) {
34 12680 return ParallelTraits::Barrier<C>::get(comm);
35 }
36
37 //! Return the maximum of the given values over all processes
38 template<Concepts::MaxCommunicator C, typename T>
39 1 inline auto max(const C& comm, const T& values, int root = 0) {
40 1 return ParallelTraits::Max<C>::get(comm, values, root);
41 }
42
43 //! Return the minimum of the given values over all processes
44 template<Concepts::MinCommunicator C, typename T>
45 1 inline auto min(const C& comm, const T& values, int root = 0) {
46 1 return ParallelTraits::Min<C>::get(comm, values, root);
47 }
48
49 //! Return the sum of the given values over all processes
50 template<Concepts::SumCommunicator C, typename T>
51 689 inline auto sum(const C& comm, const T& values, int root = 0) {
52 689 return ParallelTraits::Sum<C>::get(comm, values, root);
53 }
54
55 //! Broadcast values from the root to all other processes
56 template<Concepts::SumCommunicator C, typename T>
57 19109 inline auto broadcast(const C& comm, const T& values, int root = 0) {
58 19109 return ParallelTraits::BroadCast<C>::get(comm, values, root);
59 }
60
61 //! Gather values from all processes to the root process
62 template<Concepts::SumCommunicator C, typename T>
63 26874 inline auto gather(const C& comm, const T& values, int root = 0) {
64 26874 return ParallelTraits::Gather<C>::get(comm, values, root);
65 }
66
67 //! Scatter values from the root to all other processes
68 template<Concepts::SumCommunicator C, typename T>
69 7065 inline auto scatter(const C& comm, const T& values, int root = 0) {
70 7065 return ParallelTraits::Scatter<C>::get(comm, values, root);
71 }
72
73 //! \} group Parallel
74
75 } // namespace GridFormat::Parallel
76
77 #endif // GRIDFORMAT_PARALLEL_COMMUNICATION_HPP_
78