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" % (algoName, capAlgoName, time)
89 Provides randomly distributed boolean value with True taking only 10%. 90 The distribution has only 276 values and is reproducible, if no pattern re-generation is requested. 94 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,
95 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]
100 if useBuiltinPattern:
105 249)] + [
True for i
in range(29)]
125 """Constructs the sequence tree of CPUCrunchers with provided control flow and data flow precedence rules.""" 127 unique_sequencers = []
133 unique_data_objects = []
135 def __init__(self, timeValue, IOboolValue, sleepFraction, cfgPath, dfgPath, topSequencer,
136 showStat=
False, timeline=
False, outputLevel=INFO):
139 timeValue -- timeValue object to set algorithm execution time 140 IOboolValue -- *BooleanValue object to set whether an algorithm has to experience IO-bound execution 141 cfgPath -- relative to $GAUDIHIVEROOT/data path to GRAPHML file with control flow dependencies 142 dfgPath -- relative to $GAUDIHIVEROOT/data path to GRAPHML file with data flow dependencies 143 showStat -- print out statistics on precedence graph 163 print "\n===== Statistics on Algorithms =====" 165 print "Number of unique algorithms: ", len(self.
unique_algos)
169 print "\n===== Statistics on Sequencers =====" 172 print " -->", len(self.
dupl_seqs),
"of them being re-used with the following distribution: ", [self.
dupl_seqs[i]
for i
in self.
dupl_seqs]
176 print "\n===== Statistics on DataObjects =====" 186 """ Declare data inputs and outputs for a given algorithm. """ 189 for inNode, outNode
in self.dfg.in_edges(algo_name):
192 self.unique_data_objects.append(dataName)
194 if dataName
not in algo.inpKeys:
195 algo.inpKeys.append(dataName)
198 for inNode, outNode
in self.dfg.out_edges(algo_name):
201 self.unique_data_objects.append(dataName)
203 if dataName
not in algo.outKeys:
204 algo.outKeys.append(dataName)
207 """ Assemble the tree of sequencers. """ 210 seq = GaudiSequencer(name, ShortCircuit=
False)
212 for n
in self.
cfg[name]:
214 algo_type, algo_name = n.split(
'/')
216 algo_type =
'GaudiAlgorithm' 219 if algo_type
in [
'GaudiSequencer',
'AthSequencer',
'ProcessPhase']:
220 if algo_name
in [
'RecoITSeq',
'RecoOTSeq',
'RecoTTSeq']:
224 self.unique_sequencers.append(n)
231 seq_daughter = GaudiSequencer(algo_name, OutputLevel=INFO)
232 if self.cfg.node[n].
get(
'ModeOR') ==
'True':
233 self.OR_sequencers.append(n)
234 seq_daughter.ModeOR =
True 237 seq_daughter.ShortCircuit =
False 238 if seq_daughter
not in seq.Members:
239 seq.Members += [seq_daughter]
246 self.unique_algos.append(n)
253 avgRuntime, varRuntime = self.timeValue.get(algo_name)
254 algo_daughter = CPUCruncher(algo_name,
257 varRuntime=varRuntime,
258 avgRuntime=avgRuntime,
259 SleepFraction=self.
sleepFraction if self.IOboolValue.get()
else 0.,
264 if algo_daughter
not in seq.Members:
265 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)