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(long long * MyVals, int Count, int Root) const;
00160 
00162 
00173   int Broadcast(char * MyVals, int Count, int Root) const;
00175 
00177 
00178 
00179 
00188   int GatherAll(double * MyVals, double * AllVals, int Count) const;
00189 
00191 
00200   int GatherAll(int * MyVals, int * AllVals, int Count) const;
00201 
00203 
00212   int GatherAll(long * MyVals, long * AllVals, int Count) const;
00213 
00215 
00224   int GatherAll(long long * MyVals, long long * AllVals, int Count) const;
00226 
00228 
00229 
00230 
00240   int SumAll(double * PartialSums, double * GlobalSums, int Count) const;
00241 
00243 
00252   int SumAll(int * PartialSums, int * GlobalSums, int Count) const;
00253 
00255 
00264   int SumAll(long * PartialSums, long * GlobalSums, int Count) const;
00265 
00267 
00276   int SumAll(long long * PartialSums, long long * GlobalSums, int Count) const;
00278 
00280 
00281 
00282 
00291   int MaxAll(double * PartialMaxs, double * GlobalMaxs, int Count) const;
00292 
00294 
00303   int MaxAll(int * PartialMaxs, int * GlobalMaxs, int Count) const;
00304 
00306 
00315   int MaxAll(long * PartialMaxs, long * GlobalMaxs, int Count) const;
00316 
00318 
00327   int MaxAll(long long * PartialMaxs, long long * GlobalMaxs, int Count) const;
00328 
00330 
00339   int MinAll(double * PartialMins, double * GlobalMins, int Count) const;
00340 
00342 
00351   int MinAll(int * PartialMins, int * GlobalMins, int Count) const;
00352 
00354 
00363   int MinAll(long * PartialMins, long * GlobalMins, int Count) const;
00364 
00366 
00375   int MinAll(long long * PartialMins, long long * GlobalMins, int Count) const;
00377 
00379 
00380 
00381 
00389   int ScanSum(double * MyVals, double * ScanSums, int Count) const;
00390 
00392 
00400   int ScanSum(int * MyVals, int * ScanSums, int Count) const;
00401 
00403 
00411   int ScanSum(long * MyVals, long * ScanSums, int Count) const;
00412 
00414 
00422   int ScanSum(long long * MyVals, long long * ScanSums, int Count) const;
00424 
00426 
00427 
00429 
00432   int MyPID() const {return(SerialCommData_->MyPID_);};
00433 
00435   int NumProc() const {return(SerialCommData_->NumProc_);};
00436 
00438 
00440 
00441 
00442   Epetra_Distributor * CreateDistributor() const;
00444   Epetra_Directory * CreateDirectory(const Epetra_BlockMap & Map) const;
00446 
00448 
00449 
00450   inline void Print(std::ostream & os) const {
00451 #ifdef EPETRA_HAVE_OMP
00452 #pragma omp parallel
00453 {
00454   int numThreads = omp_get_num_threads();
00455   int threadNum = omp_get_thread_num();
00456 #pragma omp single
00457                os << "::Processor "<< MyPID()<<" of " << NumProc() << " total processors.";
00458 #pragma omp critical
00459                 os << "\n   Thread " << threadNum << " of " << numThreads << " total threads.";
00460 }
00461 #else
00462     os << "::Processor "<< MyPID()<<" of " << NumProc() << " total processors.";
00463 #endif
00464 
00465     return;
00466   }
00468   void PrintInfo(std::ostream & os) const {
00469     Epetra_SerialComm::Print(os);
00470     return;
00471   };
00473 
00475 
00476 
00478 
00479   int ReferenceCount() const;
00480 
00482 
00483   const Epetra_SerialCommData * DataPtr() const {return(SerialCommData_);};
00484 
00486 
00488   Epetra_SerialComm & operator=(const Epetra_SerialComm & Comm);
00489 
00490  private:
00491 
00492   void CleanupData();
00493   Epetra_SerialCommData * SerialCommData_;
00494 
00495 };
00496 #endif /* EPETRA_SERIALCOMM_H */
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines