14#include "arcane/utils/MemoryView.h"
16#include "arcane/parallel/mpi/MpiParallelMng.h"
17#include "arcane/parallel/mpi/MpiDatatypeList.h"
18#include "arcane/parallel/mpi/MpiDatatype.h"
19#include "arcane/parallel/mpi/MpiTimeInterval.h"
20#include "arcane/parallel/IStat.h"
22#include "arcane/impl/IDataSynchronizeBuffer.h"
23#include "arcane/impl/IDataSynchronizeImplementation.h"
25#include "arccore/message_passing_mpi/internal/MpiAdapter.h"
39class MpiDirectSendrecvVariableSynchronizerDispatcher
45 explicit MpiDirectSendrecvVariableSynchronizerDispatcher(
Factory* f);
49 void compute()
override {}
70 : m_mpi_parallel_mng(mpi_pm)
75 auto* x =
new MpiDirectSendrecvVariableSynchronizerDispatcher(
this);
88arcaneCreateMpiDirectSendrecvVariableSynchronizerFactory(
MpiParallelMng* mpi_pm)
97MpiDirectSendrecvVariableSynchronizerDispatcher::
98MpiDirectSendrecvVariableSynchronizerDispatcher(Factory* f)
99: m_mpi_parallel_mng(f->m_mpi_parallel_mng)
106void MpiDirectSendrecvVariableSynchronizerDispatcher::
107beginSynchronize(IDataSynchronizeBuffer* vs_buf)
109 Int32 nb_message = vs_buf->nbRank();
111 constexpr int serialize_tag = 523;
113 MpiParallelMng* pm = m_mpi_parallel_mng;
114 MpiDatatypeList* dtlist = pm->datatypes();
115 const MPI_Datatype mpi_dt = dtlist->datatype(
Byte())->datatype();
117 double sync_copy_send_time = 0.0;
118 double sync_copy_recv_time = 0.0;
119 double sync_wait_time = 0.0;
122 MpiTimeInterval tit(&sync_copy_send_time);
123 vs_buf->copyAllSend();
127 MpiTimeInterval tit(&sync_wait_time);
128 for (
Integer i = 0; i < nb_message; ++i) {
129 Int32 target_rank = vs_buf->targetRank(i);
130 auto rbuf = vs_buf->receiveBuffer(i).bytes().smallView();
131 auto sbuf = vs_buf->sendBuffer(i).bytes().smallView();
133 MPI_Sendrecv(sbuf.data(), sbuf.size(), mpi_dt, target_rank, serialize_tag,
134 rbuf.data(), rbuf.size(), mpi_dt, target_rank, serialize_tag,
135 pm->communicator(), MPI_STATUS_IGNORE);
140 MpiTimeInterval tit(&sync_copy_recv_time);
141 vs_buf->copyAllReceive();
144 pm->stat()->add(
"SyncCopySend", sync_copy_send_time, 1);
145 pm->stat()->add(
"SyncWait", sync_wait_time, 1);
146 pm->stat()->add(
"SyncCopyRecv", sync_copy_recv_time, 1);
Generic buffer for data synchronization.
Interface for a generic dispatcher factory.
Parallelism manager using MPI.
Reference to an instance.
-- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature --
Int32 Integer
Type representing an integer.
unsigned char Byte
Type of a byte.
auto makeRef(InstanceType *t) -> Ref< InstanceType >
Creates a reference on a pointer.
std::int32_t Int32
Signed integer type of 32 bits.