source: proiecte/hpl/openmpi_compiled/share/man/man3/MPI_Gather.3 @ 97

Last change on this file since 97 was 97, checked in by (none), 14 years ago

Adding compiled files

File size: 7.0 KB
Line 
1.\"Copyright 2006-2008 Sun Microsystems, Inc.
2.\" Copyright (c) 1996 Thinking Machines Corporation
3.TH MPI_Gather 3 "Dec 08, 2009" "1.4" "Open MPI"
4.SH NAME
5\fBMPI_Gather\fP \- Gathers values from a group of processes.
6
7.SH SYNOPSIS
8.ft R
9.SH C Syntax
10.nf
11#include <mpi.h>
12int MPI_Gather(void \fI*sendbuf\fP, int\fI sendcount\fP, MPI_Datatype\fI sendtype\fP,
13        void\fI *recvbuf\fP, int\fI recvcount\fP, MPI_Datatype\fI recvtype\fP, int \fIroot\fP,
14        MPI_Comm\fI comm\fP)
15
16.SH Fortran Syntax
17.nf
18INCLUDE 'mpif.h'
19MPI_GATHER(\fISENDBUF, SENDCOUNT, SENDTYPE, RECVBUF, RECVCOUNT,
20                RECVTYPE, ROOT, COMM, IERROR\fP)
21        <type>  \fISENDBUF(*), RECVBUF(*)\fP
22        INTEGER \fISENDCOUNT, SENDTYPE, RECVCOUNT, RECVTYPE, ROOT\fP
23        INTEGER \fICOMM, IERROR\fP
24
25.SH C++ Syntax
26.nf
27#include <mpi.h>
28void MPI::Comm::Gather(const void* \fIsendbuf\fP, int \fIsendcount\fP,
29        const MPI::Datatype& \fIsendtype\fP, void* \fIrecvbuf\fP,
30        int \fIrecvcount\fP, const MPI::Datatype& \fIrecvtype\fP, int \fIroot\fP,
31        const = 0
32
33.SH INPUT PARAMETERS
34.ft R
35.TP 1i
36sendbuf
37Starting address of send buffer (choice).
38.TP 1i
39sendcount
40Number of elements in send buffer (integer).
41.TP 1i
42sendtype
43Datatype of send buffer elements (handle).
44.TP 1i
45recvcount
46Number of elements for any single receive (integer, significant only at
47root).
48.TP 1i
49recvtype
50Datatype of recvbuffer elements (handle, significant only at root).
51.TP 1i
52root
53Rank of receiving process (integer).
54.TP 1i
55comm
56Communicator (handle).
57
58.SH OUTPUT PARAMETERS
59.TP 1i
60recvbuf
61Address of receive buffer (choice, significant only at root).
62.ft R
63.TP 1i
64IERROR
65Fortran only: Error status (integer).
66
67.SH DESCRIPTION
68.ft R
69Each process (root process included) sends the contents of its send buffer to the root process. The root process receives the messages and stores them in rank order. The outcome is as if each of the n processes in the group (including the root process) had executed a call to     
70.sp
71.nf
72    MPI_Send(sendbuf, sendcount, sendtype, root, \&...)
73.fi
74.sp
75and the root had executed n calls to
76.sp
77.nf
78    MPI_Recv(recfbuf + i * recvcount * extent(recvtype), \
79             recvcount, recvtype, i, \&...)
80.fi
81.sp
82where extent(recvtype) is the type extent obtained from a call to MPI_Type_extent().           
83.sp
84An alternative description is that the n messages sent by the processes in the group are concatenated in rank order, and the resulting message is received by the root as if by a call to MPI_RECV(recvbuf, recvcount * n, recvtype, . . . ).
85.sp
86The receive buffer is ignored for all nonroot processes.
87.sp
88General, derived datatypes are allowed for both sendtype and recvtype. The
89type signature of sendcount, sendtype on process i must be equal to the type signature of recvcount, 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.
90.sp
91All 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.
92.sp
93The specification of counts and types should not cause any location on the root to be written more than once. Such a call is erroneous.
94.sp
95Note that the recvcount argument at the root indicates the number of items it receives from each process, not the total number of items it receives.
96.sp
97\fBExample 1:\fP  Gather 100 ints from every process in group to root.
98.sp
99.nf
100  MPI_Comm comm;
101      int gsize,sendarray[100];
102      int root, *rbuf;
103      \&...
104      MPI_Comm_size( comm, &gsize);
105      rbuf = (int *)malloc(gsize*100*sizeof(int));
106      MPI_Gather( sendarray, 100, MPI_INT, rbuf, 100, MPI_INT, root, comm);
107
108.fi
109.sp
110.br
111\fBExample 2:\fP Previous example modified -- only the root allocates memory for the receive buffer.
112.sp
113.nf
114  MPI_Comm comm;
115      int gsize,sendarray[100];
116      int root, myrank, *rbuf;
117      \&...
118      MPI_Comm_rank( comm, myrank);
119      if ( myrank == root) {
120         MPI_Comm_size( comm, &gsize);
121         rbuf = (int *)malloc(gsize*100*sizeof(int));
122         }
123      MPI_Gather( sendarray, 100, MPI_INT, rbuf, 100, MPI_INT, root, comm);
124.fi
125.sp
126\fBExample 3:\fP Do the same as the previous example, but use a derived
127datatype. Note that the type cannot be the entire set of  gsize * 100 ints since type matching is defined pairwise between the root and each process in the gather.   
128
129.nf
130  MPI_Comm comm;
131      int gsize,sendarray[100];
132      int root, *rbuf;
133      MPI_Datatype rtype;
134      \&...
135      MPI_Comm_size( comm, &gsize);
136      MPI_Type_contiguous( 100, MPI_INT, &rtype );
137      MPI_Type_commit( &rtype );
138      rbuf = (int *)malloc(gsize*100*sizeof(int));
139      MPI_Gather( sendarray, 100, MPI_INT, rbuf, 1, rtype, root, comm);
140.fi
141
142.SH USE OF IN-PLACE OPTION
143When the communicator is an intracommunicator, you can perform a gather operation in-place (the output buffer is used as the input buffer).  Use the variable MPI_IN_PLACE as the value of the root process \fIsendbuf\fR.  In this case, \fIsendcount\fR and \fIsendtype\fR are ignored, and the contribution of the root process to the gathered vector is assumed to already be in the correct place in the receive buffer. 
144.sp
145Note that MPI_IN_PLACE is a special kind of value; it has the same restrictions on its use as MPI_BOTTOM.
146.sp
147Because the in-place option converts the receive buffer into a send-and-receive buffer, a Fortran binding that includes INTENT must mark these as INOUT, not OUT.   
148.sp
149.SH WHEN COMMUNICATOR IS AN INTER-COMMUNICATOR
150.sp
151When the communicator is an inter-communicator, the root process in the first group gathers data from all the processes in the second group.  The first group defines the root process.  That process uses MPI_ROOT as the value of its \fIroot\fR argument.  The remaining processes use MPI_PROC_NULL as the value of their \fIroot\fR argument.  All processes in the second group use the rank of that root process in the first group as the value of their \fIroot\fR argument.   The send buffer argument of the processes in the first group must be consistent with the receive buffer argument of the root process in the second group.   
152.sp 
153
154.SH ERRORS
155Almost all MPI routines return an error value; C routines as the value of the function and Fortran routines in the last argument. C++ functions do not return errors. If the default error handler is set to MPI::ERRORS_THROW_EXCEPTIONS, then on error the C++ exception mechanism will be used to throw an MPI:Exception object.
156.sp
157Before the error value is returned, the current MPI error handler is
158called. By default, this error handler aborts the MPI job, except for I/O function errors. The error handler may be changed with MPI_Comm_set_errhandler; the predefined error handler MPI_ERRORS_RETURN may be used to cause error values to be returned. Note that MPI does not guarantee that an MPI program can continue past an error. 
159.sp
160See the MPI man page for a full list of MPI error codes.
161
162.SH SEE ALSO
163.ft R
164.sp
165.nf
166MPI_Gatherv
167MPI_Scatter
168MPI_Scatterv
169
Note: See TracBrowser for help on using the repository browser.