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