/* * Receive a block. */ void PackedData::recv(MPI::Intracomm& comm, int source) { MPI::Request request; int myRank = comm.Get_rank(); int comm_size = comm.Get_size(); // Preconditons if (source > comm_size - 1 || source < 0) { UTIL_THROW("Source rank out of bounds"); } if (source == myRank) { UTIL_THROW("Source and desination identical"); } request = comm.Irecv(begin_, capacity_, MPI::UNSIGNED_CHAR, source, 5); request.Wait(); cursor_ = begin_; }
/* * Send and receive buffer. */ void Buffer::sendRecv(MPI::Intracomm& comm, int source, int dest) { MPI::Request request[2]; int sendBytes = 0; int myRank = comm.Get_rank(); int comm_size = comm.Get_size(); // Preconditions if (dest > comm_size - 1 || dest < 0) { UTIL_THROW("Destination rank out of bounds"); } if (source > comm_size - 1 || source < 0) { UTIL_THROW("Source rank out of bounds"); } if (dest == myRank) { UTIL_THROW("Destination and my rank are identical"); } if (source == myRank) { UTIL_THROW("Source and my rank are identical"); } // Start nonblocking receive. request[0] = comm.Irecv(recvBufferBegin_, bufferCapacity_ , MPI::CHAR, source, 5); // Start nonblocking send. sendBytes = sendPtr_ - sendBufferBegin_; request[1] = comm.Isend(sendBufferBegin_, sendBytes , MPI::CHAR, dest, 5); // Wait for completion of receive. request[0].Wait(); recvPtr_ = recvBufferBegin_; // Wait for completion of send. request[1].Wait(); // Update statistics. if (sendBytes > maxSendLocal_) { maxSendLocal_ = sendBytes; } }
/* * Receive a buffer. */ void Buffer::recv(MPI::Intracomm& comm, int source) { MPI::Request request; int myRank = comm.Get_rank(); int comm_size = comm.Get_size(); // Preconditons if (source > comm_size - 1 || source < 0) { UTIL_THROW("Source rank out of bounds"); } if (source == myRank) { UTIL_THROW("Source and destination identical"); } request = comm.Irecv(recvBufferBegin_, bufferCapacity_, MPI::CHAR, source, 5); request.Wait(); recvType_ = NONE; recvPtr_ = recvBufferBegin_; }