LAMA
|
Singleton class for an object that provides communicators of a certain type. More...
#include <CommunicatorFactory.hpp>
Public Types | |
typedef std::map< std::string, boost::shared_ptr < CommunicatorManager > > | CommunicatorToManagerMap |
Public Member Functions | |
boost::shared_ptr < CommunicatorManager > | getCommunicatorManager (const std::string &type) |
Get a communicator of a certain type from the factory. | |
void | addCommunicatorManager (const std::string &type, boost::shared_ptr< CommunicatorManager > manager) |
This method adds a new communicator manager to the factory. | |
const std::string & | getDefaultCommunicatorType () const |
Query routine for the default communicator type. | |
void | setDefaultCommunicatorType (const std::string &type) const |
Set the default communicator type. | |
virtual | ~CommunicatorFactory () |
Destructor, also frees all registered communicator managers. | |
Static Public Member Functions | |
static CommunicatorPtr | get (const std::string &type, int &argc, char **&argv) |
Get a communicator of a certain type with using inline arguments. | |
static CommunicatorPtr | get (const std::string &type) |
Get a communicator of a certain type from the factory. | |
static CommunicatorPtr | get () |
Get a default communicator from the factory. | |
static CommunicatorFactory & | getFactory () |
Method that returns a reference to the communicator factory singleton. | |
static void | release () |
Releases all communication managers registered in the communicator factory instance. | |
Private Member Functions | |
void | setDefaultCommunicatorType () const |
Routine to find a default communicator. | |
CommunicatorFactory () | |
Constructor of a communicator factory. | |
LAMA_LOG_DECL_STATIC_LOGGER (logger) | |
Private Attributes | |
CommunicatorToManagerMap | mCommunicatorToManagerMap |
Map with manager for each registered communicator type. | |
std::string | mDefaultCommunicatorType |
Singleton class for an object that provides communicators of a certain type.
The factory uses managers that must have been registered before. This gives extensibility for new communicator classes as the factory itself has no need to create any communicator by itself.
Communicator managers are stored via shared pointers so ownership of managers is flexible. The release function of the factory gives up ownership of all managers so they will be freed if there are no other references.
Note: The type of the communicator is given by a string.
typedef std::map<std::string, boost::shared_ptr<CommunicatorManager> > lama::CommunicatorFactory::CommunicatorToManagerMap |
lama::CommunicatorFactory::~CommunicatorFactory | ( | ) | [virtual] |
Destructor, also frees all registered communicator managers.
lama::CommunicatorFactory::CommunicatorFactory | ( | ) | [private] |
Constructor of a communicator factory.
The constructor is private to guarantee that only one singleton instance is created.
void lama::CommunicatorFactory::addCommunicatorManager | ( | const std::string & | type, |
boost::shared_ptr< CommunicatorManager > | manager | ||
) |
This method adds a new communicator manager to the factory.
type | is the type of communicator that is managed by the manager. |
manager | is the communicator manager that provides Communicator of the given type. |
The factory takes ownership of the manager, i.e. the manager will be deleted if it is replaced or if the factory is destroyed or released.
Referenced by lama::PGASCommunicatorManager::init().
CommunicatorPtr lama::CommunicatorFactory::get | ( | const std::string & | type, |
int & | argc, | ||
char **& | argv | ||
) | [static] |
Get a communicator of a certain type with using inline arguments.
type | is the communicator type needed |
argc | pointer to the number of command line arguments |
argv | reference to the array of command line arguments |
Note: the command line arguments might be modified.
References getDefaultCommunicatorType(), LAMA_THROWEXCEPTION, and mCommunicatorToManagerMap.
CommunicatorPtr lama::CommunicatorFactory::get | ( | const std::string & | type | ) | [static] |
Get a communicator of a certain type from the factory.
type | is the name of the needed communicator. |
CommunicatorPtr lama::CommunicatorFactory::get | ( | ) | [static] |
Get a default communicator from the factory.
Referenced by lama::MatrixCreator< T >::buildPoisson(), lama::MatrixCreator< T >::buildRandom(), lama::DenseVector< T >::DenseVector(), lama::BlockDistributionManager::getDistribution(), lama::CyclicDistributionManager::getDistribution(), lama::LUSolver::initializeCommunicator(), and tracing::TraceConfig::TraceConfig().
boost::shared_ptr< CommunicatorManager > lama::CommunicatorFactory::getCommunicatorManager | ( | const std::string & | type | ) |
Get a communicator of a certain type from the factory.
type | is the name of the needed communicator. |
References LAMA_ASSERT.
Referenced by lama::MatrixConfigGrammar::MatrixConfigGrammar().
const std::string & lama::CommunicatorFactory::getDefaultCommunicatorType | ( | ) | const |
Query routine for the default communicator type.
References LAMA_ENV_FOR_COMMUNICATOR.
Referenced by get().
CommunicatorFactory & lama::CommunicatorFactory::getFactory | ( | ) | [static] |
Method that returns a reference to the communicator factory singleton.
Referenced by lama::PGASCommunicatorManager::init(), and lama::MatrixConfigGrammar::MatrixConfigGrammar().
lama::CommunicatorFactory::LAMA_LOG_DECL_STATIC_LOGGER | ( | logger | ) | [private] |
void lama::CommunicatorFactory::release | ( | ) | [static] |
Releases all communication managers registered in the communicator factory instance.
Might be called at the end of a program to finalize all communication before program exit. NOTE: was mandatory for VAMPIR trace of MPI communication.
References mCommunicatorToManagerMap.
void lama::CommunicatorFactory::setDefaultCommunicatorType | ( | const std::string & | type | ) | const |
Set the default communicator type.
void lama::CommunicatorFactory::setDefaultCommunicatorType | ( | ) | const [private] |
Routine to find a default communicator.
References LAMA_THROWEXCEPTION.
std::string lama::CommunicatorFactory::mDefaultCommunicatorType [mutable, private] |