EpetraExt Development
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 (2011) 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 #ifndef EPETRAEXT_ZOLTANMPICOMM_H
00044 #define EPETRAEXT_ZOLTANMPICOMM_H
00045 
00046 #include "Epetra_Object.h"
00047 #include "Epetra_Comm.h"
00048 #include "EpetraExt_ZoltanMpiDistributor.h"
00049 
00050 class Epetra_Distributor;
00051 
00052 #include "Epetra_BasicDirectory.h"
00053 class Epetra_Directory;
00054 class Epetra_BlockMap;
00055 
00056 #include <mpi.h>
00057 
00058 #include "EpetraExt_ZoltanMpiCommData.h"
00059 
00060 namespace EpetraExt {
00061 
00063 
00067 class EPETRAEXT_DEPRECATED ZoltanMpiComm: public Epetra_Object, public virtual Epetra_Comm {
00068     
00069  public:
00070 
00072 
00073 
00077   ZoltanMpiComm(MPI_Comm comm);
00078 
00079 
00081 
00083   ZoltanMpiComm(const ZoltanMpiComm & Comm);
00084 
00086   Epetra_Comm * Clone() const
00087   { return(new ZoltanMpiComm(*this)); }
00088 
00090 
00095   virtual ~ZoltanMpiComm();
00097 
00099 
00100 
00103   void Barrier() const;
00105 
00107 
00108 
00119   int Broadcast(double * MyVals, int Count, int Root) const;
00120 
00122 
00133   int Broadcast(int * MyVals, int Count, int Root) const;
00135 
00137 
00138 
00148   int GatherAll(double * MyVals, double * AllVals, int Count) const;
00149 
00151 
00161   int GatherAll(int * MyVals, int * AllVals, int Count) const;
00163 
00165 
00166 
00177   int SumAll(double * PartialSums, double * GlobalSums, int Count) const;
00178 
00180 
00190   int SumAll(int * PartialSums, int * GlobalSums, int Count) const;
00192 
00194 
00195 
00205   int MaxAll(double * PartialMaxs, double * GlobalMaxs, int Count) const;
00206 
00207 
00209 
00219   int MaxAll(int * PartialMaxs, int * GlobalMaxs, int Count) const;
00220 
00222 
00232   int MinAll(double * PartialMins, double * GlobalMins, int Count) const;
00233 
00234 
00236 
00246   int MinAll(int * PartialMins, int * GlobalMins, int Count) const;
00248 
00250 
00251 
00261   int ScanSum(double * MyVals, double * ScanSums, int Count) const;
00262 
00263 
00265 
00275   int ScanSum(int * MyVals, int * ScanSums, int Count) const;
00277 
00279   
00281   MPI_Comm Comm() const {return(MpiCommData_->Comm_);};
00282 
00284 
00287   int MyPID() const {return(MpiCommData_->rank_);};
00288   
00290 
00293   int NumProc() const {return(MpiCommData_->size_);};
00295 
00297 
00298   Epetra_Distributor * CreateDistributor() const;
00300   Epetra_Directory * CreateDirectory(const Epetra_BlockMap & Map) const;
00302 
00304 
00305   int GetMpiTag() const {int tag = MpiCommData_->curTag_++; if (tag > MpiCommData_->maxTag_) tag = MpiCommData_->minTag_; return(tag);};
00306 
00308   MPI_Comm GetMpiComm() const {return(MpiCommData_->Comm_);};
00310 
00311 
00312   inline void Print(ostream & os) const {
00313   os << "  Processor "<< MyPID()<<" of " << NumProc() << " total processors"; 
00314   return;}
00316   void PrintInfo(ostream & os) const {ZoltanMpiComm::Print(os);return;};
00318 
00320 
00322 
00323   int ReferenceCount() const {return(MpiCommData_->ReferenceCount());};
00324 
00326 
00327   const ZoltanMpiCommData * DataPtr() const {return(MpiCommData_);};
00328 
00330 
00332   ZoltanMpiComm & operator=(const ZoltanMpiComm & Comm);
00333   
00334  private:
00335   
00336   int CheckInput(double * ptr, int count) const {if ((ptr==0) && (count>0)) return(-1); return(0);};
00337   int CheckInput(int * ptr, int count) const {if ((ptr==0) && (count>0)) return(-1); return(0);};
00338 
00339   void CleanupData();
00340   ZoltanMpiCommData * MpiCommData_;
00341 
00342 };
00343 
00344 } //namespace EpetraExt
00345 
00346 #endif /* EPETRAEXT_ZOLTANMPICOMM_H */
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines