Arcane  4.2.3.0
Documentation développeur
Chargement...
Recherche...
Aucune correspondance
MpiParallelDispatch.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/* MpiParallelDispatch.h (C) 2000-2026 */
9/* */
10/* Implémentation des messages avec MPI. */
11/*---------------------------------------------------------------------------*/
12#ifndef ARCANE_PARALLEL_MPI_MPIPARALLELDISPATCH_H
13#define ARCANE_PARALLEL_MPI_MPIPARALLELDISPATCH_H
14/*---------------------------------------------------------------------------*/
15/*---------------------------------------------------------------------------*/
16
17#include "arcane/utils/TraceAccessor.h"
18
19#include "arcane/core/IParallelDispatch.h"
20
21#include "arcane/parallel/mpi/ArcaneMpi.h"
22#include "arcane/parallel/mpi/MpiDatatypeList.h"
23
24#include "arccore/message_passing_mpi/internal/MpiTypeDispatcher.h"
25#include "arccore/message_passing/PointToPointMessageInfo.h"
27
28/*---------------------------------------------------------------------------*/
29/*---------------------------------------------------------------------------*/
30
31namespace Arcane
32{
33
34/*---------------------------------------------------------------------------*/
35/*---------------------------------------------------------------------------*/
36
37class MpiParallelMng;
38namespace MP = ::Arccore::MessagePassing;
39
40/*---------------------------------------------------------------------------*/
41/*---------------------------------------------------------------------------*/
45template<class Type>
46class MpiParallelDispatchT
47: public TraceAccessor
49, public IParallelDispatchT<Type>
50{
52 private:
53 class ARCANE_MPI_EXPORT MinMaxSumInfo
54 {
55 public:
56 Integer m_min_rank;
57 Integer m_max_rank;
58 Type m_min_value;
59 Type m_max_value;
60 Type m_sum_value;
61 };
62
63 public:
64 typedef Parallel::Request Request;
65 typedef Parallel::eReduceType eReduceType;
66 using PointToPointMessageInfo = Parallel::PointToPointMessageInfo;
67 public:
68 ARCANE_MPI_EXPORT MpiParallelDispatchT(ITraceMng* tm, IMessagePassingMng* parallel_mng, MpiAdapter* adapter,MpiDatatype* datatype);
69 public:
70 ARCANE_MPI_EXPORT ~MpiParallelDispatchT() override;
71 ARCANE_MPI_EXPORT void finalize() override;
72 public:
73 void broadcast(ArrayView<Type> send_buf,Int32 rank) override
74 { m_mp_dispatcher->broadcast(send_buf,rank); }
75 void allGather(ConstArrayView<Type> send_buf, ArrayView<Type> recv_buf) override
76 { m_mp_dispatcher->allGather(send_buf,recv_buf); }
77 void allGatherVariable(ConstArrayView<Type> send_buf, Array<Type>& recv_buf) override
78 { m_mp_dispatcher->allGatherVariable(send_buf,recv_buf); }
79 void gather(ConstArrayView<Type> send_buf, ArrayView<Type> recv_buf, Int32 rank) override
80 { m_mp_dispatcher->gather(send_buf,recv_buf,rank); }
81 void gatherVariable(ConstArrayView<Type> send_buf, Array<Type>& recv_buf, Int32 rank) override
82 { m_mp_dispatcher->gatherVariable(send_buf,recv_buf,rank); }
83 void scatterVariable(ConstArrayView<Type> send_buf, ArrayView<Type> recv_buf, Int32 root) override
84 { m_mp_dispatcher->scatterVariable(send_buf,recv_buf,root); }
85 void allToAll(ConstArrayView<Type> send_buf, ArrayView<Type> recv_buf, Integer count) override
86 { m_mp_dispatcher->allToAll(send_buf,recv_buf,count); }
87 void allToAllVariable(ConstArrayView<Type> send_buf, Int32ConstArrayView send_count,
88 Int32ConstArrayView send_index,ArrayView<Type> recv_buf,
89 Int32ConstArrayView recv_count,Int32ConstArrayView recv_index) override
90 { m_mp_dispatcher->allToAllVariable(send_buf,send_count,send_index,recv_buf,recv_count,recv_index); }
91 Request send(ConstArrayView<Type> send_buffer, Int32 rank, bool is_blocked) override
92 { return m_mp_dispatcher->send(send_buffer,rank,is_blocked); }
93 Request send(Span<const Type> recv_buffer, const PointToPointMessageInfo& message) override
94 { return m_mp_dispatcher->send(recv_buffer,message); }
95 Request recv(ArrayView<Type> recv_buffer, Int32 rank, bool is_blocked) override
96 { return m_mp_dispatcher->receive(recv_buffer,rank,is_blocked); }
97 Request receive(Span<Type> recv_buffer, const PointToPointMessageInfo& message) override
98 { return m_mp_dispatcher->receive(recv_buffer,message); }
99 void send(ConstArrayView<Type> send_buffer, Int32 rank) override
100 { m_mp_dispatcher->send(send_buffer,rank,true); }
101 void recv(ArrayView<Type> recv_buffer, Int32 rank) override
102 { m_mp_dispatcher->receive(recv_buffer,rank,true); }
103 Type allReduce(eReduceType op, Type send_buf) override
104 { return m_mp_dispatcher->allReduce(op,send_buf); }
105 void allReduce(eReduceType op, ArrayView<Type> send_buf) override
106 {
107 m_mp_dispatcher->allReduce(op, send_buf);
108 }
109 void allReduce(eReduceType op, ConstArrayView<Type> send_buf, ArrayView<Type> receive_buf) override
110 {
111 m_mp_dispatcher->allReduce(op, send_buf, receive_buf);
112 }
113
114 public:
115 ARCANE_MPI_EXPORT void sendRecv(ConstArrayView<Type> send_buffer, ArrayView<Type> recv_buffer, Int32 rank) override;
116 ARCANE_MPI_EXPORT Type scan(eReduceType op, Type send_buf) override;
117 ARCANE_MPI_EXPORT void scan(eReduceType op, ArrayView<Type> send_buf) override;
118 ARCANE_MPI_EXPORT void computeMinMaxSum(Type val, Type& min_val, Type& max_val, Type& sum_val,
119 Int32& min_rank,
120 Int32& max_rank) override;
121 ARCANE_MPI_EXPORT void computeMinMaxSum(ConstArrayView<Type> values,
122 ArrayView<Type> min_values,
123 ArrayView<Type> max_values,
124 ArrayView<Type> sum_values,
125 ArrayView<Int32> min_ranks,
126 ArrayView<Int32> max_ranks) override;
127
128 public:
129
130 ITypeDispatcher<Type>* toArccoreDispatcher() override;
131 MpiDatatype* datatype() const;
132
133 public:
134
135 virtual ARCANE_MPI_EXPORT void computeMinMaxSumNoInit(Type& min_val, Type& max_val, Type& sum_val,
136 Int32& min_rank,Int32& max_rank);
137 private:
138 MP::Mpi::MpiTypeDispatcher<Type>* m_mp_dispatcher;
139
140 private:
141 MPI_Datatype m_min_max_sum_datatype;
142 MPI_Op m_min_max_sum_operator;
143
144 private:
145 void _initialize();
146 MPI_Datatype _mpiDatatype();
147 MpiAdapter* _adapter();
148 MPI_Op _mpiReduceOperator(eReduceType rt);
149 static void ARCANE_MPIOP_CALL _MinMaxSumOperator(void* a,void* b,int* len,MPI_Datatype* type);
150};
151
152/*---------------------------------------------------------------------------*/
153/*---------------------------------------------------------------------------*/
154
155template<typename Type> inline MpiParallelDispatchT<Type>*
156createBuiltInDispatcher(ITraceMng* tm,IMessagePassingMng* pm,MpiAdapter* adapter,MpiDatatypeList* dtlist)
157{
158 MpiDatatype* dt = dtlist->datatype(Type());
159 return new MpiParallelDispatchT<Type>(tm,pm,adapter,dt);
160}
161
162/*---------------------------------------------------------------------------*/
163/*---------------------------------------------------------------------------*/
164
165} // End namespace Arcane
166
167/*---------------------------------------------------------------------------*/
168/*---------------------------------------------------------------------------*/
169
170#endif
171
#define ARCCORE_INTERNAL_DEFINE_REFERENCE_COUNTED_INCLASS_METHODS(OPTIONAL_OVERRIDE)
Vue modifiable d'un tableau d'un type T.
Vue constante d'un tableau de type T.
Gestion des messages parallèles pour le type Type.
Interface du gestionnaire de traces.
Interface du gestionnaire des échanges de messages.
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.
Interface des messages pour le type Type.
Gestionnaire du parallélisme utilisant MPI.
Implémentation thread-safe d'un compteur de référence.
TraceAccessor(ITraceMng *m)
Construit un accesseur via le gestionnaire de trace m.
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.
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.
Espace de nommage contenant les types et déclarations qui gèrent le mécanisme de parallélisme par éch...
Type
Type of JSON value.
Definition rapidjson.h:730