| The Gaudi Framework v28r2-patches (bc4ad17a)

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

- File List
- File Members

AvalancheSchedulerSimpleTest.py
Go to the documentation of this file.
1 #!/usr/bin/env gaudirun.py
2
3 '''
4 Reference optionfile which shows in a simple way how to take advantage of the
5 Gaudi components desicated to concurrency.
6 The components are:
7 o HiveWhiteBoard: a convenient way to collect several TES (one per "processing
8 slot"), accessible in a thread safe way, keeps a catalogue of the products
9 written on each processing slot. The number of slots in the whiteboard
10 determines also the number of events processed simultaneously by the scheduler.
11 o AvalancheSchedulerSvc: state machine of the algorithms interfaced with the
12 TBB runtime. It is responsible for the submission of the algorithms. An
13 algorithm is marked ready for submission when its needed input is available.
14 It deals the asynchronous termination of algorithms with a "receiver" thread
15 and a thread safe queue.
16 o HiveSlimEventLoopMgr: an event factory. Pushes new events and pops finished
17 events to/from the scheduler. It does not manage algorithms/streams.
18 o AlgResourcePool: Service managing the creation of algorithms (through the
19 algorithm manager), including clones. It also manages the algorithms according
20 to the resources they need (parameter NeededResources - vector of strings - of
21 the Algorithm class).
22 o InertMessageSvc: as the TBBMsgSvc, it manages the printing of the messages in
23 a multithreaded environment.
24
25 The CPUCruncher is not a component dealing with concurrency, but a useful
26 entity to test it. It's an algorithm that simply wastes cpu.
27
28 '''
29 from Gaudi.Configuration import *
30 from Configurables import (HiveWhiteBoard, HiveSlimEventLoopMgr,
31 AvalancheSchedulerSvc, AlgResourcePool,
32 CPUCruncher,
33 ContextEventCounterPtr,
34 ContextEventCounterData)
35
36 # metaconfig -------------------------------------------------------------------
37 # It's confortable to collect the relevant parameters at the top of the optionfile
38 evtslots = 23
39 evtMax = 50
40 cardinality=10
41 algosInFlight=10
42 #-------------------------------------------------------------------------------
43
44 # The configuration of the whiteboard ------------------------------------------
45 # It is useful to call it EventDataSvc to replace the usual data service with
46 # the whiteboard transparently.
47
48 whiteboard = HiveWhiteBoard("EventDataSvc",
49 EventSlots = evtslots)
50
51 #-------------------------------------------------------------------------------
52
53 # Event Loop Manager -----------------------------------------------------------
54 # It's called slim since it has less functionalities overall than the good-old
55 # event loop manager. Here we just set its outputlevel to DEBUG.
56
57 slimeventloopmgr = HiveSlimEventLoopMgr(SchedulerName = "AvalancheSchedulerSvc", OutputLevel=DEBUG)
58
59 #-------------------------------------------------------------------------------
60
61 # ForwardScheduler -------------------------------------------------------------
62 # We just decide how many algorithms in flight we want to have and how many
63 # threads in the pool. The default value is -1, which is for TBB equivalent
64 # to take over the whole machine.
65
66 scheduler = AvalancheSchedulerSvc(MaxAlgosInFlight = algosInFlight,
67 ThreadPoolSize = algosInFlight,
68 OutputLevel=WARNING)
69
70 #-------------------------------------------------------------------------------
71
72 # Algo Resource Pool -----------------------------------------------------------
73 # Nothing special here, we just set the debug level.
74 AlgResourcePool(OutputLevel=DEBUG)
75
76 #-------------------------------------------------------------------------------
77
78 # Set up of the crunchers, daily business --------------------------------------
79
80 a1 = CPUCruncher("A1")
81 a1.outKeys = ['/Event/a1']
82
83 a2 = CPUCruncher("A2")
84 a2.inpKeys = ['/Event/a1']
85 a2.outKeys = ['/Event/a2']
86
87 a3 = CPUCruncher("A3")
88 a3.inpKeys = ['/Event/a1']
89 a3.outKeys = ['/Event/a3']
90
91 a4 = CPUCruncher("A4")
92 a4.inpKeys = ['/Event/a2','/Event/a3']
93 a4.outKeys = ['/Event/a4']
94
95 for algo in [a1, a2, a3, a4]:
96 algo.shortCalib=True
97 algo.Cardinality = cardinality
98 algo.OutputLevel=WARNING
99 algo.varRuntime=.3
100 algo.avgRuntime=.5
101
102 ctrp = ContextEventCounterPtr("CNT*", Cardinality=0, OutputLevel=INFO)
103 ctrd = ContextEventCounterData("CNT&", Cardinality=0, OutputLevel=INFO)
104
105 # Application Manager ----------------------------------------------------------
106 # We put everything together and change the type of message service
107
108 ApplicationMgr( EvtMax = evtMax,
109 EvtSel = 'NONE',
110 ExtSvc =[whiteboard],
111 EventLoop = slimeventloopmgr,
112 TopAlg = [a1, a2, a3, a4, ctrp, ctrd],
113 MessageSvcType="InertMessageSvc")
114
115 #-------------------------------------------------------------------------------
CPUCruncher
A class that implements a search for prime numbers.
Definition: CPUCruncher.h:19
HiveSlimEventLoopMgr
Definition: HiveSlimEventLoopMgr.h:26
ContextEventCounterPtr
Definition: ContextEventCounter.h:15
Gaudi.Configuration
Definition: Configuration.py:1
AlgResourcePool
The AlgResourcePool is a concrete implementation of the IAlgResourcePool interface.
Definition: AlgResourcePool.h:31
ContextEventCounterData
Definition: ContextEventCounter.h:30
HiveWhiteBoard
Data service base class.
Definition: HiveWhiteBoard.cpp:95
AvalancheSchedulerSvc
Introduction
Definition: AvalancheSchedulerSvc.h:100
ApplicationMgr
The Application Manager class.
Definition: ApplicationMgr.h:47