Arcane  v3.14.10.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-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/* MpiParallelDispatch.h (C) 2000-2024 */
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/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>
47: public TraceAccessor
49, public IParallelDispatchT<Type>
50{
51 ARCCORE_INTERNAL_DEFINE_REFERENCE_COUNTED_INCLASS_METHODS();
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:
67 public:
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 { m_mp_dispatcher->allReduce(op,send_buf); }
107
108 public:
109 ARCANE_MPI_EXPORT void sendRecv(ConstArrayView<Type> send_buffer, ArrayView<Type> recv_buffer, Int32 rank) override;
110 ARCANE_MPI_EXPORT Type scan(eReduceType op, Type send_buf) override;
111 ARCANE_MPI_EXPORT void scan(eReduceType op, ArrayView<Type> send_buf) override;
112 ARCANE_MPI_EXPORT void computeMinMaxSum(Type val, Type& min_val, Type& max_val, Type& sum_val,
113 Int32& min_rank,
114 Int32& max_rank) override;
115 ARCANE_MPI_EXPORT void computeMinMaxSum(ConstArrayView<Type> values,
116 ArrayView<Type> min_values,
117 ArrayView<Type> max_values,
118 ArrayView<Type> sum_values,
119 ArrayView<Int32> min_ranks,
120 ArrayView<Int32> max_ranks) override;
121
122 public:
123
124 ITypeDispatcher<Type>* toArccoreDispatcher() override;
125 MpiDatatype* datatype() const;
126
127 public:
128
129 virtual ARCANE_MPI_EXPORT void computeMinMaxSumNoInit(Type& min_val, Type& max_val, Type& sum_val,
130 Int32& min_rank,Int32& max_rank);
131 private:
132 MP::Mpi::MpiTypeDispatcher<Type>* m_mp_dispatcher;
133
134 private:
135 MPI_Datatype m_min_max_sum_datatype;
136 MPI_Op m_min_max_sum_operator;
137
138 private:
139 void _initialize();
140 MPI_Datatype _mpiDatatype();
141 MpiAdapter* _adapter();
142 MPI_Op _mpiReduceOperator(eReduceType rt);
143 static void ARCANE_MPIOP_CALL _MinMaxSumOperator(void* a,void* b,int* len,MPI_Datatype* type);
144};
145
146/*---------------------------------------------------------------------------*/
147/*---------------------------------------------------------------------------*/
148
149template<typename Type> inline MpiParallelDispatchT<Type>*
150createBuiltInDispatcher(ITraceMng* tm,IMessagePassingMng* pm,MpiAdapter* adapter,MpiDatatypeList* dtlist)
151{
152 MpiDatatype* dt = dtlist->datatype(Type());
153 return new MpiParallelDispatchT<Type>(tm,pm,adapter,dt);
154}
155
156/*---------------------------------------------------------------------------*/
157/*---------------------------------------------------------------------------*/
158
159} // End namespace Arcane
160
161/*---------------------------------------------------------------------------*/
162/*---------------------------------------------------------------------------*/
163
164#endif
165
Gestion des messages parallèles pour le type Type.
Lecteur des fichiers de maillage via la bibliothèque LIMA.
Definition Lima.cc:120
Interface des messages 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
Implémentation thread-safe d'un compteur de référence.
-*- 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
Espace de nommage contenant les types et déclarations qui gèrent le mécanisme de parallélisme par éch...
eReduceType
Types des réductions supportées.
Type
Type of JSON value.
Definition rapidjson.h:665