9 from Configurables
import GaudiSequencer, CPUCruncher
14 if not os.path.exists(filePath):
15 __fullFilePath__ = os.path.realpath(os.path.join(
16 os.environ.get(
'GAUDIHIVEROOT',
''),
"data", filePath))
17 if not os.path.exists(__fullFilePath__):
18 print "\nERROR: invalid file path '%s'. It must be either absolute, or relative to '$GAUDIHIVEROOT/data/'." % filePath
21 __fullFilePath__ = filePath
23 return __fullFilePath__
27 """A class to manage uniform algorithm timing""" 34 def get(self, algoName=''):
35 """Get time and its variance (in a tuple) for a given algorithm name""" 41 """A class to manage real algorithm timing""" 43 def __init__(self, path, defaultTime, factor=1):
45 defaultTime -- run time, assigned to an algorithm if no time is found in provided timing library 46 (and it will also be scaled by the 'factor' argument) 57 def get(self, algoName=''):
58 """Get time for a given algorithm name""" 61 time = float(self.
timings[algoName])
63 capAlgoName = algoName[0].upper() + algoName[1:len(algoName)]
66 time = float(self.
timings[capAlgoName])
69 print "WARNING: TimiNg for %s (or %s) not found in the provided library, using default one: %s" % (
70 algoName, capAlgoName, time)
90 Provides randomly distributed boolean value with True taking only 10%. 91 The distribution has only 276 values and is reproducible, if no pattern re-generation is requested. 95 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,
96 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]
101 if useBuiltinPattern:
106 249)] + [
True for i
in range(29)]
126 """Constructs the sequence tree of CPUCrunchers with provided control flow and data flow precedence rules.""" 128 unique_sequencers = []
134 unique_data_objects = []
136 def __init__(self, timeValue, IOboolValue, sleepFraction, cfgPath, dfgPath, topSequencer,
137 showStat=
False, timeline=
False, outputLevel=INFO):
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 164 print "\n===== Statistics on Algorithms =====" 165 print "Total number of algorithm nodes: ", len(
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: ", [
172 print "\n===== Statistics on Sequencers =====" 173 print "Total number of sequencers: ", len(
176 print " -->", len(self.
dupl_seqs),
"of them being re-used with the following distribution: ", [
181 print "\n===== Statistics on DataObjects =====" 182 print "Number of unique DataObjects: ", len(
192 """ Declare data inputs and outputs for a given algorithm. """ 195 for inNode, outNode
in self.dfg.in_edges(algo_name):
198 self.unique_data_objects.append(dataName)
200 if dataName
not in algo.inpKeys:
201 algo.inpKeys.append(dataName)
204 for inNode, outNode
in self.dfg.out_edges(algo_name):
207 self.unique_data_objects.append(dataName)
209 if dataName
not in algo.outKeys:
210 algo.outKeys.append(dataName)
213 """ Assemble the tree of sequencers. """ 216 seq = GaudiSequencer(name, ShortCircuit=
False)
218 for n
in self.
cfg[name]:
220 algo_type, algo_name = n.split(
'/')
222 algo_type =
'GaudiAlgorithm' 225 if algo_type
in [
'GaudiSequencer',
'AthSequencer',
'ProcessPhase']:
226 if algo_name
in [
'RecoITSeq',
'RecoOTSeq',
'RecoTTSeq']:
230 self.unique_sequencers.append(n)
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 243 seq_daughter.ShortCircuit =
False 244 if seq_daughter
not in seq.Members:
245 seq.Members += [seq_daughter]
252 self.unique_algos.append(n)
259 avgRuntime, varRuntime = self.timeValue.get(algo_name)
260 algo_daughter = CPUCruncher(algo_name,
263 varRuntime=varRuntime,
264 avgRuntime=avgRuntime,
265 SleepFraction=self.
sleepFraction if self.IOboolValue.get()
else 0.,
270 if algo_daughter
not in seq.Members:
271 seq.Members += [algo_daughter]
def _create_generator(self, pattern)
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='')
def __init__(self, timeValue, IOboolValue, sleepFraction, cfgPath, dfgPath, topSequencer, showStat=False, timeline=False, outputLevel=INFO)
def __init__(self, useBuiltinPattern=True)
decltype(auto) range(Args &&...args)
Zips multiple containers together to form a single range.
def _declare_data_deps(self, algo_name, algo)
def _buildFilePath(filePath)