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