Skip to content

Commit 12ed233

Browse files
committed
Fix issue with buffer swapping.
1 parent 8fdaa87 commit 12ed233

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/Infrastructure/VM/src/ESMCI_VMKernel.C

+5-3
Original file line numberDiff line numberDiff line change
@@ -7034,6 +7034,8 @@ int VMK::alltoall(void *in, int inCount, void *out, int outCount,
70347034
ESMC_LogDefault.Write(msg.str(), ESMC_LOGMSG_DEBUG);
70357035
}
70367036
// Step-2: Total exchange between SSI roots
7037+
char *xferSsiSBC = NULL;
7038+
std::vector<char> xferSsiSendBuffer;
70377039
if (mpi_c_ssi_roots != MPI_COMM_NULL){
70387040
// - SSI roots prepare local xferPetMap
70397041
std::map<int,int> xferPetMap;
@@ -7071,8 +7073,8 @@ int VMK::alltoall(void *in, int inCount, void *out, int outCount,
70717073
bufferSize = inCount * size;
70727074
bufferSize *= npets - ssiLocalPetCount;
70737075
bufferSize *= ssiLocalPetCount;
7074-
std::vector<char> xferSsiSendBuffer(bufferSize);
7075-
char *xferSsiSBC = (char *)&(xferSsiSendBuffer[0]);
7076+
xferSsiSendBuffer.resize(bufferSize);
7077+
xferSsiSBC = (char *)&(xferSsiSendBuffer[0]);
70767078
int localSsi; // rank of local SSI's root, same as SSI index
70777079
MPI_Comm_rank(mpi_c_ssi_roots, &localSsi);
70787080
{
@@ -7134,7 +7136,7 @@ int VMK::alltoall(void *in, int inCount, void *out, int outCount,
71347136
}
71357137
// Step-3: SSI roots scatter xfer data to PETs on their SSI
71367138
// - SSI roots scatter xfer data to their SSI PETs from other SSI
7137-
MPI_Scatter(xferSsiBC, (npets-ssiLocalPetCount)*inCount, mpitype,
7139+
MPI_Scatter(xferSsiSBC, (npets-ssiLocalPetCount)*inCount, mpitype,
71387140
xferBC, (npets-ssiLocalPetCount)*outCount, mpitype, 0, mpi_c_ssi);
71397141
// - Each PET upacks the xferBuffer into its "out" data.
71407142
char *outC = (char *)out;

0 commit comments

Comments
 (0)