| The Gaudi Framework v29r0 (ff2e7097)

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- Class List
- Class Index
- Class Hierarchy
- Class Members

Public Member Functions | Private Types | Private Member Functions | Private Attributes | List of all members
AlgResourcePool Class Reference

The AlgResourcePool is a concrete implementation of the IAlgResourcePool interface. More...

`#include <GaudiHive/AlgResourcePool.h>`

Inheritance diagram for AlgResourcePool:
[legend]
Collaboration diagram for AlgResourcePool:
[legend]

## Public Member Functions
| ~AlgResourcePool () override
StatusCode | start () override
StatusCode | initialize () override
StatusCode | acquireAlgorithm (const std::string &name, IAlgorithm *&algo, bool blocking=false) override
| Acquire a certain algorithm using its name. More...
StatusCode | releaseAlgorithm (const std::string &name, IAlgorithm *&algo) override
| Release a certain algorithm. More...
StatusCode | acquireResource (const std::string &name) override
| Acquire a certain resource. More...
StatusCode | releaseResource (const std::string &name) override
| Release a certrain resource. More...
std::list< IAlgorithm * > | getFlatAlgList () override
std::list< IAlgorithm * > | getTopAlgList () override
StatusCode | beginRun () override
StatusCode | endRun () override
StatusCode | stop () override
concurrency::recursive_CF::ControlFlowGraph * | getCFGraph () const
Public Member Functions inherited from extends< Service, IAlgResourcePool >
void * | i_cast (const InterfaceID &tid) const override
| Implementation of IInterface::i_cast. More...
StatusCode | queryInterface (const InterfaceID &ti, void **pp) override
| Implementation of IInterface::queryInterface. More...
std::vector< std::string > | getInterfaceNames () const override
| Implementation of IInterface::getInterfaceNames. More...
| ~extends () override=default
| Virtual destructor. More...
Public Member Functions inherited from Service
const std::string & | name () const override
| Retrieve name of the service. More...
StatusCode | configure () override
StatusCode | initialize () override
StatusCode | start () override
StatusCode | stop () override
StatusCode | finalize () override
StatusCode | terminate () override
Gaudi::StateMachine::State | FSMState () const override
Gaudi::StateMachine::State | targetFSMState () const override
StatusCode | reinitialize () override
StatusCode | restart () override
StatusCode | sysInitialize () override
| Initialize Service. More...
StatusCode | sysStart () override
| Initialize Service. More...
StatusCode | sysStop () override
| Initialize Service. More...
StatusCode | sysFinalize () override
| Finalize Service. More...
StatusCode | sysReinitialize () override
| Re-initialize the Service. More...
StatusCode | sysRestart () override
| Re-initialize the Service. More...
| Service (std::string name, ISvcLocator *svcloc)
| Standard Constructor. More...
SmartIF< ISvcLocator > & | serviceLocator () const override
| Retrieve pointer to service locator. More...
StatusCode | setProperties ()
| Method for setting declared properties to the values specified for the job. More...
template<class T >
StatusCode | service (const std::string &name, const T *&psvc, bool createIf=true) const
| Access a service by name, creating it if it doesn't already exist. More...
template<class T >
StatusCode | service (const std::string &name, T *&psvc, bool createIf=true) const
template<typename IFace = IService>
SmartIF< IFace > | service (const std::string &name, bool createIf=true) const
template<class T >
StatusCode | service (const std::string &svcType, const std::string &svcName, T *&psvc) const
| Access a service by name and type, creating it if it doesn't already exist. More...
template<class T >
StatusCode | declareTool (ToolHandle< T > &handle, std::string toolTypeAndName, bool createIf=true)
| Declare used tool. More...
SmartIF< IAuditorSvc > & | auditorSvc () const
| The standard auditor service.May not be invoked before sysInitialize() has been invoked. More...
Public Member Functions inherited from PropertyHolder< CommonMessaging< implements< IService, IProperty, IStateful > > >
| PropertyHolder ()=default
| ~PropertyHolder () override=default
Gaudi::Details::PropertyBase & | declareProperty (Gaudi::Details::PropertyBase &prop)
| Declare a property. More...
Gaudi::Details::PropertyBase * | declareProperty (const std::string &name, TYPE &value, const std::string &doc="none")
| Helper to wrap a regular data member and use it as a regular property. More...
Gaudi::Details::PropertyBase * | declareProperty (const std::string &name, TYPE &value, const std::string &doc="none") const
Gaudi::Details::PropertyBase * | declareProperty (const std::string &name, Gaudi::Property< TYPE, VERIFIER, HANDLERS > &prop, const std::string &doc="none")
| Declare a PropertyBase instance setting name and documentation. More...
Gaudi::Details::PropertyBase * | declareRemoteProperty (const std::string &name, IProperty *rsvc, const std::string &rname="")
| Declare a remote property. More...
StatusCode | setProperty (const Gaudi::Details::PropertyBase &p) override
| set the property form another property More...
StatusCode | setProperty (const std::string &s) override
| set the property from the formatted string More...
StatusCode | setProperty (const std::string &n, const std::string &v) override
| set the property from name and the value More...
StatusCode | setProperty (const std::string &name, const TYPE &value)
| set the property form the value More...
StatusCode | getProperty (Gaudi::Details::PropertyBase *p) const override
| get the property More...
const Gaudi::Details::PropertyBase & | getProperty (const std::string &name) const override
| get the property by name More...
StatusCode | getProperty (const std::string &n, std::string &v) const override
| convert the property to the string More...
const std::vector< Gaudi::Details::PropertyBase * > & | getProperties () const override
| get all properties More...
bool | hasProperty (const std::string &name) const override
| Return true if we have a property with the given name. More...
| PropertyHolder (const PropertyHolder &)=delete
PropertyHolder & | operator= (const PropertyHolder &)=delete
Gaudi::Details::PropertyBase * | declareProperty (const std::string &name, GaudiHandleBase &ref, const std::string &doc="none")
| Specializations for various GaudiHandles. More...
Gaudi::Details::PropertyBase * | declareProperty (const std::string &name, GaudiHandleArrayBase &ref, const std::string &doc="none")
Gaudi::Details::PropertyBase * | declareProperty (const std::string &name, DataObjectHandleBase &ref, const std::string &doc="none")
Public Member Functions inherited from CommonMessagingBase
virtual | ~CommonMessagingBase ()=default
| Virtual destructor. More...
SmartIF< IMessageSvc > & | msgSvc () const
| The standard message service. More...
MsgStream & | msgStream () const
| Return an uninitialized MsgStream. More...
MsgStream & | msgStream (const MSG::Level level) const
| Predefined configurable message stream for the efficient printouts. More...
MsgStream & | always () const
| shortcut for the method msgStream(MSG::ALWAYS) More...
MsgStream & | fatal () const
| shortcut for the method msgStream(MSG::FATAL) More...
MsgStream & | err () const
| shortcut for the method msgStream(MSG::ERROR) More...
MsgStream & | error () const
| shortcut for the method msgStream(MSG::ERROR) More...
MsgStream & | warning () const
| shortcut for the method msgStream(MSG::WARNING) More...
MsgStream & | info () const
| shortcut for the method msgStream(MSG::INFO) More...
MsgStream & | debug () const
| shortcut for the method msgStream(MSG::DEBUG) More...
MsgStream & | verbose () const
| shortcut for the method msgStream(MSG::VERBOSE) More...
MsgStream & | msg () const
| shortcut for the method msgStream(MSG::INFO) More...
MSG::Level | msgLevel () const
| get the output level from the embedded MsgStream More...
MSG::Level | outputLevel () const __attribute__((deprecated))
| Backward compatibility function for getting the output level. More...
bool | msgLevel (MSG::Level lvl) const
| get the output level from the embedded MsgStream More...
Public Member Functions inherited from extend_interfaces< Interfaces... >
| ~extend_interfaces () override=default
| Virtual destructor. More...

