14#include "arcane/utils/FatalErrorException.h"
15#include "arcane/utils/NotSupportedException.h"
16#include "arcane/utils/CheckedConvert.h"
17#include "arcane/utils/MemoryView.h"
19#include "arcane/parallel/mpi/MpiParallelMng.h"
20#include "arcane/parallel/mpi/MpiTimeInterval.h"
21#include "arcane/parallel/mpi/IVariableSynchronizerMpiCommunicator.h"
22#include "arcane/parallel/IStat.h"
24#include "arcane/impl/IDataSynchronizeBuffer.h"
25#include "arcane/impl/IDataSynchronizeImplementation.h"
26#include "arcane/impl/DataSynchronizeInfo.h"
28#include "arccore/message_passing_mpi/internal/MpiAdapter.h"
49class MpiNeighborVariableSynchronizerDispatcher
55 explicit MpiNeighborVariableSynchronizerDispatcher(
Factory* f);
59 void compute()
override;
82 : m_mpi_parallel_mng(mpi_pm)
83 , m_synchronizer_communicator(synchronizer_communicator)
88 auto* x =
new MpiNeighborVariableSynchronizerDispatcher(
this);
102arcaneCreateMpiNeighborVariableSynchronizerFactory(
MpiParallelMng* mpi_pm,
112MpiNeighborVariableSynchronizerDispatcher::
113MpiNeighborVariableSynchronizerDispatcher(Factory* f)
114: m_mpi_parallel_mng(f->m_mpi_parallel_mng)
115, m_synchronizer_communicator(f->m_synchronizer_communicator)
122void MpiNeighborVariableSynchronizerDispatcher::
123beginSynchronize(IDataSynchronizeBuffer* buf)
131 double send_copy_time = 0.0;
133 MpiTimeInterval tit(&send_copy_time);
138 Int64 total_share_size = buf->totalSendSize();
139 m_mpi_parallel_mng->stat()->add(
"SyncSendCopy", send_copy_time, total_share_size);
145void MpiNeighborVariableSynchronizerDispatcher::
146endSynchronize(IDataSynchronizeBuffer* buf)
148 const Int32 nb_message = buf->nbRank();
150 auto* sync_communicator = m_synchronizer_communicator.get();
153 MPI_Comm communicator = sync_communicator->communicator();
154 if (communicator == MPI_COMM_NULL)
157 MpiParallelMng* pm = m_mpi_parallel_mng;
158 const MPI_Datatype mpi_dt = MP::Mpi::MpiBuiltIn::datatype(
Byte());
160 double copy_time = 0.0;
161 double wait_time = 0.0;
163 if (!buf->hasGlobalBuffer())
164 ARCANE_THROW(NotSupportedException,
"Can not use MPI_Neighbor_alltoallv when hasGlobalBufer() is false");
166 for (
Integer i = 0; i < nb_message; ++i) {
172 m_mpi_send_counts[i] = nb_send;
173 m_mpi_receive_counts[i] = nb_receive;
174 m_mpi_send_displacements[i] = send_displacement;
175 m_mpi_receive_displacements[i] = receive_displacement;
179 MpiTimeInterval tit(&wait_time);
180 auto send_buf = buf->globalSendBuffer();
181 auto receive_buf = buf->globalReceiveBuffer();
182 MPI_Neighbor_alltoallv(send_buf.data(), m_mpi_send_counts.data(), m_mpi_send_displacements.data(), mpi_dt,
183 receive_buf.data(), m_mpi_receive_counts.data(), m_mpi_receive_displacements.data(), mpi_dt,
189 MpiTimeInterval tit(©_time);
190 buf->copyAllReceive();
193 Int64 total_ghost_size = buf->totalReceiveSize();
194 Int64 total_share_size = buf->totalSendSize();
195 Int64 total_size = total_ghost_size + total_share_size;
196 pm->stat()->add(
"SyncCopy", copy_time, total_ghost_size);
197 pm->stat()->add(
"SyncWait", wait_time, total_size);
203void MpiNeighborVariableSynchronizerDispatcher::
206 DataSynchronizeInfo* sync_info = _syncInfo();
209 auto* sync_communicator = m_synchronizer_communicator.get();
212 const Int32 nb_message = sync_info->size();
217 Int32 size = nb_message;
221 m_mpi_send_counts.resize(size);
222 m_mpi_receive_counts.resize(size);
223 m_mpi_send_displacements.resize(size);
224 m_mpi_receive_displacements.resize(size);
226 m_mpi_send_counts.fill(0);
227 m_mpi_receive_counts.fill(0);
228 m_mpi_send_displacements.fill(0);
229 m_mpi_receive_displacements.fill(0);
#define ARCANE_CHECK_POINTER(ptr)
Macro retournant le pointeur ptr s'il est non nul ou lancant une exception s'il est nul.
#define ARCANE_THROW(exception_class,...)
Macro pour envoyer une exception avec formattage.
#define ARCANE_FATAL(...)
Macro envoyant une exception FatalErrorException.
Buffer générique pour la synchronisation de données.
Interface d'une fabrique dispatcher générique.
Gestionnaire du parallélisme utilisant MPI.
Référence à une instance.
Vecteur 1D de données avec sémantique par valeur (style STL).
Int32 toInt32(Int64 v)
Converti un Int64 en un Int32.
-*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-
std::int64_t Int64
Type entier signé sur 64 bits.
Int32 Integer
Type représentant un entier.
unsigned char Byte
Type d'un octet.
auto makeRef(InstanceType *t) -> Ref< InstanceType >
Créé une référence sur un pointeur.
std::int32_t Int32
Type entier signé sur 32 bits.