Epetra Package Browser (Single Doxygen Collection) Development
Epetra_MpiComm.h
Go to the documentation of this file.
00001 /*
00002 //@HEADER
00003 // ************************************************************************
00004 // 
00005 //               Epetra: Linear Algebra Services Package 
00006 //                 Copyright 2001 Sandia Corporation
00007 // 
00008 // Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
00009 // the U.S. Government retains certain rights in this software.
00010 //
00011 // Redistribution and use in source and binary forms, with or without
00012 // modification, are permitted provided that the following conditions are
00013 // met:
00014 //
00015 // 1. Redistributions of source code must retain the above copyright
00016 // notice, this list of conditions and the following disclaimer.
00017 //
00018 // 2. Redistributions in binary form must reproduce the above copyright
00019 // notice, this list of conditions and the following disclaimer in the
00020 // documentation and/or other materials provided with the distribution.
00021 //
00022 // 3. Neither the name of the Corporation nor the names of the
00023 // contributors may be used to endorse or promote products derived from
00024 // this software without specific prior written permission.
00025 //
00026 // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
00027 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00028 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
00029 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
00030 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
00031 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
00032 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
00033 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
00034 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
00035 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
00036 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00037 //
00038 // Questions? Contact Michael A. Heroux (maherou@sandia.gov) 
00039 // 
00040 // ************************************************************************
00041 //@HEADER
00042 */
00043 
00044 #ifndef EPETRA_MPICOMM_H
00045 #define EPETRA_MPICOMM_H
00046 #include "Epetra_Object.h"
00047 #include "Epetra_Comm.h"
00048 #include "Epetra_MpiDistributor.h"
00049 class Epetra_Distributor;
00050 #include "Epetra_BasicDirectory.h"
00051 class Epetra_Directory;
00052 class Epetra_BlockMap;
00053 #include <mpi.h>
00054 #include "Epetra_MpiCommData.h"
00055 
00057 
00061 class EPETRA_LIB_DLL_EXPORT Epetra_MpiComm: public Epetra_Object, public virtual Epetra_Comm {
00062     
00063   public:
00064 
00066 
00067 
00068 
00072   Epetra_MpiComm(MPI_Comm comm);
00073 
00074 
00076 
00078   Epetra_MpiComm(const Epetra_MpiComm & Comm);
00079 
00081   Epetra_Comm * Clone() const
00082     {
00083       return(new Epetra_MpiComm(*this));
00084     };
00085 
00087 
00092   virtual ~Epetra_MpiComm();
00094 
00096 
00097 
00098 
00101   void Barrier() const;
00103 
00105 
00106 
00107 
00118   int Broadcast(double * MyVals, int Count, int Root) const;
00119 
00121 
00132   int Broadcast(int * MyVals, int Count, int Root) const;
00133 
00135 
00146   int Broadcast(long * MyVals, int Count, int Root) const;
00147 
00149 
00160   int Broadcast(char * MyVals, int Count, int Root) const;
00162 
00164 
00165 
00166 
00176   int GatherAll(double * MyVals, double * AllVals, int Count) const;
00177 
00179 
00189   int GatherAll(int * MyVals, int * AllVals, int Count) const;
00190 
00192 
00202   int GatherAll(long * MyVals, long * AllVals, int Count) const;
00204 
00206 
00207 
00208 
00219   int SumAll(double * PartialSums, double * GlobalSums, int Count) const;
00220 
00222 
00232   int SumAll(int * PartialSums, int * GlobalSums, int Count) const;
00233 
00235 
00245   int SumAll(long * PartialSums, long * GlobalSums, int Count) const;
00247 
00249 
00250 
00251 
00261   int MaxAll(double * PartialMaxs, double * GlobalMaxs, int Count) const;
00262 
00264 
00274   int MaxAll(int * PartialMaxs, int * GlobalMaxs, int Count) const;
00275 
00277 
00287   int MaxAll(long * PartialMaxs, long * GlobalMaxs, int Count) const;
00288 
00290 
00300   int MinAll(double * PartialMins, double * GlobalMins, int Count) const;
00301 
00303 
00313   int MinAll(int * PartialMins, int * GlobalMins, int Count) const;
00314 
00316 
00326   int MinAll(long * PartialMins, long * GlobalMins, int Count) const;
00328 
00330 
00331 
00332 
00342   int ScanSum(double * MyVals, double * ScanSums, int Count) const;
00343 
00345 
00355   int ScanSum(int * MyVals, int * ScanSums, int Count) const;
00356 
00358 
00368   int ScanSum(long * MyVals, long * ScanSums, int Count) const;
00370 
00372 
00373   
00375   MPI_Comm Comm() const {return(MpiCommData_->Comm_);};
00376 
00378 
00381   int MyPID() const {return(MpiCommData_->rank_);};
00382   
00384 
00387   int NumProc() const {return(MpiCommData_->size_);};
00389 
00391 
00392 
00393   Epetra_Distributor * CreateDistributor() const;
00395   Epetra_Directory * CreateDirectory(const Epetra_BlockMap & Map) const;
00397 
00399 
00400 
00401   int GetMpiTag() const {int tag = MpiCommData_->curTag_++; if (tag > MpiCommData_->maxTag_) tag = MpiCommData_->minTag_; return(tag);};
00402 
00404   MPI_Comm GetMpiComm() const {return(MpiCommData_->Comm_);};
00406 
00407 
00408 
00409   inline void Print(ostream & os) const {
00410   os << "  Processor "<< MyPID()<<" of " << NumProc() << " total processors"; 
00411   return;}
00413   void PrintInfo(ostream & os) const {Epetra_MpiComm::Print(os);return;};
00415 
00417 
00418 
00420 
00421   int ReferenceCount() const {return(MpiCommData_->ReferenceCount());};
00422 
00424 
00425   const Epetra_MpiCommData * DataPtr() const {return(MpiCommData_);};
00426 
00428 
00430   Epetra_MpiComm & operator=(const Epetra_MpiComm & Comm);
00431   
00432  private:
00433   
00434   int CheckInput(double * ptr, int count) const {if ((ptr==0) && (count>0)) return(-1); return(0);};
00435   int CheckInput(int * ptr, int count) const {if ((ptr==0) && (count>0)) return(-1); return(0);};
00436   int CheckInput(long * ptr, int count) const {if ((ptr==0) && (count>0)) return(-1); return(0);};
00437   int CheckInput(char * ptr, int count) const {if ((ptr==0) && (count>0)) return(-1); return(0);};
00438 
00439   void CleanupData();
00440   Epetra_MpiCommData * MpiCommData_;
00441 
00442 };
00443 #endif /* EPETRA_MPICOMM_H */
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines