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