Loading [MathJax]/extensions/tex2jax.js
The Gaudi Framework  v38r0 (2143aa4c)
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
ManySmallAlgs.py
Go to the documentation of this file.
1 #!/usr/bin/env gaudirun.py
2 
12 """
13 A totally synthetic test of scheduler performance, with a large number of CF nodes and algorithms, but each algorithm does no work.
14 
15 In the flat mode (nested=False) 1000 algorithms are added directly to the base CF node as a baseline measurement.
16 
17 In nested mode the algorithms are grouped into sets of under a parent CF node.
18 Those nodes are then given 2 different CF node parents (20 in total) which include a prescale algorithm.
19 
20 In sequential mode (sequence=True) the prescale algorithms will randomly deactivate CF nodes at a frequency given by filterPass
21 """
22 from Configurables import AlgResourcePool, AvalancheSchedulerSvc
23 from Configurables import Gaudi__Examples__Prescaler as Prescaler
24 from Configurables import Gaudi__Sequencer, HiveSlimEventLoopMgr, HiveWhiteBoard
25 from Gaudi.Configuration import *
26 
27 # metaconfig -------------------------------------------------------------------
28 # It's confortable to collect the relevant parameters at the top of the optionfile
29 evtslots = 5
30 evtMax = 1000
31 cardinality = 10
32 threads = 5
33 nested = True
34 sequence = True
35 filterPass = 50.0
36 
37 # -------------------------------------------------------------------------------
38 
39 # The configuration of the whiteboard ------------------------------------------
40 # It is useful to call it EventDataSvc to replace the usual data service with
41 # the whiteboard transparently.
42 
43 whiteboard = HiveWhiteBoard("EventDataSvc", EventSlots=evtslots, OutputLevel=FATAL)
44 
45 # -------------------------------------------------------------------------------
46 
47 # Event Loop Manager -----------------------------------------------------------
48 # It's called slim since it has less functionalities overall than the good-old
49 # event loop manager. Here we just set its outputlevel to DEBUG.
50 
51 slimeventloopmgr = HiveSlimEventLoopMgr(
52  SchedulerName="AvalancheSchedulerSvc", OutputLevel=INFO
53 )
54 
55 # -------------------------------------------------------------------------------
56 
57 # ForwardScheduler -------------------------------------------------------------
58 # We just decide how many algorithms in flight we want to have and how many
59 # threads in the pool. The default value is -1, which is for TBB equivalent
60 # to take over the whole machine.
61 
62 scheduler = AvalancheSchedulerSvc(
63  ThreadPoolSize=threads,
64  ShowControlFlow=False,
65  ShowDataDependencies=False,
66  OutputLevel=INFO,
67 )
68 
69 # -------------------------------------------------------------------------------
70 
71 # Algo Resource Pool -----------------------------------------------------------
72 # Nothing special here, we just set the debug level.
73 AlgResourcePool(OutputLevel=FATAL)
74 
75 # -------------------------------------------------------------------------------
76 
77 # Flat structure
78 allAlgs = []
79 for i in range(1000):
80  alg = Prescaler("alg" + str(i))
81  alg.OutputLevel = FATAL
82  alg.Cardinality = cardinality
83  alg.PercentPass = 100.0
84  allAlgs.append(alg)
85 
86 baseSeq = Gaudi__Sequencer(
87  "baseSeq",
88  Members=allAlgs,
89  Sequential=sequence,
90  ModeOR=True,
91  ShortCircuit=False,
92  OutputLevel=FATAL,
93 )
94 
95 # Nested structure
96 allSeqs = []
97 allSeqSeqs = []
98 if nested:
99  for i in range(100):
100  seqAlgs = allAlgs[10 * i : 10 * (i + 1)]
101  seq = Gaudi__Sequencer(
102  "seq" + str(i),
103  Members=seqAlgs,
104  Sequential=sequence,
105  ModeOR=False,
106  ShortCircuit=True,
107  OutputLevel=FATAL,
108  )
109  allSeqs.append(seq)
110 
111  for i in range(10):
112  seqSeqs = allSeqs[10 * i : 10 * (i + 1)]
113 
114  filterAlg = Prescaler("filterAlg" + str(i))
115  filterAlg.OutputLevel = FATAL
116  filterAlg.Cardinality = cardinality
117  filterAlg.PercentPass = filterPass
118 
119  seq = Gaudi__Sequencer(
120  "seqSeq" + str(i),
121  Members=[filterAlg] + seqSeqs,
122  Sequential=sequence,
123  ModeOR=False,
124  ShortCircuit=True,
125  OutputLevel=FATAL,
126  )
127  allSeqSeqs.append(seq)
128 
129  for i in range(9):
130  seqSeqs = allSeqs[5 + (10 * i) : 15 + (10 * i)]
131 
132  filterAlg = Prescaler("filterAlg" + str(i + 10))
133  filterAlg.OutputLevel = FATAL
134  filterAlg.Cardinality = cardinality
135  filterAlg.PercentPass = filterPass
136 
137  seq = Gaudi__Sequencer(
138  "seqSeq" + str(i + 10),
139  Members=[filterAlg] + seqSeqs,
140  Sequential=sequence,
141  ModeOR=False,
142  ShortCircuit=True,
143  OutputLevel=FATAL,
144  )
145  allSeqSeqs.append(seq)
146 
147  baseSeq.Members = allSeqSeqs
148 
149 # Application Manager ----------------------------------------------------------
150 # We put everything together and change the type of message service
151 
153  EvtMax=evtMax,
154  EvtSel="NONE",
155  ExtSvc=[whiteboard],
156  EventLoop=slimeventloopmgr,
157  TopAlg=[baseSeq],
158  MessageSvcType="InertMessageSvc",
159 )
160 
161 # -------------------------------------------------------------------------------
Gaudi.Configuration
Definition: Configuration.py:1
ApplicationMgr
Definition: ApplicationMgr.h:57
Prescaler
Definition: Prescaler.h:15
Gaudi::Functional::details::zip::range
decltype(auto) range(Args &&... args)
Zips multiple containers together to form a single range.
Definition: details.h:98