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_RCP.hpp"
00040 
00041 
00042 
00043 namespace Teuchos
00044 {
00051   class MPIComm
00052     {
00053     public:
00054 
00056       MPIComm();
00057 
00058 #ifdef HAVE_MPI
00060       MPIComm(MPI_Comm comm);
00061 #endif
00062 
00064       static MPIComm& world();
00065 
00067       int getRank() const {return myRank_;}
00068 
00070       int getNProc() const {return nProc_;}
00071 
00073       void synchronize() const ;
00074 
00076 
00077 
00079       void allToAll(void* sendBuf, int sendCount, int sendType,
00080                     void* recvBuf, int recvCount, int recvType) const ;
00081 
00083       void allToAllv(void* sendBuf, int* sendCount, int* sendDisplacements,
00084                      int sendType,
00085                      void* recvBuf, int* recvCount,
00086                      int* recvDisplacements,
00087                      int recvType) const ;
00088 
00090       void allReduce(void* input, void* result, int inputCount, int type,
00091                      int op) const ;
00092 
00093 
00095       void gather(void* sendBuf, int sendCount, int sendType,
00096                   void* recvBuf, int recvCount, int recvType,
00097                   int root) const ;
00098 
00100       void gatherv(void* sendBuf, int sendCount, int sendType,
00101                    void* recvBuf, int* recvCount, int* displacements, 
00102                    int recvType, int root) const ;
00103 
00105       void allGather(void* sendBuf, int sendCount, int sendType,
00106                      void* recvBuf, int recvCount, int recvType) const ;
00107 
00109       void allGatherv(void* sendBuf, int sendCount, int sendType,
00110                       void* recvBuf, int* recvCount, int* recvDisplacements,
00111                       int recvType) const ;
00112 
00114       void bcast(void* msg, int length, int type, int src) const ;
00115 
00117 
00118 #ifdef HAVE_MPI
00120       MPI_Comm getComm() const {return comm_;}
00121 #endif
00122 
00124 
00125 
00126       const static int INT;
00128       const static int FLOAT;
00130       const static int DOUBLE;
00132       const static int CHAR;
00134 
00136 
00137 
00138       const static int SUM;
00140       const static int MIN;
00142       const static int MAX;
00144       const static int PROD;
00146 
00147       // errCheck() checks the return value of an MPI call and throws
00148       // a ParallelException upon failure.
00149       static void errCheck(int errCode, const std::string& methodName);
00150 
00151 #ifdef HAVE_MPI
00153       static MPI_Datatype getDataType(int type);
00154 
00156       static MPI_Op getOp(int op);
00157 #endif
00158     private:
00159 #ifdef HAVE_MPI
00160       MPI_Comm comm_;
00161 #endif
00162 
00163       int nProc_;
00164       int myRank_;
00165 
00167       void init();
00168 
00170       int mpiIsRunning() const ;
00171     };
00172 }
00173 #endif
00174 

Generated on Tue Oct 20 12:45:26 2009 for Teuchos - Trilinos Tools Package by doxygen 1.4.7