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 
00038 namespace Teuchos { template<typename Ordinal> class Comm; }
00039 
00040 
00041 // Enable this by hand to enable showing the dump of the RTOp
00042 #define RTOPPACK_ENABLE_SHOW_DUMP
00043 
00044 
00045 #ifdef RTOP_DEBUG
00046 #  define RTOPPACK_ENABLE_SHOW_DUMP
00047 #endif
00048 
00049 
00050 namespace RTOpPack {
00051 
00052 
00053 #ifdef RTOPPACK_ENABLE_SHOW_DUMP
00054 extern bool show_spmd_apply_op_dump;
00055 #endif // RTOPPACK_ENABLE_SHOW_DUMP
00056 
00057 
00063 template<class PrimitiveScalar>
00064 int serializedSize(
00065   int   num_values
00066   ,int  num_indexes
00067   ,int  num_chars
00068   );
00069 
00070 
00075 template<class Scalar>
00076 void serialize(
00077   const RTOpT<Scalar> &op,
00078   Ordinal num_values,
00079   Ordinal num_indexes,
00080   Ordinal num_chars,
00081   const ReductTarget &reduct_obj,
00082   char reduct_obj_ext[]
00083   );
00084 
00085 
00090 template<class Scalar>
00091 void deserialize(
00092   const RTOpT<Scalar> &op,
00093   int num_values,
00094   int num_indexes,
00095   int num_chars,
00096   const char reduct_obj_ext[],
00097   ReductTarget *reduct_obj
00098   );
00099 
00100 
00105 template<class Scalar>
00106 class ReductTargetSerializer : public Teuchos::Serializer<index_type,ReductTarget> {
00107 public:
00109   ReductTargetSerializer(
00110     const Teuchos::RCP<const RTOpT<Scalar> > &op
00111     );
00115   index_type getBufferSize(const index_type count) const;
00117   void serialize(
00118     const index_type            count
00119     ,const ReductTarget* const  reduct_objs[]
00120     ,const index_type           bytes
00121     ,char                       charBuffer[]
00122     ) const;
00124   Teuchos::RCP<ReductTarget> createObj() const;
00126   void deserialize(
00127     const index_type       bytes
00128     ,const char            charBuffer[]
00129     ,const index_type      count
00130     ,ReductTarget* const   reduct_objs[]
00131     ) const;
00133 private:
00134   Teuchos::RCP<const RTOpT<Scalar> >   op_;
00135   int                                          num_values_;
00136   int                                          num_indexes_;
00137   int                                          num_chars_;
00138   int                                          reduct_obj_ext_size_;
00139   // Not defined and not to be called!
00140   ReductTargetSerializer();
00141   ReductTargetSerializer& operator=(const ReductTargetSerializer&);
00142 };
00143 
00144 
00149 template<class Scalar>
00150 class ReductTargetReductionOp
00151   : public Teuchos::ReferenceTypeReductionOp<Teuchos_Index,ReductTarget>
00152 {
00153 public:
00155   typedef Teuchos_Index Ordinal;
00157   ReductTargetReductionOp(
00158     const Teuchos::RCP<const RTOpT<Scalar> >  &op
00159     );
00163   void reduce(
00164     const Ordinal              count
00165     ,const ReductTarget*const  inBuffer[]
00166     ,ReductTarget*const        inoutBuffer[]
00167     ) const;
00169 private:
00170   Teuchos::RCP<const RTOpT<Scalar> >  op_;
00171   // Not defined and not to be called!
00172   ReductTargetReductionOp();
00173   ReductTargetReductionOp<Scalar>(const ReductTargetReductionOp<Scalar>&);
00174   ReductTargetReductionOp<Scalar>& operator=(const ReductTargetReductionOp<Scalar>&);
00175 };
00176 
00177 
00184 template<class Scalar>
00185 void SPMD_all_reduce(
00186   const Teuchos::Comm<index_type>     *comm
00187   ,const RTOpT<Scalar>                &op
00188   ,const int                          num_cols
00189   ,const ReductTarget*const           i_reduct_objs[]
00190   ,ReductTarget*const                 reduct_objs[]
00191   );
00192 
00193 
00201 template<class Scalar>
00202 void SPMD_apply_op(
00203   const Teuchos::Comm<index_type>     *comm
00204   ,const RTOpT<Scalar>                &op
00205   ,const int                          num_vecs
00206   ,const ConstSubVectorView<Scalar>   sub_vecs[]
00207   ,const int                          num_targ_vecs
00208   ,const SubVectorView<Scalar>        targ_sub_vecs[]
00209   ,ReductTarget                       *reduct_obj
00210   );
00211 
00212 
00220 template<class Scalar>
00221 void SPMD_apply_op(
00222   const Teuchos::Comm<index_type>          *comm
00223   ,const RTOpT<Scalar>                     &op
00224   ,const int                               num_cols
00225   ,const int                               num_multi_vecs
00226   ,const ConstSubMultiVectorView<Scalar>   sub_multi_vecs[]
00227   ,const int                               num_targ_multi_vecs
00228   ,const SubMultiVectorView<Scalar>        targ_sub_multi_vecs[]
00229   ,ReductTarget*const                      reduct_objs[]
00230   );
00231 
00232 
00240 template<class Scalar>
00241 void  SPMD_apply_op(
00242   const Teuchos::Comm<index_type>           *comm
00243   ,const RTOpT<Scalar>                      &op
00244   ,const int                                num_cols
00245   ,const int                                num_vecs
00246   ,const ConstSubVectorView<Scalar>         sub_vecs[]
00247   ,const int                                num_targ_vecs
00248   ,const SubVectorView<Scalar>              sub_targ_vecs[]
00249   ,ReductTarget*const                       reduct_objs[]
00250   );
00251 
00252 
00253 } // end namespace RTOpPack
00254 
00255 
00256 #endif // RTOPPACK_SPMD_APPLY_OP_DECL_HPP
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
Generated on Wed Apr 13 09:59:06 2011 for RTOp Package Browser (Single Doxygen Collection) by  doxygen 1.6.3