Epetra Package Browser (Single Doxygen Collection)  Development
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Epetra_SerialComm.h
Go to the documentation of this file.
1 /*
2 //@HEADER
3 // ************************************************************************
4 //
5 // Epetra: Linear Algebra Services Package
6 // Copyright 2011 Sandia Corporation
7 //
8 // Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
9 // the U.S. Government retains certain rights in this software.
10 //
11 // Redistribution and use in source and binary forms, with or without
12 // modification, are permitted provided that the following conditions are
13 // met:
14 //
15 // 1. Redistributions of source code must retain the above copyright
16 // notice, this list of conditions and the following disclaimer.
17 //
18 // 2. Redistributions in binary form must reproduce the above copyright
19 // notice, this list of conditions and the following disclaimer in the
20 // documentation and/or other materials provided with the distribution.
21 //
22 // 3. Neither the name of the Corporation nor the names of the
23 // contributors may be used to endorse or promote products derived from
24 // this software without specific prior written permission.
25 //
26 // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
27 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
28 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
29 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
30 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
31 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
32 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
33 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
34 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
35 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
36 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
37 //
38 // Questions? Contact Michael A. Heroux (maherou@sandia.gov)
39 //
40 // ************************************************************************
41 //@HEADER
42 */
43 
44 #ifndef EPETRA_SERIALCOMM_H
45 #define EPETRA_SERIALCOMM_H
46 
47 #include "Epetra_ConfigDefs.h"
48 #include "Epetra_Object.h"
49 #include "Epetra_Comm.h"
50 #include "Epetra_SerialCommData.h"
51 #ifdef EPETRA_HAVE_OMP
52 #include <omp.h>
53 #endif
54 class Epetra_Distributor;
55 
57 
61 class EPETRA_LIB_DLL_EXPORT Epetra_SerialComm: public Epetra_Object, public virtual Epetra_Comm {
62 
63  public:
65 
66 
68 
74 
75 
77 
80 
82  Epetra_Comm * Clone() const {
83  return(dynamic_cast<Epetra_Comm *>(new Epetra_SerialComm(*this)));
84  };
85 
87 
92  virtual ~Epetra_SerialComm();
94 
96 
97 
100  void Barrier() const;
102 
104 
105 
117  int Broadcast(double * MyVals, int Count, int Root) const;
118 
120 
131  int Broadcast(int * MyVals, int Count, int Root) const;
132 
134 
145  int Broadcast(long * MyVals, int Count, int Root) const;
146 
148 
159  int Broadcast(long long * MyVals, int Count, int Root) const;
160 
162 
173  int Broadcast(char * MyVals, int Count, int Root) const;
175 
177 
178 
188  int GatherAll(double * MyVals, double * AllVals, int Count) const;
189 
191 
200  int GatherAll(int * MyVals, int * AllVals, int Count) const;
201 
203 
212  int GatherAll(long * MyVals, long * AllVals, int Count) const;
213 
215 
224  int GatherAll(long long * MyVals, long long * AllVals, int Count) const;
226 
228 
229 
240  int SumAll(double * PartialSums, double * GlobalSums, int Count) const;
241 
243 
252  int SumAll(int * PartialSums, int * GlobalSums, int Count) const;
253 
255 
264  int SumAll(long * PartialSums, long * GlobalSums, int Count) const;
265 
267 
276  int SumAll(long long * PartialSums, long long * GlobalSums, int Count) const;
278 
280 
281 
291  int MaxAll(double * PartialMaxs, double * GlobalMaxs, int Count) const;
292 
294 
303  int MaxAll(int * PartialMaxs, int * GlobalMaxs, int Count) const;
304 
306 
315  int MaxAll(long * PartialMaxs, long * GlobalMaxs, int Count) const;
316 
318 
327  int MaxAll(long long * PartialMaxs, long long * GlobalMaxs, int Count) const;
328 
330 
339  int MinAll(double * PartialMins, double * GlobalMins, int Count) const;
340 
342 
351  int MinAll(int * PartialMins, int * GlobalMins, int Count) const;
352 
354 
363  int MinAll(long * PartialMins, long * GlobalMins, int Count) const;
364 
366 
375  int MinAll(long long * PartialMins, long long * GlobalMins, int Count) const;
377 
379 
380 
389  int ScanSum(double * MyVals, double * ScanSums, int Count) const;
390 
392 
400  int ScanSum(int * MyVals, int * ScanSums, int Count) const;
401 
403 
411  int ScanSum(long * MyVals, long * ScanSums, int Count) const;
412 
414 
422  int ScanSum(long long * MyVals, long long * ScanSums, int Count) const;
424 
426 
427 
429 
432  int MyPID() const {return(SerialCommData_->MyPID_);};
433 
435  int NumProc() const {return(SerialCommData_->NumProc_);};
436 
438 
440 
444  Epetra_Directory * CreateDirectory(const Epetra_BlockMap & Map) const;
446 
448 
449  inline void Print(std::ostream & os) const {
451 #ifdef EPETRA_HAVE_OMP
452 #pragma omp parallel
453 {
454  int numThreads = omp_get_num_threads();
455  int threadNum = omp_get_thread_num();
456 #pragma omp single
457  os << "::Processor "<< MyPID()<<" of " << NumProc() << " total processors.";
458 #pragma omp critical
459  os << "\n Thread " << threadNum << " of " << numThreads << " total threads.";
460 }
461 #else
462  os << "::Processor "<< MyPID()<<" of " << NumProc() << " total processors.";
463 #endif
464 
465  return;
466  }
468  void PrintInfo(std::ostream & os) const {
470  return;
471  };
473 
475 
476 
478 
479  int ReferenceCount() const;
480 
482 
483  const Epetra_SerialCommData * DataPtr() const {return(SerialCommData_);};
484 
486 
489 
490  private:
491 
492  void CleanupData();
494 
495 };
496 #endif /* EPETRA_SERIALCOMM_H */
virtual void Print(std::ostream &os) const
Print object to an output stream Print method.
Epetra_Distributor: The Epetra Gather/Scatter Setup Base Class.
virtual int GatherAll(double *MyVals, double *AllVals, int Count) const =0
Epetra_Comm All Gather function.
virtual Epetra_Directory * CreateDirectory(const Epetra_BlockMap &Map) const =0
Create a directory object for the given Epetra_BlockMap.
void PrintInfo(std::ostream &os) const
Print method that implements Epetra_Comm virtual PrintInfo method.
int MyPID() const
Return my process ID.
virtual int MinAll(double *PartialMins, double *GlobalMins, int Count) const =0
Epetra_Comm Global Min function.
virtual void Barrier() const =0
Epetra_Comm Barrier function.
Epetra_Comm * Clone() const
Clone method.
virtual int MyPID() const =0
Return my process ID.
const Epetra_SerialCommData * DataPtr() const
Returns a pointer to the SerialCommData instance this SerialComm uses.
virtual int MaxAll(double *PartialMaxs, double *GlobalMaxs, int Count) const =0
Epetra_Comm Global Max function.
virtual int SumAll(double *PartialSums, double *GlobalSums, int Count) const =0
Epetra_Comm Global Sum function.
Epetra_Directory: This class is a pure virtual class whose interface allows Epetra_Map and Epetr_Bloc...
Epetra_SerialCommData: The Epetra Serial Communication Data Class.
Epetra_Comm: The Epetra Communication Abstract Base Class.
Definition: Epetra_Comm.h:73
Epetra_Object & operator=(const Epetra_Object &src)
Epetra_Object: The base Epetra class.
Definition: Epetra_Object.h:57
Epetra_BlockMap: A class for partitioning block element vectors and matrices.
int NumProc() const
Returns total number of processes (always returns 1 for SerialComm).
virtual int Broadcast(double *MyVals, int Count, int Root) const =0
Epetra_Comm Broadcast function.
Epetra_SerialComm: The Epetra Serial Communication Class.
Epetra_SerialCommData * SerialCommData_
virtual int NumProc() const =0
Returns total number of processes.
void Print(std::ostream &os) const
Print method that implements Epetra_Object virtual Print method.
virtual Epetra_Distributor * CreateDistributor() const =0
Create a distributor object.
virtual int ScanSum(double *MyVals, double *ScanSums, int Count) const =0
Epetra_Comm Scan Sum function.