Arcane  4.2.3.0
Documentation développeur
Chargement...
Recherche...
Aucune correspondance
MpiParallelMng.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/* MpiParallelMng.h (C) 2000-2026 */
9/* */
10/* Implémentation des messages avec MPI. */
11/*---------------------------------------------------------------------------*/
12#ifndef ARCANE_PARALLEL_MPI_MPIPARALLELMNG_H
13#define ARCANE_PARALLEL_MPI_MPIPARALLELMNG_H
14/*---------------------------------------------------------------------------*/
15/*---------------------------------------------------------------------------*/
16
17#include "arcane/utils/Array.h"
18#include "arcane/utils/Ref.h"
19
20#include "arcane/ParallelMngDispatcher.h"
21
22#include "arcane/parallel/mpi/ArcaneMpi.h"
23
24/*---------------------------------------------------------------------------*/
25/*---------------------------------------------------------------------------*/
26
27namespace Arcane
28{
30
31/*---------------------------------------------------------------------------*/
32/*---------------------------------------------------------------------------*/
33
34class MpiDatatypeList;
35class SerializeBuffer;
36class ArcaneMpiSerializeMessageList;
37
38/*---------------------------------------------------------------------------*/
39/*---------------------------------------------------------------------------*/
43struct ARCANE_MPI_EXPORT MpiParallelMngBuildInfo
44{
45 public:
46 MpiParallelMngBuildInfo(MPI_Comm comm, MPI_Comm machine_comm);
47 public:
48 Int32 commRank() const { return comm_rank; }
49 Int32 commSize() const { return comm_nb_rank; }
50 MPI_Comm mpiComm() const { return mpi_comm; }
51 MPI_Comm mpiMachineComm() const { return mpi_machine_comm; }
52
53 public:
54 bool is_parallel;
55 private:
56
57 Int32 comm_rank = -1;
58 Int32 comm_nb_rank = -1;
59
60 public:
61 Parallel::IStat* stat = nullptr;
62 ITraceMng* trace_mng = nullptr;
63 ITimerMng* timer_mng = nullptr;
64 IThreadMng* thread_mng = nullptr;
65 IParallelMng* world_parallel_mng = nullptr;
66 private:
67
68 MPI_Comm mpi_comm = MPI_COMM_NULL;
69 MPI_Comm mpi_machine_comm = MPI_COMM_NULL;
70
71 public:
72
73 bool is_mpi_comm_owned = false;
74 MpiLock* mpi_lock = nullptr;
75};
76
77/*---------------------------------------------------------------------------*/
78/*---------------------------------------------------------------------------*/
82class ARCANE_MPI_EXPORT MpiParallelMng
83: public ParallelMngDispatcher
84{
85 public:
86 friend ArcaneMpiSerializeMessageList;
87 class RequestList;
88 class Impl;
89
90 public:
91
92 explicit MpiParallelMng(const MpiParallelMngBuildInfo& bi);
93 ~MpiParallelMng() override;
94
95 bool isParallel() const override { return m_is_parallel; }
96 Int32 commRank() const override { return m_comm_rank; }
97 Int32 commSize() const override { return m_comm_size; }
98 void* getMPICommunicator() override { return &m_communicator; }
99 bool isThreadImplementation() const override { return false; }
100 bool isHybridImplementation() const override { return false; }
101 ITraceMng* traceMng() const override { return m_trace; }
102 IThreadMng* threadMng() const override { return m_thread_mng; }
103 IParallelMng* worldParallelMng() const override { return m_world_parallel_mng; }
104 IIOMng* ioMng() const override { return m_io_mng; }
105
106 void initialize() override;
107 bool isMasterIO() const override { return commRank()==0; }
108 Integer masterIORank() const override { return 0; }
109
110 ITimerMng* timerMng() const override { return m_timer_mng; }
111
112 void sendSerializer(ISerializer* values,Int32 rank) override;
113 Request sendSerializer(ISerializer* values,Int32 rank,ByteArray& bytes) override;
114 ISerializeMessage* createSendSerializer(Int32 rank) override;
115
116 void recvSerializer(ISerializer* values,Int32 rank) override;
117 ISerializeMessage* createReceiveSerializer(Int32 rank) override;
118
119 void freeRequests(ArrayView<Parallel::Request> requests) override;
120
121 void broadcastSerializer(ISerializer* values,Int32 rank) override;
122 MessageId probe(const PointToPointMessageInfo& message) override;
123 MessageSourceInfo legacyProbe(const PointToPointMessageInfo& message) override;
124 Request sendSerializer(const ISerializer* values,const PointToPointMessageInfo& message) override;
125 Request receiveSerializer(ISerializer* values,const PointToPointMessageInfo& message) override;
126
127 void printStats() override;
128 IParallelMng* sequentialParallelMng() override;
129 Ref<IParallelMng> sequentialParallelMngRef() override;
130 void barrier() override;
131 void waitAllRequests(ArrayView<Request> requests) override;
132 UniqueArray<Integer> waitSomeRequests(ArrayView<Request> requests) override;
133 UniqueArray<Integer> testSomeRequests(ArrayView<Request> requests) override;
134 ARCANE_DEPRECATED_260 Real reduceRank(eReduceType rt,Real v,Int32* rank)
135 {
136 Real rv = reduce(rt,v);
137 if (rank)
138 *rank = 0;
139 return rv;
140 }
141
142 IParallelNonBlockingCollective* nonBlockingCollective() const override { return m_non_blocking_collective; }
143
144 void build() override;
145
146 public:
147
148 MpiAdapter* adapter() { return m_adapter; }
149 Communicator communicator() const override { return Communicator(m_communicator); }
150 Communicator machineCommunicator() const override { return Communicator(m_machine_communicator); }
151
152 MpiLock* mpiLock() const { return m_mpi_lock; }
153
154 MpiDatatypeList* datatypes() { return m_datatype_list; }
155
156 MpiSerializeDispatcher* serializeDispatcher() const { return m_mpi_serialize_dispatcher; }
157
158 public:
159
160 IParallelMngInternal* _internalApi() override { return m_parallel_mng_internal; }
161
162 protected:
163
164 ISerializeMessageList* _createSerializeMessageList() override;
165 IParallelMng* _createSubParallelMng(Int32ConstArrayView kept_ranks) override;
166 bool _isAcceleratorAware() const override;
167 Ref<IParallelMng> _createSubParallelMngRef(Int32 color, Int32 key) override;
168 Ref<IParallelMng> _createSubParallelMngRef(bool is_kept) override;
169
170 public:
171
172 IGetVariablesValuesParallelOperation* createGetVariablesValuesOperation() override;
173 ITransferValuesParallelOperation* createTransferValuesOperation() override;
174 IParallelExchanger* createExchanger() override;
175 IParallelTopology* createTopology() override;
176 IVariableSynchronizer* createSynchronizer(IItemFamily* family) override;
177 IVariableSynchronizer* createSynchronizer(const ItemGroup& group) override;
178 Parallel::IStat* stat() override { return m_stat; }
179 IParallelReplication* replication() const override;
180 void setReplication(IParallelReplication* v) override;
181 Ref<Parallel::IRequestList> createRequestListRef() override;
182 Ref<IParallelMngUtilsFactory> _internalUtilsFactory() const override;
183
184 private:
185
186 ITraceMng* m_trace = nullptr;
187 IThreadMng* m_thread_mng = nullptr;
188 IParallelMng* m_world_parallel_mng = nullptr;
189 IIOMng* m_io_mng = nullptr;
190 Ref<IParallelMng> m_sequential_parallel_mng;
191 ITimerMng* m_timer_mng = nullptr;
192 IParallelReplication* m_replication = nullptr;
193 bool m_is_timer_owned = false;
194 MpiDatatypeList* m_datatype_list = nullptr;
195 MpiAdapter* m_adapter = nullptr;
196 bool m_is_parallel = false;
197 Int32 m_comm_rank = A_NULL_RANK;
199 bool m_is_initialized = false;
200 Parallel::IStat* m_stat = nullptr;
201 MPI_Comm m_communicator = MPI_COMM_NULL;
202 MPI_Comm m_machine_communicator = MPI_COMM_NULL;
203 bool m_is_communicator_owned = false;
204 MpiLock* m_mpi_lock = nullptr;
205 IParallelNonBlockingCollective* m_non_blocking_collective = nullptr;
206 MpiSerializeDispatcher* m_mpi_serialize_dispatcher = nullptr;
207 Ref<IParallelMngUtilsFactory> m_utils_factory;
208 IParallelMngInternal* m_parallel_mng_internal = nullptr;
209
210 private:
211
212 void _checkFinishedSubRequests();
213 UniqueArray<Integer> _waitSomeRequests(ArrayView<Request> requests, bool is_non_blocking);
214 IParallelMng* _createSubParallelMng(MPI_Comm sub_communicator);
215};
216
217/*---------------------------------------------------------------------------*/
218/*---------------------------------------------------------------------------*/
219
220} // End namespace Arcane
221
222/*---------------------------------------------------------------------------*/
223/*---------------------------------------------------------------------------*/
224
225#endif
Vue modifiable d'un tableau d'un type T.
Opérations pour accéder aux valeurs de variables d'un autre sous-domaine.
Interface du gestionnaire des entrées sorties.
Definition IIOMng.h:36
Interface d'une famille d'entités.
Definition IItemFamily.h:86
Échange d'informations entre processeurs.
Partie interne de IParallelMng.
Interface du gestionnaire de parallélisme pour un sous-domaine.
Interface des opérations parallèles collectives non bloquantes.
Informations sur la réplication des sous-domaines en parallèle.
Informations sur la topologie d'allocation des coeurs de calcul.
Interface d'un gestionnaire de thread.
Definition IThreadMng.h:30
Interface d'un gestionnaire de timer.
Definition ITimerMng.h:49
Interface du gestionnaire de traces.
Envoie de valeurs sur différents processeurs.
Interface d'un service de synchronisation de variable.
Groupe d'entités de maillage.
Definition ItemGroup.h:49
Communicateur pour l'échange de message.
Interface d'un message de sérialisation entre IMessagePassingMng.
Informations sur la source d'un message.
Verrou pour les appels MPI.
Definition MpiLock.h:37
Informations pour envoyer/recevoir un message point à point.
Requête d'un message.
Definition Request.h:77
Gère les MPI_Datatype associées aux types Arcane.
Spécialisation de MpiRequestList pour MpiParallelMng.
IParallelMng * worldParallelMng() const override
Gestionnaire de parallélisme sur l'ensemble des ressources allouées.
bool m_is_initialized
true si déjà initialisé
Int32 commRank() const override
Rang de cette instance dans le communicateur.
Communicator machineCommunicator() const override
Communicateur MPI issus du communicateur communicator() réunissant tous les processus du noeud de cal...
IThreadMng * threadMng() const override
Gestionnaire de threads.
IIOMng * ioMng() const override
Gestionnaire des entrées/sorties.
bool isThreadImplementation() const override
Indique si l'implémentation utilise les threads.
void * getMPICommunicator() override
Adresse du communicateur MPI associé à ce gestionnaire.
ITimerMng * timerMng() const override
Gestionnaire de timers.
IParallelNonBlockingCollective * nonBlockingCollective() const override
Interface des opérations collectives non blocantes.
Int32 m_comm_size
Nombre de sous-domaines.
bool isParallel() const override
Retourne true si l'exécution est parallèle.
ITraceMng * traceMng() const override
Gestionnaire de trace associé à cette instance.
Int32 m_comm_rank
Numéro du processeur actuel.
Communicator communicator() const override
Communicateur MPI associé à cette instance.
Integer masterIORank() const override
Rang de l'instance gérant les entrées/sorties (pour laquelle isMasterIO() est vrai).
Parallel::IStat * stat() override
Gestionnaire des statistiques.
bool isMasterIO() const override
true si l'instance est un gestionnaire maître des entrées/sorties.
bool isHybridImplementation() const override
Indique si l'implémentation utilise le mode hybride.
IParallelMngInternal * _internalApi() override
API interne à Arcane.
Int32 commSize() const override
Nombre d'instance dans le communicateur.
Statistiques sur le parallélisme.
Référence à une instance.
Implémentation d'un tampon pour la sérialisation.
Vecteur 1D de données avec sémantique par valeur (style STL).
eReduceType
Types des réductions supportées.
-- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature --
Int32 Integer
Type représentant un entier.
Array< Byte > ByteArray
Tableau dynamique à une dimension de caractères.
Definition UtilsTypes.h:115
ConstArrayView< Int32 > Int32ConstArrayView
Equivalent C d'un tableau à une dimension d'entiers 32 bits.
Definition UtilsTypes.h:480
double Real
Type représentant un réel.
std::int32_t Int32
Type entier signé sur 32 bits.
Infos pour construire un MpiParallelMng.