Epetra_MpiComm.h

Go to the documentation of this file.
00001 
00002 //@HEADER
00003 /*
00004 ************************************************************************
00005 
00006               Epetra: Linear Algebra Services Package 
00007                 Copyright (2001) Sandia Corporation
00008 
00009 Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive
00010 license for use of this work by or on behalf of the U.S. Government.
00011 
00012 This library is free software; you can redistribute it and/or modify
00013 it under the terms of the GNU Lesser General Public License as
00014 published by the Free Software Foundation; either version 2.1 of the
00015 License, or (at your option) any later version.
00016  
00017 This library is distributed in the hope that it will be useful, but
00018 WITHOUT ANY WARRANTY; without even the implied warranty of
00019 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00020 Lesser General Public License for more details.
00021  
00022 You should have received a copy of the GNU Lesser General Public
00023 License along with this library; if not, write to the Free Software
00024 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
00025 USA
00026 Questions? Contact Michael A. Heroux (maherou@sandia.gov) 
00027 
00028 ************************************************************************
00029 */
00030 //@HEADER
00031 
00032 #ifndef EPETRA_MPICOMM_H
00033 #define EPETRA_MPICOMM_H
00034 #include "Epetra_Object.h"
00035 #include "Epetra_Comm.h"
00036 #include "Epetra_MpiDistributor.h"
00037 class Epetra_Distributor;
00038 #include "Epetra_BasicDirectory.h"
00039 class Epetra_Directory;
00040 class Epetra_BlockMap;
00041 #include <mpi.h>
00042 #include "Epetra_MpiCommData.h"
00043 
00045 
00049 class Epetra_MpiComm: public Epetra_Object, public virtual Epetra_Comm {
00050     
00051   public:
00052 
00054 
00055 
00056 
00060   Epetra_MpiComm(MPI_Comm comm);
00061 
00062 
00064 
00066   Epetra_MpiComm(const Epetra_MpiComm & Comm);
00067 
00069   Epetra_Comm * Clone() const
00070     {
00071       return(new Epetra_MpiComm(*this));
00072     };
00073 
00075 
00080   virtual ~Epetra_MpiComm();
00082 
00084 
00085 
00086 
00089   void Barrier() const;
00091 
00093 
00094 
00095 
00106   int Broadcast(double * MyVals, int Count, int Root) const;
00107 
00109 
00120   int Broadcast(int * MyVals, int Count, int Root) const;
00121 
00123 
00134   int Broadcast(long * MyVals, int Count, int Root) const;
00135 
00137 
00148   int Broadcast(char * MyVals, int Count, int Root) const;
00150 
00152 
00153 
00154 
00164   int GatherAll(double * MyVals, double * AllVals, int Count) const;
00165 
00167 
00177   int GatherAll(int * MyVals, int * AllVals, int Count) const;
00178 
00180 
00190   int GatherAll(long * MyVals, long * AllVals, int Count) const;
00192 
00194 
00195 
00196 
00207   int SumAll(double * PartialSums, double * GlobalSums, int Count) const;
00208 
00210 
00220   int SumAll(int * PartialSums, int * GlobalSums, int Count) const;
00221 
00223 
00233   int SumAll(long * PartialSums, long * GlobalSums, int Count) const;
00235 
00237 
00238 
00239 
00249   int MaxAll(double * PartialMaxs, double * GlobalMaxs, int Count) const;
00250 
00252 
00262   int MaxAll(int * PartialMaxs, int * GlobalMaxs, int Count) const;
00263 
00265 
00275   int MaxAll(long * PartialMaxs, long * GlobalMaxs, int Count) const;
00276 
00278 
00288   int MinAll(double * PartialMins, double * GlobalMins, int Count) const;
00289 
00291 
00301   int MinAll(int * PartialMins, int * GlobalMins, int Count) const;
00302 
00304 
00314   int MinAll(long * PartialMins, long * GlobalMins, int Count) const;
00316 
00318 
00319 
00320 
00330   int ScanSum(double * MyVals, double * ScanSums, int Count) const;
00331 
00333 
00343   int ScanSum(int * MyVals, int * ScanSums, int Count) const;
00344 
00346 
00356   int ScanSum(long * MyVals, long * ScanSums, int Count) const;
00358 
00360 
00361   
00363   MPI_Comm Comm() const {return(MpiCommData_->Comm_);};
00364 
00366 
00369   int MyPID() const {return(MpiCommData_->rank_);};
00370   
00372 
00375   int NumProc() const {return(MpiCommData_->size_);};
00377 
00379 
00380 
00381   Epetra_Distributor * CreateDistributor() const;
00383   Epetra_Directory * CreateDirectory(const Epetra_BlockMap & Map) const;
00385 
00387 
00388 
00389   int GetMpiTag() const {int tag = MpiCommData_->curTag_++; if (tag > MpiCommData_->maxTag_) tag = MpiCommData_->minTag_; return(tag);};
00390 
00392   MPI_Comm GetMpiComm() const {return(MpiCommData_->Comm_);};
00394 
00395 
00396 
00397   inline void Print(ostream & os) const {
00398   os << "  Processor "<< MyPID()<<" of " << NumProc() << " total processors"; 
00399   return;}
00401   void PrintInfo(ostream & os) const {Epetra_MpiComm::Print(os);return;};
00403 
00405 
00406 
00408 
00409   int ReferenceCount() const {return(MpiCommData_->ReferenceCount());};
00410 
00412 
00413   const Epetra_MpiCommData * DataPtr() const {return(MpiCommData_);};
00414 
00416 
00418   Epetra_MpiComm & operator=(const Epetra_MpiComm & Comm);
00419   
00420  private:
00421   
00422   int CheckInput(double * ptr, int count) const {if ((ptr==0) && (count>0)) return(-1); return(0);};
00423   int CheckInput(int * ptr, int count) const {if ((ptr==0) && (count>0)) return(-1); return(0);};
00424   int CheckInput(long * ptr, int count) const {if ((ptr==0) && (count>0)) return(-1); return(0);};
00425   int CheckInput(char * ptr, int count) const {if ((ptr==0) && (count>0)) return(-1); return(0);};
00426 
00427   void CleanupData();
00428   Epetra_MpiCommData * MpiCommData_;
00429 
00430 };
00431 #endif /* EPETRA_MPICOMM_H */

Generated on Wed May 12 21:41:05 2010 for Epetra Package Browser (Single Doxygen Collection) by  doxygen 1.4.7