| The Gaudi Framework v29r1 (5cd95fa2)

- 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 "ControlFlowGraph.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 concurrency::recursive_CF::ControlFlowGraph* getCFGraph() const { return m_CFGraph; }
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 Gaudi::Property<bool> m_overrideUnClonable{this, "OverrideUnClonable", false,
85 "override the Un-Clonability of Algorithms. Use with caution!"};
86
88 ListAlg m_algList;
89
91 ListAlg m_topAlgList;
92
94 ListAlg m_flatUniqueAlgList;
95
97 std::list<IAlgorithm*> m_flatUniqueAlgPtrList;
98
100 std::list<IAlgorithm*> m_topAlgPtrList;
101
103 concurrency::recursive_CF::ControlFlowGraph* m_CFGraph = nullptr;
104 };
105
106 #endif // GAUDIHIVE_ALGRESOURCEPOOL_H
AlgResourcePool::m_flatUniqueAlgList
ListAlg m_flatUniqueAlgList
The flat list of algorithms w/o clones.
Definition: AlgResourcePool.h:94
Algorithm.h
Service::name
const std::string & name() const override
Retrieve name of the service.
Definition: Service.cpp:289
Gaudi::Property
Implementation of property with value of concrete type.
Definition: Property.h:319
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:442
AlgResourcePool::ListAlg
std::list< SmartIF< IAlgorithm > > ListAlg
Definition: AlgResourcePool.h:62
AlgResourcePool::stop
StatusCode stop() override
Definition: AlgResourcePool.cpp:485
AlgResourcePool::endRun
StatusCode endRun() override
Definition: AlgResourcePool.cpp:462
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
AlgResourcePool::m_overrideUnClonable
Gaudi::Property< bool > m_overrideUnClonable
Definition: AlgResourcePool.h:84
std::string
STL class.
Service.h
AlgResourcePool::state_type
boost::dynamic_bitset state_type
Definition: AlgResourcePool.h:63
ControlFlowGraph.h
concurrency::recursive_CF::ControlFlowGraph
Definition: ControlFlowGraph.h:144
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:97
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
AlgResourcePool::start
StatusCode start() override
Definition: AlgResourcePool.cpp:72
AlgResourcePool::~AlgResourcePool
~AlgResourcePool() override
Definition: AlgResourcePool.cpp:25
AlgResourcePool::m_topAlgPtrList
std::list< IAlgorithm * > m_topAlgPtrList
The top list of algorithms.
Definition: AlgResourcePool.h:100
AlgResourcePool::getFlatAlgList
std::list< IAlgorithm * > getFlatAlgList() override
Definition: AlgResourcePool.cpp:423
AlgResourcePool::releaseResource
StatusCode releaseResource(const std::string &name) override
Release a certrain resource.
Definition: AlgResourcePool.cpp:179
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:433
AlgResourcePool::getCFGraph
concurrency::recursive_CF::ControlFlowGraph * getCFGraph() const
Definition: AlgResourcePool.h:58
std::list< IAlgorithm * >
IAlgorithm
The IAlgorithm is the interface implemented by the Algorithm base class.
Definition: IAlgorithm.h:28
AlgResourcePool::acquireResource
StatusCode acquireResource(const std::string &name) override
Acquire a certain resource.
Definition: AlgResourcePool.cpp:169
AlgResourcePool::m_algqueue_map
std::map< size_t, concurrentQueueIAlgPtr * > m_algqueue_map
Definition: AlgResourcePool.h:68
Algorithm
Base class from which all concrete algorithm classes should be derived.
Definition: Algorithm.h:79
AlgResourcePool::decodeTopAlgs
StatusCode decodeTopAlgs()
Decode the top alg list.
Definition: AlgResourcePool.cpp:266
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:189
AlgResourcePool::acquireAlgorithm
StatusCode acquireAlgorithm(const std::string &name, IAlgorithm *&algo, bool blocking=false) override
Acquire a certain algorithm using its name.
Definition: AlgResourcePool.cpp:91
IAlgManager.h
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:39
AtlasMCRecoFullPrecedenceDump.sequencer
sequencer
Definition: AtlasMCRecoFullPrecedenceDump.py:45
AlgResourcePool::m_topAlgList
ListAlg m_topAlgList
The list of top algorithms.
Definition: AlgResourcePool.h:91
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
AlgResourcePool::releaseAlgorithm
StatusCode releaseAlgorithm(const std::string &name, IAlgorithm *&algo) override
Release a certain algorithm.
Definition: AlgResourcePool.cpp:149
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