Teuchos_MPIReductionOpBase.hpp

00001 // @HEADER
00002 // ***********************************************************************
00003 // 
00004 //                    Teuchos: Common Tools Package
00005 //                 Copyright (2004) Sandia Corporation
00006 // 
00007 // Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive
00008 // license for use of this work by or on behalf of the U.S. Government.
00009 // 
00010 // This library is free software; you can redistribute it and/or modify
00011 // it under the terms of the GNU Lesser General Public License as
00012 // published by the Free Software Foundation; either version 2.1 of the
00013 // License, or (at your option) any later version.
00014 //  
00015 // This library is distributed in the hope that it will be useful, but
00016 // WITHOUT ANY WARRANTY; without even the implied warranty of
00017 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00018 // Lesser General Public License for more details.
00019 //  
00020 // You should have received a copy of the GNU Lesser General Public
00021 // License along with this library; if not, write to the Free Software
00022 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
00023 // USA
00024 // Questions? Contact Michael A. Heroux (maherou@sandia.gov) 
00025 // 
00026 // ***********************************************************************
00027 // @HEADER
00028 
00029 #ifndef _TEUCHOS_MPI_REDUCTION_OP_BASE_HPP_
00030 #define _TEUCHOS_MPI_REDUCTION_OP_BASE_HPP_
00031 
00032 #include "Teuchos_RefCountPtr.hpp"
00033 
00034 #ifdef HAVE_MPI
00035 
00036 #include "mpi.h"
00037 
00038 extern "C" {
00039 
00050 void Teuchos_MPI_reduction_op(
00051   void              *invec
00052   ,void             *inoutvec
00053   ,int              *len
00054   ,MPI_Datatype    *datatype
00055   );
00056 
00057 } // extern "C"
00058 
00059 namespace Teuchos {
00060 
00065 class MPIReductionOpBase {
00066 public:
00068   virtual ~MPIReductionOpBase() {}
00070   virtual void reduce(
00071     void              *invec
00072     ,void             *inoutvec
00073     ,int              *len
00074     ,MPI_Datatype     *datatype
00075     ) const = 0;
00076 };
00077 
00088 void set_reduct_op( const RefCountPtr<const MPIReductionOpBase>& reduct_op );
00089 
00093 RefCountPtr<const MPIReductionOpBase> get_reduct_op();
00094 
00117 class MPIReductionOpCreator {
00118 public:
00131   MPIReductionOpCreator( const Teuchos::RefCountPtr<const MPIReductionOpBase>& reduct_op );
00133   ~MPIReductionOpCreator();
00141   const MPI_Op& mpi_op() const;
00142 private:
00143   MPI_Op mpi_op_;
00144   MPIReductionOpCreator(); // Not defined and not to be called!
00145 };
00146 
00147 // /////////////////////////
00148 // Inline defintions
00149 
00150 inline
00151 const MPI_Op& MPIReductionOpCreator::mpi_op() const
00152 {
00153   return mpi_op_;
00154 }
00155 
00156 } // namespace Teuchos
00157 
00158 #endif // HAVE_MPI
00159 
00160 #endif // _TEUCHOS_MPI_REDUCTION_OP_BASE_HPP_

Generated on Thu Sep 18 12:39:10 2008 for Teuchos - Trilinos Tools Package by doxygen 1.3.9.1