.\" Copyright 2010 Cisco Systems, Inc. All rights reserved. .\" Copyright 2006-2008 Sun Microsystems, Inc. .\" Copyright (c) 1996 Thinking Machines Corporation .TH MPI_Scatterv 3 "#OMPI_DATE#" "#PACKAGE_VERSION#" "#PACKAGE_NAME#" .SH NAME \fBMPI_Scatterv\fP \- Scatters a buffer in parts to all tasks in a group. .SH SYNTAX .ft R .SH C Syntax .nf #include int MPI_Scatterv(void *\fIsendbuf\fP, int\fI *sendcounts\fP, int\fI *displs\fP, MPI_Datatype\fI sendtype\fP, void\fI *recvbuf\fP, int\fI recvcount\fP, MPI_Datatype\fI recvtype\fP, int\fI root\fP, MPI_Comm\fI comm\fP) .fi .SH Fortran Syntax .nf INCLUDE 'mpif.h' MPI_SCATTERV(\fISENDBUF, SENDCOUNTS, DISPLS, SENDTYPE, RECVBUF, RECVCOUNT, RECVTYPE, ROOT, COMM, IERROR\fP) \fISENDBUF(*), RECVBUF(*)\fP INTEGER \fISENDCOUNTS(*), DISPLS(*), SENDTYPE\fP INTEGER \fIRECVCOUNT, RECVTYPE, ROOT, COMM, IERROR\fP .fi .SH C++ Syntax .nf #include void MPI::Comm::Scatterv(const void* \fIsendbuf\fP, const int \fIsendcounts\fP[], const int \fIdispls\fP[], const MPI::Datatype& \fIsendtype\fP, void* \fIrecvbuf\fP, int \fIrecvcount\fP, const MPI::Datatype& \fIrecvtype\fP, int \fIroot\fP) const .fi .SH INPUT PARAMETERS .ft R .TP 1i sendbuf Address of send buffer (choice, significant only at root). .TP 1i sendcounts Integer array (of length group size) specifying the number of elements to send to each processor. .TP 1i displs Integer array (of length group size). Entry i specifies the displacement (relative to sendbuf) from which to take the outgoing data to process i. .TP 1i sendtype Datatype of send buffer elements (handle). .TP 1i recvcount Number of elements in receive buffer (integer). .TP 1i recvtype Datatype of receive buffer elements (handle). .TP 1i root Rank of sending process (integer). .TP 1i comm Communicator (handle). .SH OUTPUT PARAMETERS .ft R .TP 1i recvbuf Address of receive buffer (choice). .ft R .TP 1i IERROR Fortran only: Error status (integer). .SH DESCRIPTION .ft R MPI_Scatterv is the inverse operation to MPI_Gatherv. .sp MPI_Scatterv extends the functionality of MPI_Scatter by allowing a varying count of data to be sent to each process, since \fIsendcounts\fP is now an array. It also allows more flexibility as to where the data is taken from on the root, by providing the new argument, \fIdispls\fP. .sp The outcome is as if the root executed \fIn\fP send operations, .sp .nf MPI_Send(\fIsendbuf\fP + \fIdispls\fP[\fIi\fP] * \fIextent\fP(\fIsendtype\fP), \\ \fIsendcounts\fP[i], \fIsendtype\fP, \fIi\fP, \&...) and each process executed a receive, MPI_Recv(\fIrecvbuf\fP, \fIrecvcount\fP, \fIrecvtype\fP, \fIroot\fP, \&...) The send buffer is ignored for all nonroot processes. .fi .sp The type signature implied by \fIsendcount\fP[\fIi\fP], \fIsendtype\fP at the root must be equal to the type signature implied by \fIrecvcount\fP, \fIrecvtype\fP at process \fIi\fP (however, the type maps may be different). 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. .sp All arguments to the function are significant on process \fIroot\fP, while on other processes, only arguments \fIrecvbuf\fP, \fIrecvcount\fP, \fIrecvtype\fP, \fIroot\fP, \fIcomm\fP are significant. The arguments \fIroot\fP and \fIcomm\fP 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 read more than once. .sp \fBExample 1:\fR The reverse of Example 5 in the MPI_Gatherv manpage. We have a varying stride between blocks at sending (root) side, at the receiving side we receive 100 - \fIi\fP elements into the \fIi\fPth column of a 100 x 150 C array at process \fIi\fP. .sp .nf MPI_Comm comm; int gsize,recvarray[100][150],*rptr; int root, *sendbuf, myrank, bufsize, *stride; MPI_Datatype rtype; int i, *displs, *scounts, offset; \&... MPI_Comm_size( comm, &gsize); MPI_Comm_rank( comm, &myrank ); stride = (int *)malloc(gsize*sizeof(int)); \&... /* stride[i] for i = 0 to gsize-1 is set somehow * sendbuf comes from elsewhere */ \&... displs = (int *)malloc(gsize*sizeof(int)); scounts = (int *)malloc(gsize*sizeof(int)); offset = 0; for (i=0; i= 100. .sp .nf MPI_Comm comm; int gsize,*sendbuf; int root, rbuf[100], i, *displs, *scounts; \&... MPI_Comm_size(comm, &gsize); sendbuf = (int *)malloc(gsize*stride*sizeof(int)); \&... displs = (int *)malloc(gsize*sizeof(int)); scounts = (int *)malloc(gsize*sizeof(int)); for (i=0; i