Epetra Package Browser (Single Doxygen Collection) Development
Loading...
Searching...
No Matches
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"
51#ifdef EPETRA_HAVE_OMP
52#include <omp.h>
53#endif
55
57
61class 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
441
444// CreateDirectory is defined in Winbase.h as a macro!
445#ifdef CreateDirectory
446#undef CreateDirectory
447#endif
450
452
453
454 inline void Print(std::ostream & os) const {
455#ifdef EPETRA_HAVE_OMP
456#pragma omp parallel
457{
458 int numThreads = omp_get_num_threads();
459 int threadNum = omp_get_thread_num();
460#pragma omp single
461 os << "::Processor "<< MyPID()<<" of " << NumProc() << " total processors.";
462#pragma omp critical
463 os << "\n Thread " << threadNum << " of " << numThreads << " total threads.";
464}
465#else
466 os << "::Processor "<< MyPID()<<" of " << NumProc() << " total processors.";
467#endif
468
469 return;
470 }
472 void PrintInfo(std::ostream & os) const {
474 return;
475 };
477
479
480
482
483 int ReferenceCount() const;
484
486
487 const Epetra_SerialCommData * DataPtr() const {return(SerialCommData_);};
488
490
493
494 private:
495
496 void CleanupData();
498
499};
500#endif /* EPETRA_SERIALCOMM_H */
Epetra_BlockMap: A class for partitioning block element vectors and matrices.
Epetra_Comm: The Epetra Communication Abstract Base Class.
Definition: Epetra_Comm.h:73
virtual int MaxAll(double *PartialMaxs, double *GlobalMaxs, int Count) const =0
Epetra_Comm Global Max function.
virtual int NumProc() const =0
Returns total number of processes.
virtual int Broadcast(double *MyVals, int Count, int Root) const =0
Epetra_Comm Broadcast function.
virtual Epetra_Directory * CreateDirectory(const Epetra_BlockMap &Map) const =0
Create a directory object for the given Epetra_BlockMap.
virtual int GatherAll(double *MyVals, double *AllVals, int Count) const =0
Epetra_Comm All Gather function.
virtual int MinAll(double *PartialMins, double *GlobalMins, int Count) const =0
Epetra_Comm Global Min function.
virtual int MyPID() const =0
Return my process ID.
virtual int ScanSum(double *MyVals, double *ScanSums, int Count) const =0
Epetra_Comm Scan Sum function.
virtual Epetra_Distributor * CreateDistributor() const =0
Create a distributor object.
virtual void Barrier() const =0
Epetra_Comm Barrier 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_Distributor: The Epetra Gather/Scatter Setup Base Class.
Epetra_Object: The base Epetra class.
Definition: Epetra_Object.h:57
Epetra_Object & operator=(const Epetra_Object &src)
Epetra_SerialCommData: The Epetra Serial Communication Data Class.
Epetra_SerialComm: The Epetra Serial Communication Class.
void PrintInfo(std::ostream &os) const
Print method that implements Epetra_Comm virtual PrintInfo method.
Epetra_SerialCommData * SerialCommData_
int MyPID() const
Return my process ID.
void Print(std::ostream &os) const
Print method that implements Epetra_Object virtual Print method.
Epetra_Comm * Clone() const
Clone method.
const Epetra_SerialCommData * DataPtr() const
Returns a pointer to the SerialCommData instance this SerialComm uses.
int NumProc() const
Returns total number of processes (always returns 1 for SerialComm).