2 import os, time, sys, re, glob, exceptions
4 import cmsRelRegress
as crr
5 from cmsPerfCommons
import Candles, KeywordToCfi, CandFname, cmsDriverPileUpOption, getVerFromLog
6 import cmsRelValCmd,cmsCpuInfo
18 subprocess._cleanup=_cleanup
23 threading.Thread.__init__(self)
29 self.suite.runPerfSuite(**(self.
args))
32 """A class defining timing objects to time the running of the various parts of the performance suite. The class depends on module datetime."""
34 """Initialize the start time and set the end time to some indefinite time in the future"""
36 self.
end = datetime.datetime.max
48 """Return the start time in ctime timestamp format"""
49 return self.start.ctime()
51 """Return the end time in ctime timestamp format"""
52 return self.end.ctime()
54 """Return the duration between start and end as a dictionary with keys 'hours', 'minutes', 'seconds' to express the total duration in the favourite (most appropriate) unit. The function returns truncated integers."""
67 self.
_CASTOR_DIR =
"/castor/cern.ch/cms/store/relval/performance/"
79 self.
host = os.environ[
"HOST"]
80 self.
user = os.environ[
"USER"]
82 self.logh.write(
'Error: An environment variable either SCRAM_ARCH, CMSSW_VERSION, HOST or USER is not available.\n')
83 self.logh.write(
' Please run eval `scramv1 runtime -csh` to set your environment variables\n')
88 self.
Scripts =[
"cmsDriver.py",
"cmsRelvalreport.py",
"cmsRelvalreportInput.py",
"cmsScimark2"]
89 self.
AuxiliaryScripts=[
"cmsScimarkLaunch.csh",
"cmsScimarkParser.py",
"cmsScimarkStop.py"]
110 igcommand =
'/afs/cern.ch/cms/sdt/internal/scripts/requestPerfIgprofSpace.py --version ' + self.
cmssw_version +
' --platform ' + self.
cmssw_arch
111 subprocess.Popen(igcommand,shell=
True,stdout=subprocess.PIPE,stderr=subprocess.STDOUT)
115 def __init__(self,cpu,perfsuiteinstance,**simpleGenReportArgs):
119 threading.Thread.__init__(self)
122 self.PerfTest.runPerfTest()
125 def __init__(self,cpu,perfsuiteinstance,**simpleGenReportArgs):
141 self.perfsuiteinstance.logh.flush()
143 self.perfsuiteinstance.printDate()
144 self.perfsuiteinstance.logh.flush()
148 self.PerfTestPUTimer.set_end(datetime.datetime.now())
150 self.PerfTestTimer.set_end(datetime.datetime.now())
155 parser = opt.OptionParser(usage=
'''./cmsPerfSuite.py [options]
159 cmsPerfSuite.py --step GEN-HLT -t 5 -i 2 -c 1 -m 5 --RunTimeSize MinBias,TTbar --RunIgProf TTbar --RunCallgrind TTbar --RunMemcheck TTbar --RunDigiPileUp TTbar --PUInputFile /store/relval/CMSSW_2_2_1/RelValMinBias/GEN-SIM-DIGI-RAW-HLTDEBUG/IDEAL_V9_v2/0001/101C84AF-56C4-DD11-A90D-001D09F24EC0.root --cmsdriver="--eventcontent FEVTDEBUGHLT --conditions FrontierConditions_GlobalTag,IDEAL_V9::All"
160 (this will run the suite with 5 events for TimeSize tests on MinBias and TTbar, 2 for IgProf tests on TTbar only, 1 for Callgrind tests on TTbar only, 5 for Memcheck on MinBias and TTbar, it will also run DIGI PILEUP for all TTbar tests defined, i.e. 5 TimeSize, 2 IgProf, 1 Callgrind, 5 Memcheck. The file /store/relval/CMSSW_2_2_1/RelValMinBias/GEN-SIM-DIGI-RAW-HLTDEBUG/IDEAL_V9_v2/0001/101C84AF-56C4-DD11-A90D-001D09F24EC0.root will be copied locally as INPUT_PILEUP_EVENTS.root and it will be used as the input file for the MixingModule pile up events. All these tests will be done for the step GEN-HLT, i.e. GEN,SIM,DIGI,L1,DIGI2RAW,HLT at once)
162 cmsPerfSuite.py --step GEN-HLT -t 5 -i 2 -c 1 -m 5 --RunTimeSize MinBias,TTbar --RunIgProf TTbar --RunCallgrind TTbar --RunMemcheck TTbar --RunTimeSizePU TTbar --PUInputFile /store/relval/CMSSW_2_2_1/RelValMinBias/GEN-SIM-DIGI-RAW-HLTDEBUG/IDEAL_V9_v2/0001/101C84AF-56C4-DD11-A90D-001D09F24EC0.root
163 (this will run the suite with 5 events for TimeSize tests on MinBias and TTbar, 2 for IgProf tests on TTbar only, 1 for Callgrind tests on TTbar only, 5 for Memcheck on MinBias and TTbar, it will also run DIGI PILEUP on TTbar but only for 5 TimeSize events. All these tests will be done for the step GEN-HLT, i.e. GEN,SIM,DIGI,L1,DIGI2RAW,HLT at once)
165 cmsPerfSuite.py --step GEN-HLT -t 5 -i 2 -c 1 -m 5 --RunTimeSize MinBias,TTbar --RunIgProf TTbar --RunCallgrind TTbar --RunMemcheck TTbar --RunTimeSizePU TTbar --PUInputFile /store/relval/CMSSW_2_2_1/RelValMinBias/GEN-SIM-DIGI-RAW-HLTDEBUG/IDEAL_V9_v2/0001/101C84AF-56C4-DD11-A90D-001D09F24EC0.root --cmsdriver="--eventcontent RAWSIM --conditions FrontierConditions_GlobalTag,IDEAL_V9::All"
166 (this will run the suite with 5 events for TimeSize tests on MinBias and TTbar, 2 for IgProf tests on TTbar only, 1 for Callgrind tests on TTbar only, 5 for Memcheck on MinBias and TTbar, it will also run DIGI PILEUP on TTbar but only for 5 TimeSize events. All these tests will be done for the step GEN-HLT, i.e. GEN,SIM,DIGI,L1,DIGI2RAW,HLT at once. It will also add the options "--eventcontent RAWSIM --conditions FrontierConditions_GlobalTag,IDEAL_V9::All" to all cmsDriver.py commands executed by the suite. In addition it will run only 2 cmsDriver.py "steps": "GEN,SIM" and "DIGI". Note the syntax GEN-SIM for combined cmsDriver.py steps)
168 Legal entries for individual candles (--RunTimeSize, --RunIgProf, --RunCallgrind, --RunMemcheck options):
170 ''' % (
"\n".
join(Candles)))
172 parser.set_defaults(TimeSizeEvents = 0 ,
174 CallgrindEvents = 0 ,
177 cmsScimarkLarge = 10 ,
178 cmsdriverOptions =
"--eventcontent FEVTDEBUGHLT",
183 logfile = os.path.join(os.getcwd(),
"cmsPerfSuite.log"),
203 RunCallgrindPU =
"" ,
207 parser.add_option(
'--createIgVol', action=
"store_true", dest=
'create',
208 help =
'Create IgProf AFS volume for the release and architecture')
209 parser.add_option(
'-q',
'--quiet' , action=
"store_false", dest=
'verbose' ,
210 help =
'Output less information' )
211 parser.add_option(
'-b',
'--bypass-hlt' , action=
"store_true" , dest=
'bypasshlt' ,
212 help =
'Bypass HLT root file as input to RAW2DIGI')
213 parser.add_option(
'-n',
'--notrunspare', action=
"store_false", dest=
'runonspare',
214 help =
'Do not run cmsScimark on spare cores')
215 parser.add_option(
'-t',
'--timesize' , type=
'int' , dest=
'TimeSizeEvents' , metavar=
'<#EVENTS>' ,
216 help =
'specify the number of events for the TimeSize tests' )
217 parser.add_option(
'-i',
'--igprof' , type=
'int' , dest=
'IgProfEvents' , metavar=
'<#EVENTS>' ,
218 help =
'specify the number of events for the IgProf tests' )
219 parser.add_option(
'-c',
'--callgrind' , type=
'int' , dest=
'CallgrindEvents' , metavar=
'<#EVENTS>' ,
220 help =
'specify the number of events for the Callgrind tests' )
221 parser.add_option(
'-m',
'--memcheck' , type=
'int' , dest=
'MemcheckEvents' , metavar=
'<#EVENTS>' ,
222 help =
'specify the number of events for the Memcheck tests' )
223 parser.add_option(
'--cmsScimark' , type=
'int' , dest=
'cmsScimark' , metavar=
'' ,
224 help =
'specify the number of times the cmsScimark benchmark is run before and after the performance suite on cpu1')
225 parser.add_option(
'--cmsScimarkLarge' , type=
'int' , dest=
'cmsScimarkLarge' , metavar=
'' ,
226 help =
'specify the number of times the cmsScimarkLarge benchmark is run before and after the performance suite on cpu1')
227 parser.add_option(
'--cores' , type=
'int', dest=
'cores' , metavar=
'<CORES>' ,
228 help =
'specify the number of cores of the machine (can be used with 0 to stop cmsScimark from running on the other cores)')
229 parser.add_option(
'--cmsdriver' , type=
'string', dest=
'cmsdriverOptions', metavar=
'<OPTION_STR>',
230 help =
'specify special options to use with the cmsDriver.py commands (designed for integration build use')
231 parser.add_option(
'-a',
'--archive' , type=
'string', dest=
'castordir' , metavar=
'<DIR>' ,
232 help =
'specify the wanted CASTOR directory where to store the results tarball')
233 parser.add_option(
'-L',
'--logfile' , type=
'string', dest=
'logfile' , metavar=
'<FILE>' ,
234 help =
'file to store log output of the script')
235 parser.add_option(
'-o',
'--output' , type=
'string', dest=
'outputdir' , metavar=
'<DIR>' ,
236 help =
'specify the directory where to store the output of the script')
237 parser.add_option(
'-r',
'--prevrel' , type=
'string', dest=
'previousrel' , metavar=
'<DIR>' ,
238 help =
'Top level dir of previous release for regression analysis')
239 parser.add_option(
'--step' , type=
'string', dest=
'stepOptions' , metavar=
'<STEPS>' ,
240 help =
'specify the processing steps intended (instead of the default ones)' )
241 parser.add_option(
'--cpu' , type=
'string', dest=
'cpu' , metavar=
'<CPU>' ,
242 help =
'specify the core on which to run the performance suite')
245 parser.add_option(
'--RunTimeSize' , type=
'string', dest=
'RunTimeSize' , metavar=
'<CANDLES>' ,
246 help =
'specify on which candles to run the TimeSize tests')
247 parser.add_option(
'--RunIgProf' , type=
'string', dest=
'RunIgProf' , metavar=
'<CANDLES>' ,
248 help =
'specify on which candles to run the IgProf tests')
249 parser.add_option(
'--RunCallgrind' , type=
'string', dest=
'RunCallgrind' , metavar=
'<CANDLES>' ,
250 help =
'specify on which candles to run the Callgrind tests')
251 parser.add_option(
'--RunMemcheck' , type=
'string', dest=
'RunMemcheck' , metavar=
'<CANDLES>' ,
252 help =
'specify on which candles to run the Memcheck tests')
253 parser.add_option(
'--RunDigiPileUp' , type=
'string', dest=
'RunDigiPileUp' , metavar=
'<CANDLES>' ,
254 help =
'specify the candle on which to run DIGI PILE UP and repeat all the tests set to run on that candle with PILE UP')
255 parser.add_option(
'--PUInputFile' , type=
'string', dest=
'PUInputFile' , metavar=
'<FILE>' ,
256 help =
'specify the root file to pick the pile-up events from')
257 parser.add_option(
'--RunTimeSizePU' , type=
'string', dest=
'RunTimeSizePU' , metavar=
'<CANDLES>' ,
258 help =
'specify on which candles to run the TimeSize tests with PILE UP')
259 parser.add_option(
'--RunIgProfPU' , type=
'string', dest=
'RunIgProfPU' , metavar=
'<CANDLES>' ,
260 help =
'specify on which candles to run the IgProf tests with PILE UP')
261 parser.add_option(
'--RunCallgrindPU' , type=
'string', dest=
'RunCallgrindPU' , metavar=
'<CANDLES>' ,
262 help =
'specify on which candles to run the Callgrind tests with PILE UP')
263 parser.add_option(
'--RunMemcheckPU' , type=
'string', dest=
'RunMemcheckPU' , metavar=
'<CANDLES>' ,
264 help =
'specify on which candles to run the Memcheck tests with PILE UP')
267 parser.add_option(
'--filein' , type=
'string', dest=
'userInputFile' , metavar=
'<FILE>',
268 help =
'specify input RAW root file for HLT and RAW2DIGI-RECO (list the files in the same order as the candles for the tests)')
271 parser.add_option(
'--mail', type=
'string', dest=
'MailLogRecipients', metavar=
'<EMAIL ADDRESS>', default=self.
user, help=
'specify valid email address(es) name@domain in order to receive notification at the end of the performance suite running with the cmsPerfSuite.log file')
274 parser.add_option(
'--no_tarball', action=
"store_false", dest=
'tarball', default=
True, help=
'Turn off automatic tarball creation at the end of the performance suite execution')
281 devel = opt.OptionGroup(parser,
"Developer Options",
282 "Caution: use these options at your own risk."
283 "It is believed that some of them bite.\n")
285 devel.add_option(
'-p',
'--profile' , type=
"str" , dest=
'profilers', metavar=
"<PROFILERS>" ,
286 help =
'Profile codes to use for cmsRelvalInput' )
287 devel.add_option(
'-f',
'--false-run', action=
"store_true", dest=
'dryrun' ,
289 devel.add_option(
'-d',
'--debug' , action=
'store_true', dest=
'debug' ,
291 devel.add_option(
'--quicktest' , action=
"store_true", dest=
'quicktest',
292 help =
'Quick overwrite all the defaults to small numbers so that we can run a quick test of our chosing.' )
293 devel.add_option(
'--test' , action=
"store_true", dest=
'unittest' ,
294 help =
'Perform a simple test, overrides other options. Overrides verbosity and sets it to false.' )
295 devel.add_option(
'--no_exec' , action=
"store_true", dest=
'noexec' ,
296 help =
'Run the suite without executing the cmsRelvalreport.py commands in the various directories. This is a useful debugging tool.' )
297 parser.add_option_group(devel)
298 (options, args) = parser.parse_args(argslist)
301 self.
_debug = options.debug
306 create = options.create
307 castordir = options.castordir
308 TimeSizeEvents = options.TimeSizeEvents
309 IgProfEvents = options.IgProfEvents
310 CallgrindEvents = options.CallgrindEvents
311 MemcheckEvents = options.MemcheckEvents
312 cmsScimark = options.cmsScimark
313 cmsScimarkLarge = options.cmsScimarkLarge
314 cmsdriverOptions = options.cmsdriverOptions
315 stepOptions = options.stepOptions
316 quicktest = options.quicktest
318 runonspare = options.runonspare
319 profilers = options.profilers.strip()
320 cpu = options.cpu.strip()
321 bypasshlt = options.bypasshlt
322 cores = options.cores
323 logfile = options.logfile
324 prevrel = options.previousrel
325 outputdir = options.outputdir
326 RunTimeSize = options.RunTimeSize
327 RunIgProf = options.RunIgProf
328 RunCallgrind = options.RunCallgrind
329 RunMemcheck = options.RunMemcheck
330 RunDigiPileUp = options.RunDigiPileUp
331 RunTimeSizePU = options.RunTimeSizePU
332 RunIgProfPU = options.RunIgProfPU
333 RunCallgrindPU = options.RunCallgrindPU
334 RunMemcheckPU = options.RunMemcheckPU
335 PUInputFile = options.PUInputFile
336 userInputFile = options.userInputFile
337 if options.MailLogRecipients !=
"" and self.
user not in options.MailLogRecipients:
338 MailLogRecipients= self.
user+
","+options.MailLogRecipients
340 MailLogRecipients=options.MailLogRecipients
341 tarball = options.tarball
346 if not logfile ==
None:
347 logfile = os.path.abspath(logfile)
348 logdir = os.path.dirname(logfile)
349 if not os.path.exists(logdir):
350 parser.error(
"Directory to output logfile does not exist")
352 logfile = os.path.abspath(logfile)
357 if "GEN,SIM" in stepOptions:
358 self.logh.write(
"WARNING: Please use GEN-SIM with a hypen not a \",\"!\n")
361 if stepOptions ==
"" or stepOptions ==
'Default':
364 stepOptions=
'--usersteps=%s' % (stepOptions)
369 isnumreg = re.compile(
"^-?[0-9]*$")
370 found = isnumreg.search(profilers)
372 parser.error(
"profile codes option contains non-numbers")
379 outputdir = os.getcwd()
381 outputdir = os.path.abspath(outputdir)
383 if not os.path.isdir(outputdir):
384 parser.error(
"%s is not a valid output directory" % outputdir)
390 numetcomreg = re.compile(
"^[0-9,]*")
391 if not numetcomreg.search(cpu):
392 parser.error(
"cpu option needs to be a comma separted list of ints or a single int")
398 cpu =
map(
lambda x: int(x),cpustr.split(
","))
400 cpu = [ int(cpustr) ]
405 if not prevrel ==
"":
406 prevrel = os.path.abspath(prevrel)
407 if not os.path.exists(prevrel):
408 self.logh.write(
"ERROR: Previous release dir %s could not be found" % prevrel)
427 if stepOptions ==
"":
428 stepOptions =
"GEN-SIM,DIGI,L1,DIGI2RAW,HLT,RAW2DIGI-RECO"
443 CallgrindPUCandles=[]
445 userInputRootFiles=[]
447 TimeSizeCandles = RunTimeSize.split(
",")
449 IgProfCandles = RunIgProf.split(
",")
451 CallgrindCandles = RunCallgrind.split(
",")
453 MemcheckCandles = RunMemcheck.split(
",")
455 for candle
in RunDigiPileUp.split(
","):
456 if candle
in TimeSizeCandles:
457 TimeSizePUCandles.append(candle)
458 if candle
in IgProfCandles:
459 IgProfPUCandles.append(candle)
460 if candle
in CallgrindCandles:
461 CallgrindPUCandles.append(candle)
462 if candle
in MemcheckCandles:
463 MemcheckPUCandles.append(candle)
465 TimeSizePUCandles.extend(RunTimeSizePU.split(
","))
467 temp=set(TimeSizePUCandles)
468 TimeSizePUCandles=
list(temp)
470 IgProfPUCandles.extend(RunIgProfPU.split(
","))
472 temp=set(IgProfPUCandles)
473 IgProfPUCandles=
list(temp)
475 CallgrindPUCandles.extend(RunCallgrindPU.split(
","))
477 temp=set(CallgrindPUCandles)
478 CallgrindPUCandles=
list(temp)
480 MemcheckPUCandles.extend(RunMemcheckPU.split(
","))
482 temp=set(MemcheckPUCandles)
483 MemcheckPUCandles=
list(temp)
485 userInputRootFiles=userInputFile.split(
",")
492 cmsdriverPUOptions=
""
495 if TimeSizePUCandles
or IgProfPUCandles
or CallgrindPUCandles
or MemcheckPUCandles:
497 cmsdriverPUOptions =
'--cmsdriver="%s %s%s"'%(cmsdriverOptions,
" --pileup=",cmsDriverPileUpOption)
499 cmsdriverOptions =
'--cmsdriver="%s"'%cmsdriverOptions
543 exitstat = self.
runcmd(cmd)
560 self.logh.write(str(command) +
"\n")
573 process = subprocess.Popen(command,shell=
True,stdout=subprocess.PIPE,stderr=subprocess.STDOUT)
575 exitstat= process.wait()
576 cmdout = process.stdout.read()
577 exitstat = process.returncode
578 except OSError, detail:
579 self.logh.write(
"Race condition in subprocess.Popen has robbed us of the exit code of the %s process (PID %s).Assume it failed!\n %s\n"%(command,pid,detail))
582 cmdout=
"Race condition in subprocess.Popen has robbed us of the exit code of the %s process (PID %s).Assume it failed!\n %s"%(command,pid,detail)
584 self.logh.write(cmdout)
587 self.logh.write(
"Something strange is going on! Exit code was None for command %s: check if it really ran!"%command)
596 self.logh.write(self.
getDate() +
"\n")
602 adir = os.path.join(pfdir,
"%s_%s" % (candle,profiler))
603 self.
runcmd(
"mkdir -p %s" % adir )
612 def cprootfile(self,dir,candle,NumOfEvents,cmsdriverOptions=""):
613 cmds = (
"cd %s" % dir,
614 "cp -pR ../%s_IgProf/%s_GEN,SIM.root ." % (candle,CandFname[candle]))
617 self.logh.write(
"Since there was no ../%s_IgProf/%s_GEN,SIM.root file it will be generated first\n"%(candle,CandFname[candle]))
619 cmd =
"cd %s ; cmsDriver.py %s -s GEN,SIM -n %s --fileout %s_GEN,SIM.root %s>& %s_GEN_SIM_for_valgrind.log" % (dir,KeywordToCfi[candle],str(NumOfEvents),candle,cmsdriverOptions,candle)
624 cmdout=subprocess.Popen(cmd,shell=
True,stdout=subprocess.PIPE,stderr=subprocess.STDOUT).stdout.read()
634 for line
in open(file,
"r"):
635 if "cerr" in line
or "CMSException" in line:
636 self.logh.write(
"ERROR: %s\n" % line)
638 except OSError, detail:
639 self.logh.write(
"WARNING: %s\n" % detail)
641 except IOError, detail:
642 self.logh.write(
"WARNING: %s\n" % detail)
654 InputFileName=os.path.join(dir,
"SimulationCandles_%s.txt"%(self.
cmssw_version))
655 InputFile=open(InputFileName,
"r")
656 InputLines=InputFile.readlines()
658 Outputfile=open(InputFileName,"w")
659 simRegxp=re.compile(
"step=GEN,SIM")
660 digiRegxp=re.compile(
"step=DIGI")
661 CallgrindRegxp=re.compile(
"ValgrindFCE")
662 MemcheckRegxp=re.compile(
"Memcheck")
663 NumEvtRegxp=re.compile(
"-n 1")
664 for line
in InputLines:
665 if simRegxp.search(line)
and CallgrindRegxp.search(line):
667 elif simRegxp.search(line)
and MemcheckRegxp.search(line):
669 if NumEvtRegxp.search(line):
670 line=NumEvtRegxp.sub(
r"-n 5",line)
672 self.logh.write(
"The number of Memcheck event was not changed since the original number of Callgrind event was not 1!\n")
673 Outputfile.write(line)
674 elif digiRegxp.search(line)
and MemcheckRegxp.search(line):
676 if NumEvtRegxp.search(line):
677 line=NumEvtRegxp.sub(
r"-n 5",line)
679 self.logh.write(
"The number of Memcheck event was not changed since the original number of Callgrind event was not 1!\n")
680 Outputfile.write(line)
682 Outputfile.write(line)
695 redirect =
" -large >>"
699 for i
in range(bencher):
701 if not os.path.exists(os.path.join(pfdir,os.path.basename(name))):
703 open(os.path.join(pfdir,os.path.basename(name)))
705 command= cmd + redirect + os.path.join(pfdir,os.path.basename(name))
706 self.
printFlush(command +
" [%s/%s]" % (i+1,bencher))
715 cmds = (
"cd %s" % (dir),
716 "%s -i SimulationCandles_%s.txt -t perfreport_tmp -R -P >& %s.log" % (cmd,self.
cmssw_version,candle))
721 if self.
_unittest and (
not exitstat == 0):
722 self.logh.write(
"ERROR: CMS Report returned a non-zero exit status \n")
731 cmsdrvreg = re.compile(
"^cmsDriver.py")
734 stepreg = re.compile(
"--step=([^ ]*)")
735 previousCmdOnline =
""
736 for line
in open(os.path.join(dir,
"SimulationCandles_%s.txt" % (cmsver))):
737 if (
not line.lstrip().startswith(
"#"))
and not (line.isspace()
or len(line) == 0):
738 cmdonline = line.split(
"@@@",1)[0]
739 if cmsdrvreg.search(cmdonline)
and not previousCmdOnline == cmdonline:
740 stepbeingrun =
"Unknown"
741 matches = stepreg.search(cmdonline)
742 if not matches ==
None:
743 stepbeingrun = matches.groups()[0]
744 if "PILEUP" in cmdonline:
745 stepbeingrun +=
"_PILEUP"
746 self.logh.write(cmdonline +
"\n")
747 cmds = (
"cd %s" % (dir),
748 "%s >& ../cmsdriver_unit_test_%s_%s.log" % (cmdonline,candle,stepbeingrun))
750 self.logh.write(cmds +
"\n")
755 xstatus = out & 0xffff
756 self.logh.write(
"FATAL ERROR: CMS Driver returned a non-zero exit status (which is %s) when running %s for candle %s. Signal interrupt was %s\n" % (xstatus,stepbeingrun,candle,sig))
758 previousCmdOnline = cmdonline
763 def runCmsInput(self,cpu,dir,numevents,candle,cmsdrvopts,stepopt,profiles,bypasshlt,userInputFile):
768 bypass =
"--bypass-hlt"
769 userInputFileOption=
""
771 userInputFileOption =
"--filein %s"%userInputFile
775 cmds = (
"cd %s" % (dir),
776 "%s %s \"%s\" %s %s %s %s %s" % (cmd,
782 bypass,userInputFileOption))
785 if self.
_unittest and (
not exitstat == 0):
786 self.logh.write(
"ERROR: CMS Report Input returned a non-zero exit status \n" )
792 def simpleGenReport(self,cpus,perfdir=os.getcwd(),NumEvents=1,candles=[
'MinBias'],cmsdriverOptions=
'',stepOptions=
'',Name=
'',profilers=
'',bypasshlt=
'',userInputRootFiles=
''):
793 callgrind = Name ==
"Callgrind"
794 memcheck = Name ==
"Memcheck"
796 profCodes = {
"TimeSize" :
"0123",
804 profiles = profCodes[Name]
805 if not profilers ==
"":
808 RelvalreportExitCode=0
813 pfdir = os.path.join(perfdir,
"cpu_%s" % cpu)
814 for candle
in candles:
817 if "--pileup" in cmsdriverOptions:
818 candlename=candle+
"_PU"
824 if userInputRootFiles:
825 self.logh.write(userInputRootFiles)
826 userInputFile=userInputRootFiles[0]
830 self.
runCmsInput(cpu,adir,NumEvents,candle,cmsdriverOptions,stepOptions,profiles,bypasshlt,userInputFile)
833 if userInputRootFiles:
834 self.logh.write(
"Variable userInputRootFiles is %s\n"%userInputRootFiles)
842 candleregexp=re.compile(candle)
843 for file
in userInputRootFiles:
844 if candleregexp.search(file):
846 self.logh.write(
"For these %s %s tests will use user input file %s\n"%(candlename,Name,userInputFile))
847 if userInputFile ==
"":
848 self.logh.write(
"***WARNING: For these %s %s tests could not find a matching input file in %s: will try to do without it!!!!!\n"%(candlename,Name,userInputRootFiles))
852 DummyTestName=candlename+
"_"+stepOptions.split(
"=")[1]
854 TimerInfo[Name].
update({DummyTestName:DummyTimer})
856 self.
runCmsInput(cpu,adir,NumEvents,candle,cmsdriverOptions,stepOptions,profiles,bypasshlt,userInputFile)
859 self.logh.write(
"Running in debugging mode, without executing cmsRelvalreport.py\n")
865 self.logh.write(
"Individual cmsRelvalreport.py ExitCode %s\n"%ExitCode)
866 RelvalreportExitCode=RelvalreportExitCode+ExitCode
867 self.logh.write(
"Summed cmsRelvalreport.py ExitCode %s\n"%RelvalreportExitCode)
869 DummyTimer.set_end(datetime.datetime.now())
874 globpath = os.path.join(adir,
"*.log")
875 self.logh.write(
"Looking for logs that match %s\n" % globpath)
876 logs = glob.glob(globpath)
878 self.logh.write(
"Found log %s\n" % log)
880 self.
printFlush(
"Returned cumulative RelvalreportExitCode is %s"%RelvalreportExitCode)
881 return RelvalreportExitCode
895 castordir =
"/castor/cern.ch/cms/store/relval/performance/",
896 TimeSizeEvents = 100 ,
898 CallgrindEvents = 1 ,
901 cmsScimarkLarge = 10 ,
902 cmsdriverOptions =
"" ,
903 cmsdriverPUOptions=
"" ,
913 perfsuitedir = os.getcwd(),
915 TimeSizeCandles =
"" ,
917 CallgrindCandles =
"" ,
918 MemcheckCandles =
"" ,
919 TimeSizePUCandles =
"" ,
920 IgProfPUCandles =
"" ,
921 CallgrindPUCandles =
"" ,
922 MemcheckPUCandles =
"" ,
925 MailLogRecipients =
"" ,
932 if not logfile ==
None:
934 self.
logh = open(logfile,
"a")
935 except (OSError, IOError), detail:
936 self.logh.write(detail +
"\n")
942 HEPSPEC06_file=open(
"/build/HEPSPEC06.score",
"r")
943 for line
in HEPSPEC06_file.readlines():
944 if not line.startswith(
"#")
and "HEPSPEC06" in line:
947 self.logh.write(
"***Warning***: Could not find file /build/HEPSPEC06.score file on this machine!\n")
951 localcpuinfo=os.path.join(perfsuitedir,
"cpuinfo")
953 if os.path.exists(localcpuinfo):
956 self.logh.write(
"Copying /proc/cpuinfo in current working directory (%s)\n"%perfsuitedir)
957 cpuinfo_exitcode=self.
runcmd(
"cp /proc/cpuinfo %s"%perfsuitedir)
958 localmeminfo=os.path.join(perfsuitedir,
"meminfo")
960 if os.path.exists(localmeminfo):
963 self.logh.write(
"Copying /proc/meminfo in current working directory (%s)\n"%perfsuitedir)
964 meminfo_exitcode=self.
runcmd(
"cp /proc/meminfo %s"%perfsuitedir)
965 if cpuinfo_exitcode
or meminfo_exitcode:
966 self.logh.write(
"There was an issue copying the cpuinfo or meminfo files!\n")
970 if not prevrel ==
"":
971 self.logh.write(
"Production of regression information has been requested with release directory %s\n" % prevrel)
972 if not cmsdriverOptions ==
"":
973 self.logh.write(
"Running cmsDriver.py with user defined options: %s\n" % cmsdriverOptions)
975 cmsdriverOptionsRelvalInput=
"--cmsdriver="+cmsdriverOptions
977 if not stepOptions ==
"":
978 self.logh.write(
"Running user defined steps only: %s\n" % stepOptions)
980 setpOptionsRelvalInput=
"--usersteps="+stepOptions
984 bypasshltRelvalInput=
"--bypass-hlt"
986 self.logh.write(
"Current Architecture is %s\n"%self.
cmssw_arch)
987 self.logh.write(
"Current CMSSW version is %s\n"%self.
cmssw_version)
988 self.logh.write(
"This machine ( %s ) is assumed to have %s cores, and the suite will be run on cpu %s\n" %(self.
host,cores,cpus))
989 self.logh.write(
"This machine's HEPSPEC06 score is: %s \n"%self.
HEPSPEC06)
990 path=os.path.abspath(
".")
991 self.logh.write(
"Performance Suite started running at %s on %s in directory %s, run by user %s\n" % (self.
getDate(),self.
host,path,self.
user))
996 TimerInfo={
'TotalTime':{
'TotalTime':TotalTime}}
999 showtags=subprocess.Popen(
"showtags -r",shell=
True,stdout=subprocess.PIPE,stderr=subprocess.STDOUT).stdout.read()
1000 self.logh.write(showtags)
1004 self.logh.write(
"The performance suite results tarball will be stored in CASTOR at %s\n" % self.
_CASTOR_DIR)
1005 self.logh.write(
"%s TimeSize events\n" % TimeSizeEvents)
1006 self.logh.write(
"%s IgProf events\n" % IgProfEvents)
1007 self.logh.write(
"%s Callgrind events\n" % CallgrindEvents)
1008 self.logh.write(
"%s Memcheck events\n" % MemcheckEvents)
1009 self.logh.write(
"%s cmsScimark benchmarks before starting the tests\n" % cmsScimark)
1010 self.logh.write(
"%s cmsScimarkLarge benchmarks before starting the tests\n" % cmsScimarkLarge)
1020 cpupath = os.path.join(perfsuitedir,
"cpu_%s" % cpu)
1021 if not os.path.exists(cpupath):
1031 self.logh.write(
"Full path of all the scripts used in this run of the Performance Suite:\n")
1032 for script
in AllScripts:
1033 which=
"which " + script
1038 whichstdout=subprocess.Popen(which,shell=
True,stdout=subprocess.PIPE,stderr=subprocess.STDOUT).stdout.read()
1039 self.logh.write(whichstdout)
1042 command=
"taskset -c %s %s" % (cpu,script)
1049 if (len(cpu_list) != cores):
1050 for core
in range(cores):
1051 if (
not core
in cpus)
and runonspare:
1052 self.logh.write(
"Submitting cmsScimarkLaunch.csh to run on core cpu "+str(core) +
"\n")
1053 subcmd =
"cd %s ; cmsScimarkLaunch.csh %s" % (perfsuitedir, str(core))
1054 command=
"taskset -c %s sh -c \"%s\" &" % (str(core), subcmd)
1055 self.logh.write(command +
"\n")
1061 subprocess.Popen(command,shell=
True,stdout=subprocess.PIPE,stderr=subprocess.STDOUT)
1066 benching =
not self.
_debug
1072 scimark = open(os.path.join(perfsuitedir,
"cmsScimark2.log") ,
"w")
1073 scimarklarge = open(os.path.join(perfsuitedir,
"cmsScimark2_large.log"),
"w")
1075 self.logh.write(
"Starting with %s cmsScimark on cpu%s\n" % (cmsScimark,cpu))
1076 cmsScimarkInitialTime=
PerfSuiteTimer(start=datetime.datetime.now())
1077 TimerInfo.update({
'cmsScimarkTime':{
'cmsScimarkInitial':cmsScimarkInitialTime}})
1078 self.
benchmarks(cpu,perfsuitedir,scimark.name,cmsScimark)
1079 cmsScimarkInitialTime.set_end(datetime.datetime.now())
1081 if cmsScimarkLarge > 0:
1082 self.logh.write(
"Following with %s cmsScimarkLarge on cpu%s\n" % (cmsScimarkLarge,cpu))
1083 cmsScimarkLargeInitialTime=
PerfSuiteTimer(start=datetime.datetime.now())
1084 TimerInfo[
'cmsScimarkTime'].
update({
'cmsScimarkLargeInitial':cmsScimarkLargeInitialTime})
1085 self.
benchmarks(cpu,perfsuitedir,scimarklarge.name,cmsScimarkLarge, large=
True)
1086 cmsScimarkLargeInitialTime.set_end(datetime.datetime.now())
1089 if (TimeSizePUCandles
or IgProfPUCandles
or CallgrindPUCandles
or MemcheckPUCandles)
and not (
"FASTSIM" in stepOptions):
1091 PUInputName=os.path.join(perfsuitedir,
"INPUT_PILEUP_EVENTS.root")
1097 if '/store/relval/' in PUInputFile:
1102 if PUInputFile.startswith(
'/store/relval/'):
1105 PUInputFile=
"root://eoscms//eos/cms"+PUInputFile
1107 self.logh.write(
"Copying the file %s locally to %s\n"%(PUInputFile,PUInputName))
1109 GetPUInput=subprocess.Popen(
"%s %s %s"%(copycmd,PUInputFile,PUInputName), shell=
True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
1110 GetPUInputExitCode=GetPUInput.wait()
1112 if GetPUInputExitCode:
1113 self.logh.write(
"The copying of the pile-up input file returned a non-zero exit code: %s \nThis is the stdout+stderr if the command:\n%s\n"%(GetPUInputExitCode,GetPUInput.stdout))
1115 if not os.path.exists(PUInputName):
1116 self.logh.write(
"The necessary INPUT_PILEUP_EVENTS.root file was not found in the working directory %s\nExiting now!"%perfsuitedir)
1121 self.
printFlush(
"Some PILE UP tests will be run!")
1123 self.
printFlush(
"cmsdriverPUOptions is %s"%cmsdriverPUOptions)
1127 if TimeSizeEvents > 0:
1129 TimerInfo.update({
'TimeSize':{
'TotalTime':TimeSizeTime}})
1131 self.logh.write(
"Launching the TimeSize tests (TimingReport, TimeReport, SimpleMemoryCheck, EdmSize) with %s events each\n" % TimeSizeEvents)
1133 TimerInfo[
'TimeSize'].
update({
'NoPileUpTime':NoPileUpTime})
1136 ReportExit=self.
simpleGenReport(cpus,perfsuitedir,TimeSizeEvents,TimeSizeCandles,cmsdriverOptions,stepOptions,
"TimeSize",profilers,bypasshlt,userInputFile)
1137 FinalExitCode=FinalExitCode+ReportExit
1140 NoPileUpTime.set_end(datetime.datetime.now())
1143 if TimeSizePUCandles:
1144 self.logh.write(
"Launching the PILE UP TimeSize tests (TimingReport, TimeReport, SimpleMemoryCheck, EdmSize) with %s events each\n" % TimeSizeEvents)
1146 TimerInfo[
'TimeSize'].
update({
'PileUpTime':PileUpTime})
1149 ReportExit=self.
simpleGenReport(cpus,perfsuitedir,TimeSizeEvents,TimeSizePUCandles,cmsdriverPUOptions,stepOptions,
"TimeSize",profilers,bypasshlt,userInputFile)
1150 FinalExitCode=FinalExitCode+ReportExit
1153 PileUpTime.set_end(datetime.datetime.now())
1156 if not (TimeSizeCandles
or TimeSizePUCandles):
1157 self.
printFlush(
"A number of events (%s) for TimeSize tests was selected, but no candle for regular or pileup tests was selected!"%(TimeSizeEvents))
1160 TimeSizeTime.set_end(datetime.datetime.now())
1165 self.logh.write(
"Stopping all cmsScimark jobs now\n")
1167 stopcmd =
"sh -c \"%s\"" % subcmd
1172 self.
printFlush(subprocess.Popen(stopcmd,shell=
True,stdout=subprocess.PIPE,stderr=subprocess.STDOUT).stdout.read())
1178 elif len(cpu_list) == cores:
1182 AvailableCores=range(cores)
1187 if IgProfEvents > 0:
1194 self.
printFlush(
"Special profiler option for IgProf was indicated by the user: %s"%profilers)
1196 IgProfProfilerArgs={
1197 'perfdir':perfsuitedir,
1198 'NumEvents':IgProfEvents,
1199 'candles':IgProfCandles,
1200 'cmsdriverOptions':cmsdriverOptions,
1201 'stepOptions':stepOptions,
1203 'profilers':profilers,
1204 'bypasshlt':bypasshlt,
1205 'userInputRootFiles':userInputFile
1208 TestsToDo.append(IgProfProfilerArgs)
1209 self.
printFlush(
"Appended IgProf test with profiler option %s to the TestsToDo list"%profilers)
1213 self.
printFlush(
"Splitting the IgProf tests into Perf and Mem to parallelize the cmsRun execution as much as possible:")
1217 'perfdir':perfsuitedir,
1218 'NumEvents':IgProfEvents,
1219 'candles':IgProfCandles,
1220 'cmsdriverOptions':cmsdriverOptions,
1221 'stepOptions':stepOptions,
1222 'Name':
"IgProf_Perf",
1223 'profilers':profilers,
1224 'bypasshlt':bypasshlt,
1225 'userInputRootFiles':userInputFile
1228 TestsToDo.append(IgProfPerfArgs)
1229 self.
printFlush(
"Appended IgProf PERF test to the TestsToDo list")
1233 'perfdir':perfsuitedir,
1234 'NumEvents':IgProfEvents,
1235 'candles':IgProfCandles,
1236 'cmsdriverOptions':cmsdriverOptions,
1237 'stepOptions':stepOptions,
1238 'Name':
"IgProf_Mem",
1239 'profilers':profilers,
1240 'bypasshlt':bypasshlt,
1241 'userInputRootFiles':userInputFile
1244 TestsToDo.append(IgProfMemArgs)
1245 self.
printFlush(
"Appended IgProf MEM test to the TestsToDo list")
1251 self.
printFlush(
"Preparing IgProf PileUp tests")
1256 self.
printFlush(
"Special profiler option for IgProf was indicated by the user: %s"%profilers)
1258 IgProfProfilerPUArgs={
1259 'perfdir':perfsuitedir,
1260 'NumEvents':IgProfEvents,
1261 'candles':IgProfPUCandles,
1262 'cmsdriverOptions':cmsdriverPUOptions,
1263 'stepOptions':stepOptions,
1265 'profilers':profilers,
1266 'bypasshlt':bypasshlt,
1267 'userInputRootFiles':userInputFile
1270 TestsToDo.append(IgProfProfilerPUArgs)
1271 self.
printFlush(
"Appended IgProf PileUp test with profiler option %s to the TestsToDo list"%profilers)
1273 self.
printFlush(
"Splitting the IgProf tests into Perf and Mem to parallelize the cmsRun execution as much as possible:")
1277 'perfdir':perfsuitedir,
1278 'NumEvents':IgProfEvents,
1279 'candles':IgProfPUCandles,
1280 'cmsdriverOptions':cmsdriverPUOptions,
1281 'stepOptions':stepOptions,
1282 'Name':
"IgProf_Perf",
1283 'profilers':profilers,
1284 'bypasshlt':bypasshlt,
1285 'userInputRootFiles':userInputFile
1288 TestsToDo.append(IgProfPerfPUArgs)
1289 self.
printFlush(
"Appended IgProf MEM PileUp test to the TestsToDo list")
1293 'perfdir':perfsuitedir,
1294 'NumEvents':IgProfEvents,
1295 'candles':IgProfPUCandles,
1296 'cmsdriverOptions':cmsdriverPUOptions,
1297 'stepOptions':stepOptions,
1298 'Name':
"IgProf_Mem",
1299 'profilers':profilers,
1300 'bypasshlt':bypasshlt,
1301 'userInputRootFiles':userInputFile
1304 TestsToDo.append(IgProfMemPUArgs)
1305 self.
printFlush(
"Appended IgProf MEM PileUp test to the TestsToDo list")
1306 if not (IgProfCandles
or IgProfPUCandles):
1307 self.
printFlush(
"A number of events (%s) for IgProf tests was selected, but no candle for regular or pileup tests was selected!"%(IgProfEvents))
1311 if CallgrindEvents > 0:
1312 if CallgrindCandles:
1315 'perfdir':perfsuitedir,
1316 'NumEvents':CallgrindEvents,
1317 'candles':CallgrindCandles,
1318 'cmsdriverOptions':cmsdriverOptions,
1319 'stepOptions':stepOptions,
1321 'profilers':profilers,
1322 'bypasshlt':bypasshlt,
1323 'userInputRootFiles':userInputFile
1326 TestsToDo.append(CallgrindArgs)
1327 self.
printFlush(
"Appended Callgrind test to the TestsToDo list")
1329 if CallgrindPUCandles:
1330 self.
printFlush(
"Preparing Callgrind PileUp tests")
1332 'perfdir':perfsuitedir,
1333 'NumEvents':CallgrindEvents,
1334 'candles':CallgrindPUCandles,
1335 'cmsdriverOptions':cmsdriverPUOptions,
1336 'stepOptions':stepOptions,
1338 'profilers':profilers,
1339 'bypasshlt':bypasshlt,
1340 'userInputRootFiles':userInputFile
1343 TestsToDo.append(CallgrindPUArgs)
1344 self.
printFlush(
"Appended Callgrind PileUp test to the TestsToDo list")
1345 if not (CallgrindCandles
or CallgrindPUCandles):
1346 self.
printFlush(
"A number of events (%s) for Callgrind tests was selected, but no candle for regular or pileup tests was selected!"%(CallgrindEvents))
1348 if MemcheckEvents > 0:
1352 'perfdir':perfsuitedir,
1353 'NumEvents':MemcheckEvents,
1354 'candles':MemcheckCandles,
1355 'cmsdriverOptions':cmsdriverOptions,
1356 'stepOptions':stepOptions,
1358 'profilers':profilers,
1359 'bypasshlt':bypasshlt,
1360 'userInputRootFiles':userInputFile
1363 TestsToDo.append(MemcheckArgs)
1364 self.
printFlush(
"Appended Memcheck test to the TestsToDo list")
1366 if MemcheckPUCandles:
1367 self.
printFlush(
"Preparing Memcheck PileUp tests")
1369 'perfdir':perfsuitedir,
1370 'NumEvents':MemcheckEvents,
1371 'candles':MemcheckPUCandles,
1372 'cmsdriverOptions':cmsdriverPUOptions,
1373 'stepOptions':stepOptions,
1375 'profilers':profilers,
1376 'bypasshlt':bypasshlt,
1377 'userInputRootFiles':userInputFile
1380 TestsToDo.append(MemcheckPUArgs)
1381 self.
printFlush(
"Appended Memcheck PileUp test to the TestsToDo list")
1382 if not (MemcheckCandles
or MemcheckPUCandles):
1383 self.
printFlush(
"A number of events (%s) for Memcheck tests was selected, but no candle for regular or pileup tests was selected!"%(MemcheckEvents))
1387 if IgProfEvents
or CallgrindEvents
or MemcheckEvents:
1389 self.
printFlush(
"Threading all remaining tests on all %s available cores!"%len(AvailableCores))
1395 OriginalAvailableCores=
list(AvailableCores)
1397 self.
printFlush(
"Original available cores list: %s"%AvailableCores)
1400 activePerfTestThreads={}
1409 self.
printFlush(
"Currently %s tests are scheduled to be run:"%len(TestsToDo))
1415 self.
printFlush(
"There is/are %s core(s) available"%len(AvailableCores))
1416 cpu=AvailableCores.pop()
1418 simpleGenReportArgs=TestsToDo.pop()
1419 self.
printFlush(
"Let's submit %s test on core %s"%(simpleGenReportArgs[
'Name'],cpu))
1421 if simpleGenReportArgs[
'Name']
not in TimerInfo.keys():
1424 TimerInfo.update({simpleGenReportArgs[
'Name']:{
'TotalTime':self.
PerfTestTotalTimer}})
1426 self.
printFlush(
"Starting thread %s"%threadToDo)
1427 ReportExitCode=threadToDo.start()
1428 self.
printFlush(
"Adding thread %s to the list of active threads"%threadToDo)
1429 activePerfTestThreads[cpu]=threadToDo
1435 activeTestNamesPU=[]
1436 for cpu
in activePerfTestThreads.keys():
1437 if activePerfTestThreads[cpu].isAlive():
1439 if "--pileup" in activePerfTestThreads[cpu].simpleGenReportArgs[
'cmsdriverOptions']:
1440 activeTestNamesPU.append(activePerfTestThreads[cpu].simpleGenReportArgs[
'Name'])
1442 activeTestNames.append(activePerfTestThreads[cpu].simpleGenReportArgs[
'Name'])
1444 elif cpu
not in AvailableCores:
1448 self.
printFlush(
"%s test, in thread %s is done running on core %s"%(activePerfTestThreads[cpu].simpleGenReportArgs[
'Name'],activePerfTestThreads[cpu],cpu) )
1449 self.
printFlush(
"About to append cpu %s to AvailableCores list"%cpu)
1450 AvailableCores.append(cpu)
1455 if "--pileup" in activePerfTestThreads[cpu].simpleGenReportArgs[
'cmsdriverOptions']:
1457 activeTestNamesPU.remove(activePerfTestThreads[cpu].simpleGenReportArgs[
'Name'])
1462 activeTestNames.remove(activePerfTestThreads[cpu].simpleGenReportArgs[
'Name'])
1466 activePerfTestThreads.pop(cpu)
1474 for TestName
in [
"IgProf_Perf",
"IgProf_Mem",
"Memcheck",
"Valgrind"]:
1475 if (TestName
not in activeTestNames)
and (TestName
not in activeTestNamesPU) :
1477 TimerInfo[TestName][
'TotalTime'].set_end(datetime.datetime.now())
1484 if not AvailableCores==[]
and (set(AvailableCores)==set(range(
cmsCpuInfo.get_NumOfCores()))
or set(AvailableCores)==set(OriginalAvailableCores))
and not TestsToDo:
1485 self.
printFlush(
"PHEW! We're done... all TestsToDo are done... at %s "%(self.
getDate()))
1500 self.
printFlush(
"Waiting for tests to be done...")
1509 self.logh.write(
"Ending with %s cmsScimark on cpu%s\n" % (cmsScimark,cpu))
1510 cmsScimarkFinalTime=
PerfSuiteTimer(start=datetime.datetime.now())
1511 TimerInfo[
'cmsScimarkTime'].
update({
'cmsScimarkFinal':cmsScimarkFinalTime})
1513 self.
benchmarks(cpu,perfsuitedir,scimark.name,cmsScimark)
1514 cmsScimarkFinalTime.set_end(datetime.datetime.now())
1515 if cmsScimarkLarge > 0:
1516 self.logh.write(
"Following with %s cmsScimarkLarge on cpu%s\n" % (cmsScimarkLarge,cpu))
1517 cmsScimarkLargeFinalTime=
PerfSuiteTimer(start=datetime.datetime.now())
1518 TimerInfo[
'cmsScimarkTime'].
update({
'cmsScimarkLargeFinal':cmsScimarkLargeFinalTime})
1519 self.
benchmarks(cpu,perfsuitedir,scimarklarge.name,cmsScimarkLarge,large=
True)
1520 cmsScimarkLargeFinalTime.set_end(datetime.datetime.now())
1523 self.logh.write(
"Running the regression analysis with respect to %s\n"%
getVerFromLog(prevrel))
1524 self.logh.write(time.ctime(time.time()))
1532 TimerInfo.update({
'tarballTime':{
'TotalTime':tarballTime}})
1537 if "=" in str(stepOptions):
1538 fileStepOption=str(stepOptions).
split(
"=")[1]
1540 fileStepOption=str(stepOptions)
1541 if fileStepOption==
"":
1542 fileStepOption=
"UnknownStep"
1544 fileWorkingDir=os.path.basename(perfsuitedir)
1549 fileEventContentOption=
"UnknownEventContent"
1550 fileConditionsOption=
"UnknownConditions"
1551 for token
in cmsdriverOptions.split(
"--"):
1552 if token!=
'' and 'cmsdriver' not in token:
1554 fileOption=token.split(
"=")[0]
1555 fileOptionValue=token.split(
"=")[1].strip(
"'").strip(
'"')
1557 fileOption=token.split()[0]
1558 fileOptionValue=token.split()[1].strip(
"'").strip(
'"')
1559 if "eventcontent" or "conditions" in fileOption:
1560 if "eventcontent" in fileOption:
1561 fileEventContentOption=fileOptionValue
1562 elif "conditions" in fileOption:
1565 if "auto:" in fileOptionValue:
1567 fileConditionsOption = autoCond[ fileOptionValue.split(
':')[1] ]
1573 if "," in fileOptionValue:
1574 fileConditionsOption=fileOptionValue.split(
"::")[0].
split(
",")[1]
1576 fileConditionsOption=fileOptionValue.split(
"::")[0]
1588 subprocess.Popen(
"ls -R | grep .root > rootFiles",shell=
True, stdout=subprocess.PIPE, stderr=subprocess.PIPE).stderr.read()
1589 LogFile =
"%s_%s_%s_%s_%s_%s_%s_%s_log.tgz" % (self.
cmssw_arch, self.
cmssw_version, fileStepOption, fileConditionsOption, fileEventContentOption.split()[0], fileWorkingDir, self.
host, self.
user)
1590 AbsTarFileLOG = os.path.join(perfsuitedir,LogFile)
1591 tarcmd =
"tar zcfX %s %s %s" %(AbsTarFileLOG,
"rootFiles", os.path.join(perfsuitedir,
"*"))
1592 self.
printFlush(
"Creating a tarball for the logfiles")
1594 self.
printFlush(subprocess.Popen(tarcmd,shell=
True, stdout=subprocess.PIPE, stderr=subprocess.PIPE).stderr.read())
1595 self.
printFlush(subprocess.Popen(
"rm rootFiles",shell=
True, stdout=subprocess.PIPE, stderr=subprocess.PIPE).stderr.read())
1597 fullcastorpathlog=os.path.join(castordir,LogFile)
1601 TarFile =
"%s_%s_%s_%s_%s_%s_%s_%s.tgz" % (self.
cmssw_arch, self.
cmssw_version, fileStepOption, fileConditionsOption, fileEventContentOption.split()[0], fileWorkingDir, self.
host, self.
user)
1602 AbsTarFile = os.path.join(perfsuitedir,TarFile)
1603 tarcmd =
"tar -zcf %s %s" %(AbsTarFile, os.path.join(perfsuitedir,
"*"))
1604 md5cmd =
"md5sum %s" %(AbsTarFile)
1605 self.
printFlush(
"Creating a tarball with the content of the directory")
1613 self.
printFlush(subprocess.Popen(tarcmd,shell=
True, stdout=subprocess.PIPE, stderr=subprocess.PIPE).stderr.read())
1614 md5sum = subprocess.Popen(md5cmd,shell=
True, stdout=subprocess.PIPE, stderr=subprocess.PIPE).stdout.read().
split()[0]
1615 self.
printFlush(
"The md5 checksum of the tarball: %s" %(md5sum))
1616 AbsTarFileMD5 = AbsTarFile +
".md5"
1617 md5filecmd =
"echo %s > %s" % (md5sum, AbsTarFileMD5)
1618 self.
printFlush(subprocess.Popen(md5filecmd,shell=
True, stdout=subprocess.PIPE, stderr=subprocess.PIPE).stderr.read())
1622 fullcastorpathfile=os.path.join(castordir,TarFile)
1623 fullcastorpathmd5=os.path.join(castordir,TarFile +
".md5")
1625 checkcastor=
"nsls %s" % fullcastorpathfile
1628 checkcastorout=subprocess.Popen(checkcastor,shell=
True, stdout=subprocess.PIPE, stderr=subprocess.PIPE).stdout.read()
1629 if checkcastorout.rstrip()==fullcastorpathfile:
1630 castorcmdstderr=
"File %s is already on CASTOR! Will NOT OVERWRITE!!!"%fullcastorpathfile
1635 castorcmd=
"rfcp %s %s" % (AbsTarFile,fullcastorpathfile)
1636 castormd5cmd=
"rfcp %s %s" % (AbsTarFileMD5,fullcastorpathmd5)
1637 castorlogcmd=
"rfcp %s %s" % (AbsTarFileLOG,fullcastorpathlog)
1643 castorcmdstderr=subprocess.Popen(castorcmd,shell=
True, stdout=subprocess.PIPE, stderr=subprocess.PIPE).stderr.read()
1644 subprocess.Popen(castormd5cmd,shell=
True, stdout=subprocess.PIPE, stderr=subprocess.PIPE).stderr.read()
1645 subprocess.Popen(castorlogcmd,shell=
True, stdout=subprocess.PIPE, stderr=subprocess.PIPE).stderr.read()
1650 self.
printFlush(
"Since the CASTOR archiving for the tarball failed the file %s is kept in directory %s"%(TarFile, perfsuitedir))
1653 self.
printFlush(
"Successfully archived the tarball %s in CASTOR!"%(TarFile))
1654 self.
printFlush(
"The tarball can be found: %s"%(fullcastorpathfile))
1655 self.
printFlush(
"The logfile can be found: %s"%(fullcastorpathlog))
1656 self.
printFlush(
"Deleting the local copy of the tarballs")
1657 rmtarballcmd=
"rm -Rf %s"%(AbsTarFile)
1658 rmtarballmd5cmd=
"rm -Rf %s"%(AbsTarFileMD5)
1659 rmtarballlogcmd=
"rm -Rf %s"%(AbsTarFileLOG)
1665 self.
printFlush(subprocess.Popen(rmtarballcmd,shell=
True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT).stdout.read() )
1666 self.
printFlush(subprocess.Popen(rmtarballmd5cmd,shell=
True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT).stdout.read() )
1667 self.
printFlush(subprocess.Popen(rmtarballlogcmd,shell=
True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT).stdout.read() )
1668 tarballTime.set_end(datetime.datetime.now())
1670 self.
printFlush(
"Performance Suite directory will not be archived in a tarball since --no_tarball option was chosen")
1675 date=time.ctime(time.time())
1676 self.logh.write(
"Performance Suite finished running at %s on %s in directory %s\n" % (date,self.
host,path))
1678 self.logh.write(
"There were no errors detected in any of the log files!\n")
1680 self.logh.write(
"ERROR: There were %s errors detected in the log files, please revise!\n" % self.
ERRORS)
1683 except exceptions.Exception, detail:
1684 self.logh.write(str(detail) +
"\n")
1686 if not self.logh.isatty():
1690 if MailLogRecipients !=
"":
1691 self.
printFlush(
"Sending email notification for this execution of the performance suite with command:")
1692 sendLogByMailcmd=
'cat cmsPerfSuite.log |mail -s "Performance Suite finished running on %s" '%self.
host + MailLogRecipients
1696 self.
printFlush(subprocess.Popen(sendLogByMailcmd,shell=
True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT).stdout.read() )
1698 self.
printFlush(
'No email notification will be sent for this execution of the performance suite since option --mail "" was used')
1700 TotalTime.set_end(datetime.datetime.now())
1701 self.
printFlush(
"Total Running Time\t%s hrs (%s mins)"%(TotalTime.get_duration()[
'hours'],TotalTime.get_duration()[
'minutes']))
1707 PerfSuiteTimerInfo=open(
"PerfSuiteTimerInfo.pkl",
"wb")
1711 self.logh.write(
"Test type\tActual Test\tDuration\tStart Time\tEnd Time\n")
1712 for key
in TimerInfo.keys():
1714 TimerInfoStr.update({key:{}})
1715 for test
in TimerInfo[key].
keys():
1716 TimerInfoStr[key].
update({test:[str(TimerInfo[key][test].get_duration()[
'hours'])+
" hrs ("+str(TimerInfo[key][test].get_duration()[
'minutes'])+
" mins)",TimerInfo[key][test].get_start(),TimerInfo[key][test].get_end()]})
1717 self.logh.write(key+
"\t"+test+
"\t")
1718 self.logh.write(
"%s hrs (%s mins)\t"%(TimerInfo[key][test].get_duration()[
'hours'],TimerInfo[key][test].get_duration()[
'minutes']))
1719 self.logh.write(
"%s\t"%TimerInfo[key][test].get_start())
1720 self.logh.write(
"%s\n"%TimerInfo[key][test].get_end())
1721 pickle.dump(TimerInfoStr,PerfSuiteTimerInfo)
1722 PerfSuiteTimerInfo.close()
1724 self.logh.write(
"Final Performance Suite exit code was %s"%FinalExitCode)
1726 sys.exit(FinalExitCode)
1744 (PerfSuiteArgs[
'create'],
1745 PerfSuiteArgs[
'castordir'],
1746 PerfSuiteArgs[
'TimeSizeEvents'],
1747 PerfSuiteArgs[
'IgProfEvents'],
1748 PerfSuiteArgs[
'CallgrindEvents'],
1749 PerfSuiteArgs[
'MemcheckEvents'],
1750 PerfSuiteArgs[
'cmsScimark'],
1751 PerfSuiteArgs[
'cmsScimarkLarge'],
1752 PerfSuiteArgs[
'cmsdriverOptions'],
1753 PerfSuiteArgs[
'cmsdriverPUOptions'],
1754 PerfSuiteArgs[
'stepOptions'],
1755 PerfSuiteArgs[
'quicktest'],
1756 PerfSuiteArgs[
'profilers'],
1757 PerfSuiteArgs[
'cpus'],
1758 PerfSuiteArgs[
'cores'],
1759 PerfSuiteArgs[
'prevrel'],
1760 PerfSuiteArgs[
'bypasshlt'],
1761 PerfSuiteArgs[
'runonspare'],
1762 PerfSuiteArgs[
'perfsuitedir'],
1763 PerfSuiteArgs[
'logfile'],
1764 PerfSuiteArgs[
'TimeSizeCandles'],
1765 PerfSuiteArgs[
'IgProfCandles'],
1766 PerfSuiteArgs[
'CallgrindCandles'],
1767 PerfSuiteArgs[
'MemcheckCandles'],
1768 PerfSuiteArgs[
'TimeSizePUCandles'],
1769 PerfSuiteArgs[
'IgProfPUCandles'],
1770 PerfSuiteArgs[
'CallgrindPUCandles'],
1771 PerfSuiteArgs[
'MemcheckPUCandles'],
1772 PerfSuiteArgs[
'PUInputFile'],
1773 PerfSuiteArgs[
'userInputFile'],
1774 PerfSuiteArgs[
'MailLogRecipients'],
1775 PerfSuiteArgs[
'tarball']
1776 ) = suite.optionParse(argv)
1778 if PerfSuiteArgs[
'create']:
1779 suite.createIgVolume()
1781 if not PerfSuiteArgs[
'logfile'] ==
None:
1782 if os.path.exists(PerfSuiteArgs[
'logfile']):
1783 oldlogfile=PerfSuiteArgs[
'logfile']+
"_"+time.strftime(
"%d-%m-%Y_%H:%M:%S")
1785 mvOldLogfile=subprocess.Popen(
"mv %s %s"%(PerfSuiteArgs[
'logfile'],oldlogfile), shell=
True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
1786 mvOldLogfileExitCode=mvOldLogfile.wait()
1789 ActualLogfile = open(PerfSuiteArgs[
'logfile'],
"w")
1790 if mvOldLogfileExitCode:
1791 ActualLogfile.write(
"Please check what happened: A file named %s existed already and the attempt to move it to %s produced the following output: %s\n"%(PerfSuiteArgs[
'logfile'],oldlogfile,mvOldLogfile.stdout))
1793 ActualLogfile.write(
"***WARNING! A file named %s existed already!\n***It has been moved to %s before starting the current logfile!\n"%(PerfSuiteArgs[
'logfile'],oldlogfile))
1794 except (OSError, IOError), detail:
1795 ActualLogfile.write(
"Failed to open the intended logfile %s, detail error:\n%s"%(PerfSuiteArgs[
'logfile'],detail))
1799 ActualLogfile = open(PerfSuiteArgs[
'logfile'],
"w")
1800 except (OSError, IOError), detail:
1801 ActualLogfile.write(
"Failed to open the intended logfile %s, detail error:\n%s"%(PerfSuiteArgs[
'logfile'],detail))
1802 ActualLogfile.flush()
1805 ActualLogfile.write(
"Performance suite invoked with command line:\n")
1806 cmdline=reduce(
lambda x,y:x+
" "+y,sys.argv)
1807 ActualLogfile.write(cmdline+
"\n")
1808 ActualLogfile.flush()
1811 ActualLogfile.write(
"Initial PerfSuite Arguments:\n")
1812 for key
in PerfSuiteArgs.keys():
1813 ActualLogfile.write(
"%s %s\n"%(key,PerfSuiteArgs[key]))
1814 ActualLogfile.flush()
1817 PerfSuiteArgs[
'cpu_list'] = PerfSuiteArgs[
'cpus']
1820 if len(PerfSuiteArgs[
'cpus']) > 1:
1821 ActualLogfile.write(
"More than 1 cpu: threading the Performance Suite!\n")
1822 outputdir=PerfSuiteArgs[
'perfsuitedir']
1823 runonspare=PerfSuiteArgs[
'runonspare']
1824 cpus=PerfSuiteArgs[
'cpus']
1825 cores=PerfSuiteArgs[
'cores']
1827 for core
in range(PerfSuiteArgs[
'cores']):
1828 cmsScimarkLaunch_pslist={}
1829 if len(cpus) != cores:
1830 if (core
not in cpus):
1832 ActualLogfile.write(
"Submitting cmsScimarkLaunch.csh to run on core cpu "+str(core)+
"\n")
1833 subcmd =
"cd %s ; cmsScimarkLaunch.csh %s" % (outputdir, str(core))
1834 command=
"taskset -c %s sh -c \"%s\" &" % (str(core), subcmd)
1836 ActualLogfile.write(command+
"\n")
1839 cmsScimarkLaunch_pslist[core]=subprocess.Popen(command,shell=
True,stdout=subprocess.PIPE,stderr=subprocess.PIPE)
1840 ActualLogfile.write(
"Spawned %s \n with PID %s"%(command,cmsScimarkLaunch_pslist[core].pid))
1841 ActualLogfile.flush()
1842 PerfSuiteArgs[
'runonspare']=
False
1843 logfile=PerfSuiteArgs[
'logfile']
1851 cpudir = os.path.join(outputdir,
"cpu_%s" % cpu)
1852 if not os.path.exists(cpudir):
1854 PerfSuiteArgs[
'perfsuitedir']=cpudir
1855 PerfSuiteArgs[
'cpus']=[cpu]
1856 if PerfSuiteArgs[
'logfile']:
1857 PerfSuiteArgs[
'logfile']=os.path.join(cpudir,os.path.basename(PerfSuiteArgs[
'logfile']))
1859 PerfSuiteArgs[
'logfile']=os.path.join(cpudir,
"cmsPerfSuiteThread.log")
1861 suitethread[cpu]=PerfThread(**PerfSuiteArgs)
1863 ActualLogfile.write(
"Launching PerfSuite thread on cpu%s"%cpu)
1864 ActualLogfile.flush()
1867 suitethread[cpu].
start()
1869 while reduce(
lambda x,y: x
or y,
map(
lambda x: x.isAlive(),suitethread.values())):
1873 except (KeyboardInterrupt, SystemExit):
1875 ActualLogfile.write(
"All PerfSuite threads have completed!\n")
1876 ActualLogfile.flush()
1879 suite.runPerfSuite(**PerfSuiteArgs)
1881 if __name__ ==
"__main__":
def runcmd
Run a command and return the exit status.
def mkCandleDir
Make directory for a particular candle and profiler.
def benchmarks
Run cmsScimark benchmarks a number of times.
def runCmdSet
Run a list of commands using system ! We should rewrite this not to use system (most cases it is unne...
def valFilterReport
Filter lines in the valgrind report that match GEN,SIM.
_verbose
Check logfile option.
def runCmsInput
Wrapper for cmsRelvalreportInput.
def printFlush
Print and flush a string (for output to a log file)
def simpleGenReport
Prepares the profiling directory and runs all the selected profiles (if this is not a unit test) ...
PerfTestTotalTimer
FIXME: We may want to introduce a switch here or agree on a different default (currently 10 cmsScimar...
static std::string join(char **cmd)
def cprootfile
Copy root file from another candle's directory ! Again this is messy.
def runPerfSuite
Runs benchmarking, cpu spinlocks on spare cores and profiles selected candles.
def testCmsDriver
Test cmsDriver.py (parses the simcandles file, removing duplicate lines, and runs the cmsDriver part)...
def displayErrors
Display G4 cerr errors and CMSExceptions in the logfile.
def runCmsReport
This function is a wrapper around cmsRelvalreport.
How EventSelector::AcceptEvent() decides whether to accept an event for output otherwise it is excluding the probing of A single or multiple positive and the trigger will pass if any such matching triggers are PASS or EXCEPTION[A criterion thatmatches no triggers at all is detected and causes a throw.] A single negative with an expectation of appropriate bit checking in the decision and the trigger will pass if any such matching triggers are FAIL or EXCEPTION A wildcarded negative criterion that matches more than one trigger in the trigger list("!*","!HLTx*"if it matches 2 triggers or more) will accept the event if all the matching triggers are FAIL.It will reject the event if any of the triggers are PASS or EXCEPTION(this matches the behavior of"!*"before the partial wildcard feature was incorporated).Triggers which are in the READY state are completely ignored.(READY should never be returned since the trigger paths have been run