The Gaudi Framework  master (594c33fa)
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 166 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 177 of file precedence.py.

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

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

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

◆ _generate_sequence()

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

Definition at line 275 of file precedence.py.

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

◆ get()

def GaudiHive.precedence.CruncherSequence.get (   self)

Definition at line 251 of file precedence.py.

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

Member Data Documentation

◆ BlockingBoolValue

GaudiHive.precedence.CruncherSequence.BlockingBoolValue

Definition at line 189 of file precedence.py.

◆ cardinality

GaudiHive.precedence.CruncherSequence.cardinality

Definition at line 187 of file precedence.py.

◆ cfg

GaudiHive.precedence.CruncherSequence.cfg

Definition at line 192 of file precedence.py.

◆ dfg

GaudiHive.precedence.CruncherSequence.dfg

Definition at line 193 of file precedence.py.

◆ dupl_algos

GaudiHive.precedence.CruncherSequence.dupl_algos
static

Definition at line 173 of file precedence.py.

◆ dupl_seqs

GaudiHive.precedence.CruncherSequence.dupl_seqs
static

Definition at line 170 of file precedence.py.

◆ enableTimeline

GaudiHive.precedence.CruncherSequence.enableTimeline

Definition at line 195 of file precedence.py.

◆ OR_sequencers

GaudiHive.precedence.CruncherSequence.OR_sequencers
static

Definition at line 171 of file precedence.py.

◆ outputLevel

GaudiHive.precedence.CruncherSequence.outputLevel

Definition at line 197 of file precedence.py.

◆ sequencer

GaudiHive.precedence.CruncherSequence.sequencer

Definition at line 200 of file precedence.py.

◆ sleepFraction

GaudiHive.precedence.CruncherSequence.sleepFraction

Definition at line 190 of file precedence.py.

◆ timeValue

GaudiHive.precedence.CruncherSequence.timeValue

Definition at line 188 of file precedence.py.

◆ unique_algos

GaudiHive.precedence.CruncherSequence.unique_algos
static

Definition at line 172 of file precedence.py.

◆ unique_data_objects

GaudiHive.precedence.CruncherSequence.unique_data_objects
static

Definition at line 175 of file precedence.py.

◆ unique_sequencers

GaudiHive.precedence.CruncherSequence.unique_sequencers
static

Definition at line 169 of file precedence.py.


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