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;
00135 
00137 
00138 
00139 
00149   int GatherAll(double * MyVals, double * AllVals, int Count) const;
00150 
00152 
00162   int GatherAll(int * MyVals, int * AllVals, int Count) const;
00163 
00165 
00175   int GatherAll(long * MyVals, long * AllVals, int Count) const;
00177 
00179 
00180 
00181 
00192   int SumAll(double * PartialSums, double * GlobalSums, int Count) const;
00193 
00195 
00205   int SumAll(int * PartialSums, int * GlobalSums, int Count) const;
00206 
00208 
00218   int SumAll(long * PartialSums, long * GlobalSums, int Count) const;
00220 
00222 
00223 
00224 
00234   int MaxAll(double * PartialMaxs, double * GlobalMaxs, int Count) const;
00235 
00237 
00247   int MaxAll(int * PartialMaxs, int * GlobalMaxs, int Count) const;
00248 
00250 
00260   int MaxAll(long * PartialMaxs, long * GlobalMaxs, int Count) const;
00261 
00263 
00273   int MinAll(double * PartialMins, double * GlobalMins, int Count) const;
00274 
00276 
00286   int MinAll(int * PartialMins, int * GlobalMins, int Count) const;
00287 
00289 
00299   int MinAll(long * PartialMins, long * GlobalMins, int Count) const;
00301 
00303 
00304 
00305 
00315   int ScanSum(double * MyVals, double * ScanSums, int Count) const;
00316 
00318 
00328   int ScanSum(int * MyVals, int * ScanSums, int Count) const;
00329 
00331 
00341   int ScanSum(long * MyVals, long * ScanSums, int Count) const;
00343 
00345 
00346   
00348   MPI_Comm Comm() const {return(MpiSmpCommData_->Comm_);};
00349 
00351 
00354   int MyPID() const {return(MpiSmpCommData_->rank_);};
00355   
00357 
00360   int NumProc() const {return(MpiSmpCommData_->size_);};
00362 
00364 
00365 
00366   Epetra_Distributor * CreateDistributor() const;
00368   Epetra_Directory * CreateDirectory(const Epetra_BlockMap & Map) const;
00370 
00372 
00373 
00374   int GetMpiTag() const {int tag = MpiSmpCommData_->curTag_++; if (tag>MpiSmpCommData_->maxTag_) tag = MpiSmpCommData_->minTag_; return(tag);};
00376   MPI_Comm GetMpiComm() const {return(MpiSmpCommData_->Comm_);};
00378 
00379 
00380 
00381 
00388   void NodeBarrier() const;
00389 
00391 
00394   int MyThreadID() const {return(MpiSmpCommData_->ThreadID_);};
00395 
00397 
00400   int MyNodeID() const {return(MpiSmpCommData_->NodeID_);};
00401   
00403 
00405   int SetNumThreads(int NumThreads) {MpiSmpCommData_->NumThreads_ = NumThreads; return(0);};
00406   
00408 
00410   int NumThreads() const {return(MpiSmpCommData_->NumThreads_);};
00411    
00413 
00417   int SetMyThreadID(int ThreadID) {MpiSmpCommData_->ThreadID_ = ThreadID; return(0);};
00418   
00420 
00424   int SetMyNodeID(int NodeID) {MpiSmpCommData_->NodeID_ = NodeID; return(0);};
00426 
00428 
00429 
00430   inline void Print(ostream & os) const {
00431   os << "::Processor "<< MyPID()<<" of " << NumProc() << " total processors" << endl; 
00432   os << "::Thread "<< MyThreadID()<<" of " << NumThreads() << " on node " << MyNodeID() << endl; 
00433   return;}
00434 
00436   void PrintInfo(ostream & os) const {Epetra_MpiSmpComm::Print(os);return;};
00437 
00439 
00441   Epetra_MpiSmpComm & operator=(const Epetra_MpiSmpComm & Comm);
00442   
00443  private:
00444 
00445   void CleanupData();
00446   Epetra_MpiSmpCommData * MpiSmpCommData_;
00447 
00448 };
00449 #endif /* EPETRA_MPISMPCOMM_H */

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