| The Gaudi Framework v27r1

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

BrunelScenarioForwardScheduler.py
Go to the documentation of this file.
1 from Gaudi.Configuration import *
2 from Configurables import GaudiExamplesCommonConf, CPUCruncher, HiveSlimEventLoopMgr, HiveWhiteBoard, ForwardSchedulerSvc
3
4 #-------------------------------------------------------------------------------
5 # Metaconfig
6
7 NUMBEROFEVENTS = 23
8 NUMBEROFEVENTSINFLIGHT = 7
9 NUMBEROFALGOSINFLIGHT = 11
10 CARDINALITY=11
11 SCALE = .1
12 VERBOSITY = 5
13
14 NumberOfEvents = NUMBEROFEVENTS
15 NumberOfEventsInFlight = NUMBEROFEVENTSINFLIGHT
16 NumberOfAlgosInFlight = NUMBEROFALGOSINFLIGHT
17 Cardinality = CARDINALITY
18 Scale = SCALE
19 Verbosity = VERBOSITY
20
21
22
23 #-------------------------------------------------------------------------------
24
25
26 def load_brunel_scenario(filename):
27 algs = {}
28 timing = {}
29 objs = []
30 curr = None
31 order = 0
32 nodes = ('/Event', '/Event/Rec', '/Event/DAQ')
33 for l in open(filename).readlines():
34 if l.find('StoreTracer') == 0:
35 if l.find('Executing Algorithm') != -1:
36 alg = l.split()[-1]
37 if alg not in algs.keys() : algs[alg] = (order, set(),set())
38 curr = alg
39 order += 1
40 elif l.find('Done with Algorithm') != -1:
41 curr = None
42 elif l.find('[EventDataSvc]') != -1 and curr:
43 obj = l.split()[-1]
44 if obj in nodes : continue
45 if obj.find('/Event/') == 0 : obj = obj[7:]
46 obj = obj.replace('/','_')
47 if obj not in objs : objs.append(obj)
48 talg = algs[curr]
49 if l.find('RETRIEVE') != -1:
50 if obj not in talg[1] : talg[1].add(obj)
51 elif l.find('REGOBJ') != -1:
52 if obj not in talg[2] : talg[2].add(obj)
53 if l.find("TimingAuditor") != -1:
54 algo = l.split()[2]#.rstrip("|")
55 index = 13
56 if algo.endswith("|"):
57 index = 12
58 algo = algo.rstrip("|")
59 if algo in algs.keys():
60 timing[algo] = l.split()[index]
61 else:
62 for name in algs.keys():
63 if name.startswith(algo):
64 timing[name] = l.split()[index]
65
66 all_inputs = set()
67 all_outputs = set()
68 all_algos = []
69 all_algos_inputs = []
70
71 #Scale all algo timings if needed
72 if Scale!=-1:
73 for alg in timing.keys():
74 old_timing = float(timing[alg])
75 new_timing = old_timing*Scale;
76 #print "Algorithm %s: %f --> %f" %(alg, old_timing, new_timing)
77 timing[alg]=new_timing
78
79 for i, (alg,deps) in enumerate(algs.items()):
80 if alg in ["PatPVOffline","PrsADCs"]: continue
81 if deps[1] or deps[2] :
82 inputs = []
83 inputs = [item for item in deps[1] if item not in ("DAQ_ODIN","DAQ_RawEvent") and item not in deps[2]]
84 outputs = [item for item in deps[2]]
85 new_algo = CPUCruncher(alg,
86 avgRuntime=float(timing[alg]),
87 DataInputs=map( lambda s: "/Event/"+s, inputs),
88 DataOutputs=map( lambda s: "/Event/"+s, outputs),
89 OutputLevel = 6,
90 shortCalib=True
91 )
92
93 for item in deps[1]:
94 all_inputs.add(item)
95 for item in deps[2]:
96 all_outputs.add(item)
97 all_algos.append(new_algo)
98 all_algos_inputs.append(inputs)
99 #look for the objects that haven't been provided within the job. Assume this needs to come via input
100 new_algo = CPUCruncher("input",
101 avgRuntime=1,
102 DataInputs=[],
103 OutputLevel = WARNING,
104 DataOutputs=map( lambda s: "/Event/"+s, [item for item in all_inputs.difference(all_outputs)])
105 )
106 all_algos.append(new_algo)
107 all_algos_inputs.append([])
108 for algo in all_algos:
109 algo.Cardinality=Cardinality
110 OutputLevel = WARNING
111
112 return all_algos,all_algos_inputs
113
114
115 # Set output level threshold 2=DEBUG, 3=INFO, 4=WARNING, 5=ERROR, 6=FATAL )
116 ms = MessageSvc()
117 ms.OutputLevel = Verbosity
118
119 crunchers,inputs = load_brunel_scenario("Brunel.TES.trace.log")
120
121 whiteboard = HiveWhiteBoard("EventDataSvc",
122 EventSlots = NumberOfEventsInFlight)
123
124 slimeventloopmgr = HiveSlimEventLoopMgr(OutputLevel = INFO)
125
126 scheduler = ForwardSchedulerSvc(MaxEventsInFlight = NumberOfEventsInFlight,
127 MaxAlgosInFlight = NumberOfAlgosInFlight,
128 OutputLevel = WARNING,
129 AlgosDependencies = inputs)
130
131 # And the Application Manager
132 app = ApplicationMgr()
133 app.TopAlg = crunchers
134 app.EvtSel = "NONE" # do not use any event input
135 app.EvtMax = NumberOfEvents
136 app.EventLoop = slimeventloopmgr
137 app.ExtSvc =[whiteboard]
138 app.MessageSvcType = "TBBMessageSvc"
139
140
Gaudi.Configuration
Definition: Configuration.py:1
GaudiPython.Persistency.add
def add(instance)
Definition: Persistency.py:32
Containers::map
struct GAUDI_API map
Parametrisation class for map-like implementation.
Definition: KeyedObjectManager.h:25
ApplicationMgr
The Application Manager class.
Definition: ApplicationMgr.h:46
BrunelScenarioForwardScheduler.load_brunel_scenario
def load_brunel_scenario(filename)
Definition: BrunelScenarioForwardScheduler.py:26
MessageSvc
Definition: MessageSvc.h:30
CPUCruncher
Definition: CPUCruncher.py:1