The Gaudi Framework  v36r1 (3e2fb5a8)
brunelWrapper.py
Go to the documentation of this file.
1 #! /usr/bin/env python
2 
12 """
13 This script acts as a wrapper in order to generate Gaudi configs for running
14 with different parameters in order to perform performance measurements.
15 It takes command line arguments.
16 """
17 from __future__ import print_function
18 
19 import optparse
20 """
21 NumberOfEvents = 10
22 NumberOfEventsInFlight = 5
23 NumberOfAlgosInFlight = 5
24 NumberOfThreads = 10
25 CloneAlgos = False
26 DumpQueues = False
27 """
28 
29 
31  usage = "%prog [options]"
32  parser = optparse.OptionParser(usage)
33  parser.add_option('-n', help='Number of events', dest='nevts', default=15)
34  parser.add_option('--eif', help='Events in flight', dest='eif', default=5)
35  parser.add_option('--aif', help='Algos in flight', dest='aif', default=10)
36  parser.add_option(
37  '--nthreads', help='Number of threads', dest='nthreads', default=10)
38  parser.add_option(
39  '--clone',
40  help='Clone Algos',
41  dest='clone',
42  action='store_true',
43  default=False)
44  parser.add_option(
45  '--dumpQueues',
46  help='Dump Queues',
47  dest='dumpqueues',
48  action='store_true',
49  default=False)
50  parser.add_option(
51  '-v', help='Verbosity level', dest='verbosity', default=5)
52  parser.add_option(
53  '--exec',
54  help='ExecuteWorkflow',
55  dest='execbrunel',
56  action='store_true',
57  default=False)
58  parser.add_option(
59  '--bg',
60  help='Launch in background',
61  dest='bg',
62  action='store_true',
63  default=False)
64  parser.add_option(
65  '--scale', help='Scale Algorithms time', dest='scale', default=1)
66  options, args = parser.parse_args()
67  return options
68 
69 
70 def replaceValues(cfg_name, n, eif, aif, nthreads, scale, clone, dumpQueues,
71  verbosity):
72 
73  newcfglines = open(cfg_name, "r").readlines()
74  cfg_name = cfg_name.replace(".py", "")
75  verb = ""
76  if verbosity != 6:
77  verb = "_v%s" % verbosity
78  scale_s = ""
79  if scale != 1:
80  scale_s = "_s%s" % scale
81  newcfgname = "measurement_%s_n%s_eif%s_aif%s_nthreads%s_c%s_dq%s%s%s.py" % (
82  cfg_name, n, eif, aif, nthreads, clone, dumpQueues, scale_s, verb)
83  newcfg = open(newcfgname, "w")
84  for line in newcfglines:
85  if ('NumberOfEvents' in line and 'NUMBEROFEVENTS' in line
86  and not "FLIGHT" in line):
87  line = line.replace("NUMBEROFEVENTS", str(n))
88  if ('NumberOfEventsInFlight' in line
89  and 'NUMBEROFEVENTSINFLIGHT' in line):
90  line = line.replace("NUMBEROFEVENTSINFLIGHT", str(eif))
91  if ('NumberOfAlgosInFlight' in line
92  and 'NUMBEROFALGOSINFLIGHT' in line):
93  line = line.replace("NUMBEROFALGOSINFLIGHT", str(aif))
94  if ('NumberOfThreads' in line and 'NUMBEROFTHREADS' in line):
95  line = line.replace("NUMBEROFTHREADS", str(nthreads))
96  if ('DumpQueues' in line and 'DUMPQUEUES' in line):
97  line = line.replace("DUMPQUEUES", str(dumpQueues))
98  if ('CloneAlgos' in line and 'CLONEALGOS' in line):
99  line = line.replace("CLONEALGOS", str(clone))
100  if ('Verbosity' in line and 'VERBOSITY' in line):
101  line = line.replace("VERBOSITY", str(verbosity))
102  if ('Scale' in line and 'SCALE' in line):
103  line = line.replace("SCALE", str(scale))
104  newcfg.write(line)
105  newcfg.close()
106  return newcfgname
107 
108 
109 if __name__ == "__main__":
110  options = createParser()
111  newcfg = replaceValues("BrunelScenario.py", options.nevts,
112  options.eif, options.aif, options.nthreads,
113  float(options.scale), options.clone,
114  options.dumpqueues, options.verbosity)
115 
116  logfile = newcfg.replace(".py", ".log")
117  gaudirun = "`alias gaudirun`"
118  gaudirun = "/afs/cern.ch/user/d/dpiparo/Gaudi/build.x86_64-slc5-gcc46-opt/run gaudirun.py"
119  command = "/usr/bin/time -f %%S -o timing_%s %s %s >& %s " % (
120  logfile, gaudirun, newcfg, logfile)
121  if options.bg:
122  command += " &"
123 
124  print(command)
125  if options.execbrunel:
126  import os
127  os.system(command)
brunelWrapper.replaceValues
def replaceValues(cfg_name, n, eif, aif, nthreads, scale, clone, dumpQueues, verbosity)
Definition: brunelWrapper.py:70
brunelWrapper.createParser
def createParser()
Definition: brunelWrapper.py:30