42 #ifndef TPETRA_RTI_HPP
43 #define TPETRA_RTI_HPP
45 #include <Teuchos_Tuple.hpp>
46 #include <Teuchos_Assert.hpp>
48 #include "Tpetra_ConfigDefs.hpp"
50 #include "Tpetra_Operator.hpp"
51 #include "Tpetra_Import.hpp"
52 #include "Tpetra_Export.hpp"
53 #include "Tpetra_Vector.hpp"
54 #include "Tpetra_RTI_detail.hpp"
69 static inline T identity() {
return Teuchos::ScalarTraits<T>::zero();}
81 static inline T identity() {
return Teuchos::ScalarTraits<T>::one();}
110 template <
class GOP,
class ROP,
class IOP>
118 ReductionGlob(GenOP gop, RedOP rop) : genop(gop), redop(rop) {}
122 template <
class TxOP,
class GOP,
class ROP,
class IOP>
136 template <
class IOP,
class GOP,
class ROP>
143 template <
class IOP,
class TOP,
class GOP,
class ROP>
154 template <
class S,
class LO,
class GO,
class Node,
class OP>
166 template <
class S1,
class S2,
class LO,
class GO,
class Node,
class OP>
169 #ifdef HAVE_TPETRA_DEBUG
171 "Tpetra::RTI::binary_transform(vec_inout,vec_in2): vec_in2 and vec_inout must have the same local length.");
182 template <
class S1,
class S2,
class S3,
class LO,
class GO,
class Node,
class OP>
183 void tertiary_transform(
Vector<S1,LO,GO,Node> &vec_inout,
const Vector<S2,LO,GO,Node> &vec_in2,
const Vector<S3,LO,GO,Node> &vec_in3, OP op)
185 #ifdef HAVE_TPETRA_DEBUG
187 "Tpetra::RTI::tertiary_transform(vec_inout,vec_in2,vec_in3): vec_inout, vec_in2 and vec_in3 must have the same local length.");
199 template <
class S,
class LO,
class GO,
class Node,
class Glob>
200 typename Glob::RedOP::result_type
213 template <
class S1,
class S2,
class LO,
class GO,
class Node,
class Glob>
214 typename Glob::RedOP::result_type
217 #ifdef HAVE_TPETRA_DEBUG
219 "Tpetra::RTI::reduce(vec_in1,vec_in2): vec_in1 and vec_in2 must have the same local length.");
232 template <
class S1,
class S2,
class S3,
class LO,
class GO,
class Node,
class Glob>
233 typename Glob::RedOP::result_type
234 reduce(
const Vector<S1,LO,GO,Node> &vec_in1,
const Vector<S2,LO,GO,Node> &vec_in2,
const Vector<S3,LO,GO,Node> &vec_in3, Glob glob)
236 #ifdef HAVE_TPETRA_DEBUG
238 std::runtime_error,
"Tpetra::RTI::reduce(vec_in1,vec_in2): vec_in1 and vec_in2 must have the same local length.");
251 template <
class S1,
class S2,
class LO,
class GO,
class Node,
class Glob>
252 typename Glob::RedOP::result_type
255 #ifdef HAVE_TPETRA_DEBUG
257 "Tpetra::RTI::binary_pre_transform_reduce(vec_in1,vec_in2): vec_in1 and vec_in2 must have the same local length.");
271 template <
class S1,
class S2,
class S3,
class LO,
class GO,
class Node,
class Glob>
272 typename Glob::RedOP::result_type
273 tertiary_pre_transform_reduce(
Vector<S1,LO,GO,Node> &vec_inout,
const Vector<S2,LO,GO,Node> &vec_in2,
const Vector<S3,LO,GO,Node> &vec_in3, Glob glob)
275 #ifdef HAVE_TPETRA_DEBUG
277 std::runtime_error,
"Tpetra::RTI::tertiary_pre_transform_reduce(vec_in1,vec_in2,vec_in3): vec_in1, vec_in2 and vec_in3 must have the same local length.");
287 #define TPETRA_UNARY_TRANSFORM(out,expr) \
288 Tpetra::RTI::unary_transform( *out, [=](decltype((out)->meanValue()) out) \
291 #define TPETRA_BINARY_TRANSFORM(outVec, inVec, expr) \
292 Tpetra::RTI::binary_transform( *outVec, *inVec, [=] (decltype ((outVec)->meanValue ()) outVec, \
293 decltype ((inVec)->meanValue ()) inVec) \
296 #define TPETRA_TERTIARY_TRANSFORM(out,in2,in3,expr) \
297 Tpetra::RTI::tertiary_transform( *out, *in2, *in3, \
298 [=](decltype((out)->meanValue()) out, \
299 decltype((in2)->meanValue()) in2, \
300 decltype((in3)->meanValue()) in3) \
304 #define TPETRA_REDUCE1(in, gexp, id, robj ) \
305 Tpetra::RTI::reduce( *in, \
306 Tpetra::RTI::reductionGlob<id>( [=]( decltype((in)->meanValue()) in ) \
310 #define TPETRA_REDUCE2(in1vec, in2vec, gexp, id, robj ) \
311 Tpetra::RTI::reduce (*in1vec, *in2vec, \
312 Tpetra::RTI::reductionGlob<id> ([=] (decltype((in1vec)->meanValue ()) in1vec, \
313 decltype((in2vec)->meanValue ()) in2vec ) \
317 #define TPETRA_REDUCE3(in1,in2,in3, gexp, id, robj ) \
318 Tpetra::RTI::reduce( *in1, *in2, *in3, \
319 Tpetra::RTI::reductionGlob<id>( [=]( decltype((in1)->meanValue()) in1, \
320 decltype((in2)->meanValue()) in2, \
321 decltype((in3)->meanValue()) in3 ) \
325 #define TPETRA_BINARY_PRETRANSFORM_REDUCE(out,in, texp, gexp, id, robj ) \
326 Tpetra::RTI::binary_pre_transform_reduce( *out, *in, \
327 Tpetra::RTI::reductionGlob<id>( [=]( decltype((out)->meanValue()) out, \
328 decltype((in)->meanValue()) in ) \
330 [=]( decltype((out)->meanValue()) out, \
331 decltype((in)->meanValue()) in ) \
335 #define TPETRA_TERTIARY_PRETRANSFORM_REDUCE(out,in2,in3, texp, gexp, id, robj ) \
336 Tpetra::RTI::tertiary_pre_transform_reduce( *out, *in2, *in3, \
337 Tpetra::RTI::reductionGlob<id>( [=]( decltype((out)->meanValue()) out, \
338 decltype((in2)->meanValue()) in2, \
339 decltype((in3)->meanValue()) in3 ) \
341 [=]( decltype((out)->meanValue()) out, \
342 decltype((in2)->meanValue()) in2, \
343 decltype((in3)->meanValue()) in3 ) \
347 #endif // TPETRA_RTI_HPP
OP::ReductionType transform_reduce(Vector< S1, LO, GO, Node > &vec_inout, const Vector< S2, LO, GO, Node > &vec_in2, OP op)
pass vec_inout and vec_in2 data pointers to \ op, then execute via node parallel_reduce.
void binary_transform(Vector< S1, LO, GO, Node > &vec_inout, const Vector< S2, LO, GO, Node > &vec_in2, OP op)
Transform values of vec_inout using vec_inout, vec_in2 and operator op.
adapter class between kernels for Tpetra::RTI::binary_transform and Tpetra::RTI::detail::binary_trans...
void unary_transform(Vector< S, LO, GO, Node > &vec, OP op)
pass vec data pointer to op, then execute via node parallel_for
size_t getLocalLength() const
Local number of rows on the calling process.
Glob::RedOP::result_type binary_pre_transform_reduce(Vector< S1, LO, GO, Node > &vec_inout, const Vector< S2, LO, GO, Node > &vec_in2, Glob glob)
Transforms values of vec_inout while simultaneously performing a parallel reduction.
OP::ReductionType reduce(const Vector< S, LO, GO, Node > &vec_in, OP op)
pass vec_in data pointer to \ op, then execute via node parallel_reduce.
adapter class between kernels for Tpetra::RTI::unary_transform and Tpetra::RTI::detail::unary_transfo...
void binary_transform(Vector< S1, LO, GO, Node > &vec_inout, const Vector< S2, LO, GO, Node > &vec_in2, OP op)
pass vec_inout and vec_in2 data pointers to op, then execute via node parallel_for ...
adapter class between kernels for Tpetra::RTI::binary_transform and Tpetra::RTI::detail::binary_trans...
void tertiary_transform(Vector< S1, LO, GO, Node > &vec_inout, const Vector< S2, LO, GO, Node > &vec_in2, const Vector< S3, LO, GO, Node > &vec_in3, OP op)
pass vec_inout, vec_in2 and vec_in3 data pointers to op, then execute via node parallel_for ...
Glob::RedOP::result_type reduce(const Vector< S, LO, GO, Node > &vec_in, Glob glob)
Reduce values of vec_in using the operators instantiated in glob.
ReductionGlob< GOP, ROP, IOP > reductionGlob(GOP gop, ROP rop)
Non-member constructor to instantiate a type glob of a static identity functor and generation and red...
adapter class between kernels for Tpetra::RTI::tertiary_transform and Tpetra::RTI::detail::tertiary_t...
adapter class between kernels for Tpetra::RTI::binary_transform and Tpetra::RTI::detail::binary_trans...
adapter class between kernels for Tpetra::RTI::binary_transform and Tpetra::RTI::detail::binary_trans...
Glob::RedOP::result_type tertiary_pre_transform_reduce(Vector< S1, LO, GO, Node > &vec_inout, const Vector< S2, LO, GO, Node > &vec_in2, const Vector< S3, LO, GO, Node > &vec_in3, Glob glob)
Transforms values of vec_inout while simultaneously performing a parallel reduction.
A type glob containing the types needed for calling Tpetra::RTI::reduce() with individual functors...
A distributed dense vector.
A static identity functor, providing a static method identity() that returns zero.
void unary_transform(Vector< S, LO, GO, Node > &vec_inout, OP op)
Transform values of vec_inout using via operator op.
void tertiary_transform(Vector< S1, LO, GO, Node > &vec_inout, const Vector< S2, LO, GO, Node > &vec_in2, const Vector< S3, LO, GO, Node > &vec_in3, OP op)
Transform values of vec_inout using vec_inout, vec_in2, vec_in3 and operator op.
A static identity functor, providing a static method identity() that returns one. ...