Arcane  4.2.3.0
Documentation développeur
Chargement...
Recherche...
Aucune correspondance
HybridParallelDispatch.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/* HybridParallelDispatch.h (C) 2000-2026 */
9/* */
10/* Implémentation des messages en mode hybride MPI/Mémoire partagée.. */
11/*---------------------------------------------------------------------------*/
12#ifndef ARCANE_PARALLEL_THREAD_HYBRIDPARALLELDISPATCH_H
13#define ARCANE_PARALLEL_THREAD_HYBRIDPARALLELDISPATCH_H
14/*---------------------------------------------------------------------------*/
15/*---------------------------------------------------------------------------*/
16
17#include "arcane/utils/TraceAccessor.h"
18#include "arcane/utils/Array.h"
19#include "arcane/utils/HPReal.h"
20#include "arcane/utils/DataTypeContainer.h"
21
22#include "arcane/core/IParallelDispatch.h"
23#include "arcane/core/ISerializer.h"
24
25#include "arcane/parallel/thread/ISharedMemoryMessageQueue.h"
26
28
29/*---------------------------------------------------------------------------*/
30/*---------------------------------------------------------------------------*/
31
32namespace Arcane
33{
34template<class Type>
36}
37
39{
40
43template<class Type>
45
46template<typename DataType>
48{
49 public:
51};
52
53/*---------------------------------------------------------------------------*/
54/*---------------------------------------------------------------------------*/
55
57: public ArcaneDataTypeContainer<MpiThreadDispatcherContainerTraits>
58{
59 public:
62 {
63 public:
65 };
66 public:
67 void resize(Integer n)
68 {
69 m_char.resize(n);
70 m_signed_char.resize(n);
71 m_unsigned_char.resize(n);
72 m_short.resize(n);
73 m_unsigned_short.resize(n);
74 m_int.resize(n);
75 m_unsigned_int.resize(n);
76 m_long.resize(n);
77 m_unsigned_long.resize(n);
78 m_long_long.resize(n);
79 m_unsigned_long_long.resize(n);
80 m_float.resize(n);
81 m_double.resize(n);
82 m_long_double.resize(n);
83 m_apreal.resize(n);
84 m_real2.resize(n);
85 m_real3.resize(n);
86 m_real2x2.resize(n);
87 m_real3x3.resize(n);
88 m_hpreal.resize(n);
89 }
90 public:
91 CreateSubParallelMngInfo m_create_sub_parallel_mng_info;
92};
93
94/*---------------------------------------------------------------------------*/
95/*---------------------------------------------------------------------------*/
99template<class Type>
100class HybridParallelDispatch
101: public TraceAccessor
102, public IParallelDispatchT<Type>
104, public ITypeDispatcher<Type>
105{
107
109 {
110 public:
111 Span<const Type> send_buf;
112 Int32ConstArrayView send_count;
113 Int32ConstArrayView send_index;
114 Span<Type> recv_buf;
115 Int32ConstArrayView recv_count;
116 Int32ConstArrayView recv_index;
117 };
118
120 {
121 public:
122
123 Span<const Type> send_buf;
124 Span<Type> reduce_buf_span;
125 Type reduce_value;
126 int m_index;
127 };
128
129 private:
131 {
132 public:
133 Int32 m_min_rank = A_NULL_RANK;
134 Int32 m_max_rank = A_NULL_RANK;
135 Type m_min_value = Type();
136 Type m_max_value = Type();
137 Type m_sum_value = Type();
138 };
139 public:
140
141 HybridParallelDispatch(ITraceMng* tm,HybridParallelMng* parallel_mng,HybridMessageQueue* message_queue,
142 ArrayView<HybridParallelDispatch<Type>*> all_dispatchs);
143 ~HybridParallelDispatch() override;
144 void finalize() override;
145
146 public:
147
148 using ITypeDispatcher<Type>::gather;
149
150 public:
151
153 void broadcast(Span<Type> send_buf, Int32 sub_domain) override;
154 void allGather(Span<const Type> send_buf, Span<Type> recv_buf) override;
155 void allGatherVariable(Span<const Type> send_buf, Array<Type>& recv_buf) override;
156 void gather(Span<const Type> send_buf, Span<Type> recv_buf, Int32 rank) override;
157 void gatherVariable(Span<const Type> send_buf, Array<Type>& recv_buf, Int32 rank) override;
158 void scatterVariable(Span<const Type> send_buf, Span<Type> recv_buf, Int32 root) override;
159 void allReduce(eReduceType op, Span<Type> send_buf) override;
160 void allReduce(eReduceType op, Span<const Type> send_buf, Span<Type> receive_buf) override;
161 void allToAll(Span<const Type> send_buf, Span<Type> recv_buf, Int32 count) override;
162 void allToAllVariable(Span<const Type> send_buf, ConstArrayView<Int32> send_count,
163 ConstArrayView<Int32> send_index, Span<Type> recv_buf,
164 ConstArrayView<Int32> recv_count, ConstArrayView<Int32> recv_index) override;
165 Request send(Span<const Type> send_buffer, Int32 proc, bool is_blocked) override;
166 Request send(Span<const Type> send_buffer, const PointToPointMessageInfo& message) override;
167 Request receive(Span<Type> recv_buffer, Int32 rank, bool is_blocked) override;
168 Request receive(Span<Type> recv_buffer, const PointToPointMessageInfo& message) override;
169 Request nonBlockingAllReduce(eReduceType op, Span<const Type> send_buf, Span<Type> recv_buf) override;
170 Request nonBlockingAllGather(Span<const Type> send_buf, Span<Type> recv_buf) override;
171 Request nonBlockingBroadcast(Span<Type> send_buf, Int32 rank) override;
172 Request nonBlockingGather(Span<const Type> send_buf, Span<Type> recv_buf, Int32 rank) override;
173 Request nonBlockingAllToAll(Span<const Type> send_buf, Span<Type> recv_buf, Int32 count) override;
174 Request nonBlockingAllToAllVariable(Span<const Type> send_buf, ConstArrayView<Int32> send_count,
175 ConstArrayView<Int32> send_index, Span<Type> recv_buf,
176 ConstArrayView<Int32> recv_count, ConstArrayView<Int32> recv_index) override;
177 Request gather(Arccore::MessagePassing::GatherMessageInfo<Type>&) override;
179
180 void broadcast(ArrayView<Type> send_buf, Integer sub_domain) override
181 {
182 this->broadcast(Span<Type>(send_buf), sub_domain);
183 }
184 void allGather(ConstArrayView<Type> send_buf, ArrayView<Type> recv_buf) override
185 {
186 this->allGather(Span<const Type>(send_buf), Span<Type>(recv_buf));
187 }
188 void allGatherVariable(ConstArrayView<Type> send_buf, Array<Type>& recv_buf) override
189 {
190 this->allGatherVariable(Span<const Type>(send_buf), recv_buf);
191 }
192 void gather(ConstArrayView<Type> send_buf, ArrayView<Type> recv_buf, Integer rank) override
193 {
194 this->gather(Span<const Type>(send_buf), Span<Type>(recv_buf), rank);
195 }
196 void gatherVariable(ConstArrayView<Type> send_buf, Array<Type>& recv_buf, Integer rank) override
197 {
198 this->gatherVariable(Span<const Type>(send_buf), recv_buf, rank);
199 }
200 void scatterVariable(ConstArrayView<Type> send_buf, ArrayView<Type> recv_buf, Integer root) override
201 {
202 this->scatterVariable(Span<const Type>(send_buf), Span<Type>(recv_buf), root);
203 }
204 void allToAll(ConstArrayView<Type> send_buf, ArrayView<Type> recv_buf, Integer count) override
205 {
206 this->allToAll(Span<const Type>(send_buf), Span<Type>(recv_buf), count);
207 }
208 void allToAllVariable(ConstArrayView<Type> send_buf, Int32ConstArrayView send_count,
209 Int32ConstArrayView send_index, ArrayView<Type> recv_buf,
210 Int32ConstArrayView recv_count, Int32ConstArrayView recv_index) override
211 {
212 this->allToAllVariable(Span<const Type>(send_buf), send_count, send_index,
213 Span<Type>(recv_buf), recv_count, recv_index);
214 }
215 Request send(ConstArrayView<Type> send_buffer, Integer proc, bool is_blocked) override
216 {
217 return this->send(Span<const Type>(send_buffer), proc, is_blocked);
218 }
219 Request recv(ArrayView<Type> recv_buffer, Integer proc, bool is_blocked) override
220 {
221 return this->receive(Span<Type>(recv_buffer), proc, is_blocked);
222 }
223 void allReduce(eReduceType op, ArrayView<Type> send_buf) override
224 {
225 return this->allReduce(op, Span<Type>(send_buf));
226 }
227 void allReduce(eReduceType op, ConstArrayView<Type> send_buf, ArrayView<Type> receive_buf) override
228 {
229 return this->allReduce(op, Span<const Type>(send_buf), Span<Type>(receive_buf));
230 }
231
232 void send(ConstArrayView<Type> send_buffer, Integer proc) override;
233 void recv(ArrayView<Type> recv_buffer, Integer proc) override;
234 void sendRecv(ConstArrayView<Type> send_buffer, ArrayView<Type> recv_buffer, Integer proc) override;
235 Type allReduce(eReduceType op, Type send_buf) override;
236 Type scan(eReduceType op, Type send_buf) override;
237 void scan(eReduceType op, ArrayView<Type> send_buf) override;
238 void computeMinMaxSum(Type val, Type& min_val, Type& max_val, Type& sum_val,
239 Int32& min_rank,
240 Int32& max_rank) override;
241 void computeMinMaxSum(ConstArrayView<Type> values,
242 ArrayView<Type> min_values,
243 ArrayView<Type> max_values,
244 ArrayView<Type> sum_values,
245 ArrayView<Int32> min_ranks,
246 ArrayView<Int32> max_ranks) override;
247 ITypeDispatcher<Type>* toArccoreDispatcher() override { return this; }
248
249 private:
250
251 HybridParallelMng* m_parallel_mng = nullptr;
252 Int32 m_local_rank = A_NULL_RANK;
253 Int32 m_local_nb_rank = 0;
254 Int32 m_global_rank = A_NULL_RANK;
255 Int32 m_global_nb_rank = 0;
256 Int32 m_mpi_rank = A_NULL_RANK;
257 Int32 m_mpi_nb_rank = 0;
258
259 public:
260
261 using AllDispatchView = ArrayView<HybridParallelDispatch<Type>*>;
262 Int32 globalRank() const { return m_global_rank; }
263 AllDispatchView m_all_dispatchs;
264
265 private:
266
267 Span<Type> m_broadcast_view;
268 Span<const Type> m_const_view;
269 Span<Type> m_recv_view;
270 Span<const Type> m_send_view;
271 AllToAllVariableInfo m_alltoallv_infos;
272
273 public:
274
275 ReduceInfo m_reduce_infos;
276 MinMaxSumInfo m_min_max_sum_infos;
277
278 private:
279
280 HybridMessageQueue* m_message_queue = nullptr;
281 MpiParallelDispatchT<Type>* m_mpi_dispatcher = nullptr;
282
283 private:
284
285 void _collectiveBarrier();
286 void _allReduceOrScan(eReduceType op, Span<const Type> send_buf, Span<Type> receive_buf, bool is_scan);
287 void _applyReduceOperator(eReduceType op, Span<Type> result, AllDispatchView dispatch_view,
288 Int32 first_rank, Int32 last_rank);
289};
290
291/*---------------------------------------------------------------------------*/
292/*---------------------------------------------------------------------------*/
293
294} // End namespace Arcane::MessagePassing
295
296/*---------------------------------------------------------------------------*/
297/*---------------------------------------------------------------------------*/
298
299#endif
#define ARCCORE_INTERNAL_DEFINE_REFERENCE_COUNTED_INCLASS_METHODS(OPTIONAL_OVERRIDE)
Conteneur contenant une instance d'une classe par type de donnée Arcane.
Vue modifiable d'un tableau d'un type T.
Tableau d'items de types quelconques.
Vue constante d'un tableau de type T.
Gestion des messages parallèles pour le type Type.
Interface du gestionnaire de traces.
Informations pour un message 'gather' pour le type de données DataType.
Interface d'une file de messages avec les threads.
Interface des messages pour le type Type.
Gestionnaire du parallélisme utilisant les threads.
Gestion des messages parallèles pour le type Type.
Informations nécessaires pour créer un sous-parallelMng().
Interface des messages pour le type Type.
Référence à une instance.
Implémentation thread-safe d'un compteur de référence.
Vue d'un tableau d'éléments de type T.
Definition Span.h:633
TraceAccessor(ITraceMng *m)
Construit un accesseur via le gestionnaire de trace m.
Vecteur 1D de données avec sémantique par valeur (style STL).
Déclarations des types et méthodes utilisés par les mécanismes d'échange de messages.
-- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature --
Int32 Integer
Type représentant un entier.
ConstArrayView< Int32 > Int32ConstArrayView
Equivalent C d'un tableau à une dimension d'entiers 32 bits.
Definition UtilsTypes.h:480
std::int32_t Int32
Type entier signé sur 32 bits.
Type
Type of JSON value.
Definition rapidjson.h:730