/* * Send a block (nonblocking) */ void MemoryOArchive::iSend(MPI::Intracomm& comm, MPI::Request& req, int dest) { int comm_size = comm.Get_size(); int myRank = comm.Get_rank(); // Preconditions if (dest > comm_size - 1 || dest < 0) { UTIL_THROW("Destination rank out of bounds"); } if (dest == myRank) { UTIL_THROW("Source and desination identical"); } size_t sendBytes = cursor_ - buffer_; size_t* sizePtr = (size_t*)buffer_; *sizePtr = sendBytes; req = comm.Isend(buffer_, sendBytes, MPI::UNSIGNED_CHAR, dest, 5); }
/* * 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; } }
/* * Send a block. */ void PackedData::send(MPI::Intracomm& comm, int dest) { MPI::Request request; int sendBytes = 0; int comm_size = comm.Get_size(); int myRank = comm.Get_rank(); // Preconditions if (dest > comm_size - 1 || dest < 0) { UTIL_THROW("Destination rank out of bounds"); } if (dest == myRank) { UTIL_THROW("Source and desination identical"); } sendBytes = cursor_ - begin_; request = comm.Isend(begin_, sendBytes, MPI::UNSIGNED_CHAR, dest, 5); request.Wait(); }
/* * Send a buffer. */ void Buffer::send(MPI::Intracomm& comm, int dest) { MPI::Request request; int sendBytes = 0; int comm_size = comm.Get_size(); int myRank = comm.Get_rank(); // Preconditions if (dest > comm_size - 1 || dest < 0) { UTIL_THROW("Destination rank out of bounds"); } if (dest == myRank) { UTIL_THROW("Source and destination identical"); } sendBytes = sendPtr_ - sendBufferBegin_; request = comm.Isend(sendBufferBegin_, sendBytes, MPI::CHAR, dest, 5); request.Wait(); // Update statistics. if (sendBytes > maxSendLocal_) { maxSendLocal_ = sendBytes; } }