Commit c873ea14 authored by Andrew J. Burns (Cont's avatar Andrew J. Burns (Cont Committed by Kenneth Leiter

fixed dependancy on using core 0 for accept/connect

parent 56bdaad8
......@@ -837,9 +837,9 @@ XdmfDSMBuffer::ReceiveInfo()
infoStatus = 1;
}
int groupInfoStatus[this->Comm->GetInterSize()];
int * groupInfoStatus = new int[this->Comm->GetInterSize()]();
MPI_Allgather(&infoStatus, 1, MPI_INT, &groupInfoStatus, 1, MPI_INT, this->Comm->GetInterComm());
MPI_Allgather(&infoStatus, 1, MPI_INT, &(groupInfoStatus[0]), 1, MPI_INT, this->Comm->GetInterComm());
int sendCore = 0;
......@@ -874,7 +874,7 @@ void
XdmfDSMBuffer::SendAccept(unsigned int numConnections)
{
for (int i = this->StartServerId; i <= this->EndServerId; ++i) {
if (i != this->Comm->GetId()){
if (i != this->Comm->GetInterId()){
this->SendCommandHeader(XDMF_DSM_ACCEPT, i, 0, 0, XDMF_DSM_INTER_COMM);
this->SendAcknowledgment(i, numConnections, XDMF_DSM_EXCHANGE_TAG, XDMF_DSM_INTER_COMM);
}
......@@ -1053,12 +1053,12 @@ XdmfDSMBuffer::SendInfo()
infoStatus = 2;
}
int groupInfoStatus[this->Comm->GetInterSize()];
int * groupInfoStatus = new int[this->Comm->GetInterSize()]();
MPI_Allgather(&infoStatus,
1,
MPI_INT,
&groupInfoStatus,
&(groupInfoStatus[0]),
1,
MPI_INT,
this->Comm->GetInterComm());
......
......@@ -70,6 +70,7 @@ XdmfDSMCommMPI::XdmfDSMCommMPI()
// This is the default file name for the config file.
DsmFileName = "dsmconnect.cfg";
InterCommType = XDMF_DSM_COMM_MPI;
HasOpenedPort = false;
}
XdmfDSMCommMPI::~XdmfDSMCommMPI()
......@@ -107,7 +108,20 @@ XdmfDSMCommMPI::Accept(unsigned int numConnections)
if (InterComm == MPI_COMM_NULL) {
// If there is no InterComm, then accept from IntraComm and merge into InterComm
MPI_Comm tempComm;
int status = MPI_Comm_accept(DsmPortName, MPI_INFO_NULL, 0, IntraComm, &tempComm);
int * portCheck = new int[GetInterSize()]();
int portStatus;
portStatus = 0;
if (HasOpenedPort) {
portStatus = 1;
}
MPI_Allgather(&portStatus, 1, MPI_INT, &(portCheck[0]), 1, MPI_INT, InterComm);
unsigned int index = 0;
for (index = 0; index < GetInterSize(); ++index) {
if (portCheck[index] == 1) {
break;
}
}
int status = MPI_Comm_accept(DsmPortName, MPI_INFO_NULL, index, IntraComm, &tempComm);
if (status != MPI_SUCCESS) {
try {
std::string message = "Failed to accept port ";
......@@ -136,7 +150,20 @@ XdmfDSMCommMPI::Accept(unsigned int numConnections)
else {
// If there is an InterComm, accept into the InterComm and merge
MPI_Comm tempComm;
int status = MPI_Comm_accept(DsmPortName, MPI_INFO_NULL, 0, InterComm, &tempComm);
int * portCheck = new int[GetInterSize()]();
int portStatus;
portStatus = 0;
if (HasOpenedPort) {
portStatus = 1;
}
MPI_Allgather(&portStatus, 1, MPI_INT, &(portCheck[0]), 1, MPI_INT, InterComm);
unsigned int index = 0;
for (index = 0; index < GetInterSize(); ++index) {
if (portCheck[index] == 1) {
break;
}
}
int status = MPI_Comm_accept(DsmPortName, MPI_INFO_NULL, index, InterComm, &tempComm);
if (status != MPI_SUCCESS) {
try {
std::string message = "Failed to accept port ";
......@@ -184,6 +211,7 @@ XdmfDSMCommMPI::ClosePort()
}
}
}
HasOpenedPort = false;
}
int
......@@ -455,6 +483,7 @@ XdmfDSMCommMPI::OpenPort()
throw e;
}
}
HasOpenedPort = true;
}
MPI_Bcast(DsmPortName, MPI_MAX_PORT_NAME, MPI_CHAR, 0, IntraComm);
}
......
......@@ -1046,6 +1046,7 @@ private:
int InterCommType;
char DsmPortName[MPI_MAX_PORT_NAME];
std::string DsmFileName;
bool HasOpenedPort;
};
#endif /* XDMFDSMCOMMMPI_HPP_ */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment