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 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 
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 
00062 class EPETRA_DEPRECATED Epetra_MpiSmpComm: public Epetra_Object, public virtual Epetra_Comm {
00063 
00064   public:
00065 
00067 
00068 
00069 
00073   Epetra_MpiSmpComm(MPI_Comm comm);
00074 
00075 
00077 
00079   Epetra_MpiSmpComm(const Epetra_MpiSmpComm& Comm);
00080 
00082   Epetra_Comm * Clone() const {
00083     return(dynamic_cast<Epetra_Comm *>(new Epetra_MpiSmpComm(*this)));
00084   };
00085 
00087 
00092   virtual ~Epetra_MpiSmpComm();
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 
00150 
00151 
00162   int Broadcast(char * MyVals, int Count, int Root) const;
00164 
00166 
00167 
00168 
00178   int GatherAll(double * MyVals, double * AllVals, int Count) const;
00179 
00181 
00191   int GatherAll(int * MyVals, int * AllVals, int Count) const;
00192 
00194 
00204   int GatherAll(long * MyVals, long * AllVals, int Count) const;
00206 
00208 
00209 
00210 
00221   int SumAll(double * PartialSums, double * GlobalSums, int Count) const;
00222 
00224 
00234   int SumAll(int * PartialSums, int * GlobalSums, int Count) const;
00235 
00237 
00247   int SumAll(long * PartialSums, long * GlobalSums, int Count) const;
00249 
00251 
00252 
00253 
00263   int MaxAll(double * PartialMaxs, double * GlobalMaxs, int Count) const;
00264 
00266 
00276   int MaxAll(int * PartialMaxs, int * GlobalMaxs, int Count) const;
00277 
00279 
00289   int MaxAll(long * PartialMaxs, long * GlobalMaxs, int Count) const;
00290 
00292 
00302   int MinAll(double * PartialMins, double * GlobalMins, int Count) const;
00303 
00305 
00315   int MinAll(int * PartialMins, int * GlobalMins, int Count) const;
00316 
00318 
00328   int MinAll(long * PartialMins, long * GlobalMins, int Count) const;
00330 
00332 
00333 
00334 
00344   int ScanSum(double * MyVals, double * ScanSums, int Count) const;
00345 
00347 
00357   int ScanSum(int * MyVals, int * ScanSums, int Count) const;
00358 
00360 
00370   int ScanSum(long * MyVals, long * ScanSums, int Count) const;
00372 
00374 
00375 
00377   MPI_Comm Comm() const {return(MpiSmpCommData_->Comm_);};
00378 
00380 
00383   int MyPID() const {return(MpiSmpCommData_->rank_);};
00384 
00386 
00389   int NumProc() const {return(MpiSmpCommData_->size_);};
00391 
00393 
00394 
00395   Epetra_Distributor * CreateDistributor() const;
00397   Epetra_Directory * CreateDirectory(const Epetra_BlockMap & Map) const;
00399 
00401 
00402 
00403   int GetMpiTag() const {int tag = MpiSmpCommData_->curTag_++; if (tag>MpiSmpCommData_->maxTag_) tag = MpiSmpCommData_->minTag_; return(tag);};
00405   MPI_Comm GetMpiComm() const {return(MpiSmpCommData_->Comm_);};
00407 
00408 
00409 
00410 
00417   void NodeBarrier() const;
00418 
00420 
00423   int MyThreadID() const {return(MpiSmpCommData_->ThreadID_);};
00424 
00426 
00429   int MyNodeID() const {return(MpiSmpCommData_->NodeID_);};
00430 
00432 
00434   int SetNumThreads(int NumThreads) {MpiSmpCommData_->NumThreads_ = NumThreads; return(0);};
00435 
00437 
00439   int NumThreads() const {return(MpiSmpCommData_->NumThreads_);};
00440 
00442 
00446   int SetMyThreadID(int ThreadID) {MpiSmpCommData_->ThreadID_ = ThreadID; return(0);};
00447 
00449 
00453   int SetMyNodeID(int NodeID) {MpiSmpCommData_->NodeID_ = NodeID; return(0);};
00455 
00457 
00458 
00459   inline void Print(std::ostream & os) const {
00460   os << "::Processor "<< MyPID()<<" of " << NumProc() << " total processors" << std::endl;
00461   os << "::Thread "<< MyThreadID()<<" of " << NumThreads() << " on node " << MyNodeID() << std::endl;
00462   return;}
00463 
00465   void PrintInfo(std::ostream & os) const {Epetra_MpiSmpComm::Print(os);return;};
00466 
00468 
00470   Epetra_MpiSmpComm & operator=(const Epetra_MpiSmpComm & Comm);
00471 
00472  private:
00473 
00474   void CleanupData();
00475   Epetra_MpiSmpCommData * MpiSmpCommData_;
00476 
00477 };
00478 #endif /* EPETRA_MPISMPCOMM_H */
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines