The Gaudi Framework  v30r3 (a5ef0a68)
GaudiHive.precedence.CruncherSequence Class Reference
Inheritance diagram for GaudiHive.precedence.CruncherSequence:
Collaboration diagram for GaudiHive.precedence.CruncherSequence:

Public Member Functions

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

Public Attributes

 timeValue
 
 IOboolValue
 
 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 125 of file precedence.py.

Constructor & Destructor Documentation

def GaudiHive.precedence.CruncherSequence.__init__ (   self,
  timeValue,
  IOboolValue,
  sleepFraction,
  cfgPath,
  dfgPath,
  topSequencer,
  showStat = False,
  timeline = False,
  outputLevel = INFO 
)
Keyword arguments:
timeValue -- timeValue object to set algorithm execution time
IOboolValue -- *BooleanValue object to set whether an algorithm has to experience IO-bound 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 137 of file precedence.py.

137  showStat=False, timeline=False, outputLevel=INFO):
138  """
139  Keyword arguments:
140  timeValue -- timeValue object to set algorithm execution time
141  IOboolValue -- *BooleanValue object to set whether an algorithm has to experience IO-bound execution
142  cfgPath -- relative to $GAUDIHIVEROOT/data path to GRAPHML file with control flow dependencies
143  dfgPath -- relative to $GAUDIHIVEROOT/data path to GRAPHML file with data flow dependencies
144  showStat -- print out statistics on precedence graph
145  """
146 
147  self.timeValue = timeValue
148  self.IOboolValue = IOboolValue
149  self.sleepFraction = sleepFraction
150 
151  self.cfg = nx.read_graphml(_buildFilePath(cfgPath))
152  self.dfg = nx.read_graphml(_buildFilePath(dfgPath))
153 
154  self.enableTimeline = timeline
155 
156  self.outputLevel = outputLevel
157 
158  # Generate control flow part
159  self.sequencer = self._generate_sequence(topSequencer)
160 
161  if showStat:
162  import pprint
163 
164  print "\n===== Statistics on Algorithms ====="
165  print "Total number of algorithm nodes: ", len(
166  self.unique_algos) + sum([self.dupl_algos[i] - 1 for i in self.dupl_algos])
167  print "Number of unique algorithms: ", len(self.unique_algos)
168  print " -->", len(self.dupl_algos), "of them being re-used with the following distribution: ", [
169  self.dupl_algos[i] for i in self.dupl_algos]
170  # pprint.pprint(dupl_algos)
171 
172  print "\n===== Statistics on Sequencers ====="
173  print "Total number of sequencers: ", len(
174  self.unique_sequencers) + sum([self.dupl_seqs[i] - 1 for i in self.dupl_seqs])
175  print "Number of unique sequencers: ", len(self.unique_sequencers)
176  print " -->", len(self.dupl_seqs), "of them being re-used with the following distribution: ", [
177  self.dupl_seqs[i] for i in self.dupl_seqs]
178  # pprint.pprint(dupl_seqs)
179  print "Number of OR-sequencers: ", len(self.OR_sequencers)
180 
181  print "\n===== Statistics on DataObjects ====="
182  print "Number of unique DataObjects: ", len(
183  self.unique_data_objects)
184  # pprint.pprint(self.unique_data_objects)
185  print
186 
def _generate_sequence(self, name, seq=None)
Definition: precedence.py:212
double sum(double x, double y, double z)
def _buildFilePath(filePath)
Definition: precedence.py:12

Member Function Documentation

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

Definition at line 191 of file precedence.py.

191  def _declare_data_deps(self, algo_name, algo):
192  """ Declare data inputs and outputs for a given algorithm. """
193 
194  # Declare data inputs
195  for inNode, outNode in self.dfg.in_edges(algo_name):
196  dataName = inNode
197  if dataName not in self.unique_data_objects:
198  self.unique_data_objects.append(dataName)
199 
200  if dataName not in algo.inpKeys:
201  algo.inpKeys.append(dataName)
202 
203  # Declare data outputs
204  for inNode, outNode in self.dfg.out_edges(algo_name):
205  dataName = outNode
206  if dataName not in self.unique_data_objects:
207  self.unique_data_objects.append(dataName)
208 
209  if dataName not in algo.outKeys:
210  algo.outKeys.append(dataName)
211 
def _declare_data_deps(self, algo_name, algo)
Definition: precedence.py:191
def GaudiHive.precedence.CruncherSequence._generate_sequence (   self,
  name,
  seq = None 
)
private
Assemble the tree of sequencers. 

Definition at line 212 of file precedence.py.

212  def _generate_sequence(self, name, seq=None):
213  """ Assemble the tree of sequencers. """
214 
215  if not seq:
216  seq = GaudiSequencer(name, ShortCircuit=False)
217 
218  for n in self.cfg[name]:
219  if '/' in n:
220  algo_type, algo_name = n.split('/')
221  else:
222  algo_type = 'GaudiAlgorithm'
223  algo_name = n
224 
225  if algo_type in ['GaudiSequencer', 'AthSequencer', 'ProcessPhase']:
226  if algo_name in ['RecoITSeq', 'RecoOTSeq', 'RecoTTSeq']:
227  continue
228 
229  if n not in self.unique_sequencers:
230  self.unique_sequencers.append(n)
231  else:
232  if n not in self.dupl_seqs:
233  self.dupl_seqs[n] = 2
234  else:
235  self.dupl_seqs[n] += 1
236 
237  seq_daughter = GaudiSequencer(algo_name, OutputLevel=INFO)
238  if self.cfg.node[n].get('ModeOR') == 'True':
239  self.OR_sequencers.append(n)
240  seq_daughter.ModeOR = True
241  # if self.cfg.node[n].get('Lazy') == 'False':
242  # print "Non-Lazy - ", n
243  seq_daughter.ShortCircuit = False
244  if seq_daughter not in seq.Members:
245  seq.Members += [seq_daughter]
246  # iterate deeper
247  self._generate_sequence(n, seq_daughter)
248  else:
249  #rndname = ''.join(random.choice(string.lowercase) for i in range(5))
250  #if algo_name in unique_algos: algo_name = algo_name + "-" + rndname
251  if n not in self.unique_algos:
252  self.unique_algos.append(n)
253  else:
254  if n not in self.dupl_algos:
255  self.dupl_algos[n] = 2
256  else:
257  self.dupl_algos[n] += 1
258 
259  avgRuntime, varRuntime = self.timeValue.get(algo_name)
260  algo_daughter = CPUCruncher(algo_name,
261  OutputLevel=self.outputLevel,
262  shortCalib=True,
263  varRuntime=varRuntime,
264  avgRuntime=avgRuntime,
265  SleepFraction=self.sleepFraction if self.IOboolValue.get() else 0.,
266  Timeline=self.enableTimeline)
267 
268  self._declare_data_deps(algo_name, algo_daughter)
269 
270  if algo_daughter not in seq.Members:
271  seq.Members += [algo_daughter]
272 
273  return seq
def GaudiHive.precedence.CruncherSequence.get (   self)

Definition at line 187 of file precedence.py.

187  def get(self):
188 
189  return self.sequencer
190 

Member Data Documentation

GaudiHive.precedence.CruncherSequence.cfg

Definition at line 151 of file precedence.py.

GaudiHive.precedence.CruncherSequence.dfg

Definition at line 152 of file precedence.py.

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

Definition at line 132 of file precedence.py.

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

Definition at line 129 of file precedence.py.

GaudiHive.precedence.CruncherSequence.enableTimeline

Definition at line 154 of file precedence.py.

GaudiHive.precedence.CruncherSequence.IOboolValue

Definition at line 148 of file precedence.py.

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

Definition at line 130 of file precedence.py.

GaudiHive.precedence.CruncherSequence.outputLevel

Definition at line 156 of file precedence.py.

GaudiHive.precedence.CruncherSequence.sequencer

Definition at line 159 of file precedence.py.

GaudiHive.precedence.CruncherSequence.sleepFraction

Definition at line 149 of file precedence.py.

GaudiHive.precedence.CruncherSequence.timeValue

Definition at line 147 of file precedence.py.

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

Definition at line 131 of file precedence.py.

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

Definition at line 134 of file precedence.py.

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

Definition at line 128 of file precedence.py.


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