| The Gaudi Framework v28r2p1 (f1a77ff4)

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

- File List
- File Members

AlgResourcePool.h
Go to the documentation of this file.
1 #ifndef GAUDIHIVE_ALGRESOURCEPOOL_H
2 #define GAUDIHIVE_ALGRESOURCEPOOL_H
3
4 #include "GaudiKernel/Algorithm.h"
5 #include "GaudiKernel/IAlgManager.h"
6 #include "GaudiKernel/IAlgResourcePool.h"
7 #include "GaudiKernel/IAlgorithm.h"
8 #include "GaudiKernel/Service.h"
9 // TODO: include here is only a workaround
10 #include "PrecedenceRulesGraph.h"
11
12 #include <atomic>
13 #include <bitset>
14 #include <list>
15 #include <mutex>
16 #include <string>
17 #include <vector>
18
19 // External libs
20 #include "boost/dynamic_bitset.hpp"
21 #include "tbb/concurrent_queue.h"
22
31 class AlgResourcePool : public extends<Service, IAlgResourcePool>
32 {
33 public:
34 // Standard constructor
35 using extends::extends;
36 // Standard destructor
37 ~AlgResourcePool() override;
38
39 StatusCode start() override;
40 StatusCode initialize() override;
42 StatusCode acquireAlgorithm( const std::string& name, IAlgorithm*& algo, bool blocking = false ) override;
44 StatusCode releaseAlgorithm( const std::string& name, IAlgorithm*& algo ) override;
46 StatusCode acquireResource( const std::string& name ) override;
48 StatusCode releaseResource( const std::string& name ) override;
49
50 std::list<IAlgorithm*> getFlatAlgList() override;
51 std::list<IAlgorithm*> getTopAlgList() override;
52
53 StatusCode beginRun() override;
54 StatusCode endRun() override;
55
56 StatusCode stop() override;
57
58 virtual concurrency::PrecedenceRulesGraph* getPRGraph() const { return m_PRGraph; }
59
60 private:
61 typedef tbb::concurrent_bounded_queue<IAlgorithm*> concurrentQueueIAlgPtr;
62 typedef std::list<SmartIF<IAlgorithm>> ListAlg;
63 typedef boost::dynamic_bitset<> state_type;
64
65 std::mutex m_resource_mutex;
66
67 state_type m_available_resources{0};
68 std::map<size_t, concurrentQueueIAlgPtr*> m_algqueue_map;
69 std::map<size_t, state_type> m_resource_requirements;
70 std::map<size_t, size_t> m_n_of_allowed_instances;
71 std::map<size_t, unsigned int> m_n_of_created_instances;
72 std::map<std::string, unsigned int> m_resource_indices;
73
75 StatusCode decodeTopAlgs();
76
78 StatusCode flattenSequencer( Algorithm* sequencer, ListAlg& alglist, const std::string& parentName,
79 unsigned int recursionDepth = 0 );
80
81 Gaudi::Property<bool> m_lazyCreation{this, "CreateLazily", false, ""};
82 Gaudi::Property<std::vector<std::string>> m_topAlgNames{
83 this, "TopAlg", {}, "names of the algorithms to be passed to the algorithm manager"};
84
86 ListAlg m_algList;
87
89 ListAlg m_topAlgList;
90
92 ListAlg m_flatUniqueAlgList;
93
95 std::list<IAlgorithm*> m_flatUniqueAlgPtrList;
96
98 std::list<IAlgorithm*> m_topAlgPtrList;
99
101 concurrency::PrecedenceRulesGraph* m_PRGraph = nullptr;
102 };
103
104 #endif // GAUDIHIVE_ALGRESOURCEPOOL_H
AlgResourcePool::m_flatUniqueAlgList
ListAlg m_flatUniqueAlgList
The flat list of algorithms w/o clones.
Definition: AlgResourcePool.h:92
Algorithm.h
Service::name
const std::string & name() const override
Retrieve name of the service.
Definition: Service.cpp:289
AlgResourcePool::getPRGraph
virtual concurrency::PrecedenceRulesGraph * getPRGraph() const
Definition: AlgResourcePool.h:58
Gaudi::Property
Implementation of property with value of concrete type.
Definition: Property.h:314
IAlgorithm.h
AlgResourcePool::m_resource_indices
std::map< std::string, unsigned int > m_resource_indices
Definition: AlgResourcePool.h:72
IAlgResourcePool.h
AlgResourcePool::m_resource_mutex
std::mutex m_resource_mutex
Definition: AlgResourcePool.h:65
AlgResourcePool::beginRun
StatusCode beginRun() override
Definition: AlgResourcePool.cpp:414
AlgResourcePool::ListAlg
std::list< SmartIF< IAlgorithm > > ListAlg
Definition: AlgResourcePool.h:62
AlgResourcePool::stop
StatusCode stop() override
Definition: AlgResourcePool.cpp:458
AlgResourcePool::endRun
StatusCode endRun() override
Definition: AlgResourcePool.cpp:434
AlgResourcePool
The AlgResourcePool is a concrete implementation of the IAlgResourcePool interface.
Definition: AlgResourcePool.h:31
std::map< size_t, concurrentQueueIAlgPtr * >
AlgResourcePool::m_available_resources
state_type m_available_resources
Definition: AlgResourcePool.h:67
std::mutex
std::string
STL class.
Service.h
AlgResourcePool::state_type
boost::dynamic_bitset state_type
Definition: AlgResourcePool.h:63
AlgResourcePool::concurrentQueueIAlgPtr
tbb::concurrent_bounded_queue< IAlgorithm * > concurrentQueueIAlgPtr
Definition: AlgResourcePool.h:61
AlgResourcePool::m_flatUniqueAlgPtrList
std::list< IAlgorithm * > m_flatUniqueAlgPtrList
The flat list of algorithms w/o clones which is returned.
Definition: AlgResourcePool.h:95
StatusCode
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:26
AlgResourcePool::m_resource_requirements
std::map< size_t, state_type > m_resource_requirements
Definition: AlgResourcePool.h:69
AlgResourcePool::start
StatusCode start() override
Definition: AlgResourcePool.cpp:68
AlgResourcePool::~AlgResourcePool
~AlgResourcePool() override
Definition: AlgResourcePool.cpp:25
AlgResourcePool::m_topAlgPtrList
std::list< IAlgorithm * > m_topAlgPtrList
The top list of algorithms.
Definition: AlgResourcePool.h:98
AlgResourcePool::getFlatAlgList
std::list< IAlgorithm * > getFlatAlgList() override
Definition: AlgResourcePool.cpp:396
AlgResourcePool::releaseResource
StatusCode releaseResource(const std::string &name) override
Release a certrain resource.
Definition: AlgResourcePool.cpp:172
AlgResourcePool::m_topAlgNames
Gaudi::Property< std::vector< std::string > > m_topAlgNames
Definition: AlgResourcePool.h:82
AlgResourcePool::getTopAlgList
std::list< IAlgorithm * > getTopAlgList() override
Definition: AlgResourcePool.cpp:405
std::list< IAlgorithm * >
IAlgorithm
The IAlgorithm is the interface implemented by the Algorithm base class.
Definition: IAlgorithm.h:27
AlgResourcePool::acquireResource
StatusCode acquireResource(const std::string &name) override
Acquire a certain resource.
Definition: AlgResourcePool.cpp:163
AlgResourcePool::m_algqueue_map
std::map< size_t, concurrentQueueIAlgPtr * > m_algqueue_map
Definition: AlgResourcePool.h:68
concurrency::PrecedenceRulesGraph
Definition: PrecedenceRulesGraph.h:280
Algorithm
Base class from which all concrete algorithm classes should be derived.
Definition: Algorithm.h:78
AlgResourcePool::decodeTopAlgs
StatusCode decodeTopAlgs()
Decode the top alg list.
Definition: AlgResourcePool.cpp:248
extends
Base class used to extend a class implementing other interfaces.
Definition: extends.h:10
AlgResourcePool::flattenSequencer
StatusCode flattenSequencer(Algorithm *sequencer, ListAlg &alglist, const std::string &parentName, unsigned int recursionDepth=0)
Recursively flatten an algList.
Definition: AlgResourcePool.cpp:181
AlgResourcePool::acquireAlgorithm
StatusCode acquireAlgorithm(const std::string &name, IAlgorithm *&algo, bool blocking=false) override
Acquire a certain algorithm using its name.
Definition: AlgResourcePool.cpp:86
IAlgManager.h
AtlasMCRecoScenario.sequencer
sequencer
Definition: AtlasMCRecoScenario.py:39
AlgResourcePool::m_n_of_created_instances
std::map< size_t, unsigned int > m_n_of_created_instances
Definition: AlgResourcePool.h:71
AlgResourcePool::initialize
StatusCode initialize() override
Definition: AlgResourcePool.cpp:38
AlgResourcePool::m_PRGraph
concurrency::PrecedenceRulesGraph * m_PRGraph
OMG yet another hack.
Definition: AlgResourcePool.h:101
AlgResourcePool::m_topAlgList
ListAlg m_topAlgList
The list of top algorithms.
Definition: AlgResourcePool.h:89
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:86
PrecedenceRulesGraph.h
AlgResourcePool::releaseAlgorithm
StatusCode releaseAlgorithm(const std::string &name, IAlgorithm *&algo) override
Release a certain algorithm.
Definition: AlgResourcePool.cpp:144
AlgResourcePool::m_lazyCreation
Gaudi::Property< bool > m_lazyCreation
Definition: AlgResourcePool.h:81