Arcane  v3.14.10.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-2024 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-2024 */
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>
35class MpiParallelDispatchT;
36}
37
39{
40
41class HybridParallelMng;
42class HybridMessageQueue;
43template<class Type>
44class HybridParallelDispatch;
45
46template<typename DataType>
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>
101: public TraceAccessor
102, public IParallelDispatchT<Type>
104, public ITypeDispatcher<Type>
105{
106 ARCCORE_INTERNAL_DEFINE_REFERENCE_COUNTED_INCLASS_METHODS();
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<Type> reduce_buf_span;
124 Type reduce_value;
125 int m_index;
126 };
127
128 private:
130 {
131 public:
132 Int32 m_min_rank = A_NULL_RANK;
133 Int32 m_max_rank = A_NULL_RANK;
134 Type m_min_value = Type();
135 Type m_max_value = Type();
136 Type m_sum_value = Type();
137 };
138 public:
139
142 ~HybridParallelDispatch() override;
143 void finalize() override;
144
145 public:
146
147 using ITypeDispatcher<Type>::gather;
148
149 public:
150
152 void broadcast(Span<Type> send_buf,Int32 sub_domain) override;
153 void allGather(Span<const Type> send_buf,Span<Type> recv_buf) override;
154 void allGatherVariable(Span<const Type> send_buf,Array<Type>& recv_buf) override;
155 void gather(Span<const Type> send_buf,Span<Type> recv_buf,Int32 rank) override;
156 void gatherVariable(Span<const Type> send_buf,Array<Type>& recv_buf,Int32 rank) override;
157 void scatterVariable(Span<const Type> send_buf,Span<Type> recv_buf,Int32 root) override;
158 void allReduce(eReduceType op,Span<Type> send_buf) override;
159 void allToAll(Span<const Type> send_buf,Span<Type> recv_buf,Int32 count) override;
160 void allToAllVariable(Span<const Type> send_buf,ConstArrayView<Int32> send_count,
161 ConstArrayView<Int32> send_index,Span<Type> recv_buf,
162 ConstArrayView<Int32> recv_count,ConstArrayView<Int32> recv_index) override;
163 Request send(Span<const Type> send_buffer,Int32 proc,bool is_blocked) override;
164 Request send(Span<const Type> send_buffer,const PointToPointMessageInfo& message) override;
165 Request receive(Span<Type> recv_buffer,Int32 rank,bool is_blocked) override;
166 Request receive(Span<Type> recv_buffer,const PointToPointMessageInfo& message) override;
167 Request nonBlockingAllReduce(eReduceType op,Span<const Type> send_buf,Span<Type> recv_buf) override;
168 Request nonBlockingAllGather(Span<const Type> send_buf, Span<Type> recv_buf) override;
169 Request nonBlockingBroadcast(Span<Type> send_buf, Int32 rank) override;
170 Request nonBlockingGather(Span<const Type> send_buf, Span<Type> recv_buf, Int32 rank) override;
171 Request nonBlockingAllToAll(Span<const Type> send_buf, Span<Type> recv_buf, Int32 count) override;
172 Request nonBlockingAllToAllVariable(Span<const Type> send_buf, ConstArrayView<Int32> send_count,
173 ConstArrayView<Int32> send_index, Span<Type> recv_buf,
174 ConstArrayView<Int32> recv_count, ConstArrayView<Int32> recv_index) override;
177
178 void broadcast(ArrayView<Type> send_buf,Integer sub_domain) override
179 { this->broadcast(Span<Type>(send_buf),sub_domain); }
180 void allGather(ConstArrayView<Type> send_buf,ArrayView<Type> recv_buf) override
181 { this->allGather(Span<const Type>(send_buf),Span<Type>(recv_buf)); }
182 void allGatherVariable(ConstArrayView<Type> send_buf,Array<Type>& recv_buf) override
183 { this->allGatherVariable(Span<const Type>(send_buf),recv_buf); }
184 void gather(ConstArrayView<Type> send_buf,ArrayView<Type> recv_buf,Integer rank) override
185 { this->gather(Span<const Type>(send_buf),Span<Type>(recv_buf),rank); }
186 void gatherVariable(ConstArrayView<Type> send_buf,Array<Type>& recv_buf,Integer rank) override
187 { this->gatherVariable(Span<const Type>(send_buf),recv_buf,rank); }
188 void scatterVariable(ConstArrayView<Type> send_buf,ArrayView<Type> recv_buf,Integer root) override
189 { this->scatterVariable(Span<const Type>(send_buf),Span<Type>(recv_buf),root); }
190 void allToAll(ConstArrayView<Type> send_buf,ArrayView<Type> recv_buf,Integer count) override
191 { this->allToAll(Span<const Type>(send_buf),Span<Type>(recv_buf),count); }
192 void allToAllVariable(ConstArrayView<Type> send_buf,Int32ConstArrayView send_count,
193 Int32ConstArrayView send_index,ArrayView<Type> recv_buf,
194 Int32ConstArrayView recv_count,Int32ConstArrayView recv_index) override
195 { this->allToAllVariable(Span<const Type>(send_buf),send_count,send_index,
196 Span<Type>(recv_buf),recv_count,recv_index); }
197 Request send(ConstArrayView<Type> send_buffer,Integer proc,bool is_blocked) override
198 { return this->send(Span<const Type>(send_buffer),proc,is_blocked); }
199 Request recv(ArrayView<Type> recv_buffer,Integer proc,bool is_blocked) override
200 { return this->receive(Span<Type>(recv_buffer),proc,is_blocked); }
201 void allReduce(eReduceType op,ArrayView<Type> send_buf) override
202 { return this->allReduce(op,Span<Type>(send_buf)); }
203
204 void send(ConstArrayView<Type> send_buffer,Integer proc) override;
205 void recv(ArrayView<Type> recv_buffer,Integer proc) override;
206 void sendRecv(ConstArrayView<Type> send_buffer,ArrayView<Type> recv_buffer,Integer proc) override;
207 Type allReduce(eReduceType op,Type send_buf) override;
208 Type scan(eReduceType op,Type send_buf) override;
209 void scan(eReduceType op,ArrayView<Type> send_buf) override;
210 void computeMinMaxSum(Type val,Type& min_val,Type& max_val,Type& sum_val,
211 Int32& min_rank,
212 Int32& max_rank) override;
213 void computeMinMaxSum(ConstArrayView<Type> values,
214 ArrayView<Type> min_values,
215 ArrayView<Type> max_values,
216 ArrayView<Type> sum_values,
217 ArrayView<Int32> min_ranks,
218 ArrayView<Int32> max_ranks) override;
219 ITypeDispatcher<Type>* toArccoreDispatcher() override { return this; }
220
221 private:
222
223 HybridParallelMng* m_parallel_mng = nullptr;
224 Int32 m_local_rank = A_NULL_RANK;
225 Int32 m_local_nb_rank = 0;
226 Int32 m_global_rank = A_NULL_RANK;
227 Int32 m_global_nb_rank = 0;
228 Int32 m_mpi_rank = A_NULL_RANK;
229 Int32 m_mpi_nb_rank = 0;
230
231 public:
232
233 using AllDispatchView = ArrayView<HybridParallelDispatch<Type>*>;
234 Int32 globalRank() const { return m_global_rank; }
235 AllDispatchView m_all_dispatchs;
236
237 private:
238
239 Span<Type> m_broadcast_view;
240 Span<const Type> m_const_view;
241 Span<Type> m_recv_view;
242 Span<const Type> m_send_view;
243 AllToAllVariableInfo m_alltoallv_infos;
244
245 public:
246
247 ReduceInfo m_reduce_infos;
248 MinMaxSumInfo m_min_max_sum_infos;
249
250 private:
251
252 HybridMessageQueue* m_message_queue = nullptr;
253 MpiParallelDispatchT<Type>* m_mpi_dispatcher = nullptr;
254
255 private:
256
257 void _collectiveBarrier();
258 void _allReduceOrScan(eReduceType op, Span<Type> send_buf, bool is_scan);
259 void _applyReduceOperator(eReduceType op, Span<Type> result, AllDispatchView dispatch_view,
260 Int32 first_rank, Int32 last_rank);
261};
262
263/*---------------------------------------------------------------------------*/
264/*---------------------------------------------------------------------------*/
265
266} // End namespace Arcane::MessagePassing
267
268/*---------------------------------------------------------------------------*/
269/*---------------------------------------------------------------------------*/
270
271#endif
Conteneur contenant une instance d'une classe par type de donnée Arcane.
Gestion des messages parallèles pour le type Type.
Lecteur des fichiers de maillage via la bibliothèque LIMA.
Definition Lima.cc:120
Interface d'une file de messages avec les threads.
Interface des messages pour le type Type.
Gestionnaire du parallélisme utilisant les threads.
Informations nécessaires pour créer un sous-parallelMng().
Vue modifiable d'un tableau d'un type T.
Vue constante d'un tableau de type T.
Interface du gestionnaire de traces.
Informations pour un message 'gather' pour le type de données DataType.
Gestion des messages parallèles pour le type Type.
Informations pour envoyer/recevoir un message point à point.
Requête d'un message.
Definition Request.h:77
Implémentation thread-safe d'un compteur de référence.
Déclarations des types et méthodes utilisés par les mécanismes d'échange de messages.
Definition Parallel.h:94
-*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-
ConstArrayView< Int32 > Int32ConstArrayView
Equivalent C d'un tableau à une dimension d'entiers 32 bits.
Definition UtilsTypes.h:640
eReduceType
Types des réductions supportées.
Type
Type of JSON value.
Definition rapidjson.h:665