RTOp Package Browser (Single Doxygen Collection)  Version of the Day
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 
66 #ifdef RTOPPACK_ENABLE_SHOW_DUMP
67 extern bool show_spmd_apply_op_dump;
68 #endif // RTOPPACK_ENABLE_SHOW_DUMP
69 
70 
76 template<class PrimitiveScalar>
77 int serializedSize(
78  int num_values
79  ,int num_indexes
80  ,int num_chars
81  );
82 
83 
88 template<class Scalar>
89 void serialize(
90  const RTOpT<Scalar> &op,
91  Ordinal num_values,
92  Ordinal num_indexes,
93  Ordinal num_chars,
94  const ReductTarget &reduct_obj,
95  char reduct_obj_ext[]
96  );
97 
98 
103 template<class Scalar>
104 void deserialize(
105  const RTOpT<Scalar> &op,
106  int num_values,
107  int num_indexes,
108  int num_chars,
109  const char reduct_obj_ext[],
110  ReductTarget *reduct_obj
111  );
112 
113 
118 template<class Scalar>
119 class ReductTargetSerializer : public Teuchos::Serializer<index_type,ReductTarget> {
120 public:
123  const Teuchos::RCP<const RTOpT<Scalar> > &op
124  );
128  index_type getBufferSize(const index_type count) const;
130  void serialize(
131  const index_type count
132  ,const ReductTarget* const reduct_objs[]
133  ,const index_type bytes
134  ,char charBuffer[]
135  ) const;
137  Teuchos::RCP<ReductTarget> createObj() const;
139  void deserialize(
140  const index_type bytes
141  ,const char charBuffer[]
142  ,const index_type count
143  ,ReductTarget* const reduct_objs[]
144  ) const;
146 private:
147  Teuchos::RCP<const RTOpT<Scalar> > op_;
152  // Not defined and not to be called!
155 };
156 
157 
162 template<class Scalar>
164  : public Teuchos::ReferenceTypeReductionOp<Teuchos_Ordinal,ReductTarget>
165 {
166 public:
168  typedef Teuchos_Ordinal Ordinal;
171  const Teuchos::RCP<const RTOpT<Scalar> > &op
172  );
176  void reduce(
177  const Ordinal count
178  ,const ReductTarget*const inBuffer[]
179  ,ReductTarget*const inoutBuffer[]
180  ) const;
182 private:
183  Teuchos::RCP<const RTOpT<Scalar> > op_;
184  // Not defined and not to be called!
188 };
189 
190 
197 template<class Scalar>
198 void SPMD_all_reduce(
199  const Teuchos::Comm<index_type> *comm
200  ,const RTOpT<Scalar> &op
201  ,const int num_cols
202  ,const ReductTarget*const i_reduct_objs[]
203  ,ReductTarget*const reduct_objs[]
204  );
205 
206 
214 template<class Scalar>
215 void SPMD_apply_op(
216  const Teuchos::Comm<index_type> *comm
217  ,const RTOpT<Scalar> &op
218  ,const int num_vecs
219  ,const ConstSubVectorView<Scalar> sub_vecs[]
220  ,const int num_targ_vecs
221  ,const SubVectorView<Scalar> targ_sub_vecs[]
222  ,ReductTarget *reduct_obj
223  );
224 
225 
233 template<class Scalar>
234 void SPMD_apply_op(
235  const Teuchos::Comm<index_type> *comm
236  ,const RTOpT<Scalar> &op
237  ,const int num_cols
238  ,const int num_multi_vecs
239  ,const ConstSubMultiVectorView<Scalar> sub_multi_vecs[]
240  ,const int num_targ_multi_vecs
241  ,const SubMultiVectorView<Scalar> targ_sub_multi_vecs[]
242  ,ReductTarget*const reduct_objs[]
243  );
244 
245 
253 template<class Scalar>
254 void SPMD_apply_op(
255  const Teuchos::Comm<index_type> *comm
256  ,const RTOpT<Scalar> &op
257  ,const int num_cols
258  ,const int num_vecs
259  ,const ConstSubVectorView<Scalar> sub_vecs[]
260  ,const int num_targ_vecs
261  ,const SubVectorView<Scalar> sub_targ_vecs[]
262  ,ReductTarget*const reduct_objs[]
263  );
264 
265 
266 } // end namespace RTOpPack
267 
268 
269 #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.
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.
Class for a changeable sub-vector.
void SPMD_apply_op(const Teuchos::Comm< index_type > *comm, const RTOpT< Scalar > &op, const int num_cols, const int num_vecs, const ConstSubVectorView< Scalar > sub_vecs[], const int num_targ_vecs, const SubVectorView< Scalar > sub_targ_vecs[], ReductTarget *const reduct_objs[])
Apply an RTOp in SMPD mode to a set of columns to a set of multi-vectors with contiguous storage per ...
Teuchos_Ordinal index_type
ReductionOp subclass for ReductTarget objects.
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}.
Class for a changeable sub-vector.
Abstract base class for all reduction objects.
Class for a non-changeable sub-multi-vector (submatrix).
Teuchos::RCP< const RTOpT< Scalar > > op_
Teuchos_Ordinal Ordinal
Teuchos::RCP< const RTOpT< Scalar > > op_