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/MpiAdapter.h"
21#include "arcane/parallel/mpi/MpiTimeInterval.h"
22#include "arcane/parallel/mpi/IVariableSynchronizerMpiCommunicator.h"
23#include "arcane/parallel/IStat.h"
25#include "arcane/impl/IDataSynchronizeBuffer.h"
26#include "arcane/impl/IDataSynchronizeImplementation.h"
27#include "arcane/impl/DataSynchronizeInfo.h"
58 void compute()
override;
81 : m_mpi_parallel_mng(
mpi_pm)
111MpiNeighborVariableSynchronizerDispatcher::
112MpiNeighborVariableSynchronizerDispatcher(Factory* f)
113: m_mpi_parallel_mng(f->m_mpi_parallel_mng)
114, m_synchronizer_communicator(f->m_synchronizer_communicator)
121void MpiNeighborVariableSynchronizerDispatcher::
122beginSynchronize(IDataSynchronizeBuffer* buf)
130 double send_copy_time = 0.0;
132 MpiTimeInterval tit(&send_copy_time);
137 Int64 total_share_size = buf->totalSendSize();
138 m_mpi_parallel_mng->
stat()->
add(
"SyncSendCopy", send_copy_time, total_share_size);
144void MpiNeighborVariableSynchronizerDispatcher::
145endSynchronize(IDataSynchronizeBuffer* buf)
147 const Int32 nb_message = buf->nbRank();
149 auto* sync_communicator = m_synchronizer_communicator.get();
152 MPI_Comm communicator = sync_communicator->communicator();
153 if (communicator == MPI_COMM_NULL)
156 MpiParallelMng* pm = m_mpi_parallel_mng;
157 const MPI_Datatype mpi_dt = MP::Mpi::MpiBuiltIn::datatype(
Byte());
159 double copy_time = 0.0;
160 double wait_time = 0.0;
162 if (!buf->hasGlobalBuffer())
163 ARCANE_THROW(NotSupportedException,
"Can not use MPI_Neighbor_alltoallv when hasGlobalBufer() is false");
165 for (Integer i = 0; i < nb_message; ++i) {
171 m_mpi_send_counts[i] = nb_send;
172 m_mpi_receive_counts[i] = nb_receive;
173 m_mpi_send_displacements[i] = send_displacement;
174 m_mpi_receive_displacements[i] = receive_displacement;
178 MpiTimeInterval tit(&wait_time);
179 auto send_buf = buf->globalSendBuffer();
180 auto receive_buf = buf->globalReceiveBuffer();
181 MPI_Neighbor_alltoallv(send_buf.data(), m_mpi_send_counts.
data(), m_mpi_send_displacements.
data(), mpi_dt,
182 receive_buf.data(), m_mpi_receive_counts.
data(), m_mpi_receive_displacements.
data(), mpi_dt,
188 MpiTimeInterval tit(©_time);
189 buf->copyAllReceive();
192 Int64 total_ghost_size = buf->totalReceiveSize();
193 Int64 total_share_size = buf->totalSendSize();
194 Int64 total_size = total_ghost_size + total_share_size;
195 pm->
stat()->add(
"SyncCopy", copy_time, total_ghost_size);
196 pm->
stat()->add(
"SyncWait", wait_time, total_size);
202void MpiNeighborVariableSynchronizerDispatcher::
205 DataSynchronizeInfo* sync_info = _syncInfo();
208 auto* sync_communicator = m_synchronizer_communicator.get();
211 const Int32 nb_message = sync_info->size();
216 Int32 size = nb_message;
220 m_mpi_send_counts.
resize(size);
221 m_mpi_receive_counts.
resize(size);
222 m_mpi_send_displacements.
resize(size);
223 m_mpi_receive_displacements.
resize(size);
225 m_mpi_send_counts.
fill(0);
226 m_mpi_receive_counts.
fill(0);
227 m_mpi_send_displacements.
fill(0);
228 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.
virtual IStat * stat()=0
Gestionnaire des statistiques.
Lecteur des fichiers de maillage via la bibliothèque LIMA.
Gestionnaire du parallélisme utilisant MPI.
Parallel::IStat * stat() override
Gestionnaire des statistiques.
virtual void add(const String &name, double elapsed_time, Int64 msg_size)=0
Ajoute une statistique.
const T * data() const
Accès à la racine du tableau hors toute protection.
void resize(Int64 s)
Change le nombre d'éléments du tableau à s.
void fill(ConstReferenceType value)
Remplit le tableau avec la valeur value.
Int32 toInt32(Int64 v)
Converti un Int64 en un Int32.
-*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-
unsigned char Byte
Type d'un octet.