00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030 #ifndef RTOPPACK_SPMD_APPLY_OP_DECL_HPP
00031 #define RTOPPACK_SPMD_APPLY_OP_DECL_HPP
00032
00033 #include "RTOpPack_RTOpT.hpp"
00034 #include "Teuchos_Serializer.hpp"
00035 #include "Teuchos_ReductionOp.hpp"
00036
00037 namespace Teuchos { template<typename Ordinal> class Comm; }
00038
00039
00040
00041 namespace RTOpPack {
00042
00043 #ifdef RTOPPACK_SPMD_APPLY_OP_DUMP
00044 extern bool show_spmd_apply_op_dump;
00045 #endif // RTOPPACK_SPMD_APPLY_OP_DUMP
00046
00052 template<class PrimitiveScalar>
00053 int serializedSize(
00054 int num_values
00055 ,int num_indexes
00056 ,int num_chars
00057 );
00058
00063 template<class Scalar>
00064 void serialize(
00065 const RTOpT<Scalar> &op
00066 ,int num_values
00067 ,int num_indexes
00068 ,int num_chars
00069 ,const ReductTarget &reduct_obj
00070 ,char reduct_obj_ext[]
00071 );
00072
00077 template<class Scalar>
00078 void deserialize(
00079 const RTOpT<Scalar> &op
00080 ,int num_values
00081 ,int num_indexes
00082 ,int num_chars
00083 ,const char reduct_obj_ext[]
00084 ,ReductTarget *reduct_obj
00085 );
00086
00091 template<class Scalar>
00092 class ReductTargetSerializer : public Teuchos::Serializer<index_type,ReductTarget> {
00093 public:
00095 ReductTargetSerializer(
00096 const Teuchos::RefCountPtr<const RTOpT<Scalar> > &op
00097 );
00101 index_type getBufferSize(const index_type count) const;
00103 void serialize(
00104 const index_type count
00105 ,const ReductTarget* const reduct_objs[]
00106 ,const index_type bytes
00107 ,char charBuffer[]
00108 ) const;
00110 Teuchos::RefCountPtr<ReductTarget> createObj() const;
00112 void deserialize(
00113 const index_type bytes
00114 ,const char charBuffer[]
00115 ,const index_type count
00116 ,ReductTarget* const reduct_objs[]
00117 ) const;
00119 private:
00120 Teuchos::RefCountPtr<const RTOpT<Scalar> > op_;
00121 int num_values_;
00122 int num_indexes_;
00123 int num_chars_;
00124 int reduct_obj_ext_size_;
00125
00126 ReductTargetSerializer();
00127 ReductTargetSerializer& operator=(const ReductTargetSerializer&);
00128 };
00129
00134 template<class Scalar>
00135 class ReductTargetReductionOp
00136 : public Teuchos::ReferenceTypeReductionOp<Teuchos_Index,ReductTarget>
00137 {
00138 public:
00140 typedef Teuchos_Index Ordinal;
00142 ReductTargetReductionOp(
00143 const Teuchos::RefCountPtr<const RTOpT<Scalar> > &op
00144 );
00148 void reduce(
00149 const Ordinal count
00150 ,const ReductTarget*const inBuffer[]
00151 ,ReductTarget*const inoutBuffer[]
00152 ) const;
00154 private:
00155 Teuchos::RefCountPtr<const RTOpT<Scalar> > op_;
00156
00157 ReductTargetReductionOp();
00158 ReductTargetReductionOp<Scalar>(const ReductTargetReductionOp<Scalar>&);
00159 ReductTargetReductionOp<Scalar>& operator=(const ReductTargetReductionOp<Scalar>&);
00160 };
00161
00168 template<class Scalar>
00169 void SPMD_all_reduce(
00170 const Teuchos::Comm<index_type> *comm
00171 ,const RTOpT<Scalar> &op
00172 ,const int num_cols
00173 ,const ReductTarget*const i_reduct_objs[]
00174 ,ReductTarget*const reduct_objs[]
00175 );
00176
00184 template<class Scalar>
00185 void SPMD_apply_op(
00186 const Teuchos::Comm<index_type> *comm
00187 ,const RTOpT<Scalar> &op
00188 ,const int num_vecs
00189 ,const ConstSubVectorView<Scalar> sub_vecs[]
00190 ,const int num_targ_vecs
00191 ,const SubVectorView<Scalar> targ_sub_vecs[]
00192 ,ReductTarget *reduct_obj
00193 );
00194
00202 template<class Scalar>
00203 void SPMD_apply_op(
00204 const Teuchos::Comm<index_type> *comm
00205 ,const RTOpT<Scalar> &op
00206 ,const int num_cols
00207 ,const int num_multi_vecs
00208 ,const ConstSubMultiVectorView<Scalar> sub_multi_vecs[]
00209 ,const int num_targ_multi_vecs
00210 ,const SubMultiVectorView<Scalar> targ_sub_multi_vecs[]
00211 ,ReductTarget*const reduct_objs[]
00212 );
00213
00221 template<class Scalar>
00222 void SPMD_apply_op(
00223 const Teuchos::Comm<index_type> *comm
00224 ,const RTOpT<Scalar> &op
00225 ,const int num_cols
00226 ,const int num_vecs
00227 ,const ConstSubVectorView<Scalar> sub_vecs[]
00228 ,const int num_targ_vecs
00229 ,const SubVectorView<Scalar> sub_targ_vecs[]
00230 ,ReductTarget*const reduct_objs[]
00231 );
00232
00233 }
00234
00235 #endif // RTOPPACK_SPMD_APPLY_OP_DECL_HPP