The Gaudi Framework
master (bdbe7744)
Toggle main menu visibility
Loading...
Searching...
No Matches
brunelWrapper.py
Go to the documentation of this file.
1
#! /usr/bin/env python3
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
18
import
optparse
19
20
"""
21
NumberOfEvents = 10
22
NumberOfEventsInFlight = 5
23
NumberOfAlgosInFlight = 5
24
NumberOfThreads = 10
25
CloneAlgos = False
26
DumpQueues = False
27
"""
28
29
30
def
createParser
():
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
)
39
parser.add_option(
40
"--clone"
, help=
"Clone Algos"
, dest=
"clone"
, action=
"store_true"
, default=
False
41
)
42
parser.add_option(
43
"--dumpQueues"
,
44
help=
"Dump Queues"
,
45
dest=
"dumpqueues"
,
46
action=
"store_true"
,
47
default=
False
,
48
)
49
parser.add_option(
"-v"
, help=
"Verbosity level"
, dest=
"verbosity"
, default=5)
50
parser.add_option(
51
"--exec"
,
52
help=
"ExecuteWorkflow"
,
53
dest=
"execbrunel"
,
54
action=
"store_true"
,
55
default=
False
,
56
)
57
parser.add_option(
58
"--bg"
,
59
help=
"Launch in background"
,
60
dest=
"bg"
,
61
action=
"store_true"
,
62
default=
False
,
63
)
64
parser.add_option(
"--scale"
, help=
"Scale Algorithms time"
, dest=
"scale"
, default=1)
65
options, args = parser.parse_args()
66
return
options
67
68
69
def
replaceValues
(cfg_name, n, eif, aif, nthreads, scale, clone, dumpQueues, verbosity):
70
newcfglines = open(cfg_name).readlines()
71
cfg_name = cfg_name.replace(
".py"
,
""
)
72
verb =
""
73
if
verbosity != 6:
74
verb = f
"_v{verbosity}"
75
scale_s =
""
76
if
scale != 1:
77
scale_s = f
"_s{scale}"
78
newcfgname = f
"measurement_{cfg_name}_n{n}_eif{eif}_aif{aif}_nthreads{nthreads}_c{clone}_dq{dumpQueues}{scale_s}{verb}.py"
79
newcfg = open(newcfgname,
"w"
)
80
for
line
in
newcfglines:
81
if
(
82
"NumberOfEvents"
in
line
83
and
"NUMBEROFEVENTS"
in
line
84
and
"FLIGHT"
not
in
line
85
):
86
line = line.replace(
"NUMBEROFEVENTS"
, str(n))
87
if
"NumberOfEventsInFlight"
in
line
and
"NUMBEROFEVENTSINFLIGHT"
in
line:
88
line = line.replace(
"NUMBEROFEVENTSINFLIGHT"
, str(eif))
89
if
"NumberOfAlgosInFlight"
in
line
and
"NUMBEROFALGOSINFLIGHT"
in
line:
90
line = line.replace(
"NUMBEROFALGOSINFLIGHT"
, str(aif))
91
if
"NumberOfThreads"
in
line
and
"NUMBEROFTHREADS"
in
line:
92
line = line.replace(
"NUMBEROFTHREADS"
, str(nthreads))
93
if
"DumpQueues"
in
line
and
"DUMPQUEUES"
in
line:
94
line = line.replace(
"DUMPQUEUES"
, str(dumpQueues))
95
if
"CloneAlgos"
in
line
and
"CLONEALGOS"
in
line:
96
line = line.replace(
"CLONEALGOS"
, str(clone))
97
if
"Verbosity"
in
line
and
"VERBOSITY"
in
line:
98
line = line.replace(
"VERBOSITY"
, str(verbosity))
99
if
"Scale"
in
line
and
"SCALE"
in
line:
100
line = line.replace(
"SCALE"
, str(scale))
101
newcfg.write(line)
102
newcfg.close()
103
return
newcfgname
104
105
106
if
__name__ ==
"__main__"
:
107
options =
createParser
()
108
newcfg =
replaceValues
(
109
"BrunelScenario.py"
,
110
options.nevts,
111
options.eif,
112
options.aif,
113
options.nthreads,
114
float(options.scale),
115
options.clone,
116
options.dumpqueues,
117
options.verbosity,
118
)
119
120
logfile = newcfg.replace(
".py"
,
".log"
)
121
gaudirun =
"`alias gaudirun`"
122
gaudirun = (
123
"/afs/cern.ch/user/d/dpiparo/Gaudi/build.x86_64-slc5-gcc46-opt/run gaudirun.py"
124
)
125
command = (
126
f
"/usr/bin/time -f %S -o timing_{logfile} {gaudirun} {newcfg} >& {logfile} "
127
)
128
if
options.bg:
129
command +=
" &"
130
131
print(command)
132
if
options.execbrunel:
133
import
os
134
135
os.system(command)
brunelWrapper.replaceValues
replaceValues(cfg_name, n, eif, aif, nthreads, scale, clone, dumpQueues, verbosity)
Definition
brunelWrapper.py:69
brunelWrapper.createParser
createParser()
Definition
brunelWrapper.py:30
GaudiHive
profiling
brunelWrapper.py
Generated on
for The Gaudi Framework by
1.17.0