Teuchos_MPIComm.hpp

Go to the documentation of this file.
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_MPICOMM_H
00030 #define TEUCHOS_MPICOMM_H
00031 
00036 #include "Teuchos_ConfigDefs.hpp"
00037 #include "Teuchos_Array.hpp"
00038 #include "Teuchos_MPISession.hpp"
00039 #include "Teuchos_RefCountPtr.hpp"
00040 
00041 
00042 namespace Teuchos
00043 {
00050   class MPIComm
00051     {
00052     public:
00053 
00055       MPIComm();
00056 
00057 #ifdef HAVE_MPI
00058 
00059       MPIComm(MPI_Comm comm);
00060 #endif
00061 
00063       static MPIComm& world();
00064 
00066       int getRank() const {return myRank_;}
00067 
00069       int getNProc() const {return nProc_;}
00070 
00072       void synchronize() const ;
00073 
00076 
00078       void allToAll(void* sendBuf, int sendCount, int sendType,
00079                     void* recvBuf, int recvCount, int recvType) const ;
00080 
00082       void allToAllv(void* sendBuf, int* sendCount, int* sendDisplacements,
00083                      int sendType,
00084                      void* recvBuf, int* recvCount,
00085                      int* recvDisplacements,
00086                      int recvType) const ;
00087 
00089       void allReduce(void* input, void* result, int inputCount, int type,
00090                      int op) const ;
00091 
00093       void gather(void* sendBuf, int sendCount, int sendType,
00094                   void* recvBuf, int recvCount, int recvType,
00095                   int root) const ;
00096 
00098       void allGather(void* sendBuf, int sendCount, int sendType,
00099                      void* recvBuf, int recvCount, int recvType) const ;
00100 
00102       void allGatherv(void* sendBuf, int sendCount, int sendType,
00103                       void* recvBuf, int* recvCount, int* recvDisplacements,
00104                       int recvType) const ;
00105 
00107       void bcast(void* msg, int length, int type, int src) const ;
00108 
00110 
00111 #ifdef HAVE_MPI
00112 
00113       MPI_Comm getComm() const {return comm_;}
00114 #endif
00115 
00117 
00118       const static int INT;
00120       const static int FLOAT;
00122       const static int DOUBLE;
00124       const static int CHAR;
00126 
00128 
00129       const static int SUM;
00131       const static int MIN;
00133       const static int MAX;
00135       const static int PROD;
00137 
00138       // errCheck() checks the return value of an MPI call and throws
00139       // a ParallelException upon failure.
00140       static void errCheck(int errCode, const string& methodName);
00141 
00142 #ifdef HAVE_MPI
00143 
00144       static MPI_Datatype getDataType(int type);
00145 
00147       static MPI_Op getOp(int op);
00148 #endif
00149     private:
00150 #ifdef HAVE_MPI
00151       MPI_Comm comm_;
00152 #endif
00153 
00154       int nProc_;
00155       int myRank_;
00156 
00158       void init();
00159     };
00160 }
00161 #endif
00162 

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