Arcane  v3.14.10.0
Documentation développeur
Chargement...
Recherche...
Aucune correspondance
MpiDirectSendrecvVariableSynchronizeDispatcher.cc
1// -*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-
2//-----------------------------------------------------------------------------
3// Copyright 2000-2023 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/* MpiDirectSendrecvVariableSynchronizeDispatcher.cc (C) 2000-2023 */
9/* */
10/* Gestion spécifique MPI des synchronisations des variables. */
11/*---------------------------------------------------------------------------*/
12/*---------------------------------------------------------------------------*/
13
14#include "arcane/utils/MemoryView.h"
15
16#include "arcane/parallel/mpi/MpiParallelMng.h"
17#include "arcane/parallel/mpi/MpiAdapter.h"
18#include "arcane/parallel/mpi/MpiDatatypeList.h"
19#include "arcane/parallel/mpi/MpiDatatype.h"
20#include "arcane/parallel/mpi/MpiTimeInterval.h"
21#include "arcane/parallel/IStat.h"
22
23#include "arcane/impl/IDataSynchronizeBuffer.h"
24#include "arcane/impl/IDataSynchronizeImplementation.h"
25
26/*---------------------------------------------------------------------------*/
27/*---------------------------------------------------------------------------*/
28
29namespace Arcane
30{
31
32/*---------------------------------------------------------------------------*/
33/*---------------------------------------------------------------------------*/
39{
40 public:
41
42 class Factory;
44
45 protected:
46
47 void compute() override {}
48 void beginSynchronize(IDataSynchronizeBuffer* vs_buf) override;
49 void endSynchronize(IDataSynchronizeBuffer*) override
50 {
51 // With this implementation, we do not need this function.
52 }
53
54 private:
55
56 MpiParallelMng* m_mpi_parallel_mng;
57};
58
59/*---------------------------------------------------------------------------*/
60/*---------------------------------------------------------------------------*/
61
64{
65 public:
66
68 : m_mpi_parallel_mng(mpi_pm)
69 {}
70
71 Ref<IDataSynchronizeImplementation> createInstance() override
72 {
75 }
76
77 public:
78
79 MpiParallelMng* m_mpi_parallel_mng = nullptr;
80};
81
82/*---------------------------------------------------------------------------*/
83/*---------------------------------------------------------------------------*/
84
86arcaneCreateMpiDirectSendrecvVariableSynchronizerFactory(MpiParallelMng* mpi_pm)
87{
90}
91
92/*---------------------------------------------------------------------------*/
93/*---------------------------------------------------------------------------*/
94
95MpiDirectSendrecvVariableSynchronizerDispatcher::
96MpiDirectSendrecvVariableSynchronizerDispatcher(Factory* f)
97: m_mpi_parallel_mng(f->m_mpi_parallel_mng)
98{
99}
100
101/*---------------------------------------------------------------------------*/
102/*---------------------------------------------------------------------------*/
103
104void MpiDirectSendrecvVariableSynchronizerDispatcher::
105beginSynchronize(IDataSynchronizeBuffer* vs_buf)
106{
107 Int32 nb_message = vs_buf->nbRank();
108
109 constexpr int serialize_tag = 523;
110
111 MpiParallelMng* pm = m_mpi_parallel_mng;
112 MpiDatatypeList* dtlist = pm->datatypes();
113 const MPI_Datatype mpi_dt = dtlist->datatype(Byte())->datatype();
114
115 double sync_copy_send_time = 0.0;
116 double sync_copy_recv_time = 0.0;
117 double sync_wait_time = 0.0;
118
119 {
120 MpiTimeInterval tit(&sync_copy_send_time);
121 vs_buf->copyAllSend();
122 }
123
124 {
125 MpiTimeInterval tit(&sync_wait_time);
126 for( Integer i=0; i<nb_message; ++i ){
127 Int32 target_rank = vs_buf->targetRank(i);
128 auto rbuf = vs_buf->receiveBuffer(i).bytes().smallView();
129 auto sbuf = vs_buf->sendBuffer(i).bytes().smallView();
130
131 MPI_Sendrecv(sbuf.data(), sbuf.size(), mpi_dt, target_rank, serialize_tag,
132 rbuf.data(), rbuf.size(), mpi_dt, target_rank, serialize_tag,
133 pm->communicator(), MPI_STATUS_IGNORE);
134 }
135 }
136
137 {
138 MpiTimeInterval tit(&sync_copy_recv_time);
139 vs_buf->copyAllReceive();
140 }
141
142 pm->stat()->add("SyncCopySend",sync_copy_send_time,1);
143 pm->stat()->add("SyncWait",sync_wait_time,1);
144 pm->stat()->add("SyncCopyRecv",sync_copy_recv_time,1);
145}
146
147/*---------------------------------------------------------------------------*/
148/*---------------------------------------------------------------------------*/
149
150} // End namespace Arcane
151
152/*---------------------------------------------------------------------------*/
153/*---------------------------------------------------------------------------*/
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.
virtual Parallel::Communicator communicator() const =0
Communicateur MPI associé à ce gestionnaire.
Lecteur des fichiers de maillage via la bibliothèque LIMA.
Definition Lima.cc:120
Gestionnaire du parallélisme utilisant MPI.
-*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-
unsigned char Byte
Type d'un octet.
Definition UtilsTypes.h:142