The Gaudi Framework  v36r7 (7f57a304)
GaudiHive.precedence.CruncherSequence Class Reference
Inheritance diagram for GaudiHive.precedence.CruncherSequence:
Collaboration diagram for GaudiHive.precedence.CruncherSequence:

Public Member Functions

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

Public Attributes

 cardinality
 
 timeValue
 
 BlockingBoolValue
 
 sleepFraction
 
 cfg
 
 dfg
 
 enableTimeline
 
 outputLevel
 
 sequencer
 

Static Public Attributes

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

Private Member Functions

def _declare_data_deps (self, algo_name, algo)
 
def _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 175 of file precedence.py.

Constructor & Destructor Documentation

◆ __init__()

def GaudiHive.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 186 of file precedence.py.

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

Member Function Documentation

◆ _declare_data_deps()

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

Definition at line 266 of file precedence.py.

266  def _declare_data_deps(self, algo_name, algo):
267  """Declare data inputs and outputs for a given algorithm."""
268 
269  # Declare data inputs
270  for inNode, outNode in self.dfg.in_edges(algo_name):
271  dataName = inNode
272  if dataName not in self.unique_data_objects:
273  self.unique_data_objects.append(dataName)
274 
275  if dataName not in algo.inpKeys:
276  algo.inpKeys.append(dataName)
277 
278  # Declare data outputs
279  for inNode, outNode in self.dfg.out_edges(algo_name):
280  dataName = outNode
281  if dataName not in self.unique_data_objects:
282  self.unique_data_objects.append(dataName)
283 
284  if dataName not in algo.outKeys:
285  algo.outKeys.append(dataName)
286 

◆ _generate_sequence()

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

Definition at line 287 of file precedence.py.

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

◆ get()

def GaudiHive.precedence.CruncherSequence.get (   self)

Definition at line 262 of file precedence.py.

262  def get(self):
263 
264  return self.sequencer
265 

Member Data Documentation

◆ BlockingBoolValue

GaudiHive.precedence.CruncherSequence.BlockingBoolValue

Definition at line 198 of file precedence.py.

◆ cardinality

GaudiHive.precedence.CruncherSequence.cardinality

Definition at line 196 of file precedence.py.

◆ cfg

GaudiHive.precedence.CruncherSequence.cfg

Definition at line 201 of file precedence.py.

◆ dfg

GaudiHive.precedence.CruncherSequence.dfg

Definition at line 202 of file precedence.py.

◆ dupl_algos

dictionary GaudiHive.precedence.CruncherSequence.dupl_algos = {}
static

Definition at line 182 of file precedence.py.

◆ dupl_seqs

dictionary GaudiHive.precedence.CruncherSequence.dupl_seqs = {}
static

Definition at line 179 of file precedence.py.

◆ enableTimeline

GaudiHive.precedence.CruncherSequence.enableTimeline

Definition at line 204 of file precedence.py.

◆ OR_sequencers

list GaudiHive.precedence.CruncherSequence.OR_sequencers = []
static

Definition at line 180 of file precedence.py.

◆ outputLevel

GaudiHive.precedence.CruncherSequence.outputLevel

Definition at line 206 of file precedence.py.

◆ sequencer

GaudiHive.precedence.CruncherSequence.sequencer

Definition at line 209 of file precedence.py.

◆ sleepFraction

GaudiHive.precedence.CruncherSequence.sleepFraction

Definition at line 199 of file precedence.py.

◆ timeValue

GaudiHive.precedence.CruncherSequence.timeValue

Definition at line 197 of file precedence.py.

◆ unique_algos

list GaudiHive.precedence.CruncherSequence.unique_algos = []
static

Definition at line 181 of file precedence.py.

◆ unique_data_objects

list GaudiHive.precedence.CruncherSequence.unique_data_objects = []
static

Definition at line 184 of file precedence.py.

◆ unique_sequencers

list GaudiHive.precedence.CruncherSequence.unique_sequencers = []
static

Definition at line 178 of file precedence.py.


The documentation for this class was generated from the following file:
GaudiHive.precedence._buildFilePath
def _buildFilePath(filePath)
Definition: precedence.py:29
CPUCruncher
Definition: CPUCruncher.h:29
Gaudi::Functional::details::get
auto get(const Handle &handle, const Algo &, const EventContext &) -> decltype(details::deref(handle.get()))
Definition: FunctionalDetails.h:444
GaudiSequencer
Definition: GaudiSequencer.h:38