Arcane  4.2.3.0
User documentation
Loading...
Searching...
No Matches
MessagePassingMpiGlobal.h
1// -*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-
2//-----------------------------------------------------------------------------
3// Copyright 2000-2026 CEA (www.cea.fr) IFPEN (www.ifpenergiesnouvelles.com)
4// See the top-level COPYRIGHT file for details.
5// SPDX-License-Identifier: Apache-2.0
6//-----------------------------------------------------------------------------
7/*---------------------------------------------------------------------------*/
8/* MessagePassingMpiGlobal.h (C) 2000-2025 */
9/* */
10/* Global definitions for the 'MessagePassingMpi' component of 'Arccore'. */
11/*---------------------------------------------------------------------------*/
12#ifndef ARCCORE_MESSAGEPASSINGMPI_MESSAGEPASSINGMPIGLOBAL_H
13#define ARCCORE_MESSAGEPASSINGMPI_MESSAGEPASSINGMPIGLOBAL_H
14/*---------------------------------------------------------------------------*/
15/*---------------------------------------------------------------------------*/
16
18
19/*---------------------------------------------------------------------------*/
20/*---------------------------------------------------------------------------*/
21
22// These two macros ensure that we do not compile with
23// MpiC++ support, which is obsolete
24#ifndef MPICH_SKIP_MPICXX
25#define MPICH_SKIP_MPICXX
26#endif
27#ifndef OMPI_SKIP_MPICXX
28#define OMPI_SKIP_MPICXX
29#endif
30#include <mpi.h>
31
32// Checks the minimum MPI version. Normally, we shouldn't have
33// problems because this is checked during configuration, but you never
34// know.
35#if !defined(ARCCORE_OS_WIN32)
36#if MPI_VERSION < 3 || (MPI_VERSION == 3 && MPI_SUBVERSION < 1)
37#error "MPI_VERSION 3.1 is required. Please disable MPI".
38#endif
39#endif
40
41#if defined(ARCCORE_OS_WIN32)
42// The MPI version is Microsoft's. The MPI_Op proto must
43// have the __stdcall declaration.
44// TODO: verify with other MPI implementations on Windows.
45#define ARCCORE_MPIOP_CALL __stdcall
46#endif
47
48#ifndef ARCCORE_MPIOP_CALL
49#define ARCCORE_MPIOP_CALL
50#endif
51
52/*---------------------------------------------------------------------------*/
53/*---------------------------------------------------------------------------*/
54
55#if defined(ARCCORE_COMPONENT_arccore_message_passing_mpi)
56#define ARCCORE_MESSAGEPASSINGMPI_EXPORT ARCCORE_EXPORT
57#define ARCCORE_MESSAGEPASSINGMPI_EXTERN_TPL
58#else
59#define ARCCORE_MESSAGEPASSINGMPI_EXPORT ARCCORE_IMPORT
60#define ARCCORE_MESSAGEPASSINGMPI_EXTERN_TPL extern
61#endif
62
63/*---------------------------------------------------------------------------*/
64/*---------------------------------------------------------------------------*/
65
67{
68
69/*---------------------------------------------------------------------------*/
70/*---------------------------------------------------------------------------*/
71
72/*!
73 * \brief Return the MPI communicator associated to \a mpm.
74 *
75 * If \a mpm is null or is not associated to MPI, return MPI_COMM_NULL.
76 */
77ARCCORE_MESSAGEPASSINGMPI_EXPORT MPI_Comm
79
80/*!
81 * \brief Set \a mpi_comm with the MPI communicator associated to \a mpm if it is valid.
82 *
83 * If \a mpm is not null and use MPI implementation, set \a mpi_comm with
84 * the MPI communicator associated to \a mpm. If is not the case, \a mpi_comm is inchanged.
85 *
86 * \return \a true if \a mpi_comm is set, \a false otherwise.
87 */
88ARCCORE_MESSAGEPASSINGMPI_EXPORT bool
89fillMpiCommunicatorIfValid(IMessagePassingMng* mpm,MPI_Comm* mpi_comm);
90}
91
92/*---------------------------------------------------------------------------*/
93/*---------------------------------------------------------------------------*/
94
95namespace Arcane::MessagePassing::Mpi
96{
97
98/*---------------------------------------------------------------------------*/
99/*---------------------------------------------------------------------------*/
100
101class MpiRequest;
102class MpiAdapter;
103class MpiLock;
105class IMpiProfiling;
106class NoMpiProfiling;
107class MpiDatatype;
108class MpiMessagePassingMng;
109class MpiSerializeMessageList;
110class MpiSerializeDispatcher;
112class MpiSerializeMessageList;
113template <typename DataType>
115template <typename Type>
117
118/*---------------------------------------------------------------------------*/
119/*---------------------------------------------------------------------------*/
120
121} // namespace Arcane::MessagePassing::Mpi
122
123/*---------------------------------------------------------------------------*/
124/*---------------------------------------------------------------------------*/
125
126namespace Arcane::MessagePassing::Mpi::MpiBuiltIn
127{
128
129/*---------------------------------------------------------------------------*/
130/*---------------------------------------------------------------------------*/
131
132inline MPI_Datatype
133datatype(char)
134{
135 return MPI_CHAR;
136}
137inline MPI_Datatype
138datatype(unsigned char)
139{
140 return MPI_CHAR;
141}
142inline MPI_Datatype
143datatype(signed char)
144{
145 return MPI_CHAR;
146}
147inline MPI_Datatype
148datatype(short)
149{
150 return MPI_SHORT;
151}
152inline MPI_Datatype
153datatype(int)
154{
155 return MPI_INT;
156}
157inline MPI_Datatype
158datatype(float)
159{
160 return MPI_FLOAT;
161}
162inline MPI_Datatype
163datatype(double)
164{
165 return MPI_DOUBLE;
166}
167inline MPI_Datatype
168datatype(long double)
169{
170 return MPI_LONG_DOUBLE;
171}
172inline MPI_Datatype
173datatype(long int)
174{
175 return MPI_LONG;
176}
177inline MPI_Datatype
178datatype(unsigned short)
179{
180 return MPI_UNSIGNED_SHORT;
181}
182inline MPI_Datatype
183datatype(unsigned int)
184{
185 return MPI_UNSIGNED;
186}
187inline MPI_Datatype
188datatype(unsigned long)
189{
190 return MPI_UNSIGNED_LONG;
191}
192inline MPI_Datatype
193datatype(long long)
194{
195 return MPI_LONG_LONG;
196}
197inline MPI_Datatype
198datatype(unsigned long long)
199{
200 return MPI_LONG_LONG;
201}
202/*---------------------------------------------------------------------------*/
203/*---------------------------------------------------------------------------*/
204
205} // namespace Arcane::MessagePassing::Mpi::MpiBuiltIn
206
207/*---------------------------------------------------------------------------*/
208/*---------------------------------------------------------------------------*/
209
210namespace Arccore::MessagePassing::Mpi
211{
212// For compatibility with Alien
213using Arcane::MessagePassing::internal::BasicSerializeMessage;
214
215using Arcane::MessagePassing::Mpi::IMpiProfiling;
216using Arcane::MessagePassing::Mpi::IMpiReduceOperator;
217using Arcane::MessagePassing::Mpi::MpiAdapter;
218using Arcane::MessagePassing::Mpi::MpiDatatype;
219using Arcane::MessagePassing::Mpi::MpiLock;
220using Arcane::MessagePassing::Mpi::MpiMessagePassingMng;
221using Arcane::MessagePassing::Mpi::MpiRequest;
222using Arcane::MessagePassing::Mpi::MpiSerializeDispatcher;
223using Arcane::MessagePassing::Mpi::MpiSerializeMessageList;
224using Arcane::MessagePassing::Mpi::MpiTypeDispatcher;
225using Arcane::MessagePassing::Mpi::NoMpiProfiling;
226using Arcane::MessagePassing::Mpi::StandaloneMpiMessagePassingMng;
227using Arcane::MessagePassing::Mpi::StdMpiReduceOperator;
228namespace MpiBuiltIn = Arcane::MessagePassing::Mpi::MpiBuiltIn;
229}; // namespace Arccore::MessagePassing::Mpi
230
231/*---------------------------------------------------------------------------*/
232/*---------------------------------------------------------------------------*/
233
234#endif
General declarations for the 'message_passing' component.
Interface of the message passing manager.
Reduction operators for complex types (Real2, Real3, Real2x2 and Real3x3).
Definition MpiDatatype.h:35
Standalone version of IMessagePassingMng associated to a MPI Communicator.
Reduction operators for standard types.
Definition MpiDatatype.h:60
Declarations of types and methods used by message exchange mechanisms.
ARCCORE_MESSAGEPASSINGMPI_EXPORT bool fillMpiCommunicatorIfValid(IMessagePassingMng *mpm, MPI_Comm *mpi_comm)
Set mpi_comm with the MPI communicator associated to mpm if it is valid.
ARCCORE_MESSAGEPASSINGMPI_EXPORT MPI_Comm toMpiCommunicator(IMessagePassingMng *mpm)
Return the MPI communicator associated to mpm.