## Private Types
typedef tbb::concurrent_bounded_queue< IAlgorithm * > | concurrentQueueIAlgPtr
typedef std::list< SmartIF< IAlgorithm > > | ListAlg
typedef boost::dynamic_bitset | state_type

## Private Member Functions
StatusCode | decodeTopAlgs ()
| Decode the top alg list. More...
StatusCode | flattenSequencer (Algorithm *sequencer, ListAlg &alglist, const std::string &parentName, unsigned int recursionDepth=0)
| Recursively flatten an algList. More...

## Private Attributes
std::mutex | m_resource_mutex
state_type | m_available_resources {0}
std::map< size_t, concurrentQueueIAlgPtr * > | m_algqueue_map
std::map< size_t, state_type > | m_resource_requirements
std::map< size_t, size_t > | m_n_of_allowed_instances
std::map< size_t, unsigned int > | m_n_of_created_instances
std::map< std::string, unsigned int > | m_resource_indices
Gaudi::Property< bool > | m_lazyCreation {this, "CreateLazily", false, ""}
Gaudi::Property< std::vector< std::string > > | m_topAlgNames
Gaudi::Property< bool > | m_overrideUnClonable
ListAlg | m_algList
| The list of all algorithms created withing the Pool which are not top. More...
ListAlg | m_topAlgList
| The list of top algorithms. More...
ListAlg | m_flatUniqueAlgList
| The flat list of algorithms w/o clones. More...
std::list< IAlgorithm * > | m_flatUniqueAlgPtrList
| The flat list of algorithms w/o clones which is returned. More...
std::list< IAlgorithm * > | m_topAlgPtrList
| The top list of algorithms. More...
concurrency::recursive_CF::ControlFlowGraph * | m_CFGraph = nullptr
| OMG yet another hack. More...

## Additional Inherited Members
Public Types inherited from extends< Service, IAlgResourcePool >
using | base_class = extends
| Typedef to this class. More...
using | extend_interfaces_base = extend_interfaces< Interfaces... >
| Typedef to the base of this class. More...
Public Types inherited from Service
typedef Gaudi::PluginService::Factory< IService *, const std::string &, ISvcLocator * > | Factory
Public Types inherited from PropertyHolder< CommonMessaging< implements< IService, IProperty, IStateful > > >
using | PropertyHolderImpl = PropertyHolder< CommonMessaging< implements< IService, IProperty, IStateful > > >
| Typedef used to refer to this class from derived classes, as in. More...
Public Types inherited from CommonMessaging< implements< IService, IProperty, IStateful > >
using | base_class = CommonMessaging
Public Types inherited from extend_interfaces< Interfaces... >
using | ext_iids = typename Gaudi::interface_list_cat< typename Interfaces::ext_iids... >::type
| take union of the ext_iids of all Interfaces... More...
Protected Member Functions inherited from Service
| ~Service () override
| Standard Destructor. More...
int | outputLevel () const
| get the `Service's` output level More...
Protected Member Functions inherited from PropertyHolder< CommonMessaging< implements< IService, IProperty, IStateful > > >
Gaudi::Details::PropertyBase * | property (const std::string &name) const
Protected Member Functions inherited from CommonMessaging< implements< IService, IProperty, IStateful > >
void | updateMsgStreamOutputLevel (int level)
| Update the output level of the cached MsgStream. More...
Protected Attributes inherited from Service
Gaudi::StateMachine::State | m_state = Gaudi::StateMachine::OFFLINE
| Service state. More...
Gaudi::StateMachine::State | m_targetState = Gaudi::StateMachine::OFFLINE
| Service state. More...
Gaudi::Property< int > | m_outputLevel {this, "OutputLevel", MSG::NIL, "output level"}
Gaudi::Property< bool > | m_auditInit {this, "AuditServices", false, "[[deprecated]] unused"}
Gaudi::Property< bool > | m_auditorInitialize {this, "AuditInitialize", false, "trigger auditor on initialize()"}
Gaudi::Property< bool > | m_auditorStart {this, "AuditStart", false, "trigger auditor on start()"}
Gaudi::Property< bool > | m_auditorStop {this, "AuditStop", false, "trigger auditor on stop()"}
Gaudi::Property< bool > | m_auditorFinalize {this, "AuditFinalize", false, "trigger auditor on finalize()"}
Gaudi::Property< bool > | m_auditorReinitialize {this, "AuditReinitialize", false, "trigger auditor on reinitialize()"}
Gaudi::Property< bool > | m_auditorRestart {this, "AuditRestart", false, "trigger auditor on restart()"}
SmartIF< IAuditorSvc > | m_pAuditorSvc
| Auditor Service. More...

## Detailed Description

The AlgResourcePool is a concrete implementation of the IAlgResourcePool interface.

It either creates all instances upfront or lazily. Internal bookkeeping is done via hashes of the algo names.

Author
  Benedikt Hegner

Definition at line 31 of file AlgResourcePool.h.

## Member Typedef Documentation

typedef tbb::concurrent_bounded_queue<IAlgorithm*> AlgResourcePool::concurrentQueueIAlgPtr
| private

Definition at line 61 of file AlgResourcePool.h.

typedef std::list<SmartIF<IAlgorithm> > AlgResourcePool::ListAlg
| private

Definition at line 62 of file AlgResourcePool.h.

typedef boost::dynamic_bitset AlgResourcePool::state_type
| private

Definition at line 63 of file AlgResourcePool.h.

## Constructor & Destructor Documentation

AlgResourcePool::~AlgResourcePool | ( |  | ) |
| override

Definition at line 25 of file AlgResourcePool.cpp.

26 {
27
28 for ( auto& algoId_algoQueue : m_algqueue_map ) {
29 auto* queue = algoId_algoQueue.second;
30 delete queue;
31 }
32
33 delete m_CFGraph;
34 }
AlgResourcePool::m_algqueue_map
std::map< size_t, concurrentQueueIAlgPtr * > m_algqueue_map
Definition: AlgResourcePool.h:68
AlgResourcePool::m_CFGraph
concurrency::recursive_CF::ControlFlowGraph * m_CFGraph
OMG yet another hack.
Definition: AlgResourcePool.h:103

