RTOpPack_SPMD_apply_op_decl.hpp

Go to the documentation of this file.
00001 // @HEADER
00002 // ***********************************************************************
00003 // 
00004 // RTOp: Interfaces and Support Software for Vector Reduction Transformation
00005 //       Operations
00006 //                Copyright (2006) Sandia Corporation
00007 // 
00008 // Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive
00009 // license for use of this work by or on behalf of the U.S. Government.
00010 // 
00011 // This library is free software; you can redistribute it and/or modify
00012 // it under the terms of the GNU Lesser General Public License as
00013 // published by the Free Software Foundation; either version 2.1 of the
00014 // License, or (at your option) any later version.
00015 //  
00016 // This library is distributed in the hope that it will be useful, but
00017 // WITHOUT ANY WARRANTY; without even the implied warranty of
00018 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00019 // Lesser General Public License for more details.
00020 //  
00021 // You should have received a copy of the GNU Lesser General Public
00022 // License along with this library; if not, write to the Free Software
00023 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
00024 // USA
00025 // Questions? Contact Roscoe A. Bartlett (rabartl@sandia.gov) 
00026 // 
00027 // ***********************************************************************
00028 // @HEADER
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 //#define RTOPPACK_SPMD_APPLY_OP_DUMP
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   // Not defined and not to be called!
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   // Not defined and not to be called!
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 } // end namespace RTOpPack
00234 
00235 #endif // RTOPPACK_SPMD_APPLY_OP_DECL_HPP

Generated on Thu Sep 18 12:30:43 2008 for RTOp Package Browser (Single Doxygen Collection) by doxygen 1.3.9.1