/** * vsg_packed_msg_recv_probed: * @pm: a #VsgPackedMsg. * @status: probed #MPI_Status * * Receives an already probed from @status message and stores it in * @pm. any previously stored data will be lost. */ void vsg_packed_msg_recv_probed (VsgPackedMsg *pm, MPI_Status *status) { gint ierr; gint rsize = 0; g_assert (pm->own_buffer == TRUE); MPI_Get_count (status, MPI_PACKED, &rsize); if (rsize > pm->allocated) { pm->buffer = g_realloc (pm->buffer, rsize); pm->allocated = rsize; } pm->size = rsize; ierr = MPI_Recv (pm->buffer, rsize, MPI_PACKED, status->MPI_SOURCE, status->MPI_TAG, pm->communicator, status); _recv_count ++; _recv_size += rsize; _trace_write_msg_recv (pm, "recv", status->MPI_SOURCE, status->MPI_TAG); pm->position = _PM_BEGIN_POS; if (ierr != MPI_SUCCESS) vsg_mpi_error_output (ierr); }
/** * vsg_packed_msg_bcast: * @pm: a #VsgPackedMsg. * @src: the source task id. Can be %MPI_ANY_SOURCE. * * Performs a MPI_Bcast on @pm. @pm must be of the same size across * all processes (ie. similar calls to vsg_packed_msg_send_append() * must have been previously issued on every processor). */ void vsg_packed_msg_bcast (VsgPackedMsg *pm, gint src) { gint ierr; gint rk; g_assert (pm->own_buffer == TRUE); MPI_Comm_rank (pm->communicator, &rk); if (rk == src) _trace_write_msg_send (pm, "bcast-send", src, -1); ierr = MPI_Bcast (pm->buffer, pm->position, MPI_PACKED, src, pm->communicator); _bcast_count ++; _bcast_size += pm->position; if (rk != src) _trace_write_msg_recv (pm, "bcast-recv", src, -1); pm->position = _PM_BEGIN_POS; if (ierr != MPI_SUCCESS) vsg_mpi_error_output (ierr); }
/** * vsg_packed_msg_recv: * @pm: a #VsgPackedMsg. * @src: the source task id. Can be %MPI_ANY_SOURCE. * @tag: an integer message tag. Can be %MPI_ANY_TAG. * * Receives a message from source @src with @tag message tag and stores it in * @pm. any previously stored data will be lost. */ void vsg_packed_msg_recv (VsgPackedMsg *pm, gint src, gint tag) { MPI_Status status; gint ierr; gint rsize = 0; g_assert (pm->own_buffer == TRUE); MPI_Probe (src, tag, pm->communicator, &status); MPI_Get_count (&status, MPI_PACKED, &rsize); pm->buffer = g_realloc (pm->buffer, rsize); pm->size = rsize; ierr = MPI_Recv (pm->buffer, rsize, MPI_PACKED, src, tag, pm->communicator, &status); _trace_write_msg_recv (pm, "recv", src, tag); pm->position = _PM_BEGIN_POS; if (ierr != MPI_SUCCESS) vsg_mpi_error_output (ierr); }