src/Message/GlobalComm.h

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 /***************************************************************************
00003  *
00004  * The IPPL Framework
00005  * 
00006  *
00007  * Visit http://people.web.psi.ch/adelmann/ for more details
00008  *
00009  ***************************************************************************/
00010 
00011 #ifndef GLOBAL_COMM_H
00012 #define GLOBAL_COMM_H
00013 
00014 /*
00015  * GlobalComm.h - Global communication functions, such as reduce and scatter.
00016  */
00017 
00018 
00019 // forward declarations
00020 class Communicate;
00021 
00022 
00023 // Reduce equally-sized arrays across the machine, by sending to node
00024 // 0 and broadcasting back the result.  The arguments are two begin,end
00025 // iterators for the source of the data, an iterator pointing to
00026 // where the summed data should go, and an operation to perform in
00027 // the reduction.  Return success of operation.
00028 // The final argument indicates whether the LOCAL NODE should have it's
00029 // values included in the reduction (by default, this is true).  If this
00030 // pointer to the boolean array is null, all the values will be included.
00031 // NOTE: The input iterators must iterate over simple data objects,
00032 // which do not require their own special getMessage/putMessage.  If you
00033 // need to reduce a complex quantity, use the scalar version of reduce.
00034 #ifdef __MWERKS__
00035 // Work around CodeWarrior 4.0 bug
00036 template <class InputIterator, class OutputIterator, class ReduceOp>
00037 bool reduce(Communicate&, InputIterator, InputIterator, OutputIterator,
00038             const ReduceOp&, bool *IncludeVal);
00039 
00040 template <class InputIterator, class OutputIterator, class ReduceOp>
00041 bool reduce(Communicate& c, InputIterator i1, InputIterator i2, 
00042             OutputIterator o, const ReduceOp &r) { return reduce(c,i1,i2,o,0); }
00043 
00044 // same as above, but this uses the default Communicate object
00045 template <class InputIterator, class OutputIterator, class ReduceOp>
00046 bool reduce(InputIterator, InputIterator, OutputIterator,
00047             const ReduceOp&, bool *IncludeVal0);
00048 
00049 template <class InputIterator, class OutputIterator, class ReduceOp>
00050 bool reduce(InputIterator i1, InputIterator i2, OutputIterator o,
00051             const ReduceOp &r) { return reduce(i1,i2,o,r,0); }
00052 #else
00053 template <class InputIterator, class OutputIterator, class ReduceOp>
00054 bool reduce(Communicate&, InputIterator, InputIterator, OutputIterator,
00055             const ReduceOp&, bool *IncludeVal = 0);
00056 
00057 // same as above, but this uses the default Communicate object
00058 template <class InputIterator, class OutputIterator, class ReduceOp>
00059 bool reduce(InputIterator, InputIterator, OutputIterator,
00060             const ReduceOp&, bool *IncludeVal = 0);
00061 #endif // __MWERKS__
00062 
00063 
00064 // scalar versions of reduce ... instead of iterators, these versions
00065 // expect a single quantity to reduce and a location to place the result.
00066 template <class T, class ReduceOp>
00067 bool reduce(Communicate& comm, T& input, T& output, const ReduceOp& op);
00068 
00069 // same as above, but this uses the default Communicate object
00070 template <class T, class ReduceOp>
00071 bool reduce(T& input, T& output, const ReduceOp& op);
00072 
00073 
00074 // masked scalar versions of reduce ... instead of iterators, these versions
00075 // expect a single quantity to reduce and a location to place the result.
00076 // The final argument indicates whether the LOCAL NODE should have it's
00077 // value included in the reduction (by default, this is true).
00078 // Return success of operation.
00079 template <class T, class ReduceOp>
00080 bool reduce_masked(Communicate& comm, T& input, T& output, const ReduceOp& op,
00081                    bool IncludeVal);
00082 
00083 // same as above, but this uses the default Communicate object
00084 template <class T, class ReduceOp>
00085 bool reduce_masked(T& input, T& output, const ReduceOp& op,
00086                    bool IncludeVal);
00087 
00088 
00089 // scalar versions of reduce ... instead of iterators, these versions
00090 // expect a single quantity to reduce and a location to place the result.
00091 template <class T, class ReduceOp>
00092 bool reduce(Communicate& comm, T& input, T& output, const ReduceOp& op) {
00093   return reduce_masked(comm, input, output, op, true);
00094 }
00095 
00096 // same as above, but this uses the default Communicate object
00097 template <class T, class ReduceOp>
00098 bool reduce(T& input, T& output, const ReduceOp& op) {
00099   return reduce_masked(input, output, op, true);
00100 }
00101 
00102 
00103 // Scatter the data in the given source container to all other nodes.
00104 // The data is read using the first two begin,end iterators, and written
00105 // to the location indicated by the third iterator.  The next two
00106 // arrays are for target nodes and target indices for the data in the
00107 // source array; they should be of the same length as the source array.
00108 // The final argument is an STL predicate which is used to combine data
00109 // when two or more items are scattered into the same location on the
00110 // same node.
00111 // Return success of operation.
00112 template <class InputIterator, class RandomIterator, class ScatterOp>
00113 bool scatter(Communicate&, InputIterator, InputIterator, RandomIterator,
00114              int *, int *, const ScatterOp&);
00115 
00116 // same as above, but this uses the default Communicate object
00117 template <class InputIterator, class RandomIterator, class ScatterOp>
00118 bool scatter(InputIterator, InputIterator, RandomIterator,
00119              int *, int *, const ScatterOp&);
00120 
00121 #include "Message/GlobalComm.cpp"
00122 
00123 #endif // GLOBAL_COMM_H
00124 
00125 /***************************************************************************
00126  * $RCSfile: GlobalComm.h,v $   $Author: adelmann $
00127  * $Revision: 1.1.1.1 $   $Date: 2003/01/23 07:40:28 $
00128  * IPPL_VERSION_ID: $Id: GlobalComm.h,v 1.1.1.1 2003/01/23 07:40:28 adelmann Exp $ 
00129  ***************************************************************************/
00130 

Generated on Mon Jan 16 13:23:52 2006 for IPPL by  doxygen 1.4.6