The Gaudi Framework  master (ff829712)
Loading...
Searching...
No Matches
ViewThenViewTest.py
Go to the documentation of this file.
1#!/usr/bin/env gaudirun.py
2
12"""
13A test for scheduling multiple sub-event contexts.
14The main sequence has two steps of creating and running sub-events.
15
16The ViewTester is an algorithm specifically designed to create sub-event
17contexts, pass them to the scheduler, and report on the current context.
18
19Seven 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 creates two more sub-event contexts
23 - Algorithms A5 and A6 run within the new sub-event contexts
24 - Algorithm A7 runs in the whole event context, after the sub-events
25
26"""
27
28from Configurables import (
29 AlgResourcePool,
30 AvalancheSchedulerSvc,
31 CPUCruncher,
32 Gaudi__Sequencer,
33 HiveSlimEventLoopMgr,
34 HiveWhiteBoard,
35 Test__ViewTester,
36)
37from Gaudi.Configuration import *
38
39# metaconfig -------------------------------------------------------------------
40# It's confortable to collect the relevant parameters at the top of the optionfile
41evtslots = 1
42evtMax = 10
43cardinality = 1
44threads = 1
45viewsPerEvt = 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
52whiteboard = 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
60slimeventloopmgr = 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
71scheduler = AvalancheSchedulerSvc(ThreadPoolSize=threads, OutputLevel=INFO)
72
73# -------------------------------------------------------------------------------
74
75# Algo Resource Pool -----------------------------------------------------------
76# Nothing special here, we just set the debug level.
77AlgResourcePool(OutputLevel=DEBUG)
78
79# -------------------------------------------------------------------------------
80
81# Set up of the crunchers, daily business --------------------------------------
82
83a1 = Test__ViewTester("A1")
84a1.baseViewName = "viewOne"
85a1.viewNumber = viewsPerEvt
86a1.viewNodeName = "viewNodeOne"
87
88a2 = Test__ViewTester("A2")
89a2.viewNodeName = ""
90
91a3 = Test__ViewTester("A3")
92a3.viewNodeName = ""
93
94a4 = Test__ViewTester("A4")
95a4.baseViewName = "viewTwo"
96a4.viewNumber = viewsPerEvt
97a4.viewNodeName = "viewNodeTwo"
98
99a5 = Test__ViewTester("A5")
100a5.viewNodeName = ""
101
102a6 = Test__ViewTester("A6")
103a6.viewNodeName = ""
104
105a7 = Test__ViewTester("A7")
106a7.viewNodeName = ""
107
108for algo in [a1, a2, a3, a4, a5, a6, a7]:
109 algo.Cardinality = cardinality
110 algo.OutputLevel = DEBUG
111
112viewNodeOne = Gaudi__Sequencer(
113 "viewNodeOne", Members=[a2, a3], Sequential=False, OutputLevel=VERBOSE
114)
115
116viewNodeTwo = Gaudi__Sequencer(
117 "viewNodeTwo", Members=[a5, a6], Sequential=False, OutputLevel=VERBOSE
118)
119
120createViewSeq = Gaudi__Sequencer(
121 "createViewSeq",
122 Members=[a1, viewNodeOne, a4, viewNodeTwo, a7],
123 Sequential=True,
124 OutputLevel=VERBOSE,
125)
126
127# Application Manager ----------------------------------------------------------
128# We put everything together and change the type of message service
129
131 EvtMax=evtMax,
132 EvtSel="NONE",
133 ExtSvc=[whiteboard],
134 EventLoop=slimeventloopmgr,
135 TopAlg=[createViewSeq],
136 MessageSvcType="InertMessageSvc",
137)
138
139# -------------------------------------------------------------------------------
The AlgResourcePool is a concrete implementation of the IAlgResourcePool interface.
The Application Manager class.
Data service base class.