| The Gaudi Framework v27r1

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

- File List
- File Members

GraphSchedulerSimpleTest.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 ForwardSchedulerSvc: 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 ForwardSchedulerSvc, 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(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 = ForwardSchedulerSvc(MaxAlgosInFlight = algosInFlight,
67 ThreadPoolSize = algosInFlight,
68 useGraphFlowManagement = True,
69 OutputLevel=WARNING)
70
71 #-------------------------------------------------------------------------------
72
73 # Algo Resource Pool -----------------------------------------------------------
74 # Nothing special here, we just set the debug level.
75 AlgResourcePool(OutputLevel=DEBUG)
76
77 #-------------------------------------------------------------------------------
78
79 # Set up of the crunchers, daily business --------------------------------------
80
81 a1 = CPUCruncher("A1")
82 a1.outKeys = ['/Event/a1']
83
84 a2 = CPUCruncher("A2")
85 a2.inpKeys = ['/Event/a1']
86 a2.outKeys = ['/Event/a2']
87
88 a3 = CPUCruncher("A3")
89 a3.inpKeys = ['/Event/a1']
90 a3.outKeys = ['/Event/a3']
91
92 a4 = CPUCruncher("A4")
93 a4.inpKeys = ['/Event/a2','/Event/a3']
94 a4.outKeys = ['/Event/a4']
95
96 for algo in [a1, a2, a3, a4]:
97 algo.shortCalib=True
98 algo.Cardinality = cardinality
99 algo.OutputLevel=WARNING
100 algo.varRuntime=.3
101 algo.avgRuntime=.5
102
103 ctrp = ContextEventCounterPtr("CNT*", Cardinality=0, OutputLevel=INFO)
104 ctrd = ContextEventCounterData("CNT&", Cardinality=0, OutputLevel=INFO)
105
106 # Application Manager ----------------------------------------------------------
107 # We put everything together and change the type of message service
108
109 ApplicationMgr( EvtMax = evtMax,
110 EvtSel = 'NONE',
111 ExtSvc =[whiteboard],
112 EventLoop = slimeventloopmgr,
113 TopAlg = [a1, a2, a3, a4, ctrp, ctrd],
114 MessageSvcType="InertMessageSvc")
115
116 #-------------------------------------------------------------------------------
CPUCruncher
A class that implements a search for prime numbers.
Definition: CPUCruncher.h:19
HiveSlimEventLoopMgr
Definition: HiveSlimEventLoopMgr.h:25
ContextEventCounterPtr
Definition: ContextEventCounter.h:15
Gaudi.Configuration
Definition: Configuration.py:1
ForwardSchedulerSvc
The SchedulerSvc implements the IScheduler interface.
Definition: ForwardSchedulerSvc.h:73
AlgResourcePool
The AlgResourcePool is a concrete implementation of the IAlgResourcePool interface.
Definition: AlgResourcePool.h:34
ContextEventCounterData
Definition: ContextEventCounter.h:30
HiveWhiteBoard
Data service base class.
Definition: HiveWhiteBoard.cpp:87
ApplicationMgr
The Application Manager class.
Definition: ApplicationMgr.h:46