------------------------------------------------------------------------------
| 776 | |
| 777 | //------------------------------------------------------------------------------ |
| 778 | void CommunicationManager::Exchange(vtkMPIController* comm) |
| 779 | { |
| 780 | std::map<int, unsigned char*>::iterator it; |
| 781 | |
| 782 | // STEP 0: exchange & allocate buffer sizes |
| 783 | this->AllocateRcvBuffers(comm); |
| 784 | |
| 785 | // STEP 1: Allocate vector to store request objects for non-blocking comm. |
| 786 | int rqstIdx = 0; |
| 787 | this->Requests.resize(this->NumMsgs()); |
| 788 | |
| 789 | // STEP 2: Post Rcvs |
| 790 | for (it = this->Rcv.begin(); it != this->Rcv.end(); ++it) |
| 791 | { |
| 792 | int fromRank = it->first; |
| 793 | unsigned char* buffer = it->second; |
| 794 | assert("pre: rcv buffer size not found!" && |
| 795 | this->RcvByteSize.find(fromRank) != this->RcvByteSize.end()); |
| 796 | int bytesize = this->RcvByteSize[fromRank]; |
| 797 | |
| 798 | comm->NoBlockReceive(buffer, bytesize, fromRank, 0, this->Requests[rqstIdx]); |
| 799 | ++rqstIdx; |
| 800 | } |
| 801 | |
| 802 | // STEP 3: Post Sends |
| 803 | for (it = this->Send.begin(); it != this->Send.end(); ++it) |
| 804 | { |
| 805 | int toRank = it->first; |
| 806 | unsigned char* buffer = it->second; |
| 807 | assert("pre: rcv buffer size not found!" && |
| 808 | this->SendByteSize.find(toRank) != this->SendByteSize.end()); |
| 809 | int bytesize = this->SendByteSize[toRank]; |
| 810 | |
| 811 | comm->NoBlockSend(buffer, bytesize, toRank, 0, this->Requests[rqstIdx]); |
| 812 | ++rqstIdx; |
| 813 | } |
| 814 | |
| 815 | // STEP 4: WaitAll |
| 816 | if (!this->Requests.empty()) |
| 817 | { |
| 818 | comm->WaitAll(this->NumMsgs(), this->Requests.data()); |
| 819 | } |
| 820 | this->Requests.clear(); |
| 821 | } |
| 822 | |
| 823 | VTK_ABI_NAMESPACE_END |
| 824 | } // END namespace detail |
no test coverage detected