The Gaudi Framework  v38r0 (2143aa4c)
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

 unique_sequencers
 
 dupl_seqs
 
 OR_sequencers
 
 unique_algos
 
 dupl_algos
 
 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 165 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 176 of file precedence.py.

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

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 253 of file precedence.py.

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

◆ _generate_sequence()

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

Definition at line 274 of file precedence.py.

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

◆ get()

def GaudiHive.precedence.CruncherSequence.get (   self)

Definition at line 250 of file precedence.py.

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

Member Data Documentation

◆ BlockingBoolValue

GaudiHive.precedence.CruncherSequence.BlockingBoolValue

Definition at line 188 of file precedence.py.

◆ cardinality

GaudiHive.precedence.CruncherSequence.cardinality

Definition at line 186 of file precedence.py.

◆ cfg

GaudiHive.precedence.CruncherSequence.cfg

Definition at line 191 of file precedence.py.

◆ dfg

GaudiHive.precedence.CruncherSequence.dfg

Definition at line 192 of file precedence.py.

◆ dupl_algos

GaudiHive.precedence.CruncherSequence.dupl_algos
static

Definition at line 172 of file precedence.py.

◆ dupl_seqs

GaudiHive.precedence.CruncherSequence.dupl_seqs
static

Definition at line 169 of file precedence.py.

◆ enableTimeline

GaudiHive.precedence.CruncherSequence.enableTimeline

Definition at line 194 of file precedence.py.

◆ OR_sequencers

GaudiHive.precedence.CruncherSequence.OR_sequencers
static

Definition at line 170 of file precedence.py.

◆ outputLevel

GaudiHive.precedence.CruncherSequence.outputLevel

Definition at line 196 of file precedence.py.

◆ sequencer

GaudiHive.precedence.CruncherSequence.sequencer

Definition at line 199 of file precedence.py.

◆ sleepFraction

GaudiHive.precedence.CruncherSequence.sleepFraction

Definition at line 189 of file precedence.py.

◆ timeValue

GaudiHive.precedence.CruncherSequence.timeValue

Definition at line 187 of file precedence.py.

◆ unique_algos

GaudiHive.precedence.CruncherSequence.unique_algos
static

Definition at line 171 of file precedence.py.

◆ unique_data_objects

GaudiHive.precedence.CruncherSequence.unique_data_objects
static

Definition at line 174 of file precedence.py.

◆ unique_sequencers

GaudiHive.precedence.CruncherSequence.unique_sequencers
static

Definition at line 168 of file precedence.py.


The documentation for this class was generated from the following file:
GaudiHive.precedence._buildFilePath
def _buildFilePath(filePath)
Definition: precedence.py:26
CPUCruncher
Definition: CPUCruncher.h:29
GaudiPartProp.decorators.get
get
decorate the vector of properties
Definition: decorators.py:282