Skip to content

Commit 0644fb8

Browse files
committed
Different message tag for each mpi exchanger
1 parent 636e6fd commit 0644fb8

3 files changed

Lines changed: 12 additions & 5 deletions

File tree

src/macros.hpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
#if COMPONENTS == 3
2626
#define EXPAND(a,b,c) a b c
2727
#define SELECT(a,b,c) c
28-
2928
#endif
3029

3130
#if DIMENSIONS == 1

src/mpi/exchanger.cpp

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
#include "grid.hpp"
1313
#include "arrays.hpp"
1414

15+
int Exchanger::nInstances = 0;
16+
1517
void Exchanger::Init(
1618
Grid *grid,
1719
int direction,
@@ -27,6 +29,9 @@ void Exchanger::Init(
2729
this->mapNVars = inputMap.size();
2830
this->haveVs = inputHaveVs;
2931

32+
// increase the number of instances
33+
this->thisInstance = nInstances;
34+
3035
// Compute indices of arrays we will be working with
3136
for(int dir = 0 ; dir < 3 ; dir++) {
3237
this->nghost[dir] = nghost[dir];
@@ -119,28 +124,29 @@ void Exchanger::Init(
119124
// We receive from procRecv, and we send to procSend
120125

121126
MPI_Send_init(BufferSend[faceRight].data(), bufferSize[faceRight], realMPI,
122-
procSend[faceRight], thisInstance*100+10*direction,
127+
procSend[faceRight], thisInstance*2,
123128
grid->CartComm, &sendRequest[faceRight]);
124129

125130
MPI_Recv_init(BufferRecv[faceLeft].data(), bufferSize[faceRight], realMPI,
126-
procRecv[faceLeft],thisInstance*100+10*direction,
131+
procRecv[faceLeft],thisInstance*2,
127132
grid->CartComm, &recvRequest[faceLeft]);
128133

129134
// Send to the left
130135
// We receive from procRecv, and we send to procSend
131136

132137
MPI_Send_init(BufferSend[faceLeft].data(), bufferSize[faceLeft], realMPI,
133-
procSend[faceLeft],thisInstance*100+10*direction+1,
138+
procSend[faceLeft],thisInstance*2+1,
134139
grid->CartComm, &sendRequest[faceLeft]);
135140

136141
MPI_Recv_init(BufferRecvX1[faceRight].data(), bufferSizeX1[faceLeft], realMPI,
137-
procRecv[faceRight], thisInstance*100+10*direction+1,
142+
procRecv[faceRight], thisInstance*2+1,
138143
grid->CartComm, &recvRequest[faceRight]);
139144

140145
#endif // MPI_PERSISTENT
141146

142147
// say this instance is initialized.
143148
isInitialized = true;
149+
nInstances++;
144150

145151
idfx::popRegion();
146152
}

src/mpi/exchanger.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ class Exchanger {
3434
void Exchange(IdefixArray4D<real> Vc, IdefixArray4D<real> Vs);
3535
~Exchanger();
3636

37+
static int nInstances; // total number of mpi instances in the code
38+
int thisInstance; // unique number of the current instance
3739
bool isInitialized{false};
3840

3941
// MPI throughput timer specific to this object

0 commit comments

Comments
 (0)