RTOp Package Browser (Single Doxygen Collection)  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
RTOpPack_SPMD_apply_op_decl.hpp
Go to the documentation of this file.
1 // @HEADER
2 // ***********************************************************************
3 //
4 // RTOp: Interfaces and Support Software for Vector Reduction Transformation
5 // Operations
6 // Copyright (2006) Sandia Corporation
7 //
8 // Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive
9 // license for use of this work by or on behalf of the U.S. Government.
10 //
11 // Redistribution and use in source and binary forms, with or without
12 // modification, are permitted provided that the following conditions are
13 // met:
14 //
15 // 1. Redistributions of source code must retain the above copyright
16 // notice, this list of conditions and the following disclaimer.
17 //
18 // 2. Redistributions in binary form must reproduce the above copyright
19 // notice, this list of conditions and the following disclaimer in the
20 // documentation and/or other materials provided with the distribution.
21 //
22 // 3. Neither the name of the Corporation nor the names of the
23 // contributors may be used to endorse or promote products derived from
24 // this software without specific prior written permission.
25 //
26 // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
27 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
28 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
29 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
30 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
31 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
32 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
33 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
34 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
35 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
36 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
37 //
38 // Questions? Contact Roscoe A. Bartlett (rabartl@sandia.gov)
39 //
40 // ***********************************************************************
41 // @HEADER
42 
43 #ifndef RTOPPACK_SPMD_APPLY_OP_DECL_HPP
44 #define RTOPPACK_SPMD_APPLY_OP_DECL_HPP
45 
46 #include "RTOpPack_RTOpT.hpp"
47 #include "Teuchos_Serializer.hpp"
48 #include "Teuchos_ReductionOp.hpp"
49 
50 
51 namespace Teuchos { template<typename Ordinal> class Comm; }
52 
53 
54 // Enable this by hand to enable showing the dump of the RTOp
55 #define RTOPPACK_ENABLE_SHOW_DUMP
56 
57 
58 #ifdef RTOP_DEBUG
59 # define RTOPPACK_ENABLE_SHOW_DUMP
60 #endif
61 
62 
63 namespace RTOpPack {
64 
65 
73 void set_SPMD_apply_op_dump_out(const RCP<FancyOStream> &dumpOut);
74 
75 #ifdef RTOPPACK_ENABLE_SHOW_DUMP
76 RTOP_DEPRECATED extern bool show_spmd_apply_op_dump;
77 #endif // RTOPPACK_ENABLE_SHOW_DUMP
78 
79 
85 template<class PrimitiveScalar>
86 int serializedSize(
87  int num_values
88  ,int num_indexes
89  ,int num_chars
90  );
91 
92 
97 template<class Scalar>
98 void serialize(
99  const RTOpT<Scalar> &op,
100  Ordinal num_values,
101  Ordinal num_indexes,
102  Ordinal num_chars,
103  const ReductTarget &reduct_obj,
104  char reduct_obj_ext[]
105  );
106 
107 
112 template<class Scalar>
113 void deserialize(
114  const RTOpT<Scalar> &op,
115  int num_values,
116  int num_indexes,
117  int num_chars,
118  const char reduct_obj_ext[],
119  ReductTarget *reduct_obj
120  );
121 
122 
127 template<class Scalar>
128 class ReductTargetSerializer : public Teuchos::Serializer<index_type,ReductTarget> {
129 public:
132  const Teuchos::RCP<const RTOpT<Scalar> > &op
133  );
137  index_type getBufferSize(const index_type count) const;
139  void serialize(
140  const index_type count
141  ,const ReductTarget* const reduct_objs[]
142  ,const index_type bytes
143  ,char charBuffer[]
144  ) const;
148  void deserialize(
149  const index_type bytes
150  ,const char charBuffer[]
151  ,const index_type count
152  ,ReductTarget* const reduct_objs[]
153  ) const;
155 private:
161  // Not defined and not to be called!
164 };
165 
166 
171 template<class Scalar>
173  : public Teuchos::ReferenceTypeReductionOp<Teuchos_Ordinal,ReductTarget>
174 {
175 public:
180  const Teuchos::RCP<const RTOpT<Scalar> > &op
181  );
185  void reduce(
186  const Ordinal count
187  ,const ReductTarget*const inBuffer[]
188  ,ReductTarget*const inoutBuffer[]
189  ) const;
191 private:
193  // Not defined and not to be called!
197 };
198 
199 
206 template<class Scalar>
207 void SPMD_all_reduce(
208  const Teuchos::Comm<index_type> *comm
209  ,const RTOpT<Scalar> &op
210  ,const int num_cols
211  ,const ReductTarget*const i_reduct_objs[]
212  ,ReductTarget*const reduct_objs[]
213  );
214 
215 
223 template<class Scalar>
224 void SPMD_apply_op(
225  const Teuchos::Comm<index_type> *comm
226  ,const RTOpT<Scalar> &op
227  ,const int num_vecs
228  ,const ConstSubVectorView<Scalar> sub_vecs[]
229  ,const int num_targ_vecs
230  ,const SubVectorView<Scalar> targ_sub_vecs[]
231  ,ReductTarget *reduct_obj
232  );
233 
234 
242 template<class Scalar>
243 void SPMD_apply_op(
244  const Teuchos::Comm<index_type> *comm
245  ,const RTOpT<Scalar> &op
246  ,const int num_cols
247  ,const int num_multi_vecs
248  ,const ConstSubMultiVectorView<Scalar> sub_multi_vecs[]
249  ,const int num_targ_multi_vecs
250  ,const SubMultiVectorView<Scalar> targ_sub_multi_vecs[]
251  ,ReductTarget*const reduct_objs[]
252  );
253 
254 
262 template<class Scalar>
263 void SPMD_apply_op(
264  const Teuchos::Comm<index_type> *comm
265  ,const RTOpT<Scalar> &op
266  ,const int num_cols
267  ,const int num_vecs
268  ,const ConstSubVectorView<Scalar> sub_vecs[]
269  ,const int num_targ_vecs
270  ,const SubVectorView<Scalar> sub_targ_vecs[]
271  ,ReductTarget*const reduct_objs[]
272  );
273 
274 
275 } // end namespace RTOpPack
276 
277 
278 #endif // RTOPPACK_SPMD_APPLY_OP_DECL_HPP
int serializedSize(int num_values, int num_indexes, int num_chars)
Return the size in bytes of an external representation of a ReductTarget object.
ReductTargetReductionOp< Scalar > & operator=(const ReductTargetReductionOp< Scalar > &)
void SPMD_all_reduce(const Teuchos::Comm< index_type > *comm, const RTOpT< Scalar > &op, const int num_cols, const ReductTarget *const i_reduct_objs[], ReductTarget *const reduct_objs[])
Reduce a set of reduction objects.
Teuchos::RCP< ReductTarget > createObj() const
Class for a changeable sub-vector.
void serialize(const index_type count, const ReductTarget *const reduct_objs[], const index_type bytes, char charBuffer[]) const
Teuchos_Ordinal index_type
ReductionOp subclass for ReductTarget objects.
RTOP_DEPRECATED bool show_spmd_apply_op_dump
void serialize(const RTOpT< Scalar > &op, Ordinal num_values, Ordinal num_indexes, Ordinal num_chars, const ReductTarget &reduct_obj, char reduct_obj_ext[])
Serialize a ReductTarget object.
Class for a non-changeable sub-vector.
void deserialize(const RTOpT< Scalar > &op, int num_values, int num_indexes, int num_chars, const char reduct_obj_ext[], ReductTarget *reduct_obj)
Deserialize a ReductTarget object.
Serializer subclass for ReductTarget objects.
Templated interface to vector reduction/transformation operators {abstract}.
TEUCHOS_ORDINAL_TYPE Teuchos_Ordinal
index_type getBufferSize(const index_type count) const
Class for a changeable sub-vector.
void deserialize(const index_type bytes, const char charBuffer[], const index_type count, ReductTarget *const reduct_objs[]) const
Abstract base class for all reduction objects.
void set_SPMD_apply_op_dump_out(const RCP< FancyOStream > &dumpOut)
Set up to show a dump of RTOps applied through SPMD_apply_op().
ReductTargetSerializer & operator=(const ReductTargetSerializer &)
Class for a non-changeable sub-multi-vector (submatrix).
Teuchos::RCP< const RTOpT< Scalar > > op_
Teuchos_Ordinal Ordinal
Teuchos::RCP< const RTOpT< Scalar > > op_
void SPMD_apply_op(const Teuchos::Comm< index_type > *comm, const RTOpT< Scalar > &op, const int num_vecs, const ConstSubVectorView< Scalar > sub_vecs[], const int num_targ_vecs, const SubVectorView< Scalar > targ_sub_vecs[], ReductTarget *reduct_obj)
Apply an RTOp in SMPD mode to a set of vectors with contiguous storage per process.
void reduce(const Ordinal count, const ReductTarget *const inBuffer[], ReductTarget *const inoutBuffer[]) const