Nemo  2.3.46
MPIenv Class Reference

MPI environment setup. More...

#include <MPImanager.h>

+ Collaboration diagram for MPIenv:

Public Member Functions

 MPIenv (int &argc, char **&argv, MPImanager *&_p)
 
bool isMaster () const
 
unsigned int slaveCount () const
 
unsigned int slaveRank () const
 
std::string hostName () const
 

Static Public Member Functions

static void abort (int i)
 
static void finish (MPImanager *p)
 

Private Attributes

unsigned int size
 
unsigned int rank
 
std::string host
 

Detailed Description

MPI environment setup.

Provides basic node information: rank (0 is master, 1...size-1 are slaves), hostname. Constructor creates the MPImanagers (Master or Slave). This can be instantiated also in a single cpu situation, will return trivial values. The abort() function should always be used instead of exit().

Constructor & Destructor Documentation

MPIenv::MPIenv ( int argc,
char **&  argv,
MPImanager *&  _p 
)

References host, rank, and size.

41 {
42 #ifdef USE_MPI
43  MPI::Init( argc, argv );
44  size = MPI::COMM_WORLD.Get_size();
45  rank = MPI::COMM_WORLD.Get_rank();
46  int lhost;
47  char *thost = new char[100];
48  MPI::Get_processor_name(thost, lhost);
49  host = std::string( thost, lhost );
50  delete[] thost;
51  if ( rank == 0 ) _p = new MPImaster(size-1);
52  else _p = new MPIslave();
53 #else
54  size = 1;
55  rank = 0;
56  host = std::string( "local" );
57 #endif
58 }
std::string host
Definition: MPImanager.h:135
unsigned int size
Definition: MPImanager.h:133
unsigned int rank
Definition: MPImanager.h:134

Member Function Documentation

void MPIenv::abort ( int  i)
static

Referenced by fatal().

61 {
62 #ifdef USE_MPI
63  MPI::COMM_WORLD.Abort(i);
64 #endif
65  exit(i);
66 }
void MPIenv::finish ( MPImanager p)
static

Referenced by SimRunner::run().

69 {
70 #ifdef USE_MPI
71  delete p;
72  MPI::Finalize();
73 #endif
74 }
std::string MPIenv::hostName ( ) const
inline

References host.

130 { return host; }
std::string host
Definition: MPImanager.h:135
bool MPIenv::isMaster ( ) const
inline

References rank.

Referenced by BinaryDataSaver::finish(), SimRunner::init_components(), SimRunner::Replicate_LOOP(), SimRunner::run(), and FileHandler::update().

127 { return (rank==0); }
unsigned int rank
Definition: MPImanager.h:134
unsigned int MPIenv::slaveCount ( ) const
inline

References size.

128 { return size-1; }
unsigned int size
Definition: MPImanager.h:133
unsigned int MPIenv::slaveRank ( ) const
inline

References rank.

Referenced by BinaryDataSaver::finish(), and FileServices::getFirstReplicateFileName().

129 { return rank; }
unsigned int rank
Definition: MPImanager.h:134

Member Data Documentation

std::string MPIenv::host
private

Referenced by hostName(), and MPIenv().

unsigned int MPIenv::rank
private

Referenced by isMaster(), MPIenv(), and slaveRank().

unsigned int MPIenv::size
private

Referenced by MPIenv(), and slaveCount().


The documentation for this class was generated from the following files:

Generated for Nemo v2.3.0 by  doxygen 1.8.8 --
Catalogued on GSR