def request_benchmark(cmds): #This is the function with which the server listens on the given port #cmds is a list of dictionaries: each dictionary is a set of cmsPerfSuite commands to run. #Most common use will be only 1 dictionary, but for testing with reproducibility and statistical errors #one can easily think of sending the same command 10 times for example and then compare the outputs global _outputdir, _reqnumber print "Commands received running perfsuite for these jobs:" print cmds sys.stdout.flush() try: # input is a list of dictionaries each defining the # keywords to cmsperfsuite outs = [] cmd_num = 0 exists = True #Funky way to make sure we create a directory request_n with n = serial request number (if the server is running for a while #and the client submits more than one request #This should never happen since _reqnumber is a global variable on the server side... while exists: topdir = os.path.join(_outputdir,"request_" + str(_reqnumber)) exists = os.path.exists(topdir) _reqnumber += 1 os.mkdir(topdir) #Going through each command dictionary in the cmds list (usually only 1 such dictionary): for cmd in cmds: curperfdir = os.path.abspath(os.path.join(topdir,str(cmd_num))) if not os.path.exists(curperfdir): os.mkdir(curperfdir) logfile = os.path.join(curperfdir, "cmsPerfSuite.log") if os.path.exists(logfile): logfile = logfile + str(cmd_num) print cmd if 'cpus' in cmd: if cmd['cpus'] == "All": print "Running performance suite on all CPUS!\n" cmd['cpus']="" for cpu in range(cmsCpuInfo.get_NumOfCores()): cmd["cpus"]=cmd["cpus"]+str(cpu)+"," cmd["cpus"]=cmd["cpus"][:-1] #eliminate the last comma for cleanliness print "I.e. on cpus %s\n"%cmd["cpus"] #Not sure this is the most elegant solution... we keep cloning dictionaries... cmdwdefs = {} cmdwdefs["castordir" ] = getCPSkeyword("castordir" , cmd) cmdwdefs["perfsuitedir" ] = curperfdir cmdwdefs["TimeSizeEvents" ] = getCPSkeyword("TimeSizeEvents" , cmd) cmdwdefs["TimeSizeCandles" ] = getCPSkeyword("TimeSizeCandles" , cmd) cmdwdefs["TimeSizePUCandles" ] = getCPSkeyword("TimeSizePUCandles" , cmd) cmdwdefs["IgProfEvents" ] = getCPSkeyword("IgProfEvents" , cmd) cmdwdefs["IgProfCandles" ] = getCPSkeyword("IgProfCandles" , cmd) cmdwdefs["IgProfPUCandles" ] = getCPSkeyword("IgProfPUCandles" , cmd) cmdwdefs["CallgrindEvents" ] = getCPSkeyword("CallgrindEvents" , cmd) cmdwdefs["CallgrindCandles"] = getCPSkeyword("CallgrindCandles" , cmd) cmdwdefs["CallgrindPUCandles"] = getCPSkeyword("CallgrindPUCandles" , cmd) cmdwdefs["MemcheckEvents" ] = getCPSkeyword("MemcheckEvents" , cmd) cmdwdefs["MemcheckCandles" ] = getCPSkeyword("MemcheckCandles" , cmd) cmdwdefs["MemcheckPUCandles" ] = getCPSkeyword("MemcheckPUCandles" , cmd) cmdwdefs["cmsScimark" ] = getCPSkeyword("cmsScimark" , cmd) cmdwdefs["cmsScimarkLarge" ] = getCPSkeyword("cmsScimarkLarge" , cmd) cmdwdefs["cmsdriverOptions"] = getCPSkeyword("cmsdriverOptions", cmd) cmdwdefs["stepOptions" ] = getCPSkeyword("stepOptions" , cmd) cmdwdefs["quicktest" ] = getCPSkeyword("quicktest" , cmd) cmdwdefs["profilers" ] = getCPSkeyword("profilers" , cmd) cmdwdefs["cpus" ] = getCPSkeyword("cpus" , cmd) cmdwdefs["cores" ] = getCPSkeyword("cores" , cmd) cmdwdefs["prevrel" ] = getCPSkeyword("prevrel" , cmd) # cmdwdefs["candles" ] = getCPSkeyword("candles" , cmd) # cmdwdefs["isAllCandles" ] = len(Candles) == len(cmdwdefs["candles"]) #Dangerous: in the _DEFAULTS version this is a boolean! cmdwdefs["bypasshlt" ] = getCPSkeyword("bypasshlt" , cmd) cmdwdefs["runonspare" ] = getCPSkeyword("runonspare" , cmd) cmdwdefs["logfile" ] = logfile logh = open(logfile,"w") logh.write("This perfsuite run was configured with the following options:\n") #logh.write(str(cmdwdefs) + "\n") for key in cmdwdefs.keys(): logh.write(key + "\t" +str(cmdwdefs[key])+"\n") logh.close() print "Calling cmsPerfSuite.main() function\n" cpsInputArgs=[ #"-a",cmdwdefs["castordir"], "-t",cmdwdefs["TimeSizeEvents" ], "--RunTimeSize",cmdwdefs["TimeSizeCandles"], "-o",cmdwdefs["perfsuitedir" ], #"-i",cmdwdefs["IgProfEvents" ], #"--RunIgProf",cmdwdefs["RunIgProf" ], #"-c",cmdwdefs["CallgrindEvents" ], #"--RunCallgrind",cmdwdefs["RunCallgrind" ], #"-m",cmdwdefs["MemcheckEvents"], #"--RunMemcheck",cmdwdefs["RunMemcheck"], "--cmsScimark",cmdwdefs["cmsScimark" ], "--cmsScimarkLarge",cmdwdefs["cmsScimarkLarge" ], "--cmsdriver",cmdwdefs["cmsdriverOptions"], "--step",cmdwdefs["stepOptions" ], #"--quicktest",cmdwdefs["quicktest" ], #"--profile",cmdwdefs["profilers" ], "--cpu",cmdwdefs["cpus" ], "--cores",cmdwdefs["cores" ], #"--prevrel",cmdwdefs["prevrel" ], # "--candle",cmdwdefs["candles" ], #"--bypass-hlt",cmdwdefs["bypasshlt" ], "--notrunspare"#,cmdwdefs["runonspare" ]#, #"--logfile",cmdwdefs["logfile" ] ] print cpsInputArgs cps.main(cpsInputArgs) print "Running of the Performance Suite is done!" #logreturn is false... so this does not get executed #Maybe we can replace this so that we can have more verbose logging of the server activity if _logreturn: outs.append(readlog(logfile)) else: outs.append((cmdwdefs,cph.harvest(curperfdir))) #incrementing the variable for the command number: cmd_num += 1 return outs #Not sure what James intended to return here... the contents of all logfiles in a list of logfiles? except exceptions.Exception, detail: # wrap the entire function in try except so we can log the error at client and server logh = open(os.path.join(os.getcwd(),"error.log"),"a") logh.write(str(detail) + "\n") logh.flush() logh.close() print detail sys.stdout.flush() raise
def request_benchmark(cmds): #This is the function with which the server listens on the given port #cmds is a list of dictionaries: each dictionary is a set of cmsPerfSuite commands to run. #Most common use will be only 1 dictionary, but for testing with reproducibility and statistical errors #one can easily think of sending the same command 10 times for example and then compare the outputs global _outputdir, _reqnumber print("Commands received running perfsuite for these jobs:") print(cmds) sys.stdout.flush() try: # input is a list of dictionaries each defining the # keywords to cmsperfsuite outs = [] cmd_num = 0 exists = True #Funky way to make sure we create a directory request_n with n = serial request number (if the server is running for a while #and the client submits more than one request #This should never happen since _reqnumber is a global variable on the server side... while exists: topdir = os.path.join(_outputdir,"request_" + str(_reqnumber)) exists = os.path.exists(topdir) _reqnumber += 1 os.mkdir(topdir) #Going through each command dictionary in the cmds list (usually only 1 such dictionary): for cmd in cmds: curperfdir = os.path.abspath(os.path.join(topdir,str(cmd_num))) if not os.path.exists(curperfdir): os.mkdir(curperfdir) logfile = os.path.join(curperfdir, "cmsPerfSuite.log") if os.path.exists(logfile): logfile = logfile + str(cmd_num) print(cmd) if 'cpus' in cmd: if cmd['cpus'] == "All": print("Running performance suite on all CPUS!\n") cmd['cpus']="" for cpu in range(cmsCpuInfo.get_NumOfCores()): cmd["cpus"]=cmd["cpus"]+str(cpu)+"," cmd["cpus"]=cmd["cpus"][:-1] #eliminate the last comma for cleanliness print("I.e. on cpus %s\n"%cmd["cpus"]) #Not sure this is the most elegant solution... we keep cloning dictionaries... cmdwdefs = {} cmdwdefs["castordir" ] = getCPSkeyword("castordir" , cmd) cmdwdefs["perfsuitedir" ] = curperfdir cmdwdefs["TimeSizeEvents" ] = getCPSkeyword("TimeSizeEvents" , cmd) cmdwdefs["TimeSizeCandles" ] = getCPSkeyword("TimeSizeCandles" , cmd) cmdwdefs["TimeSizePUCandles" ] = getCPSkeyword("TimeSizePUCandles" , cmd) cmdwdefs["IgProfEvents" ] = getCPSkeyword("IgProfEvents" , cmd) cmdwdefs["IgProfCandles" ] = getCPSkeyword("IgProfCandles" , cmd) cmdwdefs["IgProfPUCandles" ] = getCPSkeyword("IgProfPUCandles" , cmd) cmdwdefs["CallgrindEvents" ] = getCPSkeyword("CallgrindEvents" , cmd) cmdwdefs["CallgrindCandles"] = getCPSkeyword("CallgrindCandles" , cmd) cmdwdefs["CallgrindPUCandles"] = getCPSkeyword("CallgrindPUCandles" , cmd) cmdwdefs["MemcheckEvents" ] = getCPSkeyword("MemcheckEvents" , cmd) cmdwdefs["MemcheckCandles" ] = getCPSkeyword("MemcheckCandles" , cmd) cmdwdefs["MemcheckPUCandles" ] = getCPSkeyword("MemcheckPUCandles" , cmd) cmdwdefs["cmsScimark" ] = getCPSkeyword("cmsScimark" , cmd) cmdwdefs["cmsScimarkLarge" ] = getCPSkeyword("cmsScimarkLarge" , cmd) cmdwdefs["cmsdriverOptions"] = getCPSkeyword("cmsdriverOptions", cmd) cmdwdefs["stepOptions" ] = getCPSkeyword("stepOptions" , cmd) cmdwdefs["quicktest" ] = getCPSkeyword("quicktest" , cmd) cmdwdefs["profilers" ] = getCPSkeyword("profilers" , cmd) cmdwdefs["cpus" ] = getCPSkeyword("cpus" , cmd) cmdwdefs["cores" ] = getCPSkeyword("cores" , cmd) cmdwdefs["prevrel" ] = getCPSkeyword("prevrel" , cmd) # cmdwdefs["candles" ] = getCPSkeyword("candles" , cmd) # cmdwdefs["isAllCandles" ] = len(Candles) == len(cmdwdefs["candles"]) #Dangerous: in the _DEFAULTS version this is a boolean! cmdwdefs["bypasshlt" ] = getCPSkeyword("bypasshlt" , cmd) cmdwdefs["runonspare" ] = getCPSkeyword("runonspare" , cmd) cmdwdefs["logfile" ] = logfile logh = open(logfile,"w") logh.write("This perfsuite run was configured with the following options:\n") #logh.write(str(cmdwdefs) + "\n") for key in cmdwdefs.keys(): logh.write(key + "\t" +str(cmdwdefs[key])+"\n") logh.close() print("Calling cmsPerfSuite.main() function\n") cpsInputArgs=[ #"-a",cmdwdefs["castordir"], "-t",cmdwdefs["TimeSizeEvents" ], "--RunTimeSize",cmdwdefs["TimeSizeCandles"], "-o",cmdwdefs["perfsuitedir" ], #"-i",cmdwdefs["IgProfEvents" ], #"--RunIgProf",cmdwdefs["RunIgProf" ], #"-c",cmdwdefs["CallgrindEvents" ], #"--RunCallgrind",cmdwdefs["RunCallgrind" ], #"-m",cmdwdefs["MemcheckEvents"], #"--RunMemcheck",cmdwdefs["RunMemcheck"], "--cmsScimark",cmdwdefs["cmsScimark" ], "--cmsScimarkLarge",cmdwdefs["cmsScimarkLarge" ], "--cmsdriver",cmdwdefs["cmsdriverOptions"], "--step",cmdwdefs["stepOptions" ], #"--quicktest",cmdwdefs["quicktest" ], #"--profile",cmdwdefs["profilers" ], "--cpu",cmdwdefs["cpus" ], "--cores",cmdwdefs["cores" ], #"--prevrel",cmdwdefs["prevrel" ], # "--candle",cmdwdefs["candles" ], #"--bypass-hlt",cmdwdefs["bypasshlt" ], "--notrunspare"#,cmdwdefs["runonspare" ]#, #"--logfile",cmdwdefs["logfile" ] ] print(cpsInputArgs) cps.main(cpsInputArgs) print("Running of the Performance Suite is done!") #logreturn is false... so this does not get executed #Maybe we can replace this so that we can have more verbose logging of the server activity if _logreturn: outs.append(readlog(logfile)) else: outs.append((cmdwdefs,cph.harvest(curperfdir))) #incrementing the variable for the command number: cmd_num += 1 return outs #Not sure what James intended to return here... the contents of all logfiles in a list of logfiles? except exceptions.Exception as detail: # wrap the entire function in try except so we can log the error at client and server logh = open(os.path.join(os.getcwd(),"error.log"),"a") logh.write(str(detail) + "\n") logh.flush() logh.close() print(detail) sys.stdout.flush() raise
"IgProfCandles" : "" , "IgProfPUCandles" : "" , "CallgrindEvents" : 0 , "CallgrindCandles" : "" , "CallgrindPUCandles" : "" , "MemcheckEvents" : 0 , "MemcheckCandles" : "" , "MemcheckPUCandles" : "" , "cmsScimark" : 10 , "cmsScimarkLarge" : 10 , "cmsdriverOptions" : cmsRelValCmd.get_cmsDriverOptions(), #Get these options automatically now! "stepOptions" : "" , "quicktest" : False , "profilers" : "" , "cpus" : "1" , "cores" : cmsCpuInfo.get_NumOfCores(), #Get this option automatically "prevrel" : "" , "isAllCandles" : True , #"candles" : CandlesString[1:] , "bypasshlt" : False , "runonspare" : True , "logfile" : os.path.join(os.getcwd(),"cmsPerfSuite.log")} def optionparse(): global _outputdir parser = opt.OptionParser(usage=("""%s [Options]""" % _PROG_NAME)) parser.add_option('-p', '--port', type="int", dest='port',