## Member Function Documentation

StatusCode AlgResourcePool::acquireAlgorithm | ( | const std::string & | name,
|  | IAlgorithm *& | algo,
|  | bool | blocking = `false`
| ) |  |
| override

Acquire a certain algorithm using its name.

Definition at line 91 of file AlgResourcePool.cpp.

92 {
93
94 std::hash<std::string> hash_function;
95 size_t algo_id = hash_function( name );
96 auto itQueueIAlgPtr = m_algqueue_map.find( algo_id );
97
98 if ( itQueueIAlgPtr == m_algqueue_map.end() ) {
99 error() << "Algorithm " << name << " requested, but not recognised" << endmsg;
100 algo = nullptr;
101 return StatusCode::FAILURE;
102 }
103
104 StatusCode sc;
105 if ( blocking ) {
106 itQueueIAlgPtr->second->pop( algo );
107 sc = StatusCode::SUCCESS;
108 } else {
109 sc = itQueueIAlgPtr->second->try_pop( algo );
110 }
111
112 // Note that reentrant algos are not consumed so we put them
113 // back immediately in the queue at the end of this function.
114 // Now we may still be called again in between and get this
115 // error. In such a case, the Scheduler will retry later.
116 // This is of course not optimal, but should only happen very
117 // seldom and thud won't affect the global efficiency
118 if ( sc.isFailure() )
119 DEBUG_MSG << "No instance of algorithm " << name << " could be retrieved in non-blocking mode" << endmsg;
120
121 // if (m_lazyCreation ) {
122 // TODO: fill the lazyCreation part
123 // }
124 if ( sc.isSuccess() ) {
125 state_type requirements = m_resource_requirements[algo_id];
126 m_resource_mutex.lock();
127 if ( requirements.is_subset_of( m_available_resources ) ) {
128 m_available_resources ^= requirements;
129 } else {
130 sc = StatusCode::FAILURE;
131 error() << "Failure to allocate resources of algorithm " << name << endmsg;
132 // in case of not reentrant, push it back. Reentrant ones are pushed back
133 // in all cases further down
134 if ( 0 != algo->cardinality() ) {
135 itQueueIAlgPtr->second->push( algo );
136 }
137 }
138 m_resource_mutex.unlock();
139 if ( 0 == algo->cardinality() ) {
140 // push back reentrant algos immediately as it can be reused
141 itQueueIAlgPtr->second->push( algo );
142 }
143 }
144 return sc;
145 }
StatusCode::SUCCESS
Definition: StatusCode.h:31
std::mutex::unlock
T unlock(T...args)
StatusCode::FAILURE
Definition: StatusCode.h:31
StatusCode::isSuccess
bool isSuccess() const
Test for a status code of SUCCESS.
Definition: StatusCode.h:75
AlgResourcePool::m_resource_mutex
std::mutex m_resource_mutex
Definition: AlgResourcePool.h:65
std::map::end
T end(T...args)
StatusCode::isFailure
bool isFailure() const
Test for a status code of FAILURE.
Definition: StatusCode.h:86
AlgResourcePool::m_available_resources
state_type m_available_resources
Definition: AlgResourcePool.h:67
CommonMessagingBase::error
MsgStream & error() const
shortcut for the method msgStream(MSG::ERROR)
Definition: CommonMessaging.h:111
std::hash
StatusCode
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:28
AlgResourcePool::m_resource_requirements
std::map< size_t, state_type > m_resource_requirements
Definition: AlgResourcePool.h:69
std::mutex::lock
T lock(T...args)
IAlgorithm::cardinality
virtual unsigned int cardinality() const =0
Cardinality (Maximum number of clones that can exist) special value 0 means that algorithm is reentra...
AlgResourcePool::m_algqueue_map
std::map< size_t, concurrentQueueIAlgPtr * > m_algqueue_map
Definition: AlgResourcePool.h:68
state_type
boost::dynamic_bitset state_type
Definition: EventSchedulingState.h:10
std::map::find
T find(T...args)
DEBUG_MSG
#define DEBUG_MSG
Definition: AlgResourcePool.cpp:20
endmsg
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:209

StatusCode AlgResourcePool::acquireResource | ( | const std::string & | name | ) |
| override

Acquire a certain resource.

Definition at line 169 of file AlgResourcePool.cpp.

170 {
171 m_resource_mutex.lock();
172 m_available_resources[m_resource_indices[name]] = false;
173 m_resource_mutex.unlock();
174 return StatusCode::SUCCESS;
175 }
StatusCode::SUCCESS
Definition: StatusCode.h:31
std::mutex::unlock
T unlock(T...args)
Service::name
const std::string & name() const override
Retrieve name of the service.
Definition: Service.cpp:289
AlgResourcePool::m_resource_indices
std::map< std::string, unsigned int > m_resource_indices
Definition: AlgResourcePool.h:72
AlgResourcePool::m_resource_mutex
std::mutex m_resource_mutex
Definition: AlgResourcePool.h:65
AlgResourcePool::m_available_resources
state_type m_available_resources
Definition: AlgResourcePool.h:67
std::mutex::lock
T lock(T...args)

StatusCode AlgResourcePool::beginRun | ( |  | ) |
| override

Definition at line 442 of file AlgResourcePool.cpp.

443 {
444 auto algBeginRun = [&]( SmartIF<IAlgorithm>& algoSmartIF ) -> StatusCode {
445 StatusCode sc = algoSmartIF->sysBeginRun();
446 if ( !sc.isSuccess() ) {
447 warning() << "beginRun() of algorithm " << algoSmartIF->name() << " failed" << endmsg;
448 return StatusCode::FAILURE;
449 }
450 return StatusCode::SUCCESS;
451 };
452 // Call the beginRun() method of all algorithms
453 for ( auto& algoSmartIF : m_flatUniqueAlgList ) {
454 if ( algBeginRun( algoSmartIF ).isFailure() ) return StatusCode::FAILURE;
455 }
456
457 return StatusCode::SUCCESS;
458 }
AlgResourcePool::m_flatUniqueAlgList
ListAlg m_flatUniqueAlgList
The flat list of algorithms w/o clones.
Definition: AlgResourcePool.h:94
StatusCode::SUCCESS
Definition: StatusCode.h:31
SmartIF< IAlgorithm >
StatusCode::FAILURE
Definition: StatusCode.h:31
StatusCode::isSuccess
bool isSuccess() const
Test for a status code of SUCCESS.
Definition: StatusCode.h:75
CommonMessagingBase::warning
MsgStream & warning() const
shortcut for the method msgStream(MSG::WARNING)
Definition: CommonMessaging.h:114
StatusCode
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:28
endmsg
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:209

