The Gaudi Framework  v36r2 (27905625)
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 from Gaudi.Configuration import *
29 from Configurables import (HiveWhiteBoard, HiveSlimEventLoopMgr,
30  AvalancheSchedulerSvc, AlgResourcePool, CPUCruncher,
31  GaudiSequencer, Test__ViewTester)
32 
33 # metaconfig -------------------------------------------------------------------
34 # It's confortable to collect the relevant parameters at the top of the optionfile
35 evtslots = 1
36 evtMax = 1
37 cardinality = 1
38 threads = 1
39 viewsPerEvt = 1
40 # -------------------------------------------------------------------------------
41 
42 # The configuration of the whiteboard ------------------------------------------
43 # It is useful to call it EventDataSvc to replace the usual data service with
44 # the whiteboard transparently.
45 
46 whiteboard = HiveWhiteBoard("EventDataSvc", EventSlots=evtslots)
47 
48 # -------------------------------------------------------------------------------
49 
50 # Event Loop Manager -----------------------------------------------------------
51 # It's called slim since it has less functionalities overall than the good-old
52 # event loop manager. Here we just set its outputlevel to DEBUG.
53 
54 slimeventloopmgr = HiveSlimEventLoopMgr(
55  SchedulerName="AvalancheSchedulerSvc", OutputLevel=DEBUG)
56 
57 # -------------------------------------------------------------------------------
58 
59 # ForwardScheduler -------------------------------------------------------------
60 # We just decide how many algorithms in flight we want to have and how many
61 # threads in the pool. The default value is -1, which is for TBB equivalent
62 # to take over the whole machine.
63 
64 scheduler = AvalancheSchedulerSvc(
65  ThreadPoolSize=threads, OutputLevel=INFO, VerboseSubSlots=True)
66 
67 # -------------------------------------------------------------------------------
68 
69 # Algo Resource Pool -----------------------------------------------------------
70 # Nothing special here, we just set the debug level.
71 AlgResourcePool(OutputLevel=DEBUG)
72 
73 # -------------------------------------------------------------------------------
74 
75 # Set up of the crunchers, daily business --------------------------------------
76 
77 a1 = Test__ViewTester("A1")
78 a1.baseViewName = 'viewOne'
79 a1.viewNumber = viewsPerEvt
80 a1.viewNodeName = 'viewNodeOne'
81 
82 a2 = Test__ViewTester("A2")
83 a2.viewNodeName = ''
84 a2.outKeys = ['/Event/a2']
85 
86 a3 = Test__ViewTester("A3")
87 a3.viewNodeName = ''
88 a3.inpKeys = ['/Event/a2'
89  ] # Should be able to load a2 from the shared sub-slot
90 
91 a4 = Test__ViewTester("A4")
92 a4.baseViewName = 'viewTwo'
93 a4.viewNumber = viewsPerEvt
94 a4.viewNodeName = 'viewNodeTwo'
95 a4.outKeys = ['/Event/a4']
96 
97 a5 = Test__ViewTester("A5")
98 a5.viewNodeName = ''
99 a5.inpKeys = ['/Event/a4'
100  ] # Should not be able to load a4 from the "whole event" slot
101 
102 a6 = Test__ViewTester("A6")
103 a6.viewNodeName = ''
104 
105 a7 = Test__ViewTester("A7")
106 a7.viewNodeName = ''
107 
108 for algo in [a1, a2, a3, a4, a5, a6, a7]:
109  algo.Cardinality = cardinality
110  algo.OutputLevel = DEBUG
111 
112 viewNodeOne = GaudiSequencer(
113  "viewNodeOne", Members=[a2, a3], Sequential=False, ShortCircuit=False)
114 
115 viewNodeTwo = GaudiSequencer(
116  "viewNodeTwo", Members=[a5, a6], Sequential=False, ShortCircuit=False)
117 
118 createViewSeq = GaudiSequencer(
119  "createViewSeq",
120  Members=[a1, viewNodeOne, a4, viewNodeTwo, a7],
121  Sequential=True,
122  OutputLevel=VERBOSE)
123 
124 # Application Manager ----------------------------------------------------------
125 # We put everything together and change the type of message service
126 
128  EvtMax=evtMax,
129  EvtSel='NONE',
130  ExtSvc=[whiteboard],
131  EventLoop=slimeventloopmgr,
132  TopAlg=[createViewSeq],
133  MessageSvcType="InertMessageSvc")
134 
135 # -------------------------------------------------------------------------------
Gaudi.Configuration
Definition: Configuration.py:1
ApplicationMgr
Definition: ApplicationMgr.h:57