The Gaudi Framework  v41r0 (bdbe7744)
Loading...
Searching...
No Matches
precedence.CruncherSequence Class Reference

Public Member Functions

 __init__ (self, timeValue, BlockingBoolValue, sleepFraction, cfgPath, dfgPath, topSequencer, showStat=False, timeline=False, outputLevel=INFO, cardinality=1)
 get (self)

Public Attributes

 cardinality = cardinality
 timeValue = timeValue
 BlockingBoolValue = BlockingBoolValue
 sleepFraction = sleepFraction
 cfg = nx.read_graphml(_buildFilePath(cfgPath))
 dfg = nx.read_graphml(_buildFilePath(dfgPath))
 enableTimeline = timeline
 outputLevel = outputLevel
 sequencer = self._generate_sequence(topSequencer)

Static Public Attributes

list unique_sequencers = []
dict dupl_seqs = {}
list OR_sequencers = []
list unique_algos = []
dict dupl_algos = {}
list unique_data_objects = []

Protected Member Functions

 _declare_data_deps (self, algo_name, algo)
 _generate_sequence (self, name, seq=None)

Detailed Description

Constructs the sequence tree of CPUCrunchers with provided control flow and data flow precedence rules.

Definition at line 164 of file precedence.py.

Constructor & Destructor Documentation

◆ __init__()

precedence.CruncherSequence.__init__ ( self,
timeValue,
BlockingBoolValue,
sleepFraction,
cfgPath,
dfgPath,
topSequencer,
showStat = False,
timeline = False,
outputLevel = INFO,
cardinality = 1 )
Keyword arguments:
timeValue -- timeValue object to set algorithm execution time
BlockingBoolValue -- *BooleanValue object to set whether an algorithm has to experience CPU-blocking execution
cfgPath -- relative to $ENV_PROJECT_SOURCE_DIR/GaudiHive/data path to GRAPHML file with control flow dependencies
dfgPath -- relative to $ENV_PROJECT_SOURCE_DIR/GaudiHive/data path to GRAPHML file with data flow dependencies
showStat -- print out statistics on precedence graph

Definition at line 175 of file precedence.py.

187 ):
188 """
189 Keyword arguments:
190 timeValue -- timeValue object to set algorithm execution time
191 BlockingBoolValue -- *BooleanValue object to set whether an algorithm has to experience CPU-blocking execution
192 cfgPath -- relative to $ENV_PROJECT_SOURCE_DIR/GaudiHive/data path to GRAPHML file with control flow dependencies
193 dfgPath -- relative to $ENV_PROJECT_SOURCE_DIR/GaudiHive/data path to GRAPHML file with data flow dependencies
194 showStat -- print out statistics on precedence graph
195 """
196
197 self.cardinality = cardinality
198 self.timeValue = timeValue
199 self.BlockingBoolValue = BlockingBoolValue
200 self.sleepFraction = sleepFraction
201
202 self.cfg = nx.read_graphml(_buildFilePath(cfgPath))
203 self.dfg = nx.read_graphml(_buildFilePath(dfgPath))
204
205 self.enableTimeline = timeline
206
207 self.outputLevel = outputLevel
208
209 # Generate control flow part
210 self.sequencer = self._generate_sequence(topSequencer)
211
212 if showStat:
213 print("\n===== Statistics on Algorithms =====")
214 print(
215 "Total number of algorithm nodes: ",
216 len(self.unique_algos)
217 + sum([self.dupl_algos[i] - 1 for i in self.dupl_algos]),
218 )
219 print("Number of unique algorithms: ", len(self.unique_algos))
220 print(
221 " -->",
222 len(self.dupl_algos),
223 "of them being re-used with the following distribution: ",
224 [self.dupl_algos[i] for i in self.dupl_algos],
225 )
226 # pprint.pprint(dupl_algos)
227
228 print("\n===== Statistics on Sequencers =====")
229 print(
230 "Total number of sequencers: ",
231 len(self.unique_sequencers)
232 + sum([self.dupl_seqs[i] - 1 for i in self.dupl_seqs]),
233 )
234 print("Number of unique sequencers: ", len(self.unique_sequencers))
235 print(
236 " -->",
237 len(self.dupl_seqs),
238 "of them being re-used with the following distribution: ",
239 [self.dupl_seqs[i] for i in self.dupl_seqs],
240 )
241 # pprint.pprint(dupl_seqs)
242 print("Number of OR-sequencers: ", len(self.OR_sequencers))
243
244 print("\n===== Statistics on DataObjects =====")
245 print("Number of unique DataObjects: ", len(self.unique_data_objects))
246 # pprint.pprint(self.unique_data_objects)
247 print()
248

Member Function Documentation

◆ _declare_data_deps()

precedence.CruncherSequence._declare_data_deps ( self,
algo_name,
algo )
protected
Declare data inputs and outputs for a given algorithm.

Definition at line 252 of file precedence.py.

252 def _declare_data_deps(self, algo_name, algo):
253 """Declare data inputs and outputs for a given algorithm."""
254
255 # Declare data inputs
256 for inNode, outNode in self.dfg.in_edges(algo_name):
257 dataName = inNode
258 if dataName not in self.unique_data_objects:
259 self.unique_data_objects.append(dataName)
260
261 if dataName not in algo.inpKeys:
262 algo.inpKeys.append(dataName)
263
264 # Declare data outputs
265 for inNode, outNode in self.dfg.out_edges(algo_name):
266 dataName = outNode
267 if dataName not in self.unique_data_objects:
268 self.unique_data_objects.append(dataName)
269
270 if dataName not in algo.outKeys:
271 algo.outKeys.append(dataName)
272