StatusCode AlgResourcePool::decodeTopAlgs | ( |  | ) |
| private

Decode the top alg list.

Definition at line 266 of file AlgResourcePool.cpp.

267 {
268
269 SmartIF<IAlgManager> algMan( serviceLocator() );
270 if ( !algMan.isValid() ) {
271 error() << "Algorithm manager could not be properly fetched." << endmsg;
272 return StatusCode::FAILURE;
273 }
274
275 // Useful lambda not to repeat ourselves --------------------------
276 auto createAlg = [&algMan, this]( const std::string& item_type, const std::string& item_name, IAlgorithm*& algo ) {
277 StatusCode createAlgSc = algMan->createAlgorithm( item_type, item_name, algo, true, false );
278 if ( createAlgSc.isFailure() )
279 this->warning() << "Algorithm " << item_type << "/" << item_name << " could not be created." << endmsg;
280 };
281 // End of lambda --------------------------------------------------
282
283 StatusCode sc = StatusCode::SUCCESS;
284
285 // Fill the top alg list ----
286 const std::vector<std::string>& topAlgNames = m_topAlgNames.value();
287 for ( auto& name : topAlgNames ) {
288 IAlgorithm* algo( nullptr );
289
290 Gaudi::Utils::TypeNameString item( name );
291 const std::string& item_name = item.name();
292 const std::string& item_type = item.type();
293 SmartIF<IAlgorithm> algoSmartIF( algMan->algorithm( item_name, false ) );
294
295 if ( !algoSmartIF.isValid() ) {
296 createAlg( item_type, item_name, algo );
297 algoSmartIF = algo;
298 }
299 // Init and start
300 algoSmartIF->sysInitialize().ignore();
301 m_topAlgList.push_back( algoSmartIF );
302 }
303 // Top Alg list filled ----
304
305 // start forming the control flow graph by adding the head decision hub
306 // Only ForwardScheduler requires assembling the graph in AlgResourcePool.
307 // The AvalancheScheduler relies on the graph that is assembled by the PrecedenceSvc
308 if ( serviceLocator()->existsService( "ForwardSchedulerSvc" ) )
309 m_CFGraph->addHeadNode( "RootDecisionHub", true, false, true, true );
310
311 // Now we unroll it ----
312 for ( auto& algoSmartIF : m_topAlgList ) {
313 Algorithm* algorithm = dynamic_cast<Algorithm*>( algoSmartIF.get() );
314 if ( !algorithm ) fatal() << "Conversion from IAlgorithm to Algorithm failed" << endmsg;
315 sc = flattenSequencer( algorithm, m_flatUniqueAlgList, "RootDecisionHub" );
316 }
317 // stupid O(N^2) unique-ification..
318 for ( auto i = begin( m_flatUniqueAlgList ); i != end( m_flatUniqueAlgList ); ++i ) {
319 auto n = next( i );
320 while ( n != end( m_flatUniqueAlgList ) ) {
321 if ( *n == *i )
322 n = m_flatUniqueAlgList.erase( n );
323 else
324 ++n;
325 }
326 }
327 if ( msgLevel( MSG::DEBUG ) ) {
328 debug() << "List of algorithms is: " << endmsg;
329 for ( auto& algo : m_flatUniqueAlgList )
330 debug() << " o " << algo->type() << "/" << algo->name() << " @ " << algo << endmsg;
331 }
332
333 // Unrolled ---
334
335 // Now let's manage the clones
336 unsigned int resource_counter( 0 );
337 std::hash<std::string> hash_function;
338 for ( auto& ialgoSmartIF : m_flatUniqueAlgList ) {
339
340 const std::string& item_name = ialgoSmartIF->name();
341
342 verbose() << "Treating resource management and clones of " << item_name << endmsg;
343
344 Algorithm* algo = dynamic_cast<Algorithm*>( ialgoSmartIF.get() );
345 if ( !algo ) fatal() << "Conversion from IAlgorithm to Algorithm failed" << endmsg;
346 const std::string& item_type = algo->type();
347
348 size_t algo_id = hash_function( item_name );
349 concurrentQueueIAlgPtr* queue = new concurrentQueueIAlgPtr();
350 m_algqueue_map[algo_id] = queue;
351
352 // DP TODO Do it properly with SmartIFs, also in the queues
353 IAlgorithm* ialgo( ialgoSmartIF.get() );
354
355 queue->push( ialgo );
356 m_algList.push_back( ialgo );
357 if ( ialgo->isClonable() ) {
358 m_n_of_allowed_instances[algo_id] = ialgo->cardinality();
359 } else {
360 if ( ialgo->cardinality() == 1 ) {
361 m_n_of_allowed_instances[algo_id] = 1;
362 } else {
363 if ( !m_overrideUnClonable ) {
364 info() << "Algorithm " << ialgo->name() << " is un-Clonable but Cardinality was set to "
365 << ialgo->cardinality() << ". Only creating 1 instance" << endmsg;
366 m_n_of_allowed_instances[algo_id] = 1;
367 } else {
368 warning() << "Overriding UnClonability of Algorithm " << ialgo->name() << ". Setting Cardinality to "
369 << ialgo->cardinality() << endmsg;
370 m_n_of_allowed_instances[algo_id] = ialgo->cardinality();
371 }
372 }
373 }
374 m_n_of_created_instances[algo_id] = 1;
375
376 state_type requirements( 0 );
377
378 for ( auto& resource_name : ialgo->neededResources() ) {
379 auto ret = m_resource_indices.emplace( resource_name, resource_counter );
380 // insert successful means == wasn't known before. So increment counter
381 if ( ret.second ) ++resource_counter;
382 // Resize for every algo according to the found resources
383 requirements.resize( resource_counter );
384 // in any case the return value holds the proper product index
385 requirements[ret.first->second] = true;
386 }
387
388 m_resource_requirements[algo_id] = requirements;
389
390 // potentially create clones; if not lazy creation we have to do it now
391 if ( !m_lazyCreation ) {
392 for ( unsigned int i = 1, end = m_n_of_allowed_instances[algo_id]; i < end; ++i ) {
393 debug() << "type/name to create clone of: " << item_type << "/" << item_name << endmsg;
394 IAlgorithm* ialgoClone( nullptr );
395 createAlg( item_type, item_name, ialgoClone );
396 ialgoClone->setIndex( i );
397 if ( ialgoClone->sysInitialize().isFailure() ) {
398 error() << "unable to initialize Algorithm clone " << ialgoClone->name() << endmsg;
399 sc = StatusCode::FAILURE;
400 // FIXME: should we delete this failed clone?
401 } else {
402 queue->push( ialgoClone );
403 m_n_of_created_instances[algo_id] += 1;
404 }
405 }
406 }
407 }
408
409 // Now resize all the requirement bitsets to the same size
410 for ( auto& kv : m_resource_requirements ) {
411 kv.second.resize( resource_counter );
412 }
413
414 // Set all resources to be available
415 m_available_resources.resize( resource_counter );
416 m_available_resources.set();
417
418 return sc;
419 }
AlgResourcePool::m_flatUniqueAlgList
ListAlg m_flatUniqueAlgList
The flat list of algorithms w/o clones.
Definition: AlgResourcePool.h:94
StatusCode::SUCCESS
Definition: StatusCode.h:31
SmartIF< IAlgManager >
Service::name
const std::string & name() const override
Retrieve name of the service.
Definition: Service.cpp:289
StatusCode::FAILURE
Definition: StatusCode.h:31
CommonMessagingBase::info
MsgStream & info() const
shortcut for the method msgStream(MSG::INFO)
Definition: CommonMessaging.h:117
concurrency::recursive_CF::ControlFlowGraph::addHeadNode
void addHeadNode(const std::string &headName, bool modeConcurrent, bool modePromptDecision, bool modeOR, bool allPass)
Add a node, which has no parents.
Definition: ControlFlowGraph.cpp:217
AlgResourcePool::m_resource_indices
std::map< std::string, unsigned int > m_resource_indices
Definition: AlgResourcePool.h:72
CommonMessagingBase::verbose
MsgStream & verbose() const
shortcut for the method msgStream(MSG::VERBOSE)
Definition: CommonMessaging.h:123
MSG::DEBUG
Definition: IMessageSvc.h:16
StatusCode::isFailure
bool isFailure() const
Test for a status code of FAILURE.
Definition: StatusCode.h:86
AlgResourcePool::m_available_resources
state_type m_available_resources
Definition: AlgResourcePool.h:67
AlgResourcePool::m_overrideUnClonable
Gaudi::Property< bool > m_overrideUnClonable
Definition: AlgResourcePool.h:84
begin
auto begin(reverse_wrapper< T > &w)
Definition: reverse.h:58
std::string
STL class.
GaudiPluginService.cpluginsvc.n
n
Definition: cpluginsvc.py:228
std::list::push_back
T push_back(T...args)
CommonMessagingBase::error
MsgStream & error() const
shortcut for the method msgStream(MSG::ERROR)
Definition: CommonMessaging.h:111
Gaudi::Utils::TypeNameString
Helper class to parse a string of format "type/name".
Definition: TypeNameString.h:12
CommonMessagingBase::warning
MsgStream & warning() const
shortcut for the method msgStream(MSG::WARNING)
Definition: CommonMessaging.h:114
AlgResourcePool::concurrentQueueIAlgPtr
tbb::concurrent_bounded_queue< IAlgorithm * > concurrentQueueIAlgPtr
Definition: AlgResourcePool.h:61
std::hash
std::next
T next(T...args)
StatusCode
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:28
AlgResourcePool::m_resource_requirements
std::map< size_t, state_type > m_resource_requirements
Definition: AlgResourcePool.h:69
std::list::erase
T erase(T...args)
end
auto end(reverse_wrapper< T > &w)
Definition: reverse.h:64
AlgResourcePool::m_topAlgNames
Gaudi::Property< std::vector< std::string > > m_topAlgNames
Definition: AlgResourcePool.h:82
IAlgorithm
The IAlgorithm is the interface implemented by the Algorithm base class.
Definition: IAlgorithm.h:28
AlgResourcePool::m_algqueue_map
std::map< size_t, concurrentQueueIAlgPtr * > m_algqueue_map
Definition: AlgResourcePool.h:68
state_type
boost::dynamic_bitset state_type
Definition: EventSchedulingState.h:10
Algorithm
Base class from which all concrete algorithm classes should be derived.
Definition: Algorithm.h:78
std::vector< std::string >
CommonMessagingBase::debug
MsgStream & debug() const
shortcut for the method msgStream(MSG::DEBUG)
Definition: CommonMessaging.h:120
AlgResourcePool::flattenSequencer
StatusCode flattenSequencer(Algorithm *sequencer, ListAlg &alglist, const std::string &parentName, unsigned int recursionDepth=0)
Recursively flatten an algList.
Definition: AlgResourcePool.cpp:189
std::map::emplace
T emplace(T...args)
AlgResourcePool::m_n_of_created_instances
std::map< size_t, unsigned int > m_n_of_created_instances
Definition: AlgResourcePool.h:71
CommonMessagingBase::fatal
MsgStream & fatal() const
shortcut for the method msgStream(MSG::FATAL)
Definition: CommonMessaging.h:105
AlgResourcePool::m_topAlgList
ListAlg m_topAlgList
The list of top algorithms.
Definition: AlgResourcePool.h:91
Algorithm::type
const std::string & type() const override
The type of the algorithm object.
Definition: Algorithm.h:166
CommonMessagingBase::msgLevel
MSG::Level msgLevel() const
get the output level from the embedded MsgStream
Definition: CommonMessaging.h:129
Service::serviceLocator
SmartIF< ISvcLocator > & serviceLocator() const override
Retrieve pointer to service locator.
Definition: Service.cpp:292
AlgResourcePool::m_n_of_allowed_instances
std::map< size_t, size_t > m_n_of_allowed_instances
Definition: AlgResourcePool.h:70
AlgResourcePool::m_algList
ListAlg m_algList
The list of all algorithms created withing the Pool which are not top.
Definition: AlgResourcePool.h:88
endmsg
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:209
AlgResourcePool::m_CFGraph
concurrency::recursive_CF::ControlFlowGraph * m_CFGraph
OMG yet another hack.
Definition: AlgResourcePool.h:103
AlgResourcePool::m_lazyCreation
Gaudi::Property< bool > m_lazyCreation
Definition: AlgResourcePool.h:81

