Tpetra_MpiPlatform.hpp

00001 // @HEADER
00002 // ***********************************************************************
00003 // 
00004 //          Tpetra: Templated Linear Algebra Services 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 TPETRA_MPIPLATFORM_HPP
00030 #define TPETRA_MPIPLATFORM_HPP
00031 
00032 #include <Teuchos_RCP.hpp>
00033 #include <Teuchos_Object.hpp>
00034 #include <Teuchos_DefaultMpiComm.hpp>
00035 #include <Teuchos_TypeNameTraits.hpp>
00036 #include "Tpetra_Platform.hpp"
00037 
00038 // FINISH: this should have a getComm() method; Comm should then have a clone() method
00039 //         because of MPI tag issues, we want to always use the same Comm, unless the user 
00040 //         specifies a different Comm
00041 
00042 namespace Tpetra {
00043 
00045   template<typename Ordinal>
00046   class MpiPlatform : public virtual Platform<Ordinal> {
00047   public:
00048 
00050 
00051 
00053     MpiPlatform(const Teuchos::RCP<const Teuchos::OpaqueWrapper<MPI_Comm> > &rawMpiComm);
00054 
00056     MpiPlatform(const MpiPlatform<Ordinal> & platform);
00057 
00059     ~MpiPlatform();
00060 
00062     Teuchos::RCP< Platform<Ordinal> > clone() const;
00063 
00065 
00067 
00068 
00070     Teuchos::RCP< Teuchos::Comm<Ordinal> > createComm() const;
00071 
00073 
00074   private:
00075     Teuchos::RCP<const Teuchos::OpaqueWrapper<MPI_Comm> > MpiComm_;
00076 
00077   }; // MpiPlatform class
00078 
00079   template <typename Ordinal>
00080   MpiPlatform<Ordinal>::MpiPlatform(const Teuchos::RCP<const Teuchos::OpaqueWrapper<MPI_Comm> > &rawMpiComm)
00081   : Platform<Ordinal>("Tpetra::MpiPlatform<"+Teuchos::TypeNameTraits<Ordinal>::name()+">") 
00082   , MpiComm_(rawMpiComm)
00083   {}
00084 
00085   template <typename Ordinal>
00086   MpiPlatform<Ordinal>::MpiPlatform(const MpiPlatform<Ordinal> & platform) 
00087   : Platform<Ordinal>("Tpetra::MpiPlatform<"+Teuchos::TypeNameTraits<Ordinal>::name()+">") 
00088   , MpiComm_(platform.MpiComm_)
00089   {}
00090 
00091   template <typename Ordinal>
00092   MpiPlatform<Ordinal>::~MpiPlatform() 
00093   {}
00094 
00095   template <typename Ordinal>
00096   Teuchos::RCP< Platform<Ordinal> > 
00097   MpiPlatform<Ordinal>::clone() const 
00098   {
00099     Teuchos::RCP< MpiPlatform<Ordinal> > platform;
00100     platform = Teuchos::rcp(new MpiPlatform<Ordinal>(*this));
00101     return platform;
00102   }
00103 
00104   template <typename Ordinal>
00105   Teuchos::RCP< Teuchos::Comm<Ordinal> > 
00106   MpiPlatform<Ordinal>::createComm() const 
00107   {
00108     return Teuchos::createMpiComm<Ordinal>(MpiComm_);
00109   }
00110 
00111 } // namespace Tpetra
00112 
00113 #endif // TPETRA_MPIPLATFORM_HPP
00114 

Generated on Wed May 12 21:59:41 2010 for Tpetra Matrix/Vector Services by  doxygen 1.4.7