Skip to content

Commit f585f53

Browse files
committed
Work on GaeaC5 doing large PET count test runs.
1 parent b61764f commit f585f53

File tree

1 file changed

+45
-3
lines changed

1 file changed

+45
-3
lines changed

src/Infrastructure/VM/src/ESMCI_VMKernel.C

+45-3
Original file line numberDiff line numberDiff line change
@@ -6967,6 +6967,11 @@ int VMK::alltoall(void *in, int inCount, void *out, int outCount,
69676967
#endif
69686968
#if 1
69696969
{
6970+
{
6971+
std::stringstream msg;
6972+
msg << "VMK::alltoall(): hierarchical implementation inCount=" << inCount;
6973+
ESMC_LogDefault.Write(msg.str(), ESMC_LOGMSG_DEBUG);
6974+
}
69706975
// Hierarchical Alltoall implementation, with SSI roots as intermediary
69716976
// Step-0: SSI-local exchange via alltoallv to avoid data movements.
69726977
std::vector<int> inCounts(ssiLocalPetCount, inCount);
@@ -6985,6 +6990,11 @@ int VMK::alltoall(void *in, int inCount, void *out, int outCount,
69856990
if (ssiCount > 1){
69866991
// Multiple SSIs in the VM, under each mpi_c_ssi communicator,
69876992
// using task 0 as the SSI root PET below.
6993+
{
6994+
std::stringstream msg;
6995+
msg << "VMK::alltoall(): ssiCount=" << ssiCount;
6996+
ESMC_LogDefault.Write(msg.str(), ESMC_LOGMSG_DEBUG);
6997+
}
69886998
// Step-1: SSI root PETs gather xfer data on their SSI.
69896999
// - Each PET prepares an xferBuffer to send its "in" data that is
69907000
// destined for PETs outside the local SSI to its SSI root PET.
@@ -6997,6 +7007,12 @@ int VMK::alltoall(void *in, int inCount, void *out, int outCount,
69977007
memcpy(xferBC+outCount*size*j, inC+inCount*size*i, inCount*size);
69987008
++j;
69997009
}
7010+
{
7011+
std::stringstream msg;
7012+
msg << "VMK::alltoall(): line=" << __LINE__
7013+
<< " inCount=" << inCount;
7014+
ESMC_LogDefault.Write(msg.str(), ESMC_LOGMSG_DEBUG);
7015+
}
70007016
// - SSI roots gather xfer data from their SSI PETs toward other SSI
70017017
char *xferSsiBC = NULL;
70027018
std::vector<char> xferSsiBuffer;
@@ -7007,8 +7023,23 @@ int VMK::alltoall(void *in, int inCount, void *out, int outCount,
70077023
}
70087024
MPI_Gather(xferBC, (npets-ssiLocalPetCount)*inCount, mpitype,
70097025
xferSsiBC, (npets-ssiLocalPetCount)*outCount, mpitype, 0, mpi_c_ssi);
7026+
{
7027+
std::stringstream msg;
7028+
msg << "VMK::alltoall(): line=" << __LINE__
7029+
<< " gathered into xferSsiBuffer bytes =" << (npets-ssiLocalPetCount)
7030+
*inCount*size*ssiLocalPetCount;
7031+
ESMC_LogDefault.Write(msg.str(), ESMC_LOGMSG_DEBUG);
7032+
}
70107033
// Total exchange between SSI roots
70117034
if (mpi_c_ssi_roots != MPI_COMM_NULL){
7035+
// - SSI roots prepare local xferPetMap
7036+
std::map<int,int> xferPetMap;
7037+
j=0;
7038+
for (int i=0; i<npets; i++){
7039+
if (ssiLocalPetSet.find(i) != ssiLocalPetSet.end()) continue; //skip
7040+
xferPetMap[i]=j;
7041+
++j;
7042+
}
70127043
// - SSI roots exchange their ssiLocalPetCount
70137044
std::vector<int> ssiLocalPetCounts(ssiCount);
70147045
MPI_Allgather(&ssiLocalPetCount, 1, MPI_INT,
@@ -7024,6 +7055,7 @@ int VMK::alltoall(void *in, int inCount, void *out, int outCount,
70247055
&(ssiLocalPetLists[0]), &(ssiLocalPetCounts[0]), &(offsets[0]),
70257056
MPI_INT, mpi_c_ssi_roots);
70267057
// - SSI roots keep track of all the PETs in the other SSIs
7058+
// -> TODO: might be obsolete
70277059
std::vector<std::set<int> > ssiLocalPetSets(ssiCount);
70287060
j=0;
70297061
for (int i=0; i<ssiCount; i++){
@@ -7038,12 +7070,19 @@ int VMK::alltoall(void *in, int inCount, void *out, int outCount,
70387070
char *xferSsiSBC = (char *)&(xferSsiSendBuffer[0]);
70397071
int localSsi; // rank of local SSI's root, same as SSI index
70407072
MPI_Comm_rank(mpi_c_ssi_roots, &localSsi);
7073+
{
7074+
std::stringstream msg;
7075+
msg << "VMK::alltoall(): line=" << __LINE__
7076+
<< " localSsi=" << localSsi;
7077+
ESMC_LogDefault.Write(msg.str(), ESMC_LOGMSG_DEBUG);
7078+
}
7079+
70417080
std::vector<int> xferInCounts(ssiCount);
70427081
std::vector<int> xferInOffsets(ssiCount);
70437082
std::vector<int> xferOutCounts(ssiCount);
70447083
std::vector<int> xferOutOffsets(ssiCount);
70457084
xferInOffsets[0] = xferOutOffsets[0] = 0;
7046-
j=0; int jj=0;
7085+
j=0;
70477086
for (int i=0; i<ssiCount; i++){
70487087
// prep data block to send to PETs in SSI i
70497088
if (i > 0){
@@ -7063,18 +7102,21 @@ int VMK::alltoall(void *in, int inCount, void *out, int outCount,
70637102
// prepare block from local SSI local PET l to PET k on SSI i
70647103
memcpy(xferSsiSBC+inCount*size*j, xferSsiBC
70657104
+inCount*size*(npets-ssiLocalPetCount)*l
7066-
+inCount*size*ssiLocalPetLists[offsets[i]+k],
7105+
+inCount*size*xferPetMap[ssiLocalPetLists[offsets[i]+k]],
70677106
inCount*size);
70687107
++j;
70697108
}
70707109
}
70717110
}
7111+
#if 1
70727112
// - Alltoallv xferSsiSendBuffer -> xferSsiBuffer
70737113
MPI_Alltoallv(xferSsiSBC, &(xferInCounts[0]), &(xferInOffsets[0]),
70747114
mpitype, xferSsiBC, &(xferOutCounts[0]), &(xferOutOffsets[0]),
7075-
mpitype, mpi_c_ssi);
7115+
mpitype, mpi_c_ssi_roots);
7116+
#endif
70767117
}
70777118
}
7119+
MPI_Barrier(mpi_c); //TODO: remove once implementation done
70787120
}
70797121
#endif
70807122
}else{

0 commit comments

Comments
 (0)