Go to the documentation of this file.
23 #define ON_DEBUG if ( msgLevel( MSG::DEBUG ) )
24 #define DEBUG_MSG ON_DEBUG debug()
31 auto*
queue = algoId_algoQueue.second;
42 if ( !sc.
isSuccess() ) warning() <<
"Base class could not be started" <<
endmsg;
46 info() <<
"TopAlg list empty. Recovering the one of Application Manager" <<
endmsg;
53 if ( sc.
isFailure() ) warning() <<
"Algorithms could not be properly decoded." <<
endmsg;
65 if ( !startSc.
isSuccess() )
return startSc;
69 startSc = ialgo->sysStart();
71 error() <<
"Unable to start Algorithm: " << ialgo->name() <<
endmsg;
83 size_t algo_id = hash_function(
name );
87 error() <<
"Algorithm " <<
name <<
" requested, but not recognised" <<
endmsg;
94 itQueueIAlgPtr->second->pop( algo );
96 if ( !itQueueIAlgPtr->second->try_pop( algo ) ) {
100 ++( result->second );
115 DEBUG_MSG <<
"No instance of algorithm " <<
name <<
" could be retrieved in non-blocking mode" <<
endmsg;
127 error() <<
"Failure to allocate resources of algorithm " <<
name <<
endmsg;
130 if ( !algo->
isReEntrant() ) { itQueueIAlgPtr->second->push( algo ); }
135 itQueueIAlgPtr->second->push( algo );
146 size_t algo_id = hash_function(
name );
185 error() <<
"Unable to dcast Algorithm " << algo->
name() <<
" to a Sequence, but it has isSequence==true"
190 auto subAlgorithms =
seq->subAlgorithms();
195 for (
auto subalgo : *subAlgorithms ) {
198 error() <<
"Algorithm " << subalgo->name() <<
" could not be flattened" <<
endmsg;
215 error() <<
"Algorithm manager could not be properly fetched." <<
endmsg;
221 StatusCode createAlgSc = algMan->createAlgorithm( item_type, item_name, algo,
true,
false );
223 this->warning() <<
"Algorithm " << item_type <<
"/" << item_name <<
" could not be created." <<
endmsg;
231 for (
auto&
name : topAlgNames ) {
239 if ( !algoSmartIF.
isValid() ) {
240 createAlg( item_type, item_name, algo );
244 algoSmartIF->sysInitialize().ignore();
253 fatal() <<
"Conversion from IAlgorithm to Gaudi::Algorithm failed" <<
endmsg;
269 debug() <<
"List of algorithms is: " <<
endmsg;
271 debug() <<
" o " << algo->type() <<
"/" << algo->name() <<
" @ " << algo <<
endmsg;
277 unsigned int resource_counter( 0 );
281 const std::string& item_name = ialgoSmartIF->name();
283 verbose() <<
"Treating resource management and clones of " << item_name <<
endmsg;
287 fatal() <<
"Conversion from IAlgorithm to Gaudi::Algorithm failed" <<
endmsg;
292 size_t algo_id = hash_function( item_name );
299 queue->push( ialgo );
303 info() <<
"Algorithm " << ialgo->name() <<
" is ReEntrant, but Cardinality was set to " << ialgo->
cardinality()
304 <<
". Only creating 1 instance" <<
endmsg;
314 info() <<
"Algorithm " << ialgo->name() <<
" is un-Clonable but Cardinality was set to "
318 warning() <<
"Overriding UnClonability of Algorithm " << ialgo->name() <<
". Setting Cardinality to "
331 if ( ret.second ) ++resource_counter;
333 requirements.resize( resource_counter );
335 requirements[ret.first->second] =
true;
343 debug() <<
"type/name to create clone of: " << item_type <<
"/" << item_name <<
endmsg;
345 createAlg( item_type, item_name, ialgoClone );
348 error() <<
"unable to initialize Algorithm clone " << ialgoClone->name() <<
endmsg;
352 queue->push( ialgoClone );
397 out <<
"Hit parade of algorithm instance misses:\n"
399 <<
" ===============================================================================\n"
401 <<
"| Algorithm (# of clones) \n"
402 <<
" ===============================================================================\n";
407 for (
const auto& p : sortedAlgInstanceMisses ) {
420 if ( !stopSc.
isSuccess() )
return stopSc;
424 stopSc = ialgo->sysStop();
426 error() <<
"Unable to stop Algorithm: " << ialgo->name() <<
endmsg;
441 return extends::finalize();
~AlgResourcePool() override
StatusCode initialize() override
StatusCode initialize() override
Gaudi::Property< bool > m_countAlgInstMisses
state_type m_available_resources
const std::string & name() const
StatusCode releaseResource(std::string_view name) override
Release a certain resource.
const std::string & name() const override
The identifying name of the algorithm object.
std::deque< Stream_t > queue
StatusCode start() override
virtual void setIndex(const unsigned int &idx)=0
Set instantiation index of Alg.
const std::string & type() const override
The type of the algorithm object.
ListAlg m_algList
The list of all algorithms created within the Pool which are not top.
ListAlg m_flatUniqueAlgList
The flat list of algorithms w/o clones.
virtual unsigned int cardinality() const =0
Cardinality (Maximum number of clones that can exist) special value 0 means that algorithm is reentra...
boost::dynamic_bitset state_type
bool assign(const Details::PropertyBase &source) override
get the value from another property
std::list< IAlgorithm * > m_flatUniqueAlgPtrList
The flat list of algorithms w/o clones which is returned.
virtual const std::vector< std::string > & neededResources() const =0
Named, non thread-safe resources used during event processing.
MSG::Level msgLevel() const
get the cached level (originally extracted from the embedded MsgStream)
virtual bool isClonable() const
Specify if the algorithm is clonable.
virtual bool isReEntrant() const =0
std::map< size_t, unsigned int > m_n_of_created_instances
StatusCode finalize() override
AttribStringParser::Iterator begin(const AttribStringParser &parser)
bool isValid() const
Allow for check if smart pointer is valid.
Helper class to parse a string of format "type/name".
std::map< size_t, state_type > m_resource_requirements
const std::string & name() const override
Retrieve name of the service
std::map< std::string_view, unsigned int > m_resource_indices
Base class from which all concrete algorithm classes should be derived.
const ValueType & value() const
StatusCode stop() override
void dumpInstanceMisses() const
Dump recorded Algorithm instance misses.
StatusCode decodeTopAlgs()
Decode the top Algorithm list.
tbb::concurrent_bounded_queue< IAlgorithm * > concurrentQueueIAlgPtr
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Gaudi::Property< bool > m_overrideUnClonable
std::map< size_t, size_t > m_n_of_allowed_instances
StatusCode start() override
const std::string & type() const
std::unordered_map< std::string_view, unsigned int > m_algInstanceMisses
Counters for Algorithm instance misses.
Gaudi::Property< bool > m_lazyCreation
StatusCode acquireResource(std::string_view name) override
Acquire a certain resource.
T emplace_back(T... args)
constexpr static const auto SUCCESS
StatusCode stop() override
Gaudi::Property< std::vector< std::string > > m_topAlgNames
StatusCode flattenSequencer(Gaudi::Algorithm *sequencer, ListAlg &alglist, unsigned int recursionDepth=0)
Recursively flatten an algList.
#define DECLARE_COMPONENT(type)
std::map< size_t, concurrentQueueIAlgPtr * > m_algqueue_map
StatusCode acquireAlgorithm(std::string_view name, IAlgorithm *&algo, bool blocking=false) override
Acquire a certain algorithm using its name.
std::list< IAlgorithm * > getFlatAlgList() override
std::mutex m_resource_mutex
constexpr static const auto FAILURE
StatusCode releaseAlgorithm(std::string_view name, IAlgorithm *&algo) override
Release a certain algorithm.
virtual StatusCode sysInitialize()=0
Initialization method invoked by the framework.
std::list< IAlgorithm * > m_topAlgPtrList
The top list of algorithms.
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.
bool isSequence() const override
Are we a Sequence?
ListAlg m_topAlgList
The list of top algorithms.
std::list< IAlgorithm * > getTopAlgList() override
SmartIF< ISvcLocator > & serviceLocator() const override
Retrieve pointer to service locator