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

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

Adding compiled files

File size: 5.5 KB
Line 
1.\"Copyright 2006-2008 Sun Microsystems, Inc.
2.\" Copyright (c) 1996 Thinking Machines Corporation
3.TH MPI_Scan 3 "Dec 08, 2009" "1.4" "Open MPI"
4
5.SH NAME
6\fBMPI_Scan\fP \- Computes an inclusive scan (partial reduction)
7
8.SH SYNTAX
9.ft R
10
11.SH C Syntax
12.nf
13#include <mpi.h>
14int MPI_Scan(void *\fIsendbuf\fP, void *\fIrecvbuf\fP, int \fIcount\fP,
15        MPI_Datatype \fIdatatype\fP, MPI_Op \fIop\fP, MPI_Comm \fIcomm\fP)
16
17.SH Fortran Syntax
18.nf
19INCLUDE 'mpif.h'
20MPI_SCAN(\fISENDBUF, RECVBUF, COUNT, DATATYPE, OP, COMM, IERROR\fP)
21        <type>  \fISENDBUF(*), RECVBUF(*)\fP
22        INTEGER \fICOUNT, DATATYPE, OP, COMM, IERROR\fP
23
24.SH C++ Syntax
25.nf
26#include <mpi.h>
27void MPI::Intracomm::Scan(const void* \fIsendbuf\fP, void* \fIrecvbuf\fP,
28        int \fIcount\fP, const MPI::Datatype& \fIdatatype\fP,
29        const MPI::Op& \fIop\fP) const
30
31.SH INPUT PARAMETERS
32.ft R
33.TP 1i
34sendbuf
35Send buffer (choice).
36.TP 1i
37count
38Number of elements in input buffer (integer).
39.TP 1i
40datatype
41Data type of elements of input buffer (handle).
42.TP 1i
43op
44Operation (handle).
45.TP 1i
46comm
47Communicator (handle).
48
49.SH OUTPUT PARAMETERS
50.ft R
51.TP 1i
52recvbuf
53Receive buffer (choice).
54.ft R
55.TP 1i
56IERROR
57Fortran only: Error status (integer).
58
59.SH DESCRIPTION
60.ft R
61MPI_Scan is used to perform an inclusive prefix reduction on data
62distributed across the calling processes. The operation returns, in
63the \fIrecvbuf\fP of the process with rank i, the reduction
64(calculated according to the function \fIop\fP) of the values in the
65\fIsendbuf\fPs of processes with ranks 0, ..., i (inclusive). The type
66of operations supported, their semantics, and the constraints on send
67and receive buffers are as for MPI_Reduce.
68
69.SH EXAMPLE
70.ft R
71This example uses a user-defined operation to produce a segmented
72scan. A segmented scan takes, as input, a set of values and a set of
73logicals, where the logicals delineate the various segments of the
74scan. For example,
75.sp
76.nf
77values     v1      v2      v3      v4      v5      v6      v7      v8
78logicals   0       0       1       1       1       0       0       1
79result     v1    v1+v2     v3    v3+v4  v3+v4+v5   v6    v6+v7     v8
80.fi
81.sp
82The result for rank j is thus the sum v(i) + ... + v(j), where i is
83the lowest rank such that for all ranks n, i <= n <= j, logical(n) =
84logical(j). The operator that produces this effect is
85.sp
86.nf
87      [ u ]     [ v ]     [ w ]
88      [   ]  o  [   ]  =  [   ]
89      [ i ]     [ j ]     [ j ]
90.sp
91where
92.sp
93            ( u + v if i  = j
94      w  =  (
95            ( v     if i != j
96.fi
97.sp
98Note that this is a noncommutative operator. C code that implements it is
99given below.
100.sp
101.nf
102        typedef struct {
103                double val;
104                int log;
105        } SegScanPair;
106     
107        /*
108         * the user-defined function
109         */
110        void segScan(SegScanPair *in, SegScanPair *inout, int *len,
111                MPI_Datatype *dptr)
112        {
113                int i;
114                SegScanPair c;
115     
116                for (i = 0; i < *len; ++i) {
117                        if (in->log == inout->log)
118                                c.val = in->val + inout->val;
119                        else
120                                c.val = inout->val;
121
122                        c.log = inout->log;
123                        *inout = c;
124                        in++;
125                        inout++;
126                }
127        }
128.fi
129.sp
130Note that the inout argument to the user-defined function corresponds
131to the right-hand operand of the operator. When using this operator,
132we must be careful to specify that it is noncommutative, as in the
133following:
134.sp
135.nf
136        int                     i, base;
137        SeqScanPair     a, answer;
138        MPI_Op          myOp;
139        MPI_Datatype    type[2] = {MPI_DOUBLE, MPI_INT};
140        MPI_Aint                disp[2];
141        int                     blocklen[2] = {1, 1};
142        MPI_Datatype    sspair;
143
144        /*
145         * explain to MPI how type SegScanPair is defined
146         */
147        MPI_Get_address(a, disp);
148        MPI_Get_address(a.log, disp + 1);
149        base = disp[0];
150        for (i = 0; i < 2; ++i)
151                disp[i] -= base;
152        MPI_Type_struct(2, blocklen, disp, type, &sspair);
153        MPI_Type_commit(&sspair);
154
155        /*
156         * create the segmented-scan user-op
157         * noncommutative - set commute (arg 2) to 0
158         */
159        MPI_Op_create((MPI_User_function *)segScan, 0, &myOp);
160        \&...
161        MPI_Scan(a, answer, 1, sspair, myOp, comm);
162.fi
163
164.SH USE OF IN-PLACE OPTION
165WHen the communicator is an intracommunicator, you can perform a scanning operation in place (the output buffer is used as the input buffer).  Use the variable MPI_IN_PLACE as the value of the \fIsendbuf\fR argument.  The input data is taken from the receive buffer and replaced by the output data. 
166
167.SH NOTES ON COLLECTIVE OPERATIONS
168.ft R
169The reduction functions of type MPI_Op do not return an error value.
170As a result, if the functions detect an error, all they can do is
171either call MPI_Abort or silently skip the problem. Thus, if the
172error handler is changed from MPI_ERRORS_ARE_FATAL to something else
173(e.g., MPI_ERRORS_RETURN), then no error may be indicated.
174.sp
175The reason for this is the performance problems in ensuring that
176all collective routines return the same error value.
177
178.SH ERRORS
179.ft R
180Almost all MPI routines return an error value; C routines as
181the value of the function and Fortran routines in the last argument. C++
182functions do not return errors. If the default error handler is set to
183MPI::ERRORS_THROW_EXCEPTIONS, then on error the C++ exception mechanism
184will be used to throw an MPI:Exception object.
185.sp
186Before the error value is returned, the current MPI error handler is
187called. By default, this error handler aborts the MPI job, except for
188I/O function errors. The error handler may be changed with
189MPI_Comm_set_errhandler; the predefined error handler MPI_ERRORS_RETURN
190may be used to cause error values to be returned. Note that MPI does not
191guarantee that an MPI program can continue past an error.
192.sp
193See the MPI man page for a full list of MPI error codes.
194
195.SH SEE ALSO
196.ft R
197.nf
198MPI_Exscan
199MPI_Op_create
200MPI_Reduce
201
Note: See TracBrowser for help on using the repository browser.