StatusCode AlgResourcePool::endRun | ( |  | ) |
| override

Definition at line 462 of file AlgResourcePool.cpp.

463 {
464
465 auto algEndRun = [&]( SmartIF<IAlgorithm>& algoSmartIF ) -> StatusCode {
466 StatusCode sc = algoSmartIF->sysEndRun();
467 if ( !sc.isSuccess() ) {
468 warning() << "endRun() of algorithm " << algoSmartIF->name() << " failed" << endmsg;
469 return StatusCode::FAILURE;
470 }
471 return StatusCode::SUCCESS;
472 };
473 // Call the beginRun() method of all top algorithms
474 for ( auto& algoSmartIF : m_flatUniqueAlgList ) {
475 if ( algEndRun( algoSmartIF ).isFailure() ) return StatusCode::FAILURE;
476 }
477 for ( auto& algoSmartIF : m_topAlgList ) {
478 if ( algEndRun( algoSmartIF ).isFailure() ) return StatusCode::FAILURE;
479 }
480 return StatusCode::SUCCESS;
481 }
AlgResourcePool::m_flatUniqueAlgList
ListAlg m_flatUniqueAlgList
The flat list of algorithms w/o clones.
Definition: AlgResourcePool.h:94
StatusCode::SUCCESS
Definition: StatusCode.h:31
SmartIF< IAlgorithm >
StatusCode::FAILURE
Definition: StatusCode.h:31
StatusCode::isSuccess
bool isSuccess() const
Test for a status code of SUCCESS.
Definition: StatusCode.h:75
CommonMessagingBase::warning
MsgStream & warning() const
shortcut for the method msgStream(MSG::WARNING)
Definition: CommonMessaging.h:114
StatusCode
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:28
AlgResourcePool::m_topAlgList
ListAlg m_topAlgList
The list of top algorithms.
Definition: AlgResourcePool.h:91
endmsg
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:209

