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