Epetra Package Browser (Single Doxygen Collection) Development
Epetra_MpiSmpComm.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_MPISMPCOMM_H
00045 #define EPETRA_MPISMPCOMM_H
00046 #include "Epetra_Object.h"
00047 #include "Epetra_Comm.h"
00048 #include "Epetra_MpiDistributor.h"
00049 #include <mpi.h>
00050 class Epetra_Distributor;
00051 #include "Epetra_MpiSmpCommData.h"
00052 
00054 
00061 class Epetra_MpiSmpComm: public Epetra_Object, public virtual Epetra_Comm {
00062     
00063   public:
00064 
00066 
00067 
00068 
00072   Epetra_MpiSmpComm(MPI_Comm comm);
00073 
00074 
00076 
00078   Epetra_MpiSmpComm(const Epetra_MpiSmpComm& Comm);
00079 
00081   Epetra_Comm * Clone() const {
00082     return(dynamic_cast<Epetra_Comm *>(new Epetra_MpiSmpComm(*this)));
00083   };
00084 
00086 
00091   virtual ~Epetra_MpiSmpComm();
00093 
00095 
00096 
00097 
00100   void Barrier() const;
00102 
00104 
00105 
00106 
00117   int Broadcast(double * MyVals, int Count, int Root) const;
00118 
00120 
00131   int Broadcast(int * MyVals, int Count, int Root) const;
00132 
00134 
00145   int Broadcast(long * MyVals, int Count, int Root) const;
00146 
00148 
00149 
00150 
00161   int Broadcast(char * MyVals, int Count, int Root) const;
00163 
00165 
00166 
00167 
00177   int GatherAll(double * MyVals, double * AllVals, int Count) const;
00178 
00180 
00190   int GatherAll(int * MyVals, int * AllVals, int Count) const;
00191 
00193 
00203   int GatherAll(long * MyVals, long * AllVals, int Count) const;
00205 
00207 
00208 
00209 
00220   int SumAll(double * PartialSums, double * GlobalSums, int Count) const;
00221 
00223 
00233   int SumAll(int * PartialSums, int * GlobalSums, int Count) const;
00234 
00236 
00246   int SumAll(long * PartialSums, long * GlobalSums, int Count) const;
00248 
00250 
00251 
00252 
00262   int MaxAll(double * PartialMaxs, double * GlobalMaxs, int Count) const;
00263 
00265 
00275   int MaxAll(int * PartialMaxs, int * GlobalMaxs, int Count) const;
00276 
00278 
00288   int MaxAll(long * PartialMaxs, long * GlobalMaxs, int Count) const;
00289 
00291 
00301   int MinAll(double * PartialMins, double * GlobalMins, int Count) const;
00302 
00304 
00314   int MinAll(int * PartialMins, int * GlobalMins, int Count) const;
00315 
00317 
00327   int MinAll(long * PartialMins, long * GlobalMins, int Count) const;
00329 
00331 
00332 
00333 
00343   int ScanSum(double * MyVals, double * ScanSums, int Count) const;
00344 
00346 
00356   int ScanSum(int * MyVals, int * ScanSums, int Count) const;
00357 
00359 
00369   int ScanSum(long * MyVals, long * ScanSums, int Count) const;
00371 
00373 
00374   
00376   MPI_Comm Comm() const {return(MpiSmpCommData_->Comm_);};
00377 
00379 
00382   int MyPID() const {return(MpiSmpCommData_->rank_);};
00383   
00385 
00388   int NumProc() const {return(MpiSmpCommData_->size_);};
00390 
00392 
00393 
00394   Epetra_Distributor * CreateDistributor() const;
00396   Epetra_Directory * CreateDirectory(const Epetra_BlockMap & Map) const;
00398 
00400 
00401 
00402   int GetMpiTag() const {int tag = MpiSmpCommData_->curTag_++; if (tag>MpiSmpCommData_->maxTag_) tag = MpiSmpCommData_->minTag_; return(tag);};
00404   MPI_Comm GetMpiComm() const {return(MpiSmpCommData_->Comm_);};
00406 
00407 
00408 
00409 
00416   void NodeBarrier() const;
00417 
00419 
00422   int MyThreadID() const {return(MpiSmpCommData_->ThreadID_);};
00423 
00425 
00428   int MyNodeID() const {return(MpiSmpCommData_->NodeID_);};
00429   
00431 
00433   int SetNumThreads(int NumThreads) {MpiSmpCommData_->NumThreads_ = NumThreads; return(0);};
00434   
00436 
00438   int NumThreads() const {return(MpiSmpCommData_->NumThreads_);};
00439    
00441 
00445   int SetMyThreadID(int ThreadID) {MpiSmpCommData_->ThreadID_ = ThreadID; return(0);};
00446   
00448 
00452   int SetMyNodeID(int NodeID) {MpiSmpCommData_->NodeID_ = NodeID; return(0);};
00454 
00456 
00457 
00458   inline void Print(ostream & os) const {
00459   os << "::Processor "<< MyPID()<<" of " << NumProc() << " total processors" << endl; 
00460   os << "::Thread "<< MyThreadID()<<" of " << NumThreads() << " on node " << MyNodeID() << endl; 
00461   return;}
00462 
00464   void PrintInfo(ostream & os) const {Epetra_MpiSmpComm::Print(os);return;};
00465 
00467 
00469   Epetra_MpiSmpComm & operator=(const Epetra_MpiSmpComm & Comm);
00470   
00471  private:
00472 
00473   void CleanupData();
00474   Epetra_MpiSmpCommData * MpiSmpCommData_;
00475 
00476 };
00477 #endif /* EPETRA_MPISMPCOMM_H */
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines