2 from __future__
import print_function
3 from builtins
import range
4 import cmsPerfPublish
as cspp
5 import cmsPerfSuite
as cps
6 import cmsPerfHarvest
as cph
10 from cmsPerfCommons
import Candles
11 import optparse
as opt
12 import socket, os, sys, SimpleXMLRPCServer, threading, exceptions
15 for candle
in Candles:
16 CandlesString=CandlesString+
","+candle
17 print(CandlesString[1:])
18 _outputdir = os.getcwd()
21 _PROG_NAME = os.path.basename(sys.argv[0])
22 _CASTOR_DIR =
"/castor/cern.ch/cms/store/relval/performance/" 23 _DEFAULTS = {
"castordir" : _CASTOR_DIR,
24 "perfsuitedir" : os.getcwd(),
25 "TimeSizeEvents" : 100 ,
26 "TimeSizeCandles" :
"",
27 "TimeSizePUCandles" :
"",
29 "IgProfCandles" :
"" ,
30 "IgProfPUCandles" :
"" ,
31 "CallgrindEvents" : 0 ,
32 "CallgrindCandles" :
"" ,
33 "CallgrindPUCandles" :
"" ,
34 "MemcheckEvents" : 0 ,
35 "MemcheckCandles" :
"" ,
36 "MemcheckPUCandles" :
"" ,
38 "cmsScimarkLarge" : 10 ,
46 "isAllCandles" :
True ,
50 "logfile" : os.path.join(os.getcwd(),
"cmsPerfSuite.log")}
54 parser = opt.OptionParser(usage=(
"""%s [Options]""" % _PROG_NAME))
56 parser.add_option(
'-p',
61 help=
'Run server on a particular port',
65 parser.add_option(
'-o',
70 help=
'The output directory for all the cmsPerfSuite runs',
74 (options, args) = parser.parse_args()
76 if not options.outputdir ==
"":
77 options.outputdir = os.path.abspath(options.outputdir)
78 if not os.path.exists(options.outputdir):
79 parser.error(
"the specified output directory %s does not exist" % options.outputdir)
82 _DEFAULTS[
"perfsuitedir"] = options.outputdir
85 _outputdir = options.outputdir
87 return (options.port,options.outputdir)
101 server = SimpleXMLRPCServer.SimpleXMLRPCServer((socket.gethostname(),port))
102 server.register_function(request_benchmark)
103 except socket.error
as detail:
104 print(
"ERROR: Could not initialise server:", detail)
108 print(
"Running server on port %s... " % port)
112 server.handle_request()
114 except (KeyboardInterrupt, SystemExit):
116 server.server_close()
120 server.server_close()
122 server.server_close()
144 for line
in open(logfile,
"r"): 146 except (OSError, IOError)
as detail:
154 return _DEFAULTS[key]
162 global _outputdir, _reqnumber
163 print(
"Commands received running perfsuite for these jobs:")
176 topdir = os.path.join(_outputdir,
"request_" +
str(_reqnumber))
177 exists = os.path.exists(topdir)
182 curperfdir = os.path.abspath(os.path.join(topdir,
str(cmd_num)))
183 if not os.path.exists(curperfdir):
185 logfile = os.path.join(curperfdir,
"cmsPerfSuite.log")
186 if os.path.exists(logfile):
187 logfile = logfile +
str(cmd_num)
190 if cmd[
'cpus'] ==
"All":
191 print(
"Running performance suite on all CPUS!\n")
194 cmd[
"cpus"]=cmd[
"cpus"]+
str(cpu)+
"," 195 cmd[
"cpus"]=cmd[
"cpus"][:-1]
196 print(
"I.e. on cpus %s\n"%cmd[
"cpus"])
201 cmdwdefs[
"perfsuitedir" ] = curperfdir
202 cmdwdefs[
"TimeSizeEvents" ] =
getCPSkeyword(
"TimeSizeEvents" , cmd)
203 cmdwdefs[
"TimeSizeCandles" ] =
getCPSkeyword(
"TimeSizeCandles" , cmd)
204 cmdwdefs[
"TimeSizePUCandles" ] =
getCPSkeyword(
"TimeSizePUCandles" , cmd)
205 cmdwdefs[
"IgProfEvents" ] =
getCPSkeyword(
"IgProfEvents" , cmd)
206 cmdwdefs[
"IgProfCandles" ] =
getCPSkeyword(
"IgProfCandles" , cmd)
207 cmdwdefs[
"IgProfPUCandles" ] =
getCPSkeyword(
"IgProfPUCandles" , cmd)
208 cmdwdefs[
"CallgrindEvents" ] =
getCPSkeyword(
"CallgrindEvents" , cmd)
209 cmdwdefs[
"CallgrindCandles"] =
getCPSkeyword(
"CallgrindCandles" , cmd)
210 cmdwdefs[
"CallgrindPUCandles"] =
getCPSkeyword(
"CallgrindPUCandles" , cmd)
211 cmdwdefs[
"MemcheckEvents" ] =
getCPSkeyword(
"MemcheckEvents" , cmd)
212 cmdwdefs[
"MemcheckCandles" ] =
getCPSkeyword(
"MemcheckCandles" , cmd)
213 cmdwdefs[
"MemcheckPUCandles" ] =
getCPSkeyword(
"MemcheckPUCandles" , cmd)
215 cmdwdefs[
"cmsScimarkLarge" ] =
getCPSkeyword(
"cmsScimarkLarge" , cmd)
216 cmdwdefs[
"cmsdriverOptions"] =
getCPSkeyword(
"cmsdriverOptions", cmd)
217 cmdwdefs[
"stepOptions" ] =
getCPSkeyword(
"stepOptions" , cmd)
227 cmdwdefs[
"logfile" ] = logfile
228 logh = open(logfile,
"w")
229 logh.write(
"This perfsuite run was configured with the following options:\n")
231 for key
in cmdwdefs.keys():
232 logh.write(key +
"\t" +
str(cmdwdefs[key])+
"\n")
234 print(
"Calling cmsPerfSuite.main() function\n")
237 "-t",cmdwdefs[
"TimeSizeEvents" ],
238 "--RunTimeSize",cmdwdefs[
"TimeSizeCandles"],
239 "-o",cmdwdefs[
"perfsuitedir" ],
246 "--cmsScimark",cmdwdefs[
"cmsScimark" ],
247 "--cmsScimarkLarge",cmdwdefs[
"cmsScimarkLarge" ],
248 "--cmsdriver",cmdwdefs[
"cmsdriverOptions"],
249 "--step",cmdwdefs[
"stepOptions" ],
252 "--cpu",cmdwdefs[
"cpus" ],
253 "--cores",cmdwdefs[
"cores" ],
261 cps.main(cpsInputArgs)
262 print(
"Running of the Performance Suite is done!")
268 outs.append((cmdwdefs,cph.harvest(curperfdir)))
274 except exceptions.Exception
as detail:
276 logh = open(os.path.join(os.getcwd(),
"error.log"),
"a")
277 logh.write(
str(detail) +
"\n")
287 server_thread = threading.Thread(target =
runserv(port))
288 server_thread.setDaemon(
True)
289 server_thread.start()
291 if __name__ ==
"__main__":
S & print(S &os, JobReport::InputFile const &f)
def request_benchmark(cmds)
def get_cmsDriverOptions()
def getCPSkeyword(key, dict)