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