The Gaudi Framework  v30r3 (a5ef0a68)
ViewThenViewTest.py
Go to the documentation of this file.
1 #!/usr/bin/env gaudirun.py
2 
3 '''
4 A test for scheduling multiple sub-event contexts.
5 The main sequence has two steps of creating and running sub-events.
6 
7 The ViewTester is an algorithm specifically designed to create sub-event
8 contexts, pass them to the scheduler, and report on the current context.
9 
10 Seven instances of ViewTester are used as follows:
11  - Algorithm A1 creates two sub-event contexts
12  - Algorithms A2 and A3 run within the sub-event contexts
13  - Algorithm A4 creates two more sub-event contexts
14  - Algorithms A5 and A6 run within the new sub-event contexts
15  - Algorithm A7 runs in the whole event context, after the sub-events
16 
17 '''
18 from Gaudi.Configuration import *
19 from Configurables import (HiveWhiteBoard, HiveSlimEventLoopMgr,
20  AvalancheSchedulerSvc, AlgResourcePool,
21  CPUCruncher, GaudiSequencer, Test__ViewTester)
22 
23 # metaconfig -------------------------------------------------------------------
24 # It's confortable to collect the relevant parameters at the top of the optionfile
25 evtslots = 1
26 evtMax = 10
27 cardinality = 1
28 threads = 1
29 viewsPerEvt = 2
30 # -------------------------------------------------------------------------------
31 
32 # The configuration of the whiteboard ------------------------------------------
33 # It is useful to call it EventDataSvc to replace the usual data service with
34 # the whiteboard transparently.
35 
36 whiteboard = HiveWhiteBoard("EventDataSvc", EventSlots=evtslots)
37 
38 # -------------------------------------------------------------------------------
39 
40 # Event Loop Manager -----------------------------------------------------------
41 # It's called slim since it has less functionalities overall than the good-old
42 # event loop manager. Here we just set its outputlevel to DEBUG.
43 
44 slimeventloopmgr = HiveSlimEventLoopMgr(
45  SchedulerName="AvalancheSchedulerSvc", OutputLevel=DEBUG)
46 
47 # -------------------------------------------------------------------------------
48 
49 # ForwardScheduler -------------------------------------------------------------
50 # We just decide how many algorithms in flight we want to have and how many
51 # threads in the pool. The default value is -1, which is for TBB equivalent
52 # to take over the whole machine.
53 
54 scheduler = AvalancheSchedulerSvc(ThreadPoolSize=threads, OutputLevel=INFO)
55 
56 # -------------------------------------------------------------------------------
57 
58 # Algo Resource Pool -----------------------------------------------------------
59 # Nothing special here, we just set the debug level.
60 AlgResourcePool(OutputLevel=DEBUG)
61 
62 # -------------------------------------------------------------------------------
63 
64 # Set up of the crunchers, daily business --------------------------------------
65 
66 a1 = Test__ViewTester("A1")
67 a1.baseViewName = 'viewOne'
68 a1.viewNumber = viewsPerEvt
69 a1.viewNodeName = 'viewNodeOne'
70 
71 a2 = Test__ViewTester("A2")
72 a2.viewNodeName = ''
73 
74 a3 = Test__ViewTester("A3")
75 a3.viewNodeName = ''
76 
77 a4 = Test__ViewTester("A4")
78 a4.baseViewName = 'viewTwo'
79 a4.viewNumber = viewsPerEvt
80 a4.viewNodeName = 'viewNodeTwo'
81 
82 a5 = Test__ViewTester("A5")
83 a5.viewNodeName = ''
84 
85 a6 = Test__ViewTester("A6")
86 a6.viewNodeName = ''
87 
88 a7 = Test__ViewTester("A7")
89 a7.viewNodeName = ''
90 
91 for algo in [a1, a2, a3, a4, a5, a6, a7]:
92  algo.Cardinality = cardinality
93  algo.OutputLevel = DEBUG
94 
95 viewNodeOne = GaudiSequencer("viewNodeOne",
96  Members=[a2, a3],
97  Sequential=False,
98  OutputLevel=VERBOSE)
99 
100 viewNodeTwo = GaudiSequencer("viewNodeTwo",
101  Members=[a5, a6],
102  Sequential=False,
103  OutputLevel=VERBOSE)
104 
105 createViewSeq = GaudiSequencer("createViewSeq",
106  Members=[a1, viewNodeOne, a4, viewNodeTwo, a7],
107  Sequential=True,
108  OutputLevel=VERBOSE)
109 
110 # Application Manager ----------------------------------------------------------
111 # We put everything together and change the type of message service
112 
113 ApplicationMgr(EvtMax=evtMax,
114  EvtSel='NONE',
115  ExtSvc=[whiteboard],
116  EventLoop=slimeventloopmgr,
117  TopAlg=[createViewSeq],
118  MessageSvcType="InertMessageSvc")
119 
120 # -------------------------------------------------------------------------------
Sequencer for executing several algorithms, stopping when one is faulty.
The AlgResourcePool is a concrete implementation of the IAlgResourcePool interface.
Data service base class.
The Application Manager class.