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;
00136 
00138 
00139 
00140 
00150   int GatherAll(double * MyVals, double * AllVals, int Count) const;
00151 
00153 
00163   int GatherAll(int * MyVals, int * AllVals, int Count) const;
00164 
00166 
00176   int GatherAll(long * MyVals, long * AllVals, int Count) const;
00178 
00180 
00181 
00182 
00193   int SumAll(double * PartialSums, double * GlobalSums, int Count) const;
00194 
00196 
00206   int SumAll(int * PartialSums, int * GlobalSums, int Count) const;
00207 
00209 
00219   int SumAll(long * PartialSums, long * GlobalSums, int Count) const;
00221 
00223 
00224 
00225 
00235   int MaxAll(double * PartialMaxs, double * GlobalMaxs, int Count) const;
00236 
00238 
00248   int MaxAll(int * PartialMaxs, int * GlobalMaxs, int Count) const;
00249 
00251 
00261   int MaxAll(long * PartialMaxs, long * GlobalMaxs, int Count) const;
00262 
00264 
00274   int MinAll(double * PartialMins, double * GlobalMins, int Count) const;
00275 
00277 
00287   int MinAll(int * PartialMins, int * GlobalMins, int Count) const;
00288 
00290 
00300   int MinAll(long * PartialMins, long * GlobalMins, int Count) const;
00302 
00304 
00305 
00306 
00316   int ScanSum(double * MyVals, double * ScanSums, int Count) const;
00317 
00319 
00329   int ScanSum(int * MyVals, int * ScanSums, int Count) const;
00330 
00332 
00342   int ScanSum(long * MyVals, long * ScanSums, int Count) const;
00344 
00346 
00347   
00349   MPI_Comm Comm() const {return(MpiCommData_->Comm_);};
00350 
00352 
00355   int MyPID() const {return(MpiCommData_->rank_);};
00356   
00358 
00361   int NumProc() const {return(MpiCommData_->size_);};
00363 
00365 
00366 
00367   Epetra_Distributor * CreateDistributor() const;
00369   Epetra_Directory * CreateDirectory(const Epetra_BlockMap & Map) const;
00371 
00373 
00374 
00375   int GetMpiTag() const {int tag = MpiCommData_->curTag_++; if (tag > MpiCommData_->maxTag_) tag = MpiCommData_->minTag_; return(tag);};
00376 
00378   MPI_Comm GetMpiComm() const {return(MpiCommData_->Comm_);};
00380 
00381 
00382 
00383   inline void Print(ostream & os) const {
00384   os << "  Processor "<< MyPID()<<" of " << NumProc() << " total processors"; 
00385   return;}
00387   void PrintInfo(ostream & os) const {Epetra_MpiComm::Print(os);return;};
00389 
00391 
00392 
00394 
00395   int ReferenceCount() const {return(MpiCommData_->ReferenceCount());};
00396 
00398 
00399   const Epetra_MpiCommData * DataPtr() const {return(MpiCommData_);};
00400 
00402 
00404   Epetra_MpiComm & operator=(const Epetra_MpiComm & Comm);
00405   
00406  private:
00407   
00408   int CheckInput(double * ptr, int count) const {if ((ptr==0) && (count>0)) return(-1); return(0);};
00409   int CheckInput(int * ptr, int count) const {if ((ptr==0) && (count>0)) return(-1); return(0);};
00410   int CheckInput(long * ptr, int count) const {if ((ptr==0) && (count>0)) return(-1); return(0);};
00411 
00412   void CleanupData();
00413   Epetra_MpiCommData * MpiCommData_;
00414 
00415 };
00416 #endif /* EPETRA_MPICOMM_H */

Generated on Thu Sep 18 12:37:58 2008 for Epetra Package Browser (Single Doxygen Collection) by doxygen 1.3.9.1