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