![]() |
Peano
|
#include <ServiceRepository.h>
Data Structures | |
struct | ServiceEntry |
Public Member Functions | |
virtual | ~ServiceRepository () |
void | addService (Service *const service, const std::string &name) |
Add a new service. | |
bool | hasService (Service *service) const |
This routine is thread-safe. | |
void | removeService (Service *const service) |
This routine is thread-safe, i.e. | |
virtual void | receiveDanglingMessages () override |
Answer to MPI Messages. | |
std::string | getListOfRegisteredServices () const |
void | init () |
Maybe the only service that you don't have to init and shutdown. | |
virtual void | shutdown () override |
![]() | |
virtual | ~Service () |
Static Public Member Functions | |
static ServiceRepository & | getInstance () |
Private Types | |
typedef std::vector< ServiceEntry > | ServiceContainer |
Private Member Functions | |
ServiceRepository () | |
Private Attributes | |
ServiceContainer | _services |
tarch::multicore::RecursiveSemaphore | _receiveDanglingMessagesSemaphore |
Static Private Attributes | |
static tarch::services::ServiceRepository | _singleton |
Additional Inherited Members | |
![]() | |
tarch::multicore::RecursiveSemaphore | _receiveDanglingMessagesSemaphore |
Recursive semaphores. | |
Service Repository.
See the interface Service for a detailed description. The registry is a service itself, but it does not register as a service.
Definition at line 27 of file ServiceRepository.h.
|
private |
Definition at line 34 of file ServiceRepository.h.
|
private |
Definition at line 18 of file ServiceRepository.cpp.
|
virtual |
Definition at line 23 of file ServiceRepository.cpp.
void tarch::services::ServiceRepository::addService | ( | Service *const | service, |
const std::string & | name ) |
Add a new service.
This routine is thread-safe, i.e. it blocks other addService() calls as well as receiveDanglingMessages().
I add a recursive semaphore to the addService() routine, as I think this is correct. However, this routine is called very early in the execution. I get seg faults with TBB in this case, and guess this is due to some memory lacking a proper initialisation. So I omit the recursive semaphore whenever I use TBB.
service | Pointer to service |
name | Name of service (mandatory, not empty) |
Definition at line 41 of file ServiceRepository.cpp.
References tarch::services::ServiceRepository::ServiceEntry::_name, tarch::services::ServiceRepository::ServiceEntry::_service, and assertion2.
Referenced by tarch::mpi::BooleanSemaphore::BooleanSemaphoreService::init(), peano4::parallel::SpacetreeSet::init(), and exahype2::RefinementControlService::RefinementControlService().
|
static |
Definition at line 36 of file ServiceRepository.cpp.
Referenced by tarch::mpi::BooleanSemaphore::BooleanSemaphoreService::acquireLock(), swift2::ParticleSpecies::allReduce(), toolbox::particles::SieveParticles< T >::exchangeSieveListsGlobally(), applications::exahype2::euler::sphericalaccretion::MassAccumulator::finishAccumulation(), peano4::parallel::SpacetreeSet::finishAllOutstandingSendsAndReceives(), applications::exahype2::euler::sphericalaccretion::SSInfall::finishTimeStep(), exahype2::RefinementControlService::freeAllPendingSendRequests(), tarch::mpi::BooleanSemaphore::BooleanSemaphoreService::init(), peano4::parallel::SpacetreeSet::init(), peano4::initSingletons(), peano4::datamanagement::CellMarker::receiveAndPollDanglingMessages(), peano4::grid::AutomatonState::receiveAndPollDanglingMessages(), peano4::grid::GridControlEvent::receiveAndPollDanglingMessages(), peano4::grid::GridStatistics::receiveAndPollDanglingMessages(), peano4::grid::GridTraversalEvent::receiveAndPollDanglingMessages(), peano4::grid::GridVertex::receiveAndPollDanglingMessages(), peano4::parallel::StartTraversalMessage::receiveAndPollDanglingMessages(), peano4::parallel::TreeEntry::receiveAndPollDanglingMessages(), peano4::parallel::TreeManagementMessage::receiveAndPollDanglingMessages(), tarch::mpi::DoubleMessage::receiveAndPollDanglingMessages(), tarch::mpi::IntegerMessage::receiveAndPollDanglingMessages(), tarch::mpi::StringMessage::receiveAndPollDanglingMessages(), toolbox::particles::ParticleSet< T >::reduceParticleStateStatistics(), toolbox::particles::ParticleSet< T >::reduceReassignmentStatistics(), exahype2::RefinementControlService::RefinementControlService(), peano4::datamanagement::CellMarker::sendAndPollDanglingMessages(), peano4::grid::AutomatonState::sendAndPollDanglingMessages(), peano4::grid::GridControlEvent::sendAndPollDanglingMessages(), peano4::grid::GridStatistics::sendAndPollDanglingMessages(), peano4::grid::GridTraversalEvent::sendAndPollDanglingMessages(), peano4::grid::GridVertex::sendAndPollDanglingMessages(), peano4::parallel::StartTraversalMessage::sendAndPollDanglingMessages(), peano4::parallel::TreeEntry::sendAndPollDanglingMessages(), peano4::parallel::TreeManagementMessage::sendAndPollDanglingMessages(), tarch::mpi::DoubleMessage::sendAndPollDanglingMessages(), tarch::mpi::IntegerMessage::sendAndPollDanglingMessages(), tarch::mpi::StringMessage::sendAndPollDanglingMessages(), peano4::parallel::Node::shutdown(), peano4::parallel::SpacetreeSet::shutdown(), tarch::mpi::BooleanSemaphore::BooleanSemaphoreService::shutdown(), peano4::shutdownSingletons(), peano4::parallel::SpacetreeSet::traverse(), and exahype2::RefinementControlService::~RefinementControlService().
std::string tarch::services::ServiceRepository::getListOfRegisteredServices | ( | ) | const |
Definition at line 104 of file ServiceRepository.cpp.
This routine is thread-safe.
Definition at line 69 of file ServiceRepository.cpp.
void tarch::services::ServiceRepository::init | ( | ) |
Maybe the only service that you don't have to init and shutdown.
Definition at line 28 of file ServiceRepository.cpp.
Referenced by peano4::initSingletons().
|
overridevirtual |
Answer to MPI Messages.
Tell all registered services to answer to MPI messages that are still pending in the MPI queues.
I once had an implementation that checks via Iprobe whether to call the receiveDanglingMessages() of all registered services. Without that probe, my ExaHyPE 2 code did crash. Today, I think this has been a bug in the way how parts of the code handled the requests, so I could remove the snippet again.
From a theory point of view, it makes sense nevertheless to allow codes to do something else while receiveDanglingMessages() is called. If this routine is called, the system basically flags that there's a lack of MPI progression or poor load balancing, so the routine indeed should give a user code to do something meaningful meanwhile.
I thought it would be an excellent idea to process some tasks therefore. With a lot of tasks, this is a poor idea. Potentially p-1 threads hit the task queue (if one thread is doing I/O for example) and then they all block each other and no MPI progress is made, as very few tasks call the actual MPI routines. So I removed that line to process a task, and this has made the system much more stable.
It is important that you never ever call receiveDanglingMessages() of a service directly. Instead, you always should go to the repository. The reasons reads as follows: Most services do not protect their receiveDanglingMessages() with an additional semaphore. So two threads might hit it and both thus issue an Iprobe. Let there be one MPI message in the queue. Both probes return a true and, hence, both threads issue a receive. Unfortunately, only one of them succeeds. We could have solved that with new MPI features, but we also solve it in the old-fashioned way if you only issue receives through the repository, as the repository invokes the services, but it first blocks all other threads through a semaphore.
This routine is thread-safe compared to addService() and removeService().
Implements tarch::services::Service.
Definition at line 83 of file ServiceRepository.cpp.
References tarch::multicore::RecursiveLock::tryLock().
Referenced by tarch::mpi::BooleanSemaphore::BooleanSemaphoreService::acquireLock(), swift2::ParticleSpecies::allReduce(), toolbox::particles::SieveParticles< T >::exchangeSieveListsGlobally(), applications::exahype2::euler::sphericalaccretion::MassAccumulator::finishAccumulation(), peano4::parallel::SpacetreeSet::finishAllOutstandingSendsAndReceives(), applications::exahype2::euler::sphericalaccretion::SSInfall::finishTimeStep(), exahype2::RefinementControlService::freeAllPendingSendRequests(), peano4::datamanagement::CellMarker::receiveAndPollDanglingMessages(), peano4::grid::AutomatonState::receiveAndPollDanglingMessages(), peano4::grid::GridControlEvent::receiveAndPollDanglingMessages(), peano4::grid::GridStatistics::receiveAndPollDanglingMessages(), peano4::grid::GridTraversalEvent::receiveAndPollDanglingMessages(), peano4::grid::GridVertex::receiveAndPollDanglingMessages(), peano4::parallel::StartTraversalMessage::receiveAndPollDanglingMessages(), peano4::parallel::TreeEntry::receiveAndPollDanglingMessages(), peano4::parallel::TreeManagementMessage::receiveAndPollDanglingMessages(), tarch::mpi::DoubleMessage::receiveAndPollDanglingMessages(), tarch::mpi::IntegerMessage::receiveAndPollDanglingMessages(), tarch::mpi::StringMessage::receiveAndPollDanglingMessages(), toolbox::particles::ParticleSet< T >::reduceParticleStateStatistics(), toolbox::particles::ParticleSet< T >::reduceReassignmentStatistics(), peano4::datamanagement::CellMarker::sendAndPollDanglingMessages(), peano4::grid::AutomatonState::sendAndPollDanglingMessages(), peano4::grid::GridControlEvent::sendAndPollDanglingMessages(), peano4::grid::GridStatistics::sendAndPollDanglingMessages(), peano4::grid::GridTraversalEvent::sendAndPollDanglingMessages(), peano4::grid::GridVertex::sendAndPollDanglingMessages(), peano4::parallel::StartTraversalMessage::sendAndPollDanglingMessages(), peano4::parallel::TreeEntry::sendAndPollDanglingMessages(), peano4::parallel::TreeManagementMessage::sendAndPollDanglingMessages(), tarch::mpi::DoubleMessage::sendAndPollDanglingMessages(), tarch::mpi::IntegerMessage::sendAndPollDanglingMessages(), tarch::mpi::StringMessage::sendAndPollDanglingMessages(), peano4::parallel::Node::shutdown(), and peano4::parallel::SpacetreeSet::traverse().
This routine is thread-safe, i.e.
it blocks out receiveDanglingMessages() and all other routine which register or de-register services.
Definition at line 58 of file ServiceRepository.cpp.
Referenced by peano4::parallel::SpacetreeSet::shutdown(), tarch::mpi::BooleanSemaphore::BooleanSemaphoreService::shutdown(), and exahype2::RefinementControlService::~RefinementControlService().
|
overridevirtual |
Implements tarch::services::Service.
Definition at line 32 of file ServiceRepository.cpp.
Referenced by peano4::shutdownSingletons().
|
private |
Definition at line 38 of file ServiceRepository.h.
|
private |
Definition at line 36 of file ServiceRepository.h.
|
staticprivate |
Definition at line 43 of file ServiceRepository.h.