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