StatusCode AlgResourcePool::flattenSequencer | ( | Algorithm * | sequencer,
|  | ListAlg & | alglist,
|  | const std::string & | parentName,
|  | unsigned int | recursionDepth = `0`
| ) |  |
| private

Recursively flatten an algList.

Definition at line 189 of file AlgResourcePool.cpp.

191 {
192
193 StatusCode sc = StatusCode::SUCCESS;
194
195 bool isGaudiSequencer( false );
196 bool isAthSequencer( false );
197
198 if ( algo->isSequence() ) {
199 if ( algo->hasProperty( "ShortCircuit" ) )
200 isGaudiSequencer = true;
201 else if ( algo->hasProperty( "StopOverride" ) )
202 isAthSequencer = true;
203 }
204
205 std::vector<Algorithm*>* subAlgorithms = algo->subAlgorithms();
206 if ( // we only want to add basic algorithms -> have no subAlgs
207 // and exclude the case of empty sequencers
208 ( subAlgorithms->empty() && !( isGaudiSequencer || isAthSequencer ) ) ) {
209
210 alglist.emplace_back( algo );
211 // Only ForwardScheduler requires assembling the graph in AlgResourcePool.
212 // The AvalancheScheduler relies on the graph that is assembled by the PrecedenceSvc
213 if ( serviceLocator()->existsService( "ForwardSchedulerSvc" ) ) {
214 m_CFGraph->addAlgorithmNode( algo, parentName, false, false ).ignore();
215 DEBUG_MSG << std::string( recursionDepth, ' ' ) << algo->name() << " is not a sequencer. Appending it" << endmsg;
216 }
217 return sc;
218 }
219
220 // Recursively unroll
221 ++recursionDepth;
222
223 // Only ForwardScheduler requires assembling the graph in AlgResourcePool.
224 // The AvalancheScheduler relies on the graph that is assembled by the PrecedenceSvc
225 if ( serviceLocator()->existsService( "ForwardSchedulerSvc" ) ) {
226 DEBUG_MSG << std::string( recursionDepth, ' ' ) << algo->name() << " is a sequencer. Flattening it." << endmsg;
227
228 bool modeOR = false;
229 bool allPass = false;
230 bool isLazy = false;
231 bool isSequential = false;
232
233 if ( isGaudiSequencer ) {
234 modeOR = ( algo->getProperty( "ModeOR" ).toString() == "True" ) ? true : false;
235 allPass = ( algo->getProperty( "IgnoreFilterPassed" ).toString() == "True" ) ? true : false;
236 isLazy = ( algo->getProperty( "ShortCircuit" ).toString() == "True" ) ? true : false;
237 if ( allPass ) isLazy = false; // standard GaudiSequencer behavior on all pass is to execute everything
238 isSequential =
239 ( algo->hasProperty( "Sequential" ) && ( algo->getProperty( "Sequential" ).toString() == "True" ) );
240 } else if ( isAthSequencer ) {
241 modeOR = ( algo->getProperty( "ModeOR" ).toString() == "True" ) ? true : false;
242 allPass = ( algo->getProperty( "IgnoreFilterPassed" ).toString() == "True" ) ? true : false;
243 isLazy = ( algo->getProperty( "StopOverride" ).toString() == "True" ) ? false : true;
244 isSequential =
245 ( algo->hasProperty( "Sequential" ) && ( algo->getProperty( "Sequential" ).toString() == "True" ) );
246 }
247 sc = m_CFGraph->addDecisionHubNode( algo, parentName, !isSequential, isLazy, modeOR, allPass );
248 if ( sc.isFailure() ) {
249 error() << "Failed to add DecisionHub " << algo->name() << " to control flow graph" << endmsg;
250 return sc;
251 }
252 }
253
254 for ( Algorithm* subalgo : *subAlgorithms ) {
255 sc = flattenSequencer( subalgo, alglist, algo->name(), recursionDepth );
256 if ( sc.isFailure() ) {
257 error() << "Algorithm " << subalgo->name() << " could not be flattened" << endmsg;
258 return sc;
259 }
260 }
261 return sc;
262 }
StatusCode::SUCCESS
Definition: StatusCode.h:31
std::vector::empty
T empty(T...args)
concurrency::recursive_CF::ControlFlowGraph::addDecisionHubNode
StatusCode addDecisionHubNode(Algorithm *daughterAlgo, const std::string &parentName, bool modeConcurrent, bool modePromptDecision, bool modeOR, bool allPass)
Add a node, which aggregates decisions of direct daughter nodes.
Definition: ControlFlowGraph.cpp:181
StatusCode::isFailure
bool isFailure() const
Test for a status code of FAILURE.
Definition: StatusCode.h:86
std::string
STL class.
CommonMessagingBase::error
MsgStream & error() const
shortcut for the method msgStream(MSG::ERROR)
Definition: CommonMessaging.h:111
StatusCode
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:28
Algorithm
Base class from which all concrete algorithm classes should be derived.
Definition: Algorithm.h:78
std::vector< Algorithm * >
AlgResourcePool::flattenSequencer
StatusCode flattenSequencer(Algorithm *sequencer, ListAlg &alglist, const std::string &parentName, unsigned int recursionDepth=0)
Recursively flatten an algList.
Definition: AlgResourcePool.cpp:189
DEBUG_MSG
#define DEBUG_MSG
Definition: AlgResourcePool.cpp:20
StatusCode::ignore
void ignore() const
Definition: StatusCode.h:109
concurrency::recursive_CF::ControlFlowGraph::addAlgorithmNode
StatusCode addAlgorithmNode(Algorithm *daughterAlgo, const std::string &parentName, bool inverted, bool allPass)
Add algorithm node.
Definition: ControlFlowGraph.cpp:146
Service::serviceLocator
SmartIF< ISvcLocator > & serviceLocator() const override
Retrieve pointer to service locator.
Definition: Service.cpp:292
endmsg
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:209
AlgResourcePool::m_CFGraph
concurrency::recursive_CF::ControlFlowGraph * m_CFGraph
OMG yet another hack.
Definition: AlgResourcePool.h:103
std::vector::emplace_back
T emplace_back(T...args)

concurrency::recursive_CF::ControlFlowGraph* AlgResourcePool::getCFGraph | ( |  | ) | const
| inline

Definition at line 58 of file AlgResourcePool.h.