◆ _generate_sequence()

precedence.CruncherSequence._generate_sequence ( self,
name,
seq = None )
protected
Assemble the tree of sequencers.

Definition at line 273 of file precedence.py.

273 def _generate_sequence(self, name, seq=None):
274 """Assemble the tree of sequencers."""
275
276 if not seq:
277 seq = Gaudi__Sequencer(name, ShortCircuit=False)
278
279 for n in self.cfg[name]:
280 # extract entity name and type
281 algo_name = n.split("/")[1] if "/" in n else n
282
283 if "type" in self.cfg.nodes[n]:
284 # first rely on explicit type, if given
285 algo_type = self.cfg.nodes[n].get("type")
286 else:
287 # if the type is not given explicitly, try to extract it from entity name,
288 # and, if unsuccessful, assume it is an algorithm
289 algo_type = n.split("/")[0] if "/" in n else "Algorithm"
290
291 if algo_type in ["GaudiSequencer", "AthSequencer", "ProcessPhase"]:
292 if algo_name in ["RecoITSeq", "RecoOTSeq", "RecoTTSeq"]:
293 continue
294
295 if n not in self.unique_sequencers:
296 self.unique_sequencers.append(n)
297 else:
298 if n not in self.dupl_seqs:
299 self.dupl_seqs[n] = 2
300 else:
301 self.dupl_seqs[n] += 1
302
303 seq_daughter = Gaudi__Sequencer(algo_name, OutputLevel=INFO)
304 if self.cfg.nodes[n].get("ModeOR") == "True":
305 self.OR_sequencers.append(n)
306 seq_daughter.ModeOR = True
307 # if self.cfg.nodes[n].get('Lazy') == 'False':
308 # print "Non-Lazy - ", n
309 seq_daughter.ShortCircuit = False
310 if seq_daughter not in seq.Members:
311 seq.Members += [seq_daughter]
312 # iterate deeper
313 self._generate_sequence(n, seq_daughter)
314 else:
315 # rndname = ''.join(random.choice(string.lowercase) for i in range(5))
316 # if algo_name in unique_algos: algo_name = algo_name + "-" + rndname
317 if n not in self.unique_algos:
318 self.unique_algos.append(n)
319 else:
320 if n not in self.dupl_algos:
321 self.dupl_algos[n] = 2
322 else:
323 self.dupl_algos[n] += 1
324
325 avgRuntime, varRuntime = self.timeValue.get(algo_name)
326
327 algo_daughter = CPUCruncher(
328 algo_name,
329 Cardinality=self.cardinality,
330 OutputLevel=self.outputLevel,
331 varRuntime=varRuntime,
332 avgRuntime=avgRuntime,
333 SleepFraction=self.sleepFraction
334 if self.BlockingBoolValue.get()
335 else 0.0,
336 Timeline=self.enableTimeline,
337 )
338
339 self._declare_data_deps(algo_name, algo_daughter)
340
341 if algo_daughter not in seq.Members:
342 seq.Members += [algo_daughter]
343
344 return seq
A class that implements a search for prime numbers.
Definition CPUCruncher.h:30

◆ get()

precedence.CruncherSequence.get ( self)

Definition at line 249 of file precedence.py.

249 def get(self):
250 return self.sequencer
251

Member Data Documentation

◆ BlockingBoolValue

precedence.CruncherSequence.BlockingBoolValue = BlockingBoolValue

Definition at line 199 of file precedence.py.

◆ cardinality

precedence.CruncherSequence.cardinality = cardinality

Definition at line 197 of file precedence.py.

◆ cfg

precedence.CruncherSequence.cfg = nx.read_graphml(_buildFilePath(cfgPath))

Definition at line 202 of file precedence.py.

◆ dfg

precedence.CruncherSequence.dfg = nx.read_graphml(_buildFilePath(dfgPath))

Definition at line 203 of file precedence.py.

◆ dupl_algos

precedence.CruncherSequence.dupl_algos = {}
static

Definition at line 171 of file precedence.py.

◆ dupl_seqs

precedence.CruncherSequence.dupl_seqs = {}
static

Definition at line 168 of file precedence.py.

◆ enableTimeline

precedence.CruncherSequence.enableTimeline = timeline

Definition at line 205 of file precedence.py.

◆ OR_sequencers

precedence.CruncherSequence.OR_sequencers = []
static

Definition at line 169 of file precedence.py.

◆ outputLevel

precedence.CruncherSequence.outputLevel = outputLevel

Definition at line 207 of file precedence.py.

◆ sequencer

precedence.CruncherSequence.sequencer = self._generate_sequence(topSequencer)

Definition at line 210 of file precedence.py.

◆ sleepFraction

precedence.CruncherSequence.sleepFraction = sleepFraction

Definition at line 200 of file precedence.py.

◆ timeValue

precedence.CruncherSequence.timeValue = timeValue

Definition at line 198 of file precedence.py.

◆ unique_algos

precedence.CruncherSequence.unique_algos = []
static

Definition at line 170 of file precedence.py.

◆ unique_data_objects

precedence.CruncherSequence.unique_data_objects = []
static

Definition at line 173 of file precedence.py.

◆ unique_sequencers

precedence.CruncherSequence.unique_sequencers = []
static

Definition at line 167 of file precedence.py.


The documentation for this class was generated from the following file: