.\"Copyright 2006, Sun Microsystems, Inc. All rights reserved. Use is subject to license terms. .\" Copyright (c) 1996 Thinking Machines Corporation .TH MPI_Gatherv 3OpenMPI "September 2006" "Open MPI 1.2" " " .SH NAME \fBMPI_Gatherv\fP \- Gathers varying amounts of data from all processes to the root process .SH SYNTAX .ft R .SH C Syntax .nf #include int MPI_Gatherv(void *\fIsendbuf\fP, int\fI sendcount\fP, MPI_Datatype\fI sendtype\fP, void\fI *recvbuf\fP, int\fI *recvcounts\fP, int\fI *displs\fP, MPI_Datatype\fI recvtype\fP, int \fIroot\fP, MPI_Comm\fI comm\fP) .SH Fortran Syntax .nf INCLUDE 'mpif.h' MPI_GATHERV(\fISENDBUF, SENDCOUNT, SENDTYPE, RECVBUF, RECVCOUNTS, DISPLS, RECVTYPE, ROOT, COMM, IERROR\fP) \fISENDBUF(*), RECVBUF(*)\fP INTEGER \fISENDCOUNT, SENDTYPE, RECVCOUNTS(*), DISPLS(*)\fP INTEGER \fIRECVTYPE, ROOT, COMM, IERROR\fP .SH C++ Syntax .nf #include void MPI::Comm::Gatherv(const void* \fIsendbuf\fP, int \fIsendcount\fP, const MPI::Datatype& \fIsendtype\fP, void* \fIrecvbuf\fP, const int \fIrecvcounts\fP[], const int \fIdispls\fP[], const MPI::Datatype& \fIrecvtype\fP, int \fIroot\fP) const = 0 .SH INPUT PARAMETERS .ft R .TP 1i sendbuf Starting address of send buffer (choice). .TP 1i sendcount Number of elements in send buffer (integer). .TP 1i sendtype Datatype of send buffer elements (handle). .TP 1i recvcounts Integer array (of length group size) containing the number of elements that are received from each process (significant only at root). .TP 1i displs Integer array (of length group size). Entry i specifies the displacement relative to recvbuf at which to place the incoming data from process i (significant only at root). .TP 1i recvtype Datatype of recv buffer elements (significant only at root) (handle). .TP 1i root Rank of receiving process (integer). .TP 1i comm Communicator (handle). .SH OUTPUT PARAMETERS .ft R .TP 1i recvbuf Address of receive buffer (choice, significant only at root). .ft R .TP 1i IERROR Fortran only: Error status (integer). .SH DESCRIPTION .ft R MPI_Gatherv extends the functionality of MPI_Gather by allowing a varying count of data from each process, since recvcounts is now an array. It also allows more flexibility as to where the data is placed on the root, by providing the new argument, displs. .sp The outcome is as if each process, including the root process, sends a message to the root, .sp .nf MPI_Send(sendbuf, sendcount, sendtype, root, \&...) .fi .sp and the root executes n receives, .sp .nf MPI_Recv(recvbuf + disp[i] * extent(recvtype), \\ recvcounts[i], recvtype, i, \&...) .fi .sp Messages are placed in the receive buffer of the root process in rank order, that is, the data sent from process j is placed in the jth portion of the receive buffer recvbuf on process root. The jth portion of recvbuf begins at offset displs[j] elements (in terms of recvtype) into recvbuf. .sp The receive buffer is ignored for all nonroot processes. .sp The type signature implied by sendcount, sendtype on process i must be equal to the type signature implied by recvcounts[i], recvtype at the root. This implies that the amount of data sent must be equal to the amount of data received, pairwise between each process and the root. Distinct type maps between sender and receiver are still allowed, as illustrated in Example 2, below. .sp All arguments to the function are significant on process root, while on other processes, only arguments sendbuf, sendcount, sendtype, root, comm are significant. The arguments root and comm must have identical values on all processes. .sp The specification of counts, types, and displacements should not cause any location on the root to be written more than once. Such a call is erroneous. .sp \fBExample 1:\fP Now have each process send 100 ints to root, but place each set (of 100) stride ints apart at receiving end. Use MPI_Gatherv and the displs argument to achieve this effect. Assume stride >= 100. .sp .nf MPI_Comm comm; int gsize,sendarray[100]; int root, *rbuf, stride; int *displs,i,*rcounts; \&... MPI_Comm_size(comm, &gsize); rbuf = (int *)malloc(gsize*stride*sizeof(int)); displs = (int *)malloc(gsize*sizeof(int)); rcounts = (int *)malloc(gsize*sizeof(int)); for (i=0; i