EpetraExt_ZoltanMpiComm.h

Go to the documentation of this file.
00001 
00002 //@HEADER
00003 // ***********************************************************************
00004 // 
00005 //     EpetraExt: Epetra Extended - Linear Algebra Services Package
00006 //                 Copyright (2001) Sandia Corporation
00007 // 
00008 // Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive
00009 // license for use of this work by or on behalf of the U.S. Government.
00010 // 
00011 // This library is free software; you can redistribute it and/or modify
00012 // it under the terms of the GNU Lesser General Public License as
00013 // published by the Free Software Foundation; either version 2.1 of the
00014 // License, or (at your option) any later version.
00015 //  
00016 // This library is distributed in the hope that it will be useful, but
00017 // WITHOUT ANY WARRANTY; without even the implied warranty of
00018 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00019 // Lesser General Public License for more details.
00020 //  
00021 // You should have received a copy of the GNU Lesser General Public
00022 // License along with this library; if not, write to the Free Software
00023 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
00024 // USA
00025 // Questions? Contact Michael A. Heroux (maherou@sandia.gov) 
00026 // 
00027 // ***********************************************************************
00028 //@HEADER
00029 
00030 #ifndef EPETRAEXT_ZOLTANMPICOMM_H
00031 #define EPETRAEXT_ZOLTANMPICOMM_H
00032 
00033 #include "Epetra_Object.h"
00034 #include "Epetra_Comm.h"
00035 #include "EpetraExt_ZoltanMpiDistributor.h"
00036 
00037 class Epetra_Distributor;
00038 
00039 #include "Epetra_BasicDirectory.h"
00040 class Epetra_Directory;
00041 class Epetra_BlockMap;
00042 
00043 #include <mpi.h>
00044 
00045 #include "EpetraExt_ZoltanMpiCommData.h"
00046 
00047 namespace EpetraExt {
00048 
00050 
00054 class ZoltanMpiComm: public Epetra_Object, public virtual Epetra_Comm {
00055     
00056  public:
00057 
00059 
00060 
00064   ZoltanMpiComm(MPI_Comm comm);
00065 
00066 
00068 
00070   ZoltanMpiComm(const ZoltanMpiComm & Comm);
00071 
00073   Epetra_Comm * Clone() const
00074   { return(new ZoltanMpiComm(*this)); }
00075 
00077 
00082   virtual ~ZoltanMpiComm();
00084 
00086 
00087 
00090   void Barrier() const;
00092 
00094 
00095 
00106   int Broadcast(double * MyVals, int Count, int Root) const;
00107 
00109 
00120   int Broadcast(int * MyVals, int Count, int Root) const;
00122 
00124 
00125 
00135   int GatherAll(double * MyVals, double * AllVals, int Count) const;
00136 
00138 
00148   int GatherAll(int * MyVals, int * AllVals, int Count) const;
00150 
00152 
00153 
00164   int SumAll(double * PartialSums, double * GlobalSums, int Count) const;
00165 
00167 
00177   int SumAll(int * PartialSums, int * GlobalSums, int Count) const;
00179 
00181 
00182 
00192   int MaxAll(double * PartialMaxs, double * GlobalMaxs, int Count) const;
00193 
00194 
00196 
00206   int MaxAll(int * PartialMaxs, int * GlobalMaxs, int Count) const;
00207 
00209 
00219   int MinAll(double * PartialMins, double * GlobalMins, int Count) const;
00220 
00221 
00223 
00233   int MinAll(int * PartialMins, int * GlobalMins, int Count) const;
00235 
00237 
00238 
00248   int ScanSum(double * MyVals, double * ScanSums, int Count) const;
00249 
00250 
00252 
00262   int ScanSum(int * MyVals, int * ScanSums, int Count) const;
00264 
00266   
00268   MPI_Comm Comm() const {return(MpiCommData_->Comm_);};
00269 
00271 
00274   int MyPID() const {return(MpiCommData_->rank_);};
00275   
00277 
00280   int NumProc() const {return(MpiCommData_->size_);};
00282 
00284 
00285   Epetra_Distributor * CreateDistributor() const;
00287   Epetra_Directory * CreateDirectory(const Epetra_BlockMap & Map) const;
00289 
00291 
00292   int GetMpiTag() const {int tag = MpiCommData_->curTag_++; if (tag > MpiCommData_->maxTag_) tag = MpiCommData_->minTag_; return(tag);};
00293 
00295   MPI_Comm GetMpiComm() const {return(MpiCommData_->Comm_);};
00297 
00298 
00299   inline void Print(ostream & os) const {
00300   os << "  Processor "<< MyPID()<<" of " << NumProc() << " total processors"; 
00301   return;}
00303   void PrintInfo(ostream & os) const {ZoltanMpiComm::Print(os);return;};
00305 
00307 
00309 
00310   int ReferenceCount() const {return(MpiCommData_->ReferenceCount());};
00311 
00313 
00314   const ZoltanMpiCommData * DataPtr() const {return(MpiCommData_);};
00315 
00317 
00319   ZoltanMpiComm & operator=(const ZoltanMpiComm & Comm);
00320   
00321  private:
00322   
00323   int CheckInput(double * ptr, int count) const {if ((ptr==0) && (count>0)) return(-1); return(0);};
00324   int CheckInput(int * ptr, int count) const {if ((ptr==0) && (count>0)) return(-1); return(0);};
00325 
00326   void CleanupData();
00327   ZoltanMpiCommData * MpiCommData_;
00328 
00329 };
00330 
00331 } //namespace EpetraExt
00332 
00333 #endif /* EPETRAEXT_ZOLTANMPICOMM_H */

Generated on Wed May 12 21:24:46 2010 for EpetraExt by  doxygen 1.4.7