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, outputLevel = INFO):
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 if dataName
not in algo.inpKeys: algo.inpKeys.append(dataName)
184 for inNode, outNode
in self.dfg.out_edges(algo_name):
187 self.unique_data_objects.append(dataName)
189 if dataName
not in algo.outKeys: algo.outKeys.append(dataName)
193 """ Assemble the tree of sequencers. """ 196 seq = GaudiSequencer(name, ShortCircuit =
False)
198 for n
in self.
cfg[name]:
200 algo_type, algo_name = n.split(
'/')
202 algo_type =
'GaudiAlgorithm' 205 if algo_type
in [
'GaudiSequencer',
'AthSequencer',
'ProcessPhase']:
206 if algo_name
in [
'RecoITSeq',
'RecoOTSeq',
'RecoTTSeq']:
continue 209 self.unique_sequencers.append(n)
214 seq_daughter=GaudiSequencer(algo_name, OutputLevel=INFO )
215 if self.cfg.node[n].
get(
'ModeOR') ==
'True':
216 self.OR_sequencers.append(n)
217 seq_daughter.ModeOR =
True 220 seq_daughter.ShortCircuit =
False 221 if seq_daughter
not in seq.Members:
222 seq.Members += [seq_daughter]
229 self.unique_algos.append(n)
234 avgRuntime, varRuntime = self.timeValue.get(algo_name)
235 algo_daughter = CPUCruncher(algo_name,
238 varRuntime = varRuntime,
239 avgRuntime = avgRuntime,
240 SleepFraction = self.
sleepFraction if self.IOboolValue.get()
else 0.)
244 if algo_daughter
not in seq.Members:
245 seq.Members += [algo_daughter]
def _create_generator(self, pattern)
def __init__(self, path, defaultTime, factor=1)
def _generate_sequence(self, name, seq=None)
decltype(auto) range(Args &&...args)
Zips multiple containers together to form a single range.
double sum(double x, double y, double z)
def get(self, algoName='')
def __init__(self, timeValue, IOboolValue, sleepFraction, cfgPath, dfgPath, topSequencer, showStat=False, outputLevel=INFO)
def __init__(self, useBuiltinPattern=True)
def _declare_data_deps(self, algo_name, algo)
def _buildFilePath(filePath)