Epetra_MpiSmpComm.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_MPISMPCOMM_H
00033 #define EPETRA_MPISMPCOMM_H
00034 #include "Epetra_Object.h"
00035 #include "Epetra_Comm.h"
00036 #include "Epetra_MpiDistributor.h"
00037 #include <mpi.h>
00038 class Epetra_Distributor;
00039 #include "Epetra_MpiSmpCommData.h"
00040 
00042 
00049 class Epetra_MpiSmpComm: public Epetra_Object, public virtual Epetra_Comm {
00050     
00051   public:
00052 
00054 
00055 
00056 
00060   Epetra_MpiSmpComm(MPI_Comm comm);
00061 
00062 
00064 
00066   Epetra_MpiSmpComm(const Epetra_MpiSmpComm& Comm);
00067 
00069   Epetra_Comm * Clone() const {
00070     return(dynamic_cast<Epetra_Comm *>(new Epetra_MpiSmpComm(*this)));
00071   };
00072 
00074 
00079   virtual ~Epetra_MpiSmpComm();
00081 
00083 
00084 
00085 
00088   void Barrier() const;
00090 
00092 
00093 
00094 
00105   int Broadcast(double * MyVals, int Count, int Root) const;
00106 
00108 
00119   int Broadcast(int * MyVals, int Count, int Root) const;
00120 
00122 
00133   int Broadcast(long * MyVals, int Count, int Root) const;
00134 
00136 
00137 
00138 
00149   int Broadcast(char * MyVals, int Count, int Root) const;
00151 
00153 
00154 
00155 
00165   int GatherAll(double * MyVals, double * AllVals, int Count) const;
00166 
00168 
00178   int GatherAll(int * MyVals, int * AllVals, int Count) const;
00179 
00181 
00191   int GatherAll(long * MyVals, long * AllVals, int Count) const;
00193 
00195 
00196 
00197 
00208   int SumAll(double * PartialSums, double * GlobalSums, int Count) const;
00209 
00211 
00221   int SumAll(int * PartialSums, int * GlobalSums, int Count) const;
00222 
00224 
00234   int SumAll(long * PartialSums, long * GlobalSums, int Count) const;
00236 
00238 
00239 
00240 
00250   int MaxAll(double * PartialMaxs, double * GlobalMaxs, int Count) const;
00251 
00253 
00263   int MaxAll(int * PartialMaxs, int * GlobalMaxs, int Count) const;
00264 
00266 
00276   int MaxAll(long * PartialMaxs, long * GlobalMaxs, int Count) const;
00277 
00279 
00289   int MinAll(double * PartialMins, double * GlobalMins, int Count) const;
00290 
00292 
00302   int MinAll(int * PartialMins, int * GlobalMins, int Count) const;
00303 
00305 
00315   int MinAll(long * PartialMins, long * GlobalMins, int Count) const;
00317 
00319 
00320 
00321 
00331   int ScanSum(double * MyVals, double * ScanSums, int Count) const;
00332 
00334 
00344   int ScanSum(int * MyVals, int * ScanSums, int Count) const;
00345 
00347 
00357   int ScanSum(long * MyVals, long * ScanSums, int Count) const;
00359 
00361 
00362   
00364   MPI_Comm Comm() const {return(MpiSmpCommData_->Comm_);};
00365 
00367 
00370   int MyPID() const {return(MpiSmpCommData_->rank_);};
00371   
00373 
00376   int NumProc() const {return(MpiSmpCommData_->size_);};
00378 
00380 
00381 
00382   Epetra_Distributor * CreateDistributor() const;
00384   Epetra_Directory * CreateDirectory(const Epetra_BlockMap & Map) const;
00386 
00388 
00389 
00390   int GetMpiTag() const {int tag = MpiSmpCommData_->curTag_++; if (tag>MpiSmpCommData_->maxTag_) tag = MpiSmpCommData_->minTag_; return(tag);};
00392   MPI_Comm GetMpiComm() const {return(MpiSmpCommData_->Comm_);};
00394 
00395 
00396 
00397 
00404   void NodeBarrier() const;
00405 
00407 
00410   int MyThreadID() const {return(MpiSmpCommData_->ThreadID_);};
00411 
00413 
00416   int MyNodeID() const {return(MpiSmpCommData_->NodeID_);};
00417   
00419 
00421   int SetNumThreads(int NumThreads) {MpiSmpCommData_->NumThreads_ = NumThreads; return(0);};
00422   
00424 
00426   int NumThreads() const {return(MpiSmpCommData_->NumThreads_);};
00427    
00429 
00433   int SetMyThreadID(int ThreadID) {MpiSmpCommData_->ThreadID_ = ThreadID; return(0);};
00434   
00436 
00440   int SetMyNodeID(int NodeID) {MpiSmpCommData_->NodeID_ = NodeID; return(0);};
00442 
00444 
00445 
00446   inline void Print(ostream & os) const {
00447   os << "::Processor "<< MyPID()<<" of " << NumProc() << " total processors" << endl; 
00448   os << "::Thread "<< MyThreadID()<<" of " << NumThreads() << " on node " << MyNodeID() << endl; 
00449   return;}
00450 
00452   void PrintInfo(ostream & os) const {Epetra_MpiSmpComm::Print(os);return;};
00453 
00455 
00457   Epetra_MpiSmpComm & operator=(const Epetra_MpiSmpComm & Comm);
00458   
00459  private:
00460 
00461   void CleanupData();
00462   Epetra_MpiSmpCommData * MpiSmpCommData_;
00463 
00464 };
00465 #endif /* EPETRA_MPISMPCOMM_H */

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