CMSSWScenario.py
Go to the documentation of this file.
1 import json
2 from Gaudi.Configuration import *
3 # ============================================================================
4 from Configurables import GaudiExamplesCommonConf, CPUCruncher,HiveEventLoopMgr
5 #GaudiExamplesCommonConf()
6 # ============================================================================
7 
8 #-------------------------------------------------------------------------------
9 # Metaconfig
10 
11 NUMBEROFEVENTS = 1
12 NUMBEROFEVENTSINFLIGHT = 1
13 NUMBEROFALGOSINFLIGHT = 1000
14 NUMBEROFTHREADS = 1
15 CLONEALGOS = False
16 DUMPQUEUES = False
17 VERBOSITY = 3
18 
19 
20 NumberOfEvents = NUMBEROFEVENTS
21 NumberOfEventsInFlight = NUMBEROFEVENTSINFLIGHT
22 NumberOfAlgosInFlight = NUMBEROFALGOSINFLIGHT
23 NumberOfThreads = NUMBEROFTHREADS
24 CloneAlgos = CLONEALGOS
25 DumpQueues = DUMPQUEUES
26 Verbosity = VERBOSITY
27 
28 
29 def load_CMSSW_scenario(filename):
30  data = open(filename).read()
31  workflow = eval(data)
32  cpu_cruncher_algos = []
33  cpu_cruncher_algos_inputs = []
34  all_outputs = set()
35  all_inputs = set()
36  for algo in workflow["process"]["producers"]:
37  # in the next two lines replace the slash as that is a reserved character in the data store
38  inputs = [ item["label"].replace("/","_") for item in algo["toGet"] ]
39  outputs = [algo["@label"].replace("/","_"),]
40  new_algo = CPUCruncher(algo["@label"],
41  avgRuntime=float(algo["eventTimes"][0]),
42  DataInputs = inputs,
43  DataOutputs = outputs
44  )
45 
46  cpu_cruncher_algos.append(new_algo)
47  all_outputs.update(outputs)
48  all_inputs.update(inputs)
49  cpu_cruncher_algos_inputs.append(inputs)
50 
51  #look for the objects that haven't been provided within the job. Assume this needs to come via input
52  new_algo = CPUCruncher("input",
53  avgRuntime=1,
54  DataInputs=[],
55  DataOutputs=[item for item in all_inputs.difference(all_outputs)]
56  )
57  cpu_cruncher_algos.append(new_algo)
58  cpu_cruncher_algos_inputs.append([])
59 
60  print [item for item in all_inputs.difference(all_outputs)]
61  return cpu_cruncher_algos,cpu_cruncher_algos_inputs
62 
63 # Set output level threshold 2=DEBUG, 3=INFO, 4=WARNING, 5=ERROR, 6=FATAL )
64 ms = MessageSvc()
65 ms.OutputLevel = Verbosity
66 
67 crunchers,inputs = load_CMSSW_scenario("CMS_multijet.json")
68 
69 # Setup the Event Loop Manager
70 evtloop = HiveEventLoopMgr()
71 evtloop.MaxAlgosParallel = NumberOfAlgosInFlight
72 evtloop.MaxEventsParallel = NumberOfEventsInFlight
73 evtloop.NumThreads = NumberOfThreads
74 evtloop.CloneAlgorithms = CloneAlgos
75 evtloop.DumpQueues = DumpQueues
76 evtloop.AlgosDependencies = inputs
77 
78 # And the Application Manager
80 app.TopAlg = crunchers
81 app.EvtSel = "NONE" # do not use any event input
82 app.EvtMax = NumberOfEvents
83 app.EventLoop = evtloop
84 #app.MessageSvcType = "TBBMessageSvc"
85 
86 
def load_CMSSW_scenario(filename)
The Application Manager class.