Nemo  2.3.56
Simulate forward-in-time genetic evolution in a spatially explicit, individual-based stochastic simulator
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 workerCount () const
 
unsigned int workerRank () 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 workers), hostname. Constructor creates the MPImanagers (Master or worker). 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::MPIenv ( int argc,
char **&  argv,
MPImanager *&  _p 
)
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 MPIworker();
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

References host, rank, and size.

Member Function Documentation

◆ abort()

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

Referenced by abort(), and fatal().

+ Here is the caller graph for this function:

◆ finish()

void MPIenv::finish ( MPImanager p)
static
69{
70#ifdef USE_MPI
71 delete p;
72 MPI::Finalize();
73#endif
74}

Referenced by SimRunner::run().

+ Here is the caller graph for this function:

◆ hostName()

std::string MPIenv::hostName ( ) const
inline
130{ return host; }

References host.

◆ isMaster()

bool MPIenv::isMaster ( ) const
inline

◆ workerCount()

unsigned int MPIenv::workerCount ( ) const
inline
128{ return size-1; }

References size.

Referenced by RAND::init().

+ Here is the caller graph for this function:

◆ workerRank()

unsigned int MPIenv::workerRank ( ) const
inline
129{ return rank; }

References rank.

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

+ Here is the caller graph for this function:

Member Data Documentation

◆ host

std::string MPIenv::host
private

Referenced by hostName(), and MPIenv().

◆ rank

unsigned int MPIenv::rank
private

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

◆ size

unsigned int MPIenv::size
private

Referenced by MPIenv(), and workerCount().


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

Generated for Nemo v2.3.56 by  doxygen 1.9.0 -- Nemo is hosted on  Download Nemo

Locations of visitors to this page
Catalogued on GSR