58 { return m_CFGraph; }
AlgResourcePool::m_CFGraph
concurrency::recursive_CF::ControlFlowGraph * m_CFGraph
OMG yet another hack.
Definition: AlgResourcePool.h:103

std::list< IAlgorithm * > AlgResourcePool::getFlatAlgList | ( |  | ) |
| override

Definition at line 423 of file AlgResourcePool.cpp.

424 {
425 m_flatUniqueAlgPtrList.clear();
426 for ( auto algoSmartIF : m_flatUniqueAlgList )
427 m_flatUniqueAlgPtrList.push_back( const_cast<IAlgorithm*>( algoSmartIF.get() ) );
428 return m_flatUniqueAlgPtrList;
429 }
AlgResourcePool::m_flatUniqueAlgList
ListAlg m_flatUniqueAlgList
The flat list of algorithms w/o clones.
Definition: AlgResourcePool.h:94
std::list::push_back
T push_back(T...args)
AlgResourcePool::m_flatUniqueAlgPtrList
std::list< IAlgorithm * > m_flatUniqueAlgPtrList
The flat list of algorithms w/o clones which is returned.
Definition: AlgResourcePool.h:97
std::list::clear
T clear(T...args)

std::list< IAlgorithm * > AlgResourcePool::getTopAlgList | ( |  | ) |
| override

Definition at line 433 of file AlgResourcePool.cpp.

434 {
435 m_topAlgPtrList.clear();
436 for ( auto algoSmartIF : m_topAlgList ) m_topAlgPtrList.push_back( const_cast<IAlgorithm*>( algoSmartIF.get() ) );
437 return m_topAlgPtrList;
438 }
std::list::push_back
T push_back(T...args)
AlgResourcePool::m_topAlgPtrList
std::list< IAlgorithm * > m_topAlgPtrList
The top list of algorithms.
Definition: AlgResourcePool.h:100
std::list::clear
T clear(T...args)
AlgResourcePool::m_topAlgList
ListAlg m_topAlgList
The list of top algorithms.
Definition: AlgResourcePool.h:91

StatusCode AlgResourcePool::initialize | ( |  | ) |
| override

Definition at line 39 of file AlgResourcePool.cpp.

40 {
41
42 StatusCode sc( Service::initialize() );
43 if ( !sc.isSuccess() ) warning() << "Base class could not be started" << endmsg;
44
45 // Try to recover the topAlgList from the ApplicationManager for backward-compatibility
46 if ( m_topAlgNames.value().empty() ) {
47 info() << "TopAlg list empty. Recovering the one of Application Manager" << endmsg;
48 const Gaudi::Utils::TypeNameString appMgrName( "ApplicationMgr/ApplicationMgr" );
49 SmartIF<IProperty> appMgrProps( serviceLocator()->service( appMgrName ) );
50 m_topAlgNames.assign( appMgrProps->getProperty( "TopAlg" ) );
51 }
52
53 // Prepare empty control flow graph
54 // (Only ForwardScheduler requires assembling the graph in AlgResourcePool.
55 // The AvalancheScheduler relies on the graph that is assembled by the PrecedenceSvc)
56 if ( serviceLocator()->existsService( "ForwardSchedulerSvc" ) ) {
57 const std::string& name = "ControlFlowGraph";
58 SmartIF<ISvcLocator> svc = serviceLocator();
59 m_CFGraph = new concurrency::recursive_CF::ControlFlowGraph( name, svc );
60 }
61
62 sc = decodeTopAlgs();
63 if ( sc.isFailure() ) warning() << "Algorithms could not be properly decoded." << endmsg;
64
65 // let's assume all resources are there
66 m_available_resources.set();
67 return StatusCode::SUCCESS;
68 }
Service::initialize
StatusCode initialize() override
Definition: Service.cpp:64
StatusCode::SUCCESS
Definition: StatusCode.h:31
SmartIF< IProperty >
Service::name
const std::string & name() const override
Retrieve name of the service.
Definition: Service.cpp:289
CommonMessagingBase::info
MsgStream & info() const
shortcut for the method msgStream(MSG::INFO)
Definition: CommonMessaging.h:117
ISvcLocator::existsService
virtual bool existsService(const std::string &name) const =0
Check the existence of a service given a service name.
AlgResourcePool::m_available_resources
state_type m_available_resources
Definition: AlgResourcePool.h:67
std::string
STL class.
concurrency::recursive_CF::ControlFlowGraph
Definition: ControlFlowGraph.h:144
Gaudi::Utils::TypeNameString
Helper class to parse a string of format "type/name".
Definition: TypeNameString.h:12
CommonMessagingBase::warning
MsgStream & warning() const
shortcut for the method msgStream(MSG::WARNING)
Definition: CommonMessaging.h:114
StatusCode
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:28
AlgResourcePool::m_topAlgNames
Gaudi::Property< std::vector< std::string > > m_topAlgNames
Definition: AlgResourcePool.h:82
AlgResourcePool::decodeTopAlgs
StatusCode decodeTopAlgs()
Decode the top alg list.
Definition: AlgResourcePool.cpp:266
Service::service
StatusCode service(const std::string &name, const T *&psvc, bool createIf=true) const
Access a service by name, creating it if it doesn&#39;t already exist.
Definition: Service.h:85
Service::serviceLocator
SmartIF< ISvcLocator > & serviceLocator() const override
Retrieve pointer to service locator.
Definition: Service.cpp:292
endmsg
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:209
AlgResourcePool::m_CFGraph
concurrency::recursive_CF::ControlFlowGraph * m_CFGraph
OMG yet another hack.
Definition: AlgResourcePool.h:103

StatusCode AlgResourcePool::releaseAlgorithm | ( | const std::string & | name,
|  | IAlgorithm *& | algo
| ) |  |
| override

Release a certain algorithm.

Definition at line 149 of file AlgResourcePool.cpp.

150 {
151
152 std::hash<std::string> hash_function;
153 size_t algo_id = hash_function( name );
154
155 // release resources used by the algorithm
156 m_resource_mutex.lock();
157 m_available_resources |= m_resource_requirements[algo_id];
158 m_resource_mutex.unlock();
159
160 // release algorithm itself if not reentrant
161 if ( 0 != algo->cardinality() ) {
162 m_algqueue_map[algo_id]->push( algo );
163 }
164 return StatusCode::SUCCESS;
165 }
StatusCode::SUCCESS
Definition: StatusCode.h:31
std::mutex::unlock
T unlock(T...args)
AlgResourcePool::m_resource_mutex
std::mutex m_resource_mutex
Definition: AlgResourcePool.h:65
AlgResourcePool::m_available_resources
state_type m_available_resources
Definition: AlgResourcePool.h:67
std::hash
AlgResourcePool::m_resource_requirements
std::map< size_t, state_type > m_resource_requirements
Definition: AlgResourcePool.h:69
std::mutex::lock
T lock(T...args)
IAlgorithm::cardinality
virtual unsigned int cardinality() const =0
Cardinality (Maximum number of clones that can exist) special value 0 means that algorithm is reentra...
AlgResourcePool::m_algqueue_map
std::map< size_t, concurrentQueueIAlgPtr * > m_algqueue_map
Definition: AlgResourcePool.h:68

