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