1 import os, sys, random, string, json
5 from Configurables
import GaudiSequencer, CPUCruncher
10 if not os.path.exists(filePath):
11 __fullFilePath__ = os.path.realpath(os.path.join(os.environ.get(
'GAUDIHIVEROOT',
''),
"data", filePath))
12 if not os.path.exists(__fullFilePath__):
13 print "\nERROR: invalid file path '%s'. It must be either absolute, or relative to '$GAUDIHIVEROOT/data/'." %filePath
16 __fullFilePath__ = filePath
18 return __fullFilePath__
21 """A class to manage uniform algorithm timing""" 23 def __init__(self, avgRuntime, varRuntime = 0):
28 def get(self, algoName = ''):
29 """Get time and its variance (in a tuple) for a given algorithm name""" 34 """A class to manage real algorithm timing""" 36 def __init__(self, path, defaultTime, factor = 1):
38 defaultTime -- run time, assigned to an algorithm if no time is found in provided timing library 39 (and it will also be scaled by the 'factor' argument) 51 def get(self, algoName = ''):
52 """Get time for a given algorithm name""" 55 time = float(self.
timings[algoName])
57 capAlgoName = algoName[0].upper() + algoName[1:len(algoName)]
60 time = float(self.
timings[capAlgoName])
63 print "WARNING: TimiNg for %s (or %s) not found in the provided library, using default one: %s" %(algoName,capAlgoName,time)
81 Provides randomly distributed boolean value with True taking only 10%. 82 The distribution has only 276 values and is reproducible, if no pattern re-generation is requested. 86 builtinPattern = [
True,
False,
False,
True,
False,
False,
False,
False,
False,
False,
False,
False,
False,
False,
False,
False,
True,
False,
False,
True,
False,
False,
False,
False,
False,
False,
False,
False,
False,
True,
False,
False,
False,
False,
False,
False,
False,
False,
False,
False,
False,
True,
False,
False,
False,
False,
False,
False,
False,
False,
True,
False,
False,
False,
False,
False,
False,
False,
False,
True,
False,
False,
False,
False,
False,
False,
False,
False,
False,
False,
False,
False,
False,
False,
True,
False,
True,
False,
True,
False,
False,
False,
False,
False,
False,
False,
False,
True,
False,
True,
False,
False,
True,
False,
False,
False,
False,
False,
False,
False,
False,
False,
False,
False,
False,
False,
False,
False,
False,
False,
False,
False,
False,
False,
False,
False,
False,
False,
False,
False,
True,
False,
False,
False,
False,
False,
False,
False,
False,
False,
True,
False,
False,
False,
False,
True,
True,
False,
False,
False,
False,
False,
False,
False,
False,
False,
False,
True,
True,
False,
True,
False,
False,
False,
False,
False,
False,
False,
False,
False,
False,
True,
False,
False,
False,
False,
False,
False,
False,
False,
False,
False,
False,
False,
False,
False,
False,
False,
False,
False,
False,
False,
False,
False,
False,
False,
False,
False,
False,
False,
False,
False,
False,
False,
False,
False,
False,
False,
False,
False,
True,
False,
False,
False,
False,
False,
False,
False,
False,
False,
False,
False,
False,
False,
False,
False,
False,
False,
False,
False,
False,
False,
False,
False,
False,
False,
True,
False,
False,
False,
False,
False,
False,
False,
False,
False,
False,
False,
True,
False,
False,
False,
False,
False,
False,
False,
False,
False,
False,
False,
True,
False,
False,
False,
True,
False,
False,
False,
False,
False,
False,
False,
False,
True,
False,
False,
False,
False,
False,
False,
False,
False,
False,
False,
False,
True,
False,
True]
115 """Constructs the sequence tree of CPUCrunchers with provided control flow and data flow precedence rules.""" 123 unique_data_objects = []
125 def __init__(self, timeValue, IOboolValue, sleepFraction, cfgPath, dfgPath, topSequencer, showStat=False, algoDebug = False):
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 150 print "\n===== Statistics on Algorithms =====" 152 print "Number of unique algorithms: ", len(self.
unique_algos)
156 print "\n===== Statistics on 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]
163 print "\n===== Statistics on DataObjects =====" 173 """ Declare data inputs and outputs for a given algorithm. """ 176 for inNode, outNode
in self.dfg.in_edges(algo_name):
179 self.unique_data_objects.append(dataName)
181 algo.inpKeys.append(dataName)
184 for inNode, outNode
in self.dfg.out_edges(algo_name):
187 self.unique_data_objects.append(dataName)
188 algo.outKeys.append(dataName)
192 """ Assemble the tree of sequencers. """ 195 seq = GaudiSequencer(name, ShortCircuit =
False)
197 for n
in self.
cfg[name]:
199 algo_type, algo_name = n.split(
'/')
201 algo_type =
'GaudiAlgorithm' 204 if algo_type
in [
'GaudiSequencer',
'AthSequencer',
'ProcessPhase']:
205 if algo_name
in [
'RecoITSeq',
'RecoOTSeq',
'RecoTTSeq']:
continue 208 self.unique_sequencers.append(n)
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 219 seq_daughter.ShortCircuit =
False 220 if seq_daughter
not in seq.Members:
221 seq.Members += [seq_daughter]
228 self.unique_algos.append(n)
233 avgRuntime, varRuntime = self.timeValue.get(algo_name)
234 algo_daughter = CPUCruncher(algo_name,
235 OutputLevel = DEBUG
if self.
algoDebug else INFO,
237 varRuntime = varRuntime,
238 avgRuntime = avgRuntime,
239 SleepFraction = self.
sleepFraction if self.IOboolValue.get()
else 0.)
243 if algo_daughter
not in seq.Members:
244 seq.Members += [algo_daughter]
def _create_generator(self, pattern)
def __init__(self, timeValue, IOboolValue, sleepFraction, cfgPath, dfgPath, topSequencer, showStat=False, algoDebug=False)
def __init__(self, path, defaultTime, factor=1)
def _generate_sequence(self, name, seq=None)
double sum(double x, double y, double z)
def get(self, algoName='')
NamedRange_< CONTAINER > range(const CONTAINER &cnt, std::string name)
simple function to create the named range form arbitrary container
def __init__(self, useBuiltinPattern=True)
def _declare_data_deps(self, algo_name, algo)
def _buildFilePath(filePath)