The Gaudi Framework  v33r2 (a6f0ec87)
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)
 
def get (self)
 

Public Attributes

 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 149 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 
)
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 $GAUDIHIVEROOT/data path to GRAPHML file with control flow dependencies
dfgPath -- relative to $GAUDIHIVEROOT/data path to GRAPHML file with data flow dependencies
showStat -- print out statistics on precedence graph

Definition at line 160 of file precedence.py.

160  def __init__(self,
161  timeValue,
162  BlockingBoolValue,
163  sleepFraction,
164  cfgPath,
165  dfgPath,
166  topSequencer,
167  showStat=False,
168  timeline=False,
169  outputLevel=INFO):
170  """
171  Keyword arguments:
172  timeValue -- timeValue object to set algorithm execution time
173  BlockingBoolValue -- *BooleanValue object to set whether an algorithm has to experience CPU-blocking execution
174  cfgPath -- relative to $GAUDIHIVEROOT/data path to GRAPHML file with control flow dependencies
175  dfgPath -- relative to $GAUDIHIVEROOT/data path to GRAPHML file with data flow dependencies
176  showStat -- print out statistics on precedence graph
177  """
178 
179  self.timeValue = timeValue
180  self.BlockingBoolValue = BlockingBoolValue
181  self.sleepFraction = sleepFraction
182 
183  self.cfg = nx.read_graphml(_buildFilePath(cfgPath))
184  self.dfg = nx.read_graphml(_buildFilePath(dfgPath))
185 
186  self.enableTimeline = timeline
187 
188  self.outputLevel = outputLevel
189 
190  # Generate control flow part
191  self.sequencer = self._generate_sequence(topSequencer)
192 
193  if showStat:
194  import pprint
195 
196  print("\n===== Statistics on Algorithms =====")
197  print(
198  "Total number of algorithm nodes: ",
199  len(self.unique_algos) + sum(
200  [self.dupl_algos[i] - 1 for i in self.dupl_algos]))
201  print("Number of unique algorithms: ", len(self.unique_algos))
202  print(" -->", len(self.dupl_algos),
203  "of them being re-used with the following distribution: ",
204  [self.dupl_algos[i] for i in self.dupl_algos])
205  # pprint.pprint(dupl_algos)
206 
207  print("\n===== Statistics on Sequencers =====")
208  print(
209  "Total number of sequencers: ",
210  len(self.unique_sequencers) + sum(
211  [self.dupl_seqs[i] - 1 for i in self.dupl_seqs]))
212  print("Number of unique sequencers: ", len(self.unique_sequencers))
213  print(" -->", len(self.dupl_seqs),
214  "of them being re-used with the following distribution: ",
215  [self.dupl_seqs[i] for i in self.dupl_seqs])
216  # pprint.pprint(dupl_seqs)
217  print("Number of OR-sequencers: ", len(self.OR_sequencers))
218 
219  print("\n===== Statistics on DataObjects =====")
220  print("Number of unique DataObjects: ",
221  len(self.unique_data_objects))
222  # pprint.pprint(self.unique_data_objects)
223  print()
224 
def _buildFilePath(filePath)
Definition: precedence.py:23

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

229  def _declare_data_deps(self, algo_name, algo):
230  """ Declare data inputs and outputs for a given algorithm. """
231 
232  # Declare data inputs
233  for inNode, outNode in self.dfg.in_edges(algo_name):
234  dataName = inNode
235  if dataName not in self.unique_data_objects:
236  self.unique_data_objects.append(dataName)
237 
238  if dataName not in algo.inpKeys:
239  algo.inpKeys.append(dataName)
240 
241  # Declare data outputs
242  for inNode, outNode in self.dfg.out_edges(algo_name):
243  dataName = outNode
244  if dataName not in self.unique_data_objects:
245  self.unique_data_objects.append(dataName)
246 
247  if dataName not in algo.outKeys:
248  algo.outKeys.append(dataName)
249 

◆ _generate_sequence()

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

Definition at line 250 of file precedence.py.

