KaMPIng 0.2.1
Flexible and (near) zero-overhead C++ bindings for MPI
Loading...
Searching...
No Matches
thread_levels.hpp
Go to the documentation of this file.
1// This file is part of KaMPIng.
2//
3// Copyright 2022-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 MPI thread support levels.
16
17#pragma once
18
19#include <mpi.h>
20
21namespace kamping {
22/// @brief MPI thread support levels defining the allowed concurrency of MPI calls relative to application threads.
23/// You can obtain the underlying values by casting the enum value to \c int.
24enum class ThreadLevel : int {
25 /// No thread support; only one thread may execute, and only the main thread can make MPI calls.
27 /// Only the main thread will make MPI calls, but the application may be multi-threaded.
29 /// Multiple threads may exist, but only one at a time will make MPI calls (calls are serialized).
31 /// Full thread support; multiple threads may call MPI concurrently.
33};
34
35/// @brief Comparison operator for \ref ThreadLevel.
36inline bool operator==(ThreadLevel lhs, ThreadLevel rhs) noexcept {
37 return static_cast<int>(lhs) == static_cast<int>(rhs);
38}
39
40/// @brief Comparison operator for \ref ThreadLevel.
41inline bool operator!=(ThreadLevel lhs, ThreadLevel rhs) noexcept {
42 return !(lhs == rhs);
43}
44
45/// @brief Comparison operator for \ref ThreadLevel.
46inline bool operator<(ThreadLevel lhs, ThreadLevel rhs) noexcept {
47 return static_cast<int>(lhs) < static_cast<int>(rhs);
48}
49
50/// @brief Comparison operator for \ref ThreadLevel.
51inline bool operator<=(ThreadLevel lhs, ThreadLevel rhs) noexcept {
52 return static_cast<int>(lhs) <= static_cast<int>(rhs);
53}
54
55/// @brief Comparison operator for \ref ThreadLevel.
56inline bool operator>(ThreadLevel lhs, ThreadLevel rhs) noexcept {
57 return static_cast<int>(lhs) > static_cast<int>(rhs);
58}
59
60/// @brief Comparison operator for \ref ThreadLevel.
61inline bool operator>=(ThreadLevel lhs, ThreadLevel rhs) noexcept {
62 return static_cast<int>(lhs) >= static_cast<int>(rhs);
63}
64} // namespace kamping
STL-compatible allocator for requesting memory using the builtin MPI allocator.
Definition allocator.hpp:32
ThreadLevel
MPI thread support levels defining the allowed concurrency of MPI calls relative to application threa...
Definition thread_levels.hpp:24
@ funneled
Only the main thread will make MPI calls, but the application may be multi-threaded.
@ multiple
Full thread support; multiple threads may call MPI concurrently.
@ single
No thread support; only one thread may execute, and only the main thread can make MPI calls.
@ serialized
Multiple threads may exist, but only one at a time will make MPI calls (calls are serialized).
bool operator>=(ThreadLevel lhs, ThreadLevel rhs) noexcept
Comparison operator for ThreadLevel.
Definition thread_levels.hpp:61
bool operator>(ThreadLevel lhs, ThreadLevel rhs) noexcept
Comparison operator for ThreadLevel.
Definition thread_levels.hpp:56