The Gaudi Framework  v38r3 (c3fc9673)
ViewIsolationTest.py
Go to the documentation of this file.
1 #!/usr/bin/env gaudirun.py
2 
12 """
13 A test for issue 13 in gitlab.
14 Two different sets of sub-event contexts are created, and the
15 same algorithms (attached to a common control flow node) run in each
16 
17 The ViewTester is an algorithm specifically designed to create sub-event
18 contexts, pass them to the scheduler, and report on the current context.
19 
20 Five instances of ViewTester are used as follows:
21  - Algorithm A1 creates two sub-event contexts
22  - Algorithms A2 and A3 run within the sub-event contexts
23  - Algorithm A4 creates two more sub-event contexts
24  - Algorithms A2 and A3 run again, in the new contexts
25  - Algorithm A5 runs in the whole event context, after the sub-events
26 
27 """
28 
29 from Configurables import (
30  AlgResourcePool,
31  AvalancheSchedulerSvc,
32  CPUCruncher,
33  Gaudi__Sequencer,
34  HiveSlimEventLoopMgr,
35  HiveWhiteBoard,
36  Test__ViewTester,
37 )
38 from Gaudi.Configuration import *
39 
40 # metaconfig -------------------------------------------------------------------
41 # It's confortable to collect the relevant parameters at the top of the optionfile
42 evtslots = 1
43 evtMax = 10
44 cardinality = 1
45 threads = 1
46 viewsPerEvt = 2
47 # -------------------------------------------------------------------------------
48 
49 # The configuration of the whiteboard ------------------------------------------
50 # It is useful to call it EventDataSvc to replace the usual data service with
51 # the whiteboard transparently.
52 
53 whiteboard = HiveWhiteBoard("EventDataSvc", EventSlots=evtslots)
54 
55 # -------------------------------------------------------------------------------
56 
57 # Event Loop Manager -----------------------------------------------------------
58 # It's called slim since it has less functionalities overall than the good-old
59 # event loop manager. Here we just set its outputlevel to DEBUG.
60 
61 slimeventloopmgr = HiveSlimEventLoopMgr(
62  SchedulerName="AvalancheSchedulerSvc", OutputLevel=INFO
63 )
64 
65 # -------------------------------------------------------------------------------
66 
67 # ForwardScheduler -------------------------------------------------------------
68 # We just decide how many algorithms in flight we want to have and how many
69 # threads in the pool. The default value is -1, which is for TBB equivalent
70 # to take over the whole machine.
71 
72 scheduler = AvalancheSchedulerSvc(ThreadPoolSize=threads, OutputLevel=INFO)
73 
74 # -------------------------------------------------------------------------------
75 
76 # Algo Resource Pool -----------------------------------------------------------
77 # Nothing special here, we just set the debug level.
78 AlgResourcePool(OutputLevel=INFO)
79 
80 # -------------------------------------------------------------------------------
81 
82 # Set up of the crunchers, daily business --------------------------------------
83 
84 a1 = Test__ViewTester("A1")
85 a1.baseViewName = "viewOne"
86 a1.viewNumber = viewsPerEvt
87 a1.viewNodeName = "viewNodeOne"
88 
89 a2 = Test__ViewTester("A2")
90 a2.viewNodeName = ""
91 
92 a3 = Test__ViewTester("A3")
93 a3.viewNodeName = ""
94 
95 a4 = Test__ViewTester("A4")
96 a4.baseViewName = "viewTwo"
97 a4.viewNumber = viewsPerEvt
98 a4.viewNodeName = "viewNodeTwo"
99 
100 a5 = Test__ViewTester("A5")
101 a5.viewNodeName = ""
102 
103 for algo in [a1, a2, a3, a4, a5]:
104  algo.Cardinality = cardinality
105  algo.OutputLevel = INFO
106 
107 extraNode = Gaudi__Sequencer(
108  "extraNode", Members=[a2, a3], Sequential=True, OutputLevel=INFO
109 )
110 
111 viewNodeOne = Gaudi__Sequencer(
112  "viewNodeOne",
113  Members=[extraNode],
114  Sequential=False,
115  ShortCircuit=False,
116  OutputLevel=INFO,
117 )
118 
119 viewNodeTwo = Gaudi__Sequencer(
120  "viewNodeTwo",
121  Members=[extraNode],
122  Sequential=False,
123  ShortCircuit=False,
124  OutputLevel=INFO,
125 )
126 
127 createViewSeq = Gaudi__Sequencer(
128  "createViewSeq",
129  Members=[a1, viewNodeOne, a4, viewNodeTwo, a5],
130  Sequential=True,
131  OutputLevel=INFO,
132 )
133 
134 # Application Manager ----------------------------------------------------------
135 # We put everything together and change the type of message service
136 
138  EvtMax=evtMax,
139  EvtSel="NONE",
140  ExtSvc=[whiteboard],
141  EventLoop=slimeventloopmgr,
142  TopAlg=[createViewSeq],
143  MessageSvcType="InertMessageSvc",
144 )
145 
146 # -------------------------------------------------------------------------------
Gaudi.Configuration
Definition: Configuration.py:1
ApplicationMgr
Definition: ApplicationMgr.h:57