| The Gaudi Framework v28r2-patches (bc4ad17a)

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