|
Nemo
2.2.0
|
MPI environment setup. More...
#include <MPImanager.h>
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 |
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().
Definition at line 120 of file MPImanager.h.
| MPIenv::MPIenv | ( | int & | argc, |
| char **& | argv, | ||
| MPImanager *& | _p | ||
| ) |
Definition at line 40 of file MPImanager.cc.
References host, rank, and size.
{
#ifdef USE_MPI
MPI::Init( argc, argv );
size = MPI::COMM_WORLD.Get_size();
rank = MPI::COMM_WORLD.Get_rank();
int lhost;
char *thost = new char[100];
MPI::Get_processor_name(thost, lhost);
host = std::string( thost, lhost );
delete[] thost;
if ( rank == 0 ) _p = new MPImaster(size-1);
else _p = new MPIslave();
#else
size = 1;
rank = 0;
host = std::string( "local" );
#endif
}
| void MPIenv::abort | ( | int | i | ) | [static] |
Definition at line 60 of file MPImanager.cc.
Referenced by fatal().
{
#ifdef USE_MPI
MPI::COMM_WORLD.Abort(i);
#endif
exit(i);
}
| void MPIenv::finish | ( | MPImanager * | p | ) | [static] |
Definition at line 68 of file MPImanager.cc.
Referenced by SimRunner::run().
{
#ifdef USE_MPI
delete p;
MPI::Finalize();
#endif
}
| std::string MPIenv::hostName | ( | ) | const [inline] |
| bool MPIenv::isMaster | ( | ) | const [inline] |
Definition at line 126 of file MPImanager.h.
References rank.
Referenced by StatHandler< SH >::execute(), BinaryDataSaver::finish(), FileHandler::init(), SimRunner::run(), and FileHandler::update().
{ return (rank==0); }
| unsigned int MPIenv::slaveCount | ( | ) | const [inline] |
| unsigned int MPIenv::slaveRank | ( | ) | const [inline] |
Definition at line 128 of file MPImanager.h.
References rank.
Referenced by BinaryDataSaver::finish(), and FileServices::getFirstReplicateFileName().
{ return rank; }
std::string MPIenv::host [private] |
Definition at line 134 of file MPImanager.h.
Referenced by hostName(), and MPIenv().
unsigned int MPIenv::rank [private] |
Definition at line 133 of file MPImanager.h.
Referenced by isMaster(), MPIenv(), and slaveRank().
unsigned int MPIenv::size [private] |
Definition at line 132 of file MPImanager.h.
Referenced by MPIenv(), and slaveCount().
1.7.5.1 -- Nemo is hosted by