The Gaudi Framework  v38r3 (c3fc9673)
SubSlotVsSlotIsolation.py
Go to the documentation of this file.
1 #!/usr/bin/env gaudirun.py
2 
12 """
13 A test for isolating sub-slot data from the parent slot.
14 The main sequence has two steps of creating and running sub-events.
15 
16 The ViewTester is an algorithm specifically designed to create sub-event
17 contexts, pass them to the scheduler, and report on the current context.
18 
19 Seven instances of ViewTester are used as follows:
20  - Algorithm A1 creates a sub-event context
21  - Algorithms A2 and A3 run within the sub-event, sharing data
22  - Algorithm A4 creates another sub-event contexts, and a data output
23  - Algorithms A5 and A6 run within the new sub-event, but cannot access data from A4
24  - Algorithm A7 runs in the whole event context, after the sub-events
25 
26 The test should stall if isolation is working
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 = 1
44 cardinality = 1
45 threads = 1
46 viewsPerEvt = 1
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=DEBUG
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(
73  ThreadPoolSize=threads, OutputLevel=INFO, VerboseSubSlots=True
74 )
75 
76 # -------------------------------------------------------------------------------
77 
78 # Algo Resource Pool -----------------------------------------------------------
79 # Nothing special here, we just set the debug level.
80 AlgResourcePool(OutputLevel=DEBUG)
81 
82 # -------------------------------------------------------------------------------
83 
84 # Set up of the crunchers, daily business --------------------------------------
85 
86 a1 = Test__ViewTester("A1")
87 a1.baseViewName = "viewOne"
88 a1.viewNumber = viewsPerEvt
89 a1.viewNodeName = "viewNodeOne"
90 
91 a2 = Test__ViewTester("A2")
92 a2.viewNodeName = ""
93 a2.outKeys = ["/Event/a2"]
94 
95 a3 = Test__ViewTester("A3")
96 a3.viewNodeName = ""
97 a3.inpKeys = ["/Event/a2"] # Should be able to load a2 from the shared sub-slot
98 
99 a4 = Test__ViewTester("A4")
100 a4.baseViewName = "viewTwo"
101 a4.viewNumber = viewsPerEvt
102 a4.viewNodeName = "viewNodeTwo"
103 a4.outKeys = ["/Event/a4"]
104 
105 a5 = Test__ViewTester("A5")
106 a5.viewNodeName = ""
107 a5.inpKeys = ["/Event/a4"] # Should not be able to load a4 from the "whole event" slot
108 
109 a6 = Test__ViewTester("A6")
110 a6.viewNodeName = ""
111 
112 a7 = Test__ViewTester("A7")
113 a7.viewNodeName = ""
114 
115 for algo in [a1, a2, a3, a4, a5, a6, a7]:
116  algo.Cardinality = cardinality
117  algo.OutputLevel = DEBUG
118 
119 viewNodeOne = Gaudi__Sequencer(
120  "viewNodeOne", Members=[a2, a3], Sequential=False, ShortCircuit=False
121 )
122 
123 viewNodeTwo = Gaudi__Sequencer(
124  "viewNodeTwo", Members=[a5, a6], Sequential=False, ShortCircuit=False
125 )
126 
127 createViewSeq = Gaudi__Sequencer(
128  "createViewSeq",
129  Members=[a1, viewNodeOne, a4, viewNodeTwo, a7],
130  Sequential=True,
131  OutputLevel=VERBOSE,
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