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 #if defined(Epetra_SHOW_DEPRECATED_WARNINGS)
48 #ifdef __GNUC__
49 #warning "The Epetra package is deprecated"
50 #endif
51 #endif
52 
53 
54 
55 #include "Epetra_ConfigDefs.h"
56 #include "Epetra_Object.h"
57 #include "Epetra_Comm.h"
58 #include "Epetra_SerialCommData.h"
59 #ifdef EPETRA_HAVE_OMP
60 #include <omp.h>
61 #endif
62 class Epetra_Distributor;
63 
65 
69 class EPETRA_LIB_DLL_EXPORT Epetra_SerialComm: public Epetra_Object, public virtual Epetra_Comm {
70 
71  public:
73 
74 
76 
82 
83 
85 
88 
90  Epetra_Comm * Clone() const {
91  return(dynamic_cast<Epetra_Comm *>(new Epetra_SerialComm(*this)));
92  };
93 
95 
100  virtual ~Epetra_SerialComm();
102 
104 
105 
108  void Barrier() const;
110 
112 
113 
125  int Broadcast(double * MyVals, int Count, int Root) const;
126 
128 
139  int Broadcast(int * MyVals, int Count, int Root) const;
140 
142 
153  int Broadcast(long * MyVals, int Count, int Root) const;
154 
156 
167  int Broadcast(long long * MyVals, int Count, int Root) const;
168 
170 
181  int Broadcast(char * MyVals, int Count, int Root) const;
183 
185 
186 
196  int GatherAll(double * MyVals, double * AllVals, int Count) const;
197 
199 
208  int GatherAll(int * MyVals, int * AllVals, int Count) const;
209 
211 
220  int GatherAll(long * MyVals, long * AllVals, int Count) const;
221 
223 
232  int GatherAll(long long * MyVals, long long * AllVals, int Count) const;
234 
236 
237 
248  int SumAll(double * PartialSums, double * GlobalSums, int Count) const;
249 
251 
260  int SumAll(int * PartialSums, int * GlobalSums, int Count) const;
261 
263 
272  int SumAll(long * PartialSums, long * GlobalSums, int Count) const;
273 
275 
284  int SumAll(long long * PartialSums, long long * GlobalSums, int Count) const;
286 
288 
289 
299  int MaxAll(double * PartialMaxs, double * GlobalMaxs, int Count) const;
300 
302 
311  int MaxAll(int * PartialMaxs, int * GlobalMaxs, int Count) const;
312 
314 
323  int MaxAll(long * PartialMaxs, long * GlobalMaxs, int Count) const;
324 
326 
335  int MaxAll(long long * PartialMaxs, long long * GlobalMaxs, int Count) const;
336 
338 
347  int MinAll(double * PartialMins, double * GlobalMins, int Count) const;
348 
350 
359  int MinAll(int * PartialMins, int * GlobalMins, int Count) const;
360 
362 
371  int MinAll(long * PartialMins, long * GlobalMins, int Count) const;
372 
374 
383  int MinAll(long long * PartialMins, long long * GlobalMins, int Count) const;
385 
387 
388 
397  int ScanSum(double * MyVals, double * ScanSums, int Count) const;
398 
400 
408  int ScanSum(int * MyVals, int * ScanSums, int Count) const;
409 
411 
419  int ScanSum(long * MyVals, long * ScanSums, int Count) const;
420 
422 
430  int ScanSum(long long * MyVals, long long * ScanSums, int Count) const;
432 
434 
435 
437 
440  int MyPID() const {return(SerialCommData_->MyPID_);};
441 
443  int NumProc() const {return(SerialCommData_->NumProc_);};
444 
446 
448 
452 // CreateDirectory is defined in Winbase.h as a macro!
453 #ifdef CreateDirectory
454 #undef CreateDirectory
455 #endif
456  Epetra_Directory * CreateDirectory(const Epetra_BlockMap & Map) const;
458 
460 
461  inline void Print(std::ostream & os) const {
463 #ifdef EPETRA_HAVE_OMP
464 #pragma omp parallel
465 {
466  int numThreads = omp_get_num_threads();
467  int threadNum = omp_get_thread_num();
468 #pragma omp single
469  os << "::Processor "<< MyPID()<<" of " << NumProc() << " total processors.";
470 #pragma omp critical
471  os << "\n Thread " << threadNum << " of " << numThreads << " total threads.";
472 }
473 #else
474  os << "::Processor "<< MyPID()<<" of " << NumProc() << " total processors.";
475 #endif
476 
477  return;
478  }
480  void PrintInfo(std::ostream & os) const {
482  return;
483  };
485 
487 
488 
490 
491  int ReferenceCount() const;
492 
494 
495  const Epetra_SerialCommData * DataPtr() const {return(SerialCommData_);};
496 
498 
501 
502  private:
503 
504  void CleanupData();
506 
507 };
508 #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:81
Epetra_Object & operator=(const Epetra_Object &src)
Epetra_Object: The base Epetra class.
Definition: Epetra_Object.h:65
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.