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 // RTOp: Interfaces and Support Software for Vector Reduction Transformation
4 // Operations
5 //
6 // Copyright 2006 NTESS and the RTOp contributors.
7 // SPDX-License-Identifier: BSD-3-Clause
8 // *****************************************************************************
9 // @HEADER
10 
11 #ifndef RTOPPACK_SPMD_APPLY_OP_DECL_HPP
12 #define RTOPPACK_SPMD_APPLY_OP_DECL_HPP
13 
14 #include "RTOpPack_RTOpT.hpp"
15 #include "Teuchos_Serializer.hpp"
16 #include "Teuchos_ReductionOp.hpp"
17 
18 
19 namespace Teuchos { template<typename Ordinal> class Comm; }
20 
21 
22 // Enable this by hand to enable showing the dump of the RTOp
23 #define RTOPPACK_ENABLE_SHOW_DUMP
24 
25 
26 #ifdef RTOP_DEBUG
27 # define RTOPPACK_ENABLE_SHOW_DUMP
28 #endif
29 
30 
31 namespace RTOpPack {
32 
33 
41 void set_SPMD_apply_op_dump_out(const RCP<FancyOStream> &dumpOut);
42 
43 
49 template<class PrimitiveScalar>
50 int serializedSize(
51  int num_values
52  ,int num_indexes
53  ,int num_chars
54  );
55 
56 
61 template<class Scalar>
62 void serialize(
63  const RTOpT<Scalar> &op,
64  Ordinal num_values,
65  Ordinal num_indexes,
66  Ordinal num_chars,
67  const ReductTarget &reduct_obj,
68  char reduct_obj_ext[]
69  );
70 
71 
76 template<class Scalar>
77 void deserialize(
78  const RTOpT<Scalar> &op,
79  int num_values,
80  int num_indexes,
81  int num_chars,
82  const char reduct_obj_ext[],
83  ReductTarget *reduct_obj
84  );
85 
86 
91 template<class Scalar>
92 class ReductTargetSerializer : public Teuchos::Serializer<index_type,ReductTarget> {
93 public:
96  const Teuchos::RCP<const RTOpT<Scalar> > &op
97  );
101  index_type getBufferSize(const index_type count) const;
103  void serialize(
104  const index_type count
105  ,const ReductTarget* const reduct_objs[]
106  ,const index_type bytes
107  ,char charBuffer[]
108  ) const;
112  void deserialize(
113  const index_type bytes
114  ,const char charBuffer[]
115  ,const index_type count
116  ,ReductTarget* const reduct_objs[]
117  ) const;
119 private:
125  // Not defined and not to be called!
128 };
129 
130 
135 template<class Scalar>
137  : public Teuchos::ReferenceTypeReductionOp<Teuchos_Ordinal,ReductTarget>
138 {
139 public:
144  const Teuchos::RCP<const RTOpT<Scalar> > &op
145  );
149  void reduce(
150  const Ordinal count
151  ,const ReductTarget*const inBuffer[]
152  ,ReductTarget*const inoutBuffer[]
153  ) const;
155 private:
157  // Not defined and not to be called!
161 };
162 
163 
170 template<class Scalar>
171 void SPMD_all_reduce(
172  const Teuchos::Comm<index_type> *comm
173  ,const RTOpT<Scalar> &op
174  ,const int num_cols
175  ,const ReductTarget*const i_reduct_objs[]
176  ,ReductTarget*const reduct_objs[]
177  );
178 
179 
187 template<class Scalar>
188 void SPMD_apply_op(
189  const Teuchos::Comm<index_type> *comm
190  ,const RTOpT<Scalar> &op
191  ,const int num_vecs
192  ,const ConstSubVectorView<Scalar> sub_vecs[]
193  ,const int num_targ_vecs
194  ,const SubVectorView<Scalar> targ_sub_vecs[]
195  ,ReductTarget *reduct_obj
196  );
197 
198 
206 template<class Scalar>
207 void SPMD_apply_op(
208  const Teuchos::Comm<index_type> *comm
209  ,const RTOpT<Scalar> &op
210  ,const int num_cols
211  ,const int num_multi_vecs
212  ,const ConstSubMultiVectorView<Scalar> sub_multi_vecs[]
213  ,const int num_targ_multi_vecs
214  ,const SubMultiVectorView<Scalar> targ_sub_multi_vecs[]
215  ,ReductTarget*const reduct_objs[]
216  );
217 
218 
226 template<class Scalar>
227 void SPMD_apply_op(
228  const Teuchos::Comm<index_type> *comm
229  ,const RTOpT<Scalar> &op
230  ,const int num_cols
231  ,const int num_vecs
232  ,const ConstSubVectorView<Scalar> sub_vecs[]
233  ,const int num_targ_vecs
234  ,const SubVectorView<Scalar> sub_targ_vecs[]
235  ,ReductTarget*const reduct_objs[]
236  );
237 
238 
239 } // end namespace RTOpPack
240 
241 
242 #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.
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