RTOp Package Browser (Single Doxygen Collection) Version of the Day
Loading...
Searching...
No Matches
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
51namespace 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
63namespace RTOpPack {
64
65
73void set_SPMD_apply_op_dump_out(const RCP<FancyOStream> &dumpOut);
74
75
81template<class PrimitiveScalar>
83 int num_values
84 ,int num_indexes
85 ,int num_chars
86 );
87
88
93template<class Scalar>
94void serialize(
95 const RTOpT<Scalar> &op,
96 Ordinal num_values,
97 Ordinal num_indexes,
98 Ordinal num_chars,
99 const ReductTarget &reduct_obj,
100 char reduct_obj_ext[]
101 );
102
103
108template<class Scalar>
109void deserialize(
110 const RTOpT<Scalar> &op,
111 int num_values,
112 int num_indexes,
113 int num_chars,
114 const char reduct_obj_ext[],
115 ReductTarget *reduct_obj
116 );
117
118
123template<class Scalar>
124class ReductTargetSerializer : public Teuchos::Serializer<index_type,ReductTarget> {
125public:
128 const Teuchos::RCP<const RTOpT<Scalar> > &op
129 );
133 index_type getBufferSize(const index_type count) const;
135 void serialize(
136 const index_type count
137 ,const ReductTarget* const reduct_objs[]
138 ,const index_type bytes
139 ,char charBuffer[]
140 ) const;
142 Teuchos::RCP<ReductTarget> createObj() const;
144 void deserialize(
145 const index_type bytes
146 ,const char charBuffer[]
147 ,const index_type count
148 ,ReductTarget* const reduct_objs[]
149 ) const;
151private:
152 Teuchos::RCP<const RTOpT<Scalar> > op_;
157 // Not defined and not to be called!
160};
161
162
167template<class Scalar>
169 : public Teuchos::ReferenceTypeReductionOp<Teuchos_Ordinal,ReductTarget>
170{
171public:
173 typedef Teuchos_Ordinal Ordinal;
176 const Teuchos::RCP<const RTOpT<Scalar> > &op
177 );
181 void reduce(
182 const Ordinal count
183 ,const ReductTarget*const inBuffer[]
184 ,ReductTarget*const inoutBuffer[]
185 ) const;
187private:
188 Teuchos::RCP<const RTOpT<Scalar> > op_;
189 // Not defined and not to be called!
191 ReductTargetReductionOp<Scalar>(const ReductTargetReductionOp<Scalar>&);
192 ReductTargetReductionOp<Scalar>& operator=(const ReductTargetReductionOp<Scalar>&);
193};
194
195
202template<class Scalar>
203void SPMD_all_reduce(
204 const Teuchos::Comm<index_type> *comm
205 ,const RTOpT<Scalar> &op
206 ,const int num_cols
207 ,const ReductTarget*const i_reduct_objs[]
208 ,ReductTarget*const reduct_objs[]
209 );
210
211
219template<class Scalar>
220void SPMD_apply_op(
221 const Teuchos::Comm<index_type> *comm
222 ,const RTOpT<Scalar> &op
223 ,const int num_vecs
224 ,const ConstSubVectorView<Scalar> sub_vecs[]
225 ,const int num_targ_vecs
226 ,const SubVectorView<Scalar> targ_sub_vecs[]
227 ,ReductTarget *reduct_obj
228 );
229
230
238template<class Scalar>
239void SPMD_apply_op(
240 const Teuchos::Comm<index_type> *comm
241 ,const RTOpT<Scalar> &op
242 ,const int num_cols
243 ,const int num_multi_vecs
244 ,const ConstSubMultiVectorView<Scalar> sub_multi_vecs[]
245 ,const int num_targ_multi_vecs
246 ,const SubMultiVectorView<Scalar> targ_sub_multi_vecs[]
247 ,ReductTarget*const reduct_objs[]
248 );
249
250
258template<class Scalar>
259void SPMD_apply_op(
260 const Teuchos::Comm<index_type> *comm
261 ,const RTOpT<Scalar> &op
262 ,const int num_cols
263 ,const int num_vecs
264 ,const ConstSubVectorView<Scalar> sub_vecs[]
265 ,const int num_targ_vecs
266 ,const SubVectorView<Scalar> sub_targ_vecs[]
267 ,ReductTarget*const reduct_objs[]
268 );
269
270
271} // end namespace RTOpPack
272
273
274#endif // RTOPPACK_SPMD_APPLY_OP_DECL_HPP
ReductionOp subclass for ReductTarget objects.
void reduce(const Ordinal count, const ReductTarget *const inBuffer[], ReductTarget *const inoutBuffer[]) const
ReductTargetReductionOp< Scalar > & operator=(const ReductTargetReductionOp< Scalar > &)
Teuchos::RCP< const RTOpT< Scalar > > op_
Serializer subclass for ReductTarget objects.
index_type getBufferSize(const index_type count) const
void deserialize(const index_type bytes, const char charBuffer[], const index_type count, ReductTarget *const reduct_objs[]) const
Teuchos::RCP< const RTOpT< Scalar > > op_
ReductTargetSerializer & operator=(const ReductTargetSerializer &)
void serialize(const index_type count, const ReductTarget *const reduct_objs[], const index_type bytes, char charBuffer[]) const
Teuchos::RCP< ReductTarget > createObj() const
Abstract base class for all reduction objects.
Teuchos_Ordinal index_type
Teuchos_Ordinal Ordinal
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.
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.
void set_SPMD_apply_op_dump_out(const RCP< FancyOStream > &dumpOut)
Set up to show a dump of RTOps applied through SPMD_apply_op().
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.
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.