The Gaudi Framework  v36r10 (fc05264c)
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 (
23  AlgResourcePool,
24  AvalancheSchedulerSvc,
25  GaudiSequencer,
26  HiveSlimEventLoopMgr,
27  HiveWhiteBoard,
28  Prescaler,
29  Test__ViewTester,
30 )
31 from Gaudi.Configuration import *
32 
33 # metaconfig -------------------------------------------------------------------
34 # It's confortable to collect the relevant parameters at the top of the optionfile
35 evtslots = 5
36 evtMax = 1000
37 cardinality = 10
38 threads = 5
39 nested = True
40 sequence = True
41 filterPass = 50.0
42 
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, OutputLevel=FATAL)
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(
69  ThreadPoolSize=threads,
70  ShowControlFlow=False,
71  ShowDataDependencies=False,
72  OutputLevel=INFO,
73 )
74 
75 # -------------------------------------------------------------------------------
76 
77 # Algo Resource Pool -----------------------------------------------------------
78 # Nothing special here, we just set the debug level.
79 AlgResourcePool(OutputLevel=FATAL)
80 
81 # -------------------------------------------------------------------------------
82 
83 # Flat structure
84 allAlgs = []
85 for i in range(1000):
86  alg = Prescaler("alg" + str(i))
87  alg.OutputLevel = FATAL
88  alg.Cardinality = cardinality
89  alg.PercentPass = 100.0
90  allAlgs.append(alg)
91 
92 baseSeq = GaudiSequencer(
93  "baseSeq",
94  Members=allAlgs,
95  Sequential=sequence,
96  ModeOR=True,
97  ShortCircuit=False,
98  OutputLevel=FATAL,
99 )
100 
101 # Nested structure
102 allSeqs = []
103 allSeqSeqs = []
104 if nested:
105  for i in range(100):
106  seqAlgs = allAlgs[10 * i : 10 * (i + 1)]
107  seq = GaudiSequencer(
108  "seq" + str(i),
109  Members=seqAlgs,
110  Sequential=sequence,
111  ModeOR=False,
112  ShortCircuit=True,
113  OutputLevel=FATAL,
114  )
115  allSeqs.append(seq)
116 
117  for i in range(10):
118  seqSeqs = allSeqs[10 * i : 10 * (i + 1)]
119 
120  filterAlg = Prescaler("filterAlg" + str(i))
121  filterAlg.OutputLevel = FATAL
122  filterAlg.Cardinality = cardinality
123  filterAlg.PercentPass = filterPass
124 
125  seq = GaudiSequencer(
126  "seqSeq" + str(i),
127  Members=[filterAlg] + seqSeqs,
128  Sequential=sequence,
129  ModeOR=False,
130  ShortCircuit=True,
131  OutputLevel=FATAL,
132  )
133  allSeqSeqs.append(seq)
134 
135  for i in range(9):
136  seqSeqs = allSeqs[5 + (10 * i) : 15 + (10 * i)]
137 
138  filterAlg = Prescaler("filterAlg" + str(i + 10))
139  filterAlg.OutputLevel = FATAL
140  filterAlg.Cardinality = cardinality
141  filterAlg.PercentPass = filterPass
142 
143  seq = GaudiSequencer(
144  "seqSeq" + str(i + 10),
145  Members=[filterAlg] + seqSeqs,
146  Sequential=sequence,
147  ModeOR=False,
148  ShortCircuit=True,
149  OutputLevel=FATAL,
150  )
151  allSeqSeqs.append(seq)
152 
153  baseSeq.Members = allSeqSeqs
154 
155 # Application Manager ----------------------------------------------------------
156 # We put everything together and change the type of message service
157 
159  EvtMax=evtMax,
160  EvtSel="NONE",
161  ExtSvc=[whiteboard],
162  EventLoop=slimeventloopmgr,
163  TopAlg=[baseSeq],
164  MessageSvcType="InertMessageSvc",
165 )
166 
167 # -------------------------------------------------------------------------------
Gaudi.Configuration
Definition: Configuration.py:1
ApplicationMgr
Definition: ApplicationMgr.h:57
Gaudi::Functional::details::zip::range
decltype(auto) range(Args &&... args)
Zips multiple containers together to form a single range.
Definition: FunctionalDetails.h:102