Epetra Package Browser (Single Doxygen Collection) Development
Epetra_SerialComm.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_SERIALCOMM_H
00045 #define EPETRA_SERIALCOMM_H
00046 
00047 #include "Epetra_ConfigDefs.h"
00048 #include "Epetra_Object.h"
00049 #include "Epetra_Comm.h"
00050 #include "Epetra_SerialCommData.h"
00051 #ifdef EPETRA_HAVE_OMP
00052 #include <omp.h>
00053 #endif
00054 class Epetra_Distributor;
00055 
00057 
00061 class EPETRA_LIB_DLL_EXPORT Epetra_SerialComm: public Epetra_Object, public virtual Epetra_Comm {
00062     
00063   public:
00065 
00066 
00068 
00073   Epetra_SerialComm();
00074 
00075 
00077 
00079   Epetra_SerialComm(const Epetra_SerialComm& Comm);
00080 
00082   Epetra_Comm * Clone() const {
00083     return(dynamic_cast<Epetra_Comm *>(new Epetra_SerialComm(*this)));
00084   };
00085 
00087 
00092   virtual ~Epetra_SerialComm();
00094 
00096 
00097 
00098 
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 
00159   int Broadcast(char * MyVals, int Count, int Root) const;
00161 
00163 
00164 
00165 
00174   int GatherAll(double * MyVals, double * AllVals, int Count) const;
00175 
00177 
00186   int GatherAll(int * MyVals, int * AllVals, int Count) const;
00187 
00189 
00198   int GatherAll(long * MyVals, long * AllVals, int Count) const;
00200 
00202 
00203 
00204 
00214   int SumAll(double * PartialSums, double * GlobalSums, int Count) const;
00215 
00217 
00226   int SumAll(int * PartialSums, int * GlobalSums, int Count) const;
00227 
00229 
00238   int SumAll(long * PartialSums, long * GlobalSums, int Count) const;
00240 
00242 
00243 
00244 
00253   int MaxAll(double * PartialMaxs, double * GlobalMaxs, int Count) const;
00254 
00256 
00265   int MaxAll(int * PartialMaxs, int * GlobalMaxs, int Count) const;
00266 
00268 
00277   int MaxAll(long * PartialMaxs, long * GlobalMaxs, int Count) const;
00278 
00280 
00289   int MinAll(double * PartialMins, double * GlobalMins, int Count) const;
00290 
00292 
00301   int MinAll(int * PartialMins, int * GlobalMins, int Count) const;
00302 
00304 
00313   int MinAll(long * PartialMins, long * GlobalMins, int Count) const;
00315 
00317 
00318 
00319 
00327   int ScanSum(double * MyVals, double * ScanSums, int Count) const;
00328 
00330 
00338   int ScanSum(int * MyVals, int * ScanSums, int Count) const;
00339 
00341 
00349   int ScanSum(long * MyVals, long * ScanSums, int Count) const;
00351 
00353 
00354   
00356 
00359   int MyPID() const {return(SerialCommData_->MyPID_);};
00360   
00362   int NumProc() const {return(SerialCommData_->NumProc_);};
00363 
00365 
00367 
00368 
00369   Epetra_Distributor * CreateDistributor() const;
00371   Epetra_Directory * CreateDirectory(const Epetra_BlockMap & Map) const;
00373 
00375 
00376 
00377   inline void Print(ostream & os) const {
00378 #ifdef EPETRA_HAVE_OMP
00379 #pragma omp parallel 
00380 {
00381   int numThreads = omp_get_num_threads();
00382   int threadNum = omp_get_thread_num();
00383 #pragma omp single
00384                os << "::Processor "<< MyPID()<<" of " << NumProc() << " total processors.";
00385 #pragma omp critical
00386                 os << "\n   Thread " << threadNum << " of " << numThreads << " total threads."; 
00387 }
00388 #else
00389     os << "::Processor "<< MyPID()<<" of " << NumProc() << " total processors."; 
00390 #endif
00391 
00392     return; 
00393   }
00395   void PrintInfo(ostream & os) const {
00396     Epetra_SerialComm::Print(os);
00397     return;
00398   };
00400 
00402 
00403 
00405 
00406   int ReferenceCount() const;
00407 
00409 
00410   const Epetra_SerialCommData * DataPtr() const {return(SerialCommData_);};
00411 
00413 
00415   Epetra_SerialComm & operator=(const Epetra_SerialComm & Comm);
00416 
00417  private:
00418 
00419   void CleanupData();
00420   Epetra_SerialCommData * SerialCommData_;
00421   
00422 };
00423 #endif /* EPETRA_SERIALCOMM_H */
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines