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, algoDebug=False)
 
def get (self)
 

Public Attributes

 timeValue
 
 IOboolValue
 
 sleepFraction
 
 cfg
 
 dfg
 
 algoDebug
 
 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 114 of file precedence.py.

Constructor & Destructor Documentation

def GaudiHive.precedence.CruncherSequence.__init__ (   self,
  timeValue,
  IOboolValue,
  sleepFraction,
  cfgPath,
  dfgPath,
  topSequencer,
  showStat = False,
  algoDebug = False 
)
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 125 of file precedence.py.

125  def __init__(self, timeValue, IOboolValue, sleepFraction, cfgPath, dfgPath, topSequencer, showStat=False, algoDebug = False):
126  """
127  Keyword arguments:
128  timeValue -- timeValue object to set algorithm execution time
129  IOboolValue -- *BooleanValue object to set whether an algorithm has to experience IO-bound execution
130  cfgPath -- relative to $GAUDIHIVEROOT/data path to GRAPHML file with control flow dependencies
131  dfgPath -- relative to $GAUDIHIVEROOT/data path to GRAPHML file with data flow dependencies
132  showStat -- print out statistics on precedence graph
133  """
134 
135  self.timeValue = timeValue
136  self.IOboolValue = IOboolValue
137  self.sleepFraction = sleepFraction
138 
139  self.cfg = nx.read_graphml(_buildFilePath(cfgPath))
140  self.dfg = nx.read_graphml(_buildFilePath(dfgPath))
141 
142  self.algoDebug = algoDebug
143 
144  # Generate control flow part
145  self.sequencer = self._generate_sequence(topSequencer)
146 
147  if showStat:
148  import pprint
149 
150  print "\n===== Statistics on Algorithms ====="
151  print "Total number of algorithm nodes: ", len(self.unique_algos) + sum([self.dupl_algos[i]-1 for i in self.dupl_algos])
152  print "Number of unique algorithms: ", len(self.unique_algos)
153  print " -->", len(self.dupl_algos), "of them being re-used with the following distribution: ", [self.dupl_algos[i] for i in self.dupl_algos]
154  #pprint.pprint(dupl_algos)
155 
156  print "\n===== Statistics on Sequencers ====="
157  print "Total number of sequencers: ", len(self.unique_sequencers) + sum([self.dupl_seqs[i]-1 for i in self.dupl_seqs])
158  print "Number of unique sequencers: ", len(self.unique_sequencers)
159  print " -->", len(self.dupl_seqs), "of them being re-used with the following distribution: ", [self.dupl_seqs[i] for i in self.dupl_seqs]
160  #pprint.pprint(dupl_seqs)
161  print "Number of OR-sequencers: ", len(self.OR_sequencers)
162 
163  print "\n===== Statistics on DataObjects ====="
164  print "Number of unique DataObjects: ", len(self.unique_data_objects)
165  #pprint.pprint(self.unique_data_objects)
166  print
167 
def __init__(self, timeValue, IOboolValue, sleepFraction, cfgPath, dfgPath, topSequencer, showStat=False, algoDebug=False)
Definition: precedence.py:125
def _generate_sequence(self, name, seq=None)
Definition: precedence.py:191
double sum(double x, double y, double z)
def _buildFilePath(filePath)
Definition: precedence.py:8

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

172  def _declare_data_deps(self, algo_name, algo):
173  """ Declare data inputs and outputs for a given algorithm. """
174 
175  # Declare data inputs
176  for inNode, outNode in self.dfg.in_edges(algo_name):
177  dataName = inNode
178  if dataName not in self.unique_data_objects:
179  self.unique_data_objects.append(dataName)
180 
181  algo.inpKeys.append(dataName)
182 
183  # Declare data outputs
184  for inNode, outNode in self.dfg.out_edges(algo_name):
185  dataName = outNode
186  if dataName not in self.unique_data_objects:
187  self.unique_data_objects.append(dataName)
188  algo.outKeys.append(dataName)
189 
190 
def _declare_data_deps(self, algo_name, algo)
Definition: precedence.py:172
def GaudiHive.precedence.CruncherSequence._generate_sequence (   self,
  name,
  seq = None 
)
private
Assemble the tree of sequencers. 

