| The Gaudi Framework v30r0 (c919700c)

- 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
10 #include <atomic>
11 #include <bitset>
12 #include <list>
13 #include <mutex>
14 #include <string>
15 #include <vector>
16
17 // External libs
18 #include "boost/dynamic_bitset.hpp"
19 #include "tbb/concurrent_queue.h"
20
29 class AlgResourcePool : public extends<Service, IAlgResourcePool>
30 {
31 public:
32 // Standard constructor
33 using extends::extends;
34 // Standard destructor
35 ~AlgResourcePool() override;
36
37 StatusCode start() override;
38 StatusCode initialize() override;
40 StatusCode acquireAlgorithm( const std::string& name, IAlgorithm*& algo, bool blocking = false ) override;
42 StatusCode releaseAlgorithm( const std::string& name, IAlgorithm*& algo ) override;
44 StatusCode acquireResource( const std::string& name ) override;
46 StatusCode releaseResource( const std::string& name ) override;
47
48 std::list<IAlgorithm*> getFlatAlgList() override;
49 std::list<IAlgorithm*> getTopAlgList() override;
50
51 StatusCode beginRun() override;
52 StatusCode endRun() override;
53
54 StatusCode stop() override;
55
56 private:
57 typedef tbb::concurrent_bounded_queue<IAlgorithm*> concurrentQueueIAlgPtr;
58 typedef std::list<SmartIF<IAlgorithm>> ListAlg;
59 typedef boost::dynamic_bitset<> state_type;
60
61 std::mutex m_resource_mutex;
62
63 state_type m_available_resources{0};
64 std::map<size_t, concurrentQueueIAlgPtr*> m_algqueue_map;
65 std::map<size_t, state_type> m_resource_requirements;
66 std::map<size_t, size_t> m_n_of_allowed_instances;
67 std::map<size_t, unsigned int> m_n_of_created_instances;
68 std::map<std::string, unsigned int> m_resource_indices;
69
71 StatusCode decodeTopAlgs();
72
74 StatusCode flattenSequencer( Algorithm* sequencer, ListAlg& alglist, unsigned int recursionDepth = 0 );
75
76 Gaudi::Property<bool> m_lazyCreation{this, "CreateLazily", false, ""};
77 Gaudi::Property<std::vector<std::string>> m_topAlgNames{
78 this, "TopAlg", {}, "names of the algorithms to be passed to the algorithm manager"};
79 Gaudi::Property<bool> m_overrideUnClonable{this, "OverrideUnClonable", false,
80 "override the Un-Clonability of Algorithms. Use with caution!"};
81
83 ListAlg m_algList;
84
86 ListAlg m_topAlgList;
87
89 ListAlg m_flatUniqueAlgList;
90
92 std::list<IAlgorithm*> m_flatUniqueAlgPtrList;
93
95 std::list<IAlgorithm*> m_topAlgPtrList;
96 };
97
98 #endif // GAUDIHIVE_ALGRESOURCEPOOL_H
AlgResourcePool::m_flatUniqueAlgList
ListAlg m_flatUniqueAlgList
The flat list of algorithms w/o clones.
Definition: AlgResourcePool.h:89
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:68
AlgResourcePool::flattenSequencer
StatusCode flattenSequencer(Algorithm *sequencer, ListAlg &alglist, unsigned int recursionDepth=0)
Recursively flatten an algList.
Definition: AlgResourcePool.cpp:179
IAlgResourcePool.h
AlgResourcePool::m_resource_mutex
std::mutex m_resource_mutex
Definition: AlgResourcePool.h:61
AlgResourcePool::beginRun
StatusCode beginRun() override
Definition: AlgResourcePool.cpp:388
AlgResourcePool::ListAlg
std::list< SmartIF< IAlgorithm > > ListAlg
Definition: AlgResourcePool.h:58
AlgResourcePool::stop
StatusCode stop() override
Definition: AlgResourcePool.cpp:431
AlgResourcePool::endRun
StatusCode endRun() override
Definition: AlgResourcePool.cpp:408
AlgResourcePool
The AlgResourcePool is a concrete implementation of the IAlgResourcePool interface.
Definition: AlgResourcePool.h:29
std::map< size_t, concurrentQueueIAlgPtr * >
AlgResourcePool::m_available_resources
state_type m_available_resources
Definition: AlgResourcePool.h:63
std::mutex
AlgResourcePool::m_overrideUnClonable
Gaudi::Property< bool > m_overrideUnClonable
Definition: AlgResourcePool.h:79
std::string
STL class.
Service.h
AlgResourcePool::state_type
boost::dynamic_bitset state_type
Definition: AlgResourcePool.h:59
AlgResourcePool::concurrentQueueIAlgPtr
tbb::concurrent_bounded_queue< IAlgorithm * > concurrentQueueIAlgPtr
Definition: AlgResourcePool.h:57
AlgResourcePool::m_flatUniqueAlgPtrList
std::list< IAlgorithm * > m_flatUniqueAlgPtrList
The flat list of algorithms w/o clones which is returned.
Definition: AlgResourcePool.h:92
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:65
AlgResourcePool::start
StatusCode start() override
Definition: AlgResourcePool.cpp:61
AlgResourcePool::~AlgResourcePool
~AlgResourcePool() override
Definition: AlgResourcePool.cpp:25
AlgResourcePool::m_topAlgPtrList
std::list< IAlgorithm * > m_topAlgPtrList
The top list of algorithms.
Definition: AlgResourcePool.h:95
AlgResourcePool::getFlatAlgList
std::list< IAlgorithm * > getFlatAlgList() override
Definition: AlgResourcePool.cpp:369
AlgResourcePool::releaseResource
StatusCode releaseResource(const std::string &name) override
Release a certrain resource.
Definition: AlgResourcePool.cpp:169
AlgResourcePool::m_topAlgNames
Gaudi::Property< std::vector< std::string > > m_topAlgNames
Definition: AlgResourcePool.h:77
AlgResourcePool::getTopAlgList
std::list< IAlgorithm * > getTopAlgList() override
Definition: AlgResourcePool.cpp:379
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:159
AlgResourcePool::m_algqueue_map
std::map< size_t, concurrentQueueIAlgPtr * > m_algqueue_map
Definition: AlgResourcePool.h:64
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:218
extends
Base class used to extend a class implementing other interfaces.
Definition: extends.h:10
AlgResourcePool::acquireAlgorithm
StatusCode acquireAlgorithm(const std::string &name, IAlgorithm *&algo, bool blocking=false) override
Acquire a certain algorithm using its name.
Definition: AlgResourcePool.cpp:80
IAlgManager.h
AlgResourcePool::m_n_of_created_instances
std::map< size_t, unsigned int > m_n_of_created_instances
Definition: AlgResourcePool.h:67
AlgResourcePool::initialize
StatusCode initialize() override
Definition: AlgResourcePool.cpp:37
AtlasMCRecoFullPrecedenceDump.sequencer
sequencer
Definition: AtlasMCRecoFullPrecedenceDump.py:45
AlgResourcePool::m_topAlgList
ListAlg m_topAlgList
The list of top algorithms.
Definition: AlgResourcePool.h:86
AlgResourcePool::m_n_of_allowed_instances
std::map< size_t, size_t > m_n_of_allowed_instances
Definition: AlgResourcePool.h:66
AlgResourcePool::m_algList
ListAlg m_algList
The list of all algorithms created withing the Pool which are not top.
Definition: AlgResourcePool.h:83
AlgResourcePool::releaseAlgorithm
StatusCode releaseAlgorithm(const std::string &name, IAlgorithm *&algo) override
Release a certain algorithm.
Definition: AlgResourcePool.cpp:139
AlgResourcePool::m_lazyCreation
Gaudi::Property< bool > m_lazyCreation
Definition: AlgResourcePool.h:76