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_RCP.hpp"
00039 
00040 #ifdef HAVE_MPI
00041 #include "mpi.h"
00042 #endif
00043 
00044 
00045 namespace Teuchos
00046 {
00053   class TEUCHOS_LIB_DLL_EXPORT MPIComm
00054     {
00055     public:
00056 
00058       MPIComm();
00059 
00060 #ifdef HAVE_MPI
00061 
00062       MPIComm(MPI_Comm comm);
00063 #endif
00064 
00066       static MPIComm& world();
00067 
00069       int getRank() const {return myRank_;}
00070 
00072       int getNProc() const {return nProc_;}
00073 
00075       void synchronize() const ;
00076 
00078 
00079 
00081       void allToAll(void* sendBuf, int sendCount, int sendType,
00082                     void* recvBuf, int recvCount, int recvType) const ;
00083 
00085       void allToAllv(void* sendBuf, int* sendCount, int* sendDisplacements,
00086                      int sendType,
00087                      void* recvBuf, int* recvCount,
00088                      int* recvDisplacements,
00089                      int recvType) const ;
00090 
00092       void allReduce(void* input, void* result, int inputCount, int type,
00093                      int op) const ;
00094 
00095 
00097       void gather(void* sendBuf, int sendCount, int sendType,
00098                   void* recvBuf, int recvCount, int recvType,
00099                   int root) const ;
00100 
00102       void gatherv(void* sendBuf, int sendCount, int sendType,
00103                    void* recvBuf, int* recvCount, int* displacements, 
00104                    int recvType, int root) const ;
00105 
00107       void allGather(void* sendBuf, int sendCount, int sendType,
00108                      void* recvBuf, int recvCount, int recvType) const ;
00109 
00111       void allGatherv(void* sendBuf, int sendCount, int sendType,
00112                       void* recvBuf, int* recvCount, int* recvDisplacements,
00113                       int recvType) const ;
00114 
00116       void bcast(void* msg, int length, int type, int src) const ;
00117 
00119 
00120 #ifdef HAVE_MPI
00121 
00122       MPI_Comm getComm() const {return comm_;}
00123 #endif
00124 
00126 
00127 
00128       static const int INT;
00130       static const int FLOAT;
00132       static const int DOUBLE;
00134       static const int CHAR;
00136 
00138 
00139 
00140       static const int SUM;
00142       static const int MIN;
00144       static const int MAX;
00146       static const int PROD;
00148 
00149       // errCheck() checks the return value of an MPI call and throws
00150       // a ParallelException upon failure.
00151       static void errCheck(int errCode, const std::string& methodName);
00152 
00153 #ifdef HAVE_MPI
00154 
00155       static MPI_Datatype getDataType(int type);
00156 
00158       static MPI_Op getOp(int op);
00159 #endif
00160     private:
00161 #ifdef HAVE_MPI
00162       MPI_Comm comm_;
00163 #endif
00164 
00165       int nProc_;
00166       int myRank_;
00167 
00169       void init();
00170 
00172       int mpiIsRunning() const ;
00173     };
00174 }
00175 #endif
00176 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
Generated on Wed Apr 13 09:57:43 2011 for Teuchos - Trilinos Tools Package by  doxygen 1.6.3