Epetra Package Browser (Single Doxygen Collection)  Development
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Epetra_MpiSmpComm.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_MPISMPCOMM_H
45 #define EPETRA_MPISMPCOMM_H
46 #include "Epetra_Object.h"
47 #include "Epetra_Comm.h"
48 #include "Epetra_MpiDistributor.h"
49 #include <mpi.h>
50 class Epetra_Distributor;
51 #include "Epetra_MpiSmpCommData.h"
52 
54 
62 class EPETRA_DEPRECATED Epetra_MpiSmpComm: public Epetra_Object, public virtual Epetra_Comm {
63 
64  public:
65 
67 
68 
73  Epetra_MpiSmpComm(MPI_Comm comm);
74 
75 
77 
80 
82  Epetra_Comm * Clone() const {
83  return(dynamic_cast<Epetra_Comm *>(new Epetra_MpiSmpComm(*this)));
84  };
85 
87 
92  virtual ~Epetra_MpiSmpComm();
94 
96 
97 
101  void Barrier() const;
103 
105 
106 
118  int Broadcast(double * MyVals, int Count, int Root) const;
119 
121 
132  int Broadcast(int * MyVals, int Count, int Root) const;
133 
135 
146  int Broadcast(long * MyVals, int Count, int Root) const;
147 
149 
150 
162  int Broadcast(char * MyVals, int Count, int Root) const;
164 
166 
167 
178  int GatherAll(double * MyVals, double * AllVals, int Count) const;
179 
181 
191  int GatherAll(int * MyVals, int * AllVals, int Count) const;
192 
194 
204  int GatherAll(long * MyVals, long * AllVals, int Count) const;
206 
208 
209 
221  int SumAll(double * PartialSums, double * GlobalSums, int Count) const;
222 
224 
234  int SumAll(int * PartialSums, int * GlobalSums, int Count) const;
235 
237 
247  int SumAll(long * PartialSums, long * GlobalSums, int Count) const;
249 
251 
252 
263  int MaxAll(double * PartialMaxs, double * GlobalMaxs, int Count) const;
264 
266 
276  int MaxAll(int * PartialMaxs, int * GlobalMaxs, int Count) const;
277 
279 
289  int MaxAll(long * PartialMaxs, long * GlobalMaxs, int Count) const;
290 
292 
302  int MinAll(double * PartialMins, double * GlobalMins, int Count) const;
303 
305 
315  int MinAll(int * PartialMins, int * GlobalMins, int Count) const;
316 
318 
328  int MinAll(long * PartialMins, long * GlobalMins, int Count) const;
330 
332 
333 
344  int ScanSum(double * MyVals, double * ScanSums, int Count) const;
345 
347 
357  int ScanSum(int * MyVals, int * ScanSums, int Count) const;
358 
360 
370  int ScanSum(long * MyVals, long * ScanSums, int Count) const;
372 
374 
375 
377  MPI_Comm Comm() const {return(MpiSmpCommData_->Comm_);};
378 
380 
383  int MyPID() const {return(MpiSmpCommData_->rank_);};
384 
386 
389  int NumProc() const {return(MpiSmpCommData_->size_);};
391 
393 
397  Epetra_Directory * CreateDirectory(const Epetra_BlockMap & Map) const;
399 
401 
402  int GetMpiTag() const {int tag = MpiSmpCommData_->curTag_++; if (tag>MpiSmpCommData_->maxTag_) tag = MpiSmpCommData_->minTag_; return(tag);};
405  MPI_Comm GetMpiComm() const {return(MpiSmpCommData_->Comm_);};
407 
409 
417  void NodeBarrier() const;
418 
420 
423  int MyThreadID() const {return(MpiSmpCommData_->ThreadID_);};
424 
426 
429  int MyNodeID() const {return(MpiSmpCommData_->NodeID_);};
430 
432 
434  int SetNumThreads(int NumThreads) {MpiSmpCommData_->NumThreads_ = NumThreads; return(0);};
435 
437 
439  int NumThreads() const {return(MpiSmpCommData_->NumThreads_);};
440 
442 
446  int SetMyThreadID(int ThreadID) {MpiSmpCommData_->ThreadID_ = ThreadID; return(0);};
447 
449 
453  int SetMyNodeID(int NodeID) {MpiSmpCommData_->NodeID_ = NodeID; return(0);};
455 
457 
458  inline void Print(std::ostream & os) const {
460  os << "::Processor "<< MyPID()<<" of " << NumProc() << " total processors" << std::endl;
461  os << "::Thread "<< MyThreadID()<<" of " << NumThreads() << " on node " << MyNodeID() << std::endl;
462  return;}
463 
465  void PrintInfo(std::ostream & os) const {Epetra_MpiSmpComm::Print(os);return;};
466 
468 
471 
472  private:
473 
474  void CleanupData();
476 
477 };
478 #endif /* EPETRA_MPISMPCOMM_H */
int NumThreads() const
Get number of threads on this node.
int SetMyThreadID(int ThreadID)
Set my thread ID.
virtual void Print(std::ostream &os) const
Print object to an output stream Print method.
void PrintInfo(std::ostream &os) const
Print method that implements Epetra_Comm virtual PrintInfo method.
int MyThreadID() const
Return my thread ID.
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.
Epetra_MpiSmpComm: The Epetra MPI Shared Memory Parallel Communication Class.
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.
virtual int MyPID() const =0
Return my process ID.
Epetra_MpiSmpCommData * MpiSmpCommData_
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...
void Print(std::ostream &os) const
Print method that implements Epetra_Object virtual Print method.
Epetra_Comm: The Epetra Communication Abstract Base Class.
Definition: Epetra_Comm.h:73
Epetra_Object & operator=(const Epetra_Object &src)
MPI_Comm Comm() const
Extract MPI Communicator from a Epetra_MpiSmpComm object.
Epetra_Object: The base Epetra class.
Definition: Epetra_Object.h:57
MPI_Comm GetMpiComm() const
Acquire an MPI tag from the Epetra range of 24050-24099, increment tag.
Epetra_MpiSmpCommData: The Epetra Mpi Shared Memory ParallelCommunication Data Class.
Epetra_BlockMap: A class for partitioning block element vectors and matrices.
int SetNumThreads(int NumThreads)
Set number of threads on this node.
virtual int Broadcast(double *MyVals, int Count, int Root) const =0
Epetra_Comm Broadcast function.
int MyPID() const
Return my process ID.
virtual int NumProc() const =0
Returns total number of processes.
int MyNodeID() const
Return my node ID.
virtual Epetra_Distributor * CreateDistributor() const =0
Create a distributor object.
int SetMyNodeID(int NodeID)
Set my node ID.
int NumProc() const
Returns total number of processes.
virtual int ScanSum(double *MyVals, double *ScanSums, int Count) const =0
Epetra_Comm Scan Sum function.
Epetra_Comm * Clone() const
Clone method.