Skip to content

Commit 6c267ad

Browse files
committed
Remove unnecessary shuffle of data on the receiving side. Code cleanup.
1 parent 12ed233 commit 6c267ad

File tree

1 file changed

+3
-38
lines changed

1 file changed

+3
-38
lines changed

src/Infrastructure/VM/src/ESMCI_VMKernel.C

+3-38
Original file line numberDiff line numberDiff line change
@@ -7009,12 +7009,6 @@ int VMK::alltoall(void *in, int inCount, void *out, int outCount,
70097009
memcpy(xferBC+inCount*size*j, inC+inCount*size*i, inCount*size);
70107010
++j;
70117011
}
7012-
{
7013-
std::stringstream msg;
7014-
msg << "VMK::alltoall(): line=" << __LINE__
7015-
<< " inCount=" << inCount;
7016-
ESMC_LogDefault.Write(msg.str(), ESMC_LOGMSG_DEBUG);
7017-
}
70187012
// - SSI roots gather xfer data from their SSI PETs toward other SSI
70197013
char *xferSsiBC = NULL;
70207014
std::vector<char> xferSsiBuffer;
@@ -7027,15 +7021,7 @@ int VMK::alltoall(void *in, int inCount, void *out, int outCount,
70277021
}
70287022
MPI_Gather(xferBC, (npets-ssiLocalPetCount)*inCount, mpitype,
70297023
xferSsiBC, (npets-ssiLocalPetCount)*outCount, mpitype, 0, mpi_c_ssi);
7030-
{
7031-
std::stringstream msg;
7032-
msg << "VMK::alltoall(): line=" << __LINE__
7033-
<< " gathered into xferSsiBuffer bytes =" << bufferSize;
7034-
ESMC_LogDefault.Write(msg.str(), ESMC_LOGMSG_DEBUG);
7035-
}
70367024
// Step-2: Total exchange between SSI roots
7037-
char *xferSsiSBC = NULL;
7038-
std::vector<char> xferSsiSendBuffer;
70397025
if (mpi_c_ssi_roots != MPI_COMM_NULL){
70407026
// - SSI roots prepare local xferPetMap
70417027
std::map<int,int> xferPetMap;
@@ -7073,16 +7059,10 @@ int VMK::alltoall(void *in, int inCount, void *out, int outCount,
70737059
bufferSize = inCount * size;
70747060
bufferSize *= npets - ssiLocalPetCount;
70757061
bufferSize *= ssiLocalPetCount;
7076-
xferSsiSendBuffer.resize(bufferSize);
7077-
xferSsiSBC = (char *)&(xferSsiSendBuffer[0]);
7062+
std::vector<char> xferSsiSendBuffer(bufferSize);
7063+
char *xferSsiSBC = (char *)&(xferSsiSendBuffer[0]);
70787064
int localSsi; // rank of local SSI's root, same as SSI index
70797065
MPI_Comm_rank(mpi_c_ssi_roots, &localSsi);
7080-
{
7081-
std::stringstream msg;
7082-
msg << "VMK::alltoall(): line=" << __LINE__
7083-
<< " localSsi=" << localSsi;
7084-
ESMC_LogDefault.Write(msg.str(), ESMC_LOGMSG_DEBUG);
7085-
}
70867066
std::vector<int> xferInCounts(ssiCount);
70877067
std::vector<int> xferInOffsets(ssiCount);
70887068
std::vector<int> xferOutCounts(ssiCount);
@@ -7118,25 +7098,10 @@ int VMK::alltoall(void *in, int inCount, void *out, int outCount,
71187098
MPI_Alltoallv(xferSsiSBC, &(xferInCounts[0]), &(xferInOffsets[0]),
71197099
mpitype, xferSsiBC, &(xferOutCounts[0]), &(xferOutOffsets[0]),
71207100
mpitype, mpi_c_ssi_roots);
7121-
// - SSI roots re-arrange data for scattering to PETs on same SSI
7122-
for (int i=0; i<ssiCount; i++){
7123-
// data block received from PETs in SSI i
7124-
if (i == localSsi) continue; // no self communication for local SSI
7125-
for (int k=0; k<ssiLocalPetCounts[i]; k++){
7126-
// data block from local PET k on SSI i to local SSI
7127-
for (int l=0; l<ssiLocalPetCount; l++){
7128-
// data block from local PET k on SSI i to SSI local PET l
7129-
memcpy(xferSsiSBC+inCount*size*(npets-ssiLocalPetCount)*l
7130-
+inCount*size*xferPetMap[ssiLocalPetLists[offsets[i]+k]],
7131-
xferSsiBC+inCount*size*j, inCount*size);
7132-
++j;
7133-
}
7134-
}
7135-
}
71367101
}
71377102
// Step-3: SSI roots scatter xfer data to PETs on their SSI
71387103
// - SSI roots scatter xfer data to their SSI PETs from other SSI
7139-
MPI_Scatter(xferSsiSBC, (npets-ssiLocalPetCount)*inCount, mpitype,
7104+
MPI_Scatter(xferSsiBC, (npets-ssiLocalPetCount)*inCount, mpitype,
71407105
xferBC, (npets-ssiLocalPetCount)*outCount, mpitype, 0, mpi_c_ssi);
71417106
// - Each PET upacks the xferBuffer into its "out" data.
71427107
char *outC = (char *)out;

0 commit comments

Comments
 (0)