KaMPIng 0.2.1
(Near) zero-overhead MPI wrapper for C++
Loading...
Searching...
No Matches
contiguous_type_fwd.hpp
Go to the documentation of this file.
1// This file is part of KaMPIng.
2//
3// Copyright 2021-2026 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/// @brief Forward declarations for contiguous_type and byte_serialized to break include cycles.
16
17#pragma once
18#include <cstddef>
19
20#include <mpi.h>
21
23
24namespace kamping::types {
25
26/// @addtogroup kamping_types
27/// @{
28
29/// @brief Forward declaration of the default lookup policy for \ref contiguous_type and \ref struct_type.
30/// @see type_dispatcher_lookup
31struct type_dispatcher_lookup;
32
33/// @brief Constructs a contiguous MPI type of \p N elements of type \p T using `MPI_Type_contiguous`.
34/// @tparam T The element type.
35/// @tparam N The number of elements.
36/// @tparam Lookup The lookup policy used to resolve the MPI_Datatype for \p T.
37/// Defaults to \ref type_dispatcher_lookup, which uses \ref kamping::types::mpi_type_traits.
38template <typename T, size_t N, typename Lookup = type_dispatcher_lookup>
40 static constexpr TypeCategory category = TypeCategory::contiguous; ///< The type's \ref TypeCategory.
41 static constexpr bool has_to_be_committed =
42 category_has_to_be_committed(category); ///< Whether the type must be committed before use.
43 static MPI_Datatype data_type(); ///< Returns the MPI_Datatype for a contiguous block of \p N elements of type \p T.
44};
45
46/// @brief Constructs a type serialized as a sequence of `sizeof(T)` bytes using `MPI_BYTE`.
47template <typename T>
48struct byte_serialized : contiguous_type<std::byte, sizeof(T)> {};
49
50/// @}
51
52} // namespace kamping::types
STL-compatible allocator for requesting memory using the builtin MPI allocator.
Definition allocator.hpp:32
TypeCategory
Type groups as defined in Section 6.9.2 of the MPI 4.0 standard.
Definition builtin_types.hpp:32
static MPI_Datatype data_type()
Returns the MPI_Datatype for a contiguous block of N elements of type T.
Definition contiguous_type.hpp:36
constexpr bool category_has_to_be_committed(TypeCategory category)
Returns whether an MPI_Datatype of the given category must be committed before use.
Definition builtin_types.hpp:35
Mapping of C++ datatypes to builtin MPI types.
Constructs a type serialized as a sequence of sizeof(T) bytes using MPI_BYTE.
Definition contiguous_type_fwd.hpp:48
Constructs a contiguous MPI type of N elements of type T using MPI_Type_contiguous.
Definition contiguous_type_fwd.hpp:39
static constexpr TypeCategory category
The type's TypeCategory.
Definition contiguous_type_fwd.hpp:40
static constexpr bool has_to_be_committed
Whether the type must be committed before use.
Definition contiguous_type_fwd.hpp:41