Arcane  4.1.12.0
User documentation
Loading...
Searching...
No Matches
ParallelNonBlockingCollectiveDispatcher.cc
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/* ParallelNonBlockingCollectiveDispatcher.cc (C) 2000-2016 */
9/* */
10/* Redirection of message handling based on argument type. */
11/*---------------------------------------------------------------------------*/
12/*---------------------------------------------------------------------------*/
13
14#include "arcane/utils/ArcanePrecomp.h"
15
16#include "arcane/utils/ArrayView.h"
17
18#include "arcane/utils/Real2.h"
19#include "arcane/utils/Real3.h"
20#include "arcane/utils/Real2x2.h"
21#include "arcane/utils/Real3x3.h"
22#include "arcane/utils/HPReal.h"
23
24#include "arcane/core/ParallelNonBlockingCollectiveDispatcher.h"
25#include "arcane/core/IParallelMng.h"
26#include "arcane/core/Timer.h"
27
28#include <iostream>
29
30/*---------------------------------------------------------------------------*/
31/*---------------------------------------------------------------------------*/
32
33namespace Arcane
34{
35
36/*---------------------------------------------------------------------------*/
37/*---------------------------------------------------------------------------*/
38
39ParallelNonBlockingCollectiveDispatcher::
40ParallelNonBlockingCollectiveDispatcher(IParallelMng* pm)
41: m_parallel_mng(pm)
42, m_char(0)
43, m_unsigned_char(0)
44, m_signed_char(0)
45, m_short(0)
46, m_unsigned_short(0)
47, m_int(0)
48, m_unsigned_int(0)
49, m_long(0)
50, m_unsigned_long(0)
51, m_long_long(0)
52, m_unsigned_long_long(0)
53, m_float(0)
54, m_double(0)
55, m_long_double(0)
56, m_real2(0)
57, m_real3(0)
58, m_real2x2(0)
59, m_real3x3(0)
60, m_hpreal(0)
61{
62}
63
64/*---------------------------------------------------------------------------*/
65/*---------------------------------------------------------------------------*/
66
67ParallelNonBlockingCollectiveDispatcher::
68~ParallelNonBlockingCollectiveDispatcher()
69{
70 delete m_char;
71 delete m_signed_char;
72 delete m_unsigned_char;
73 delete m_short;
74 delete m_unsigned_short;
75 delete m_int;
76 delete m_unsigned_int;
77 delete m_long;
78 delete m_unsigned_long;
79 delete m_long_long;
80 delete m_unsigned_long_long;
81#ifdef ARCANE_REAL_NOT_BUILTIN
82 delete m_real;
83#endif
84 delete m_float;
85 delete m_double;
86 delete m_long_double;
87 delete m_real2;
88 delete m_real3;
89 delete m_real2x2;
90 delete m_real3x3;
91 delete m_hpreal;
92}
93
94/*---------------------------------------------------------------------------*/
95/*---------------------------------------------------------------------------*/
96
97void ParallelNonBlockingCollectiveDispatcher::
98_setDispatchers(IParallelNonBlockingCollectiveDispatchT<char>* c,
99 IParallelNonBlockingCollectiveDispatchT<signed char>* sc,
100 IParallelNonBlockingCollectiveDispatchT<unsigned char>* uc,
101 IParallelNonBlockingCollectiveDispatchT<short>* s,
102 IParallelNonBlockingCollectiveDispatchT<unsigned short>* us,
103 IParallelNonBlockingCollectiveDispatchT<int>* i,
104 IParallelNonBlockingCollectiveDispatchT<unsigned int>* ui,
105 IParallelNonBlockingCollectiveDispatchT<long>* l,
106 IParallelNonBlockingCollectiveDispatchT<unsigned long>* ul,
107 IParallelNonBlockingCollectiveDispatchT<long long>* ll,
108 IParallelNonBlockingCollectiveDispatchT<unsigned long long>* ull,
109#ifdef ARCANE_REAL_NOT_BUILTIN
110 IParallelNonBlockingCollectiveDispatchT<Real>* r,
111#endif
112 IParallelNonBlockingCollectiveDispatchT<float>* f,
113 IParallelNonBlockingCollectiveDispatchT<double>* d,
114 IParallelNonBlockingCollectiveDispatchT<long double>* ld,
115 IParallelNonBlockingCollectiveDispatchT<Real2>* r2,
116 IParallelNonBlockingCollectiveDispatchT<Real3>* r3,
117 IParallelNonBlockingCollectiveDispatchT<Real2x2>* r22,
118 IParallelNonBlockingCollectiveDispatchT<Real3x3>* r33,
119 IParallelNonBlockingCollectiveDispatchT<HPReal>* hpr)
120{
121 m_char = c;
122 m_signed_char = sc;
123 m_unsigned_char = uc;
124 m_short = s;
125 m_unsigned_short = us;
126 m_int = i;
127 m_unsigned_int = ui;
128 m_long = l;
129 m_unsigned_long = ul;
130 m_long_long = ll;
131 m_unsigned_long_long = ull;
132#ifdef ARCANE_REAL_NOT_BUILTIN
133 m_real = r;
134#endif
135 m_float = f;
136 m_double = d;
137 m_long_double = ld;
138 m_real2 = r2;
139 m_real3 = r3;
140 m_real2x2 = r22;
141 m_real3x3 = r33;
142 m_hpreal = hpr;
143}
144
145/*---------------------------------------------------------------------------*/
146/*---------------------------------------------------------------------------*/
147
148ITimeStats* ParallelNonBlockingCollectiveDispatcher::
149timeStats()
150{
151 return m_parallel_mng->timeStats();
152}
153
154/*---------------------------------------------------------------------------*/
155/*---------------------------------------------------------------------------*/
156
157#define ARCANE_PARALLEL_MANAGER_DISPATCH(field, type) \
158 Parallel::Request ParallelNonBlockingCollectiveDispatcher:: \
159 allGather(ConstArrayView<type> send_buf, ArrayView<type> recv_buf) \
160 { \
161 Timer::Phase tphase(timeStats(), TP_Communication); \
162 return field->allGather(send_buf, recv_buf); \
163 } \
164 Parallel::Request ParallelNonBlockingCollectiveDispatcher:: \
165 gather(ConstArrayView<type> send_buf, ArrayView<type> recv_buf, Integer rank) \
166 { \
167 Timer::Phase tphase(timeStats(), TP_Communication); \
168 return field->gather(send_buf, recv_buf, rank); \
169 } \
170 Parallel::Request ParallelNonBlockingCollectiveDispatcher:: \
171 allGatherVariable(ConstArrayView<type> send_buf, Array<type>& recv_buf) \
172 { \
173 Timer::Phase tphase(timeStats(), TP_Communication); \
174 return field->allGatherVariable(send_buf, recv_buf); \
175 } \
176 Parallel::Request ParallelNonBlockingCollectiveDispatcher:: \
177 gatherVariable(ConstArrayView<type> send_buf, Array<type>& recv_buf, Integer rank) \
178 { \
179 Timer::Phase tphase(timeStats(), TP_Communication); \
180 return field->gatherVariable(send_buf, recv_buf, rank); \
181 } \
182 Parallel::Request ParallelNonBlockingCollectiveDispatcher:: \
183 scatterVariable(ConstArrayView<type> send_buf, ArrayView<type> recv_buf, Integer root) \
184 { \
185 Timer::Phase tphase(timeStats(), TP_Communication); \
186 return field->scatterVariable(send_buf, recv_buf, root); \
187 } \
188 Parallel::Request ParallelNonBlockingCollectiveDispatcher:: \
189 allReduce(eReduceType rt, ConstArrayView<type> send_buf, ArrayView<type> v) \
190 { \
191 Timer::Phase tphase(timeStats(), TP_Communication); \
192 return field->allReduce(rt, send_buf, v); \
193 } \
194 Parallel::Request ParallelNonBlockingCollectiveDispatcher:: \
195 broadcast(ArrayView<type> send_buf, Integer id) \
196 { \
197 Timer::Phase tphase(timeStats(), TP_Communication); \
198 return field->broadcast(send_buf, id); \
199 } \
200 Parallel::Request ParallelNonBlockingCollectiveDispatcher:: \
201 allToAll(ConstArrayView<type> send_buf, ArrayView<type> recv_buf, Integer count) \
202 { \
203 Timer::Phase tphase(timeStats(), TP_Communication); \
204 return field->allToAll(send_buf, recv_buf, count); \
205 } \
206 Parallel::Request ParallelNonBlockingCollectiveDispatcher:: \
207 allToAllVariable(ConstArrayView<type> send_buf, Int32ConstArrayView send_count, \
208 Int32ConstArrayView send_index, ArrayView<type> recv_buf, \
209 Int32ConstArrayView recv_count, Int32ConstArrayView recv_index) \
210 { \
211 Timer::Phase tphase(timeStats(), TP_Communication); \
212 return field->allToAllVariable(send_buf, send_count, send_index, recv_buf, recv_count, recv_index); \
213 } \
214 IParallelNonBlockingCollectiveDispatchT<type>* ParallelNonBlockingCollectiveDispatcher:: \
215 dispatcher(type*) \
216 { \
217 return field; \
218 }
219
220ARCANE_PARALLEL_MANAGER_DISPATCH(m_char, char)
221ARCANE_PARALLEL_MANAGER_DISPATCH(m_unsigned_char, unsigned char)
222ARCANE_PARALLEL_MANAGER_DISPATCH(m_signed_char, signed char)
223ARCANE_PARALLEL_MANAGER_DISPATCH(m_short, short)
224ARCANE_PARALLEL_MANAGER_DISPATCH(m_unsigned_short, unsigned short)
225ARCANE_PARALLEL_MANAGER_DISPATCH(m_int, int)
226ARCANE_PARALLEL_MANAGER_DISPATCH(m_unsigned_int, unsigned int)
227ARCANE_PARALLEL_MANAGER_DISPATCH(m_long, long)
228ARCANE_PARALLEL_MANAGER_DISPATCH(m_unsigned_long, unsigned long)
229ARCANE_PARALLEL_MANAGER_DISPATCH(m_long_long, long long)
230ARCANE_PARALLEL_MANAGER_DISPATCH(m_unsigned_long_long, unsigned long long)
231ARCANE_PARALLEL_MANAGER_DISPATCH(m_float, float)
232ARCANE_PARALLEL_MANAGER_DISPATCH(m_double, double)
233ARCANE_PARALLEL_MANAGER_DISPATCH(m_long_double, long double)
234#ifdef ARCANE_REAL_NOT_BUILTIN
235ARCANE_PARALLEL_MANAGER_DISPATCH(m_real, Real)
236#endif
237ARCANE_PARALLEL_MANAGER_DISPATCH(m_real2, Real2)
238ARCANE_PARALLEL_MANAGER_DISPATCH(m_real3, Real3)
239ARCANE_PARALLEL_MANAGER_DISPATCH(m_real2x2, Real2x2)
240ARCANE_PARALLEL_MANAGER_DISPATCH(m_real3x3, Real3x3)
241ARCANE_PARALLEL_MANAGER_DISPATCH(m_hpreal, HPReal)
242
243/*---------------------------------------------------------------------------*/
244/*---------------------------------------------------------------------------*/
245
246} // namespace Arcane
247
248/*---------------------------------------------------------------------------*/
249/*---------------------------------------------------------------------------*/
Interface of the parallelism manager for a subdomain.
-- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature --