AtomicAlgSequencerTest.py
Go to the documentation of this file.
1 from Gaudi.Configuration import *
2 from Configurables import (HiveWhiteBoard, HiveSlimEventLoopMgr,
3  ForwardSchedulerSvc, AlgResourcePool,
4  CPUCruncher,
5  ContextEventCounterPtr,
6  ContextEventCounterData,
7  GaudiAtomicSequencer)
8 
9 # metaconfig -------------------------------------------------------------------
10 # It's confortable to collect the relevant parameters at the top of the optionfile
11 evtslots = 5
12 evtMax = 20
13 cardinality=5
14 algosInFlight=10
15 #-------------------------------------------------------------------------------
16 
17 # The configuration of the whiteboard ------------------------------------------
18 # It is useful to call it EventDataSvc to replace the usual data service with
19 # the whiteboard transparently.
20 
21 whiteboard = HiveWhiteBoard("EventDataSvc",
22  EventSlots = evtslots)
23 
24 #-------------------------------------------------------------------------------
25 
26 # Event Loop Manager -----------------------------------------------------------
27 # It's called slim since it has less functionalities overall than the good-old
28 # event loop manager. Here we just set its outputlevel to DEBUG.
29 
30 slimeventloopmgr = HiveSlimEventLoopMgr(OutputLevel=DEBUG)
31 
32 #-------------------------------------------------------------------------------
33 
34 # ForwardScheduler -------------------------------------------------------------
35 # We just decide how many algorithms in flight we want to have and how many
36 # threads in the pool. The default value is -1, which is for TBB equivalent
37 # to take over the whole machine.
38 
39 scheduler = ForwardSchedulerSvc(MaxAlgosInFlight = algosInFlight,
40  ThreadPoolSize = algosInFlight,
41  useGraphFlowManagement = True,
42  OutputLevel=DEBUG)
43 
44 #-------------------------------------------------------------------------------
45 
46 # Algo Resource Pool -----------------------------------------------------------
47 # Nothing special here, we just set the debug level.
48 AlgResourcePool(OutputLevel=DEBUG)
49 
50 #-------------------------------------------------------------------------------
51 
52 # Set up of the crunchers, daily business --------------------------------------
53 
54 a1 = CPUCruncher("A1")
55 a1.outKeys = ['/Event/a1']
56 
57 a2 = CPUCruncher("A2")
58 a2.inpKeys = ['/Event/a1']
59 a2.outKeys = ['/Event/a2']
60 
61 a3 = CPUCruncher("A3")
62 a3.inpKeys = ['/Event/a1']
63 a3.outKeys = ['/Event/a3']
64 
65 a4 = CPUCruncher("A4")
66 a4.inpKeys = ['/Event/a2']
67 a4.outKeys = ['/Event/a4']
68 
69 for algo in [a1, a2, a3, a4]:
70  algo.shortCalib=True
71  algo.OutputLevel=DEBUG
72  algo.varRuntime=.3
73  algo.avgRuntime=.5
74 
75 for algo in [a3]:
76  algo.Cardinality = cardinality
77 
78 seq = GaudiAtomicSequencer("CriticalSection",
79  Members=[a1,a2,a4],
80  OutputLevel=VERBOSE)
81 
82 # Application Manager ----------------------------------------------------------
83 # We put everything together and change the type of message service
84 
85 ApplicationMgr( EvtMax = evtMax,
86  EvtSel = 'NONE',
87  ExtSvc =[whiteboard],
88  EventLoop = slimeventloopmgr,
89  TopAlg = [seq, a3],
90  MessageSvcType="InertMessageSvc")
A class that implements a search for prime numbers.
Definition: CPUCruncher.h:19
Sequencer for executing several algorithms, stopping when one is faulty.
The SchedulerSvc implements the IScheduler interface.
The AlgResourcePool is a concrete implementation of the IAlgResourcePool interface.
Data service base class.
The Application Manager class.