KaMPIng 0.1.1
Flexible and (near) zero-overhead C++ bindings for MPI
Loading...
Searching...
No Matches
status.hpp
1// This file is part of KaMPIng.
2//
3// Copyright 2022 The KaMPIng Authors
4//
5// KaMPIng is free software : you can redistribute it and/or modify it under the
6// terms of the GNU Lesser General Public License as published by the Free
7// Software Foundation, either version 3 of the License, or (at your option) any
8// later version. KaMPIng is distributed in the hope that it will be useful, but
9// WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10// FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
11// for more details.
12//
13// You should have received a copy of the GNU Lesser General Public License
14// along with KaMPIng. If not, see <https://www.gnu.org/licenses/>.
15
16#pragma once
17
18#include <cstddef>
19
20#include <mpi.h>
21
24
25namespace kamping {
26
27/// @brief Wrapper for MPI_Status
28class Status {
29public:
30 /// @brief Construct a status object. Note that all values are undefined until passed to a communication function.
31 Status() : _status() {}
32 /// @brief Construct a status object from a given MPI_Status.
33 /// @param status The status.
35
36 /// @return The source rank. May be undefined.
37 [[nodiscard]] int source_signed() const {
38 return _status.MPI_SOURCE;
39 }
40
41 /// @return The source rank. May be undefined.
42 [[nodiscard]] size_t source() const {
44 }
45
46 /// @return The tag. May be undefined.
47 [[nodiscard]] int tag() const {
48 return _status.MPI_TAG;
49 }
50
51 /// @param data_type The datatype.
52 /// @return The number of top-level elements received for the given type \c
53 /// DataType.
54 [[nodiscard]] int count_signed(MPI_Datatype data_type) const {
55 int count;
56 MPI_Get_count(&_status, data_type, &count);
57 return count;
58 }
59
60 /// @tparam DataType The datatype.
61 /// @return The number of top-level elements received for the given type \c
62 /// DataType.
63 template <typename DataType>
64 [[nodiscard]] int count_signed() const {
66 }
67
68 /// @param data_type The datatype.
69 /// @return The number of top-level elements received for the given type \c
70 /// DataType.
71 [[nodiscard]] size_t count(MPI_Datatype data_type) const {
72 return asserting_cast<size_t>(this->count_signed(data_type));
73 }
74
75 /// @tparam DataType The datatype.
76 /// @return The number of top-level elements received for the given type \c
77 /// DataType.
78 template <typename DataType>
79 [[nodiscard]] size_t count() const {
81 }
82
83 /// @return A reference to the underlying native MPI_Status.
85 return _status;
86 }
87
88 /// @return A reference to the underlying native MPI_Status.
89 [[nodiscard]] MPI_Status const& native() const {
90 return _status;
91 }
92
93private:
94 MPI_Status _status; ///< The wrapped status.
95};
96} // namespace kamping
Helper functions that make casts safer.
STL-compatible allocator for requesting memory using the builtin MPI allocator.
Definition allocator.hpp:32
Wrapper for MPI_Status.
Definition status.hpp:28
size_t count(MPI_Datatype data_type) const
Definition status.hpp:71
int tag() const
Definition status.hpp:47
int source_signed() const
Definition status.hpp:37
int count_signed() const
Definition status.hpp:64
MPI_Status const & native() const
Definition status.hpp:89
MPI_Status & native()
Definition status.hpp:84
size_t source() const
Definition status.hpp:42
size_t count() const
Definition status.hpp:79
int count_signed(MPI_Datatype data_type) const
Definition status.hpp:54
Status(MPI_Status status)
Construct a status object from a given MPI_Status.
Definition status.hpp:34
Status()
Construct a status object. Note that all values are undefined until passed to a communication functio...
Definition status.hpp:31
auto status(internal::ignore_t< void >)
pass MPI_STATUS_IGNORE to the underlying MPI call.
Definition status_parameters.hpp:52
Utility that maps C++ types to types that can be understood by MPI.
STL namespace.