Definition at line 191 of file precedence.py.

191  def _generate_sequence(self, name, seq=None):
192  """ Assemble the tree of sequencers. """
193 
194  if not seq:
195  seq = GaudiSequencer(name, ShortCircuit = False)
196 
197  for n in self.cfg[name]:
198  if '/' in n:
199  algo_type, algo_name = n.split('/')
200  else:
201  algo_type = 'GaudiAlgorithm'
202  algo_name = n
203 
204  if algo_type in ['GaudiSequencer', 'AthSequencer', 'ProcessPhase']:
205  if algo_name in ['RecoITSeq','RecoOTSeq','RecoTTSeq']: continue
206 
207  if n not in self.unique_sequencers:
208  self.unique_sequencers.append(n)
209  else:
210  if n not in self.dupl_seqs: self.dupl_seqs[n] = 2
211  else: self.dupl_seqs[n] += 1
212 
213  seq_daughter=GaudiSequencer(algo_name, OutputLevel=INFO )
214  if self.cfg.node[n].get('ModeOR') == 'True':
215  self.OR_sequencers.append(n)
216  seq_daughter.ModeOR = True
217  #if self.cfg.node[n].get('Lazy') == 'False':
218  # print "Non-Lazy - ", n
219  seq_daughter.ShortCircuit = False
220  if seq_daughter not in seq.Members:
221  seq.Members += [seq_daughter]
222  # iterate deeper
223  self._generate_sequence(n,seq_daughter)
224  else:
225  #rndname = ''.join(random.choice(string.lowercase) for i in range(5))
226  #if algo_name in unique_algos: algo_name = algo_name + "-" + rndname
227  if n not in self.unique_algos:
228  self.unique_algos.append(n)
229  else:
230  if n not in self.dupl_algos: self.dupl_algos[n] = 2
231  else: self.dupl_algos[n] += 1
232 
233  avgRuntime, varRuntime = self.timeValue.get(algo_name)
234  algo_daughter = CPUCruncher(algo_name,
235  OutputLevel = DEBUG if self.algoDebug else INFO,
236  shortCalib = True,
237  varRuntime = varRuntime,
238  avgRuntime = avgRuntime,
239  SleepFraction = self.sleepFraction if self.IOboolValue.get() else 0.)
240 
241  self._declare_data_deps(algo_name, algo_daughter)
242 
243  if algo_daughter not in seq.Members:
244  seq.Members += [algo_daughter]
245 
246  return seq
def GaudiHive.precedence.CruncherSequence.get (   self)

Definition at line 168 of file precedence.py.

168  def get(self):
169 
170  return self.sequencer
171 

Member Data Documentation

GaudiHive.precedence.CruncherSequence.algoDebug

Definition at line 142 of file precedence.py.

GaudiHive.precedence.CruncherSequence.cfg

Definition at line 139 of file precedence.py.

GaudiHive.precedence.CruncherSequence.dfg

Definition at line 140 of file precedence.py.

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

Definition at line 121 of file precedence.py.

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

Definition at line 118 of file precedence.py.

GaudiHive.precedence.CruncherSequence.IOboolValue

Definition at line 136 of file precedence.py.

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

Definition at line 119 of file precedence.py.

GaudiHive.precedence.CruncherSequence.sequencer

Definition at line 145 of file precedence.py.

GaudiHive.precedence.CruncherSequence.sleepFraction

Definition at line 137 of file precedence.py.

GaudiHive.precedence.CruncherSequence.timeValue

Definition at line 135 of file precedence.py.

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

Definition at line 120 of file precedence.py.

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

Definition at line 123 of file precedence.py.

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

Definition at line 117 of file precedence.py.


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