RTOp Package Browser (Single Doxygen Collection) Version of the Day
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 // Redistribution and use in source and binary forms, with or without
00012 // modification, are permitted provided that the following conditions are
00013 // met:
00014 //
00015 // 1. Redistributions of source code must retain the above copyright
00016 // notice, this list of conditions and the following disclaimer.
00017 //
00018 // 2. Redistributions in binary form must reproduce the above copyright
00019 // notice, this list of conditions and the following disclaimer in the
00020 // documentation and/or other materials provided with the distribution.
00021 //
00022 // 3. Neither the name of the Corporation nor the names of the
00023 // contributors may be used to endorse or promote products derived from
00024 // this software without specific prior written permission.
00025 //
00026 // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
00027 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00028 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
00029 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
00030 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
00031 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
00032 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
00033 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
00034 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
00035 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
00036 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00037 //
00038 // Questions? Contact Roscoe A. Bartlett (rabartl@sandia.gov) 
00039 // 
00040 // ***********************************************************************
00041 // @HEADER
00042 
00043 #ifndef RTOPPACK_SPMD_APPLY_OP_DECL_HPP
00044 #define RTOPPACK_SPMD_APPLY_OP_DECL_HPP
00045 
00046 #include "RTOpPack_RTOpT.hpp"
00047 #include "Teuchos_Serializer.hpp"
00048 #include "Teuchos_ReductionOp.hpp"
00049 
00050 
00051 namespace Teuchos { template<typename Ordinal> class Comm; }
00052 
00053 
00054 // Enable this by hand to enable showing the dump of the RTOp
00055 #define RTOPPACK_ENABLE_SHOW_DUMP
00056 
00057 
00058 #ifdef RTOP_DEBUG
00059 #  define RTOPPACK_ENABLE_SHOW_DUMP
00060 #endif
00061 
00062 
00063 namespace RTOpPack {
00064 
00065 
00066 #ifdef RTOPPACK_ENABLE_SHOW_DUMP
00067 extern bool show_spmd_apply_op_dump;
00068 #endif // RTOPPACK_ENABLE_SHOW_DUMP
00069 
00070 
00076 template<class PrimitiveScalar>
00077 int serializedSize(
00078   int   num_values
00079   ,int  num_indexes
00080   ,int  num_chars
00081   );
00082 
00083 
00088 template<class Scalar>
00089 void serialize(
00090   const RTOpT<Scalar> &op,
00091   Ordinal num_values,
00092   Ordinal num_indexes,
00093   Ordinal num_chars,
00094   const ReductTarget &reduct_obj,
00095   char reduct_obj_ext[]
00096   );
00097 
00098 
00103 template<class Scalar>
00104 void deserialize(
00105   const RTOpT<Scalar> &op,
00106   int num_values,
00107   int num_indexes,
00108   int num_chars,
00109   const char reduct_obj_ext[],
00110   ReductTarget *reduct_obj
00111   );
00112 
00113 
00118 template<class Scalar>
00119 class ReductTargetSerializer : public Teuchos::Serializer<index_type,ReductTarget> {
00120 public:
00122   ReductTargetSerializer(
00123     const Teuchos::RCP<const RTOpT<Scalar> > &op
00124     );
00128   index_type getBufferSize(const index_type count) const;
00130   void serialize(
00131     const index_type            count
00132     ,const ReductTarget* const  reduct_objs[]
00133     ,const index_type           bytes
00134     ,char                       charBuffer[]
00135     ) const;
00137   Teuchos::RCP<ReductTarget> createObj() const;
00139   void deserialize(
00140     const index_type       bytes
00141     ,const char            charBuffer[]
00142     ,const index_type      count
00143     ,ReductTarget* const   reduct_objs[]
00144     ) const;
00146 private:
00147   Teuchos::RCP<const RTOpT<Scalar> >   op_;
00148   int                                          num_values_;
00149   int                                          num_indexes_;
00150   int                                          num_chars_;
00151   int                                          reduct_obj_ext_size_;
00152   // Not defined and not to be called!
00153   ReductTargetSerializer();
00154   ReductTargetSerializer& operator=(const ReductTargetSerializer&);
00155 };
00156 
00157 
00162 template<class Scalar>
00163 class ReductTargetReductionOp
00164   : public Teuchos::ReferenceTypeReductionOp<Teuchos_Ordinal,ReductTarget>
00165 {
00166 public:
00168   typedef Teuchos_Ordinal Ordinal;
00170   ReductTargetReductionOp(
00171     const Teuchos::RCP<const RTOpT<Scalar> >  &op
00172     );
00176   void reduce(
00177     const Ordinal              count
00178     ,const ReductTarget*const  inBuffer[]
00179     ,ReductTarget*const        inoutBuffer[]
00180     ) const;
00182 private:
00183   Teuchos::RCP<const RTOpT<Scalar> >  op_;
00184   // Not defined and not to be called!
00185   ReductTargetReductionOp();
00186   ReductTargetReductionOp<Scalar>(const ReductTargetReductionOp<Scalar>&);
00187   ReductTargetReductionOp<Scalar>& operator=(const ReductTargetReductionOp<Scalar>&);
00188 };
00189 
00190 
00197 template<class Scalar>
00198 void SPMD_all_reduce(
00199   const Teuchos::Comm<index_type>     *comm
00200   ,const RTOpT<Scalar>                &op
00201   ,const int                          num_cols
00202   ,const ReductTarget*const           i_reduct_objs[]
00203   ,ReductTarget*const                 reduct_objs[]
00204   );
00205 
00206 
00214 template<class Scalar>
00215 void SPMD_apply_op(
00216   const Teuchos::Comm<index_type>     *comm
00217   ,const RTOpT<Scalar>                &op
00218   ,const int                          num_vecs
00219   ,const ConstSubVectorView<Scalar>   sub_vecs[]
00220   ,const int                          num_targ_vecs
00221   ,const SubVectorView<Scalar>        targ_sub_vecs[]
00222   ,ReductTarget                       *reduct_obj
00223   );
00224 
00225 
00233 template<class Scalar>
00234 void SPMD_apply_op(
00235   const Teuchos::Comm<index_type>          *comm
00236   ,const RTOpT<Scalar>                     &op
00237   ,const int                               num_cols
00238   ,const int                               num_multi_vecs
00239   ,const ConstSubMultiVectorView<Scalar>   sub_multi_vecs[]
00240   ,const int                               num_targ_multi_vecs
00241   ,const SubMultiVectorView<Scalar>        targ_sub_multi_vecs[]
00242   ,ReductTarget*const                      reduct_objs[]
00243   );
00244 
00245 
00253 template<class Scalar>
00254 void  SPMD_apply_op(
00255   const Teuchos::Comm<index_type>           *comm
00256   ,const RTOpT<Scalar>                      &op
00257   ,const int                                num_cols
00258   ,const int                                num_vecs
00259   ,const ConstSubVectorView<Scalar>         sub_vecs[]
00260   ,const int                                num_targ_vecs
00261   ,const SubVectorView<Scalar>              sub_targ_vecs[]
00262   ,ReductTarget*const                       reduct_objs[]
00263   );
00264 
00265 
00266 } // end namespace RTOpPack
00267 
00268 
00269 #endif // RTOPPACK_SPMD_APPLY_OP_DECL_HPP
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines