The Gaudi Framework  v36r2 (27905625)
CFinViewTest.py
Go to the documentation of this file.
1 #!/usr/bin/env gaudirun.py
2 
12 '''
13 A test for control flow scheduling within sub-event contexts.
14 The sub-event control flow node has a child node attached.
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 Six 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  - Algorithms B1 and B2 run within the sub-event contexts,
23  on a child control flow node
24  - Algorithm A4 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 = 'view'
77 a1.viewNumber = viewsPerEvt
78 a1.viewNodeName = 'viewNode'
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.viewNodeName = ''
88 
89 b1 = Test__ViewTester("B1")
90 b1.viewNodeName = ''
91 
92 b2 = Test__ViewTester("B2")
93 b2.viewNodeName = ''
94 
95 for algo in [a1, a2, a3, a4, b1, b2]:
96  algo.Cardinality = cardinality
97  algo.OutputLevel = DEBUG
98 
99 nodeInView = GaudiSequencer(
100  "nodeInView", Members=[b1, b2], Sequential=False, OutputLevel=VERBOSE)
101 
102 viewNode = GaudiSequencer(
103  "viewNode",
104  Members=[a2, nodeInView, a3],
105  Sequential=False,
106  OutputLevel=VERBOSE)
107 
108 createViewSeq = GaudiSequencer(
109  "createViewSeq",
110  Members=[a1, viewNode, a4],
111  Sequential=True,
112  OutputLevel=VERBOSE)
113 
114 # Application Manager ----------------------------------------------------------
115 # We put everything together and change the type of message service
116 
118  EvtMax=evtMax,
119  EvtSel='NONE',
120  ExtSvc=[whiteboard],
121  EventLoop=slimeventloopmgr,
122  TopAlg=[createViewSeq],
123  MessageSvcType="InertMessageSvc")
124 
125 # -------------------------------------------------------------------------------
Gaudi.Configuration
Definition: Configuration.py:1
ApplicationMgr
Definition: ApplicationMgr.h:57