250  def _generate_sequence(self, name, seq=None):
251  """ Assemble the tree of sequencers. """
252 
253  if not seq:
254  seq = GaudiSequencer(name, ShortCircuit=False)
255 
256  for n in self.cfg[name]:
257  # extract entity name and type
258  algo_name = n.split('/')[1] if '/' in n else n
259 
260  if 'type' in self.cfg.node[n]:
261  # first rely on explicit type, if given
262  algo_type = self.cfg.node[n].get('type')
263  else:
264  # if the type is not given explicitly, try to extract it from entity name,
265  # and, if unsuccessful, assume it is an algorithm
266  algo_type = n.split('/')[0] if '/' in n else 'Algorithm'
267 
268  if algo_type in ['GaudiSequencer', 'AthSequencer', 'ProcessPhase']:
269  if algo_name in ['RecoITSeq', 'RecoOTSeq', 'RecoTTSeq']:
270  continue
271 
272  if n not in self.unique_sequencers:
273  self.unique_sequencers.append(n)
274  else:
275  if n not in self.dupl_seqs:
276  self.dupl_seqs[n] = 2
277  else:
278  self.dupl_seqs[n] += 1
279 
280  seq_daughter = GaudiSequencer(algo_name, OutputLevel=INFO)
281  if self.cfg.node[n].get('ModeOR') == 'True':
282  self.OR_sequencers.append(n)
283  seq_daughter.ModeOR = True
284  # if self.cfg.node[n].get('Lazy') == 'False':
285  # print "Non-Lazy - ", n
286  seq_daughter.ShortCircuit = False
287  if seq_daughter not in seq.Members:
288  seq.Members += [seq_daughter]
289  # iterate deeper
290  self._generate_sequence(n, seq_daughter)
291  else:
292  #rndname = ''.join(random.choice(string.lowercase) for i in range(5))
293  #if algo_name in unique_algos: algo_name = algo_name + "-" + rndname
294  if n not in self.unique_algos:
295  self.unique_algos.append(n)
296  else:
297  if n not in self.dupl_algos:
298  self.dupl_algos[n] = 2
299  else:
300  self.dupl_algos[n] += 1
301 
302  avgRuntime, varRuntime = self.timeValue.get(algo_name)
303 
304  algo_daughter = CPUCruncher(
305  algo_name,
306  OutputLevel=self.outputLevel,
307  varRuntime=varRuntime,
308  avgRuntime=avgRuntime,
309  SleepFraction=self.sleepFraction
310  if self.BlockingBoolValue.get() else 0.,
311  Timeline=self.enableTimeline)
312 
313  self._declare_data_deps(algo_name, algo_daughter)
314 
315  if algo_daughter not in seq.Members:
316  seq.Members += [algo_daughter]
317 
318  return seq
A class that implements a search for prime numbers.
Definition: CPUCruncher.h:29
Sequencer for executing several algorithms, stopping when one is faulty.
auto get(const Handle &handle, const Algo &, const EventContext &) -> decltype(details::deref(handle.get()))

◆ get()

def GaudiHive.precedence.CruncherSequence.get (   self)

Definition at line 225 of file precedence.py.

225  def get(self):
226 
227  return self.sequencer
228 
auto get(const Handle &handle, const Algo &, const EventContext &) -> decltype(details::deref(handle.get()))

Member Data Documentation

◆ BlockingBoolValue

GaudiHive.precedence.CruncherSequence.BlockingBoolValue

Definition at line 171 of file precedence.py.

◆ cfg

GaudiHive.precedence.CruncherSequence.cfg

Definition at line 174 of file precedence.py.

◆ dfg

GaudiHive.precedence.CruncherSequence.dfg

Definition at line 175 of file precedence.py.

◆ dupl_algos

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

Definition at line 156 of file precedence.py.

◆ dupl_seqs

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

Definition at line 153 of file precedence.py.

◆ enableTimeline

GaudiHive.precedence.CruncherSequence.enableTimeline

Definition at line 177 of file precedence.py.

◆ OR_sequencers

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

Definition at line 154 of file precedence.py.

◆ outputLevel

GaudiHive.precedence.CruncherSequence.outputLevel

Definition at line 179 of file precedence.py.

◆ sequencer

GaudiHive.precedence.CruncherSequence.sequencer

Definition at line 182 of file precedence.py.

◆ sleepFraction

GaudiHive.precedence.CruncherSequence.sleepFraction

Definition at line 172 of file precedence.py.

◆ timeValue

GaudiHive.precedence.CruncherSequence.timeValue

Definition at line 170 of file precedence.py.

◆ unique_algos

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

Definition at line 155 of file precedence.py.

◆ unique_data_objects

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

Definition at line 158 of file precedence.py.

◆ unique_sequencers

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

Definition at line 152 of file precedence.py.


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