void HPC::MPICommunication::waitReception(Request::Handle ioRequest) const { Beagle_StackTraceBeginM(); Beagle_NonNullPointerAssertM(ioRequest); MPI::Status lStatus; ioRequest->mSizeRequest.Wait(lStatus); if(lStatus.Is_cancelled()) return; int lRank = lStatus.Get_source(); int lMsgSize = ioRequest->mSize; std::string lStringTag = ioRequest->mTag + "_str"; MPI::COMM_WORLD.Probe(lRank,hashTag(lStringTag),lStatus); Beagle_AssertM(lStatus.Get_count(MPI::CHAR) == lMsgSize); //constructing a string of the right size. std::string lMsg(lMsgSize, ' '); MPI::COMM_WORLD.Recv(&lMsg[0], lMsgSize, MPI::CHAR, lRank, hashTag(lStringTag)); #ifdef BEAGLE_HAVE_LIBZ if(mCompressionLevel->getWrappedValue() > 0){ ioRequest->mMessage = new Beagle::String; decompressString(lMsg, ioRequest->mMessage->getWrappedValue()); } else { ioRequest->mMessage = new Beagle::String(lMsg); } #else ioRequest->mMessage = new Beagle::String(lMsg); #endif Beagle_HPC_StackTraceEndM("void HPC::MPICommunication::waitReception(Request::Handle) const"); }
void HPC::MPICommunication::waitSending(Request::Handle ioRequest) const { Beagle_StackTraceBeginM(); Beagle_NonNullPointerAssertM(ioRequest); MPI::Status lStatus; ioRequest->mSizeRequest.Wait(lStatus); if(lStatus.Is_cancelled()) return; ioRequest->mMsgRequest.Wait(); Beagle_HPC_StackTraceEndM("void HPC::MPICommunication::waitReception(Request::Handle) const"); }
int HPC::MPICommunication::waitAny(Request::Bag& ioRequests) const { Beagle_StackTraceBeginM(); unsigned int lSize = ioRequests.size(); std::vector<MPI::Request> lRequests; lRequests.reserve(lSize); for(unsigned int i = 0; i < lSize; ++i){ lRequests.push_back(ioRequests[i]->mSizeRequest); } MPI::Status lStatus; int lIndex = MPI::Request::Waitany(lSize, &lRequests[0], lStatus); ioRequests[lIndex]->mSizeRequest = lRequests[lIndex]; if(lStatus.Is_cancelled()) return -1; if(ioRequests[lIndex]->mType == Request::RECEPTION){ int lRank = lStatus.Get_source(); std::string lStringTag = ioRequests[lIndex]->mTag + "_str"; int lMsgSize = ioRequests[lIndex]->mSize; MPI::COMM_WORLD.Probe(lRank,hashTag(lStringTag),lStatus); Beagle_AssertM(lStatus.Get_count(MPI::CHAR) == lMsgSize); //constructing a string of the right size. std::string lMsg(lMsgSize,' '); MPI::COMM_WORLD.Recv(&lMsg[0], lMsgSize, MPI::CHAR, lRank, hashTag(lStringTag)); #ifdef BEAGLE_HAVE_LIBZ if(mCompressionLevel->getWrappedValue() > 0){ ioRequests[lIndex]->mMessage = new Beagle::String; decompressString(lMsg, ioRequests[lIndex]->mMessage->getWrappedValue()); } else { ioRequests[lIndex]->mMessage = new Beagle::String(lMsg); } #else ioRequests[lIndex]->mMessage = new Beagle::String(lMsg); #endif } else if(ioRequests[lIndex]->mType == Request::SENDING){ ioRequests[lIndex]->mMsgRequest.Wait(); } else { throw RunTimeException("MPI::Communication::waitAll(Request&) the request"+uint2str(lIndex)+ " is invalid",__FILE__,__LINE__); } return lIndex; Beagle_HPC_StackTraceEndM("int HPC::MPICommunication::waitAny(Request::Bag&) const"); }