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