StatusCode AlgResourcePool::releaseResource | ( | const std::string & | name | ) |
| override

Release a certrain resource.

Definition at line 179 of file AlgResourcePool.cpp.

180 {
181 m_resource_mutex.lock();
182 m_available_resources[m_resource_indices[name]] = true;
183 m_resource_mutex.unlock();
184 return StatusCode::SUCCESS;
185 }
StatusCode::SUCCESS
Definition: StatusCode.h:31
std::mutex::unlock
T unlock(T...args)
Service::name
const std::string & name() const override
Retrieve name of the service.
Definition: Service.cpp:289
AlgResourcePool::m_resource_indices
std::map< std::string, unsigned int > m_resource_indices
Definition: AlgResourcePool.h:72
AlgResourcePool::m_resource_mutex
std::mutex m_resource_mutex
Definition: AlgResourcePool.h:65
AlgResourcePool::m_available_resources
state_type m_available_resources
Definition: AlgResourcePool.h:67
std::mutex::lock
T lock(T...args)

StatusCode AlgResourcePool::start | ( |  | ) |
| override

Definition at line 72 of file AlgResourcePool.cpp.

73 {
74
75 StatusCode startSc = Service::start();
76 if ( !startSc.isSuccess() ) return startSc;
77
78 // sys-Start the algos
79 for ( auto& ialgo : m_algList ) {
80 startSc = ialgo->sysStart();
81 if ( startSc.isFailure() ) {
82 error() << "Unable to start Algorithm: " << ialgo->name() << endmsg;
83 return startSc;
84 }
85 }
86 return StatusCode::SUCCESS;
87 }
StatusCode::SUCCESS
Definition: StatusCode.h:31
Service::start
StatusCode start() override
Definition: Service.cpp:137
StatusCode::isSuccess
bool isSuccess() const
Test for a status code of SUCCESS.
Definition: StatusCode.h:75
StatusCode::isFailure
bool isFailure() const
Test for a status code of FAILURE.
Definition: StatusCode.h:86
CommonMessagingBase::error
MsgStream & error() const
shortcut for the method msgStream(MSG::ERROR)
Definition: CommonMessaging.h:111
StatusCode
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:28
AlgResourcePool::m_algList
ListAlg m_algList
The list of all algorithms created withing the Pool which are not top.
Definition: AlgResourcePool.h:88
endmsg
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:209

StatusCode AlgResourcePool::stop | ( |  | ) |
| override

Definition at line 485 of file AlgResourcePool.cpp.

486 {
487
488 StatusCode stopSc = Service::stop();
489 if ( !stopSc.isSuccess() ) return stopSc;
490
491 // sys-Stop the algos
492 for ( auto& ialgo : m_algList ) {
493 stopSc = ialgo->sysStop();
494 if ( stopSc.isFailure() ) {
495 error() << "Unable to stop Algorithm: " << ialgo->name() << endmsg;
496 return stopSc;
497 }
498 }
499 return StatusCode::SUCCESS;
500 }
StatusCode::SUCCESS
Definition: StatusCode.h:31
StatusCode::isSuccess
bool isSuccess() const
Test for a status code of SUCCESS.
Definition: StatusCode.h:75
StatusCode::isFailure
bool isFailure() const
Test for a status code of FAILURE.
Definition: StatusCode.h:86
CommonMessagingBase::error
MsgStream & error() const
shortcut for the method msgStream(MSG::ERROR)
Definition: CommonMessaging.h:111
StatusCode
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:28
Service::stop
StatusCode stop() override
Definition: Service.cpp:130
AlgResourcePool::m_algList
ListAlg m_algList
The list of all algorithms created withing the Pool which are not top.
Definition: AlgResourcePool.h:88
endmsg
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:209

## Member Data Documentation

ListAlg AlgResourcePool::m_algList
| private

The list of all algorithms created withing the Pool which are not top.

Definition at line 88 of file AlgResourcePool.h.

std::map<size_t, concurrentQueueIAlgPtr*> AlgResourcePool::m_algqueue_map
| private

Definition at line 68 of file AlgResourcePool.h.

state_type AlgResourcePool::m_available_resources {0}
| private

Definition at line 67 of file AlgResourcePool.h.

concurrency::recursive_CF::ControlFlowGraph* AlgResourcePool::m_CFGraph = nullptr
| private

OMG yet another hack.

Definition at line 103 of file AlgResourcePool.h.

ListAlg AlgResourcePool::m_flatUniqueAlgList
| private

The flat list of algorithms w/o clones.

Definition at line 94 of file AlgResourcePool.h.

std::list<IAlgorithm*> AlgResourcePool::m_flatUniqueAlgPtrList
| private

The flat list of algorithms w/o clones which is returned.

Definition at line 97 of file AlgResourcePool.h.

Gaudi::Property<bool> AlgResourcePool::m_lazyCreation {this, "CreateLazily", false, ""}
| private

Definition at line 81 of file AlgResourcePool.h.

std::map<size_t, size_t> AlgResourcePool::m_n_of_allowed_instances
| private

Definition at line 70 of file AlgResourcePool.h.

std::map<size_t, unsigned int> AlgResourcePool::m_n_of_created_instances
| private

Definition at line 71 of file AlgResourcePool.h.

Gaudi::Property<bool> AlgResourcePool::m_overrideUnClonable
| private

Initial value:
{this, "OverrideUnClonable", false,
"override the Un-Clonability of Algorithms. Use with caution!"}

Definition at line 84 of file AlgResourcePool.h.

std::map<std::string, unsigned int> AlgResourcePool::m_resource_indices
| private

Definition at line 72 of file AlgResourcePool.h.

std::mutex AlgResourcePool::m_resource_mutex
| private

Definition at line 65 of file AlgResourcePool.h.

std::map<size_t, state_type> AlgResourcePool::m_resource_requirements
| private

Definition at line 69 of file AlgResourcePool.h.

ListAlg AlgResourcePool::m_topAlgList
| private

The list of top algorithms.

Definition at line 91 of file AlgResourcePool.h.

Gaudi::Property<std::vector<std::string> > AlgResourcePool::m_topAlgNames
| private

Initial value:
{
this, "TopAlg", {}, "names of the algorithms to be passed to the algorithm manager"}

Definition at line 82 of file AlgResourcePool.h.

std::list<IAlgorithm*> AlgResourcePool::m_topAlgPtrList
| private

The top list of algorithms.

Definition at line 100 of file AlgResourcePool.h.

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

- GaudiHive/src/AlgResourcePool.h
- GaudiHive/src/AlgResourcePool.cpp