01728 :
01729
01730
01731
01732
01733
01734
01735
01736
01737 suite=PerfSuite()
01738
01739
01740
01741
01742
01743 PerfSuiteArgs={}
01744 (PerfSuiteArgs['create'],
01745 PerfSuiteArgs['castordir'],
01746 PerfSuiteArgs['TimeSizeEvents'],
01747 PerfSuiteArgs['IgProfEvents'],
01748 PerfSuiteArgs['CallgrindEvents'],
01749 PerfSuiteArgs['MemcheckEvents'],
01750 PerfSuiteArgs['cmsScimark'],
01751 PerfSuiteArgs['cmsScimarkLarge'],
01752 PerfSuiteArgs['cmsdriverOptions'],
01753 PerfSuiteArgs['cmsdriverPUOptions'],
01754 PerfSuiteArgs['stepOptions'],
01755 PerfSuiteArgs['quicktest'],
01756 PerfSuiteArgs['profilers'],
01757 PerfSuiteArgs['cpus'],
01758 PerfSuiteArgs['cores'],
01759 PerfSuiteArgs['prevrel'],
01760 PerfSuiteArgs['bypasshlt'],
01761 PerfSuiteArgs['runonspare'],
01762 PerfSuiteArgs['perfsuitedir'],
01763 PerfSuiteArgs['logfile'],
01764 PerfSuiteArgs['TimeSizeCandles'],
01765 PerfSuiteArgs['IgProfCandles'],
01766 PerfSuiteArgs['CallgrindCandles'],
01767 PerfSuiteArgs['MemcheckCandles'],
01768 PerfSuiteArgs['TimeSizePUCandles'],
01769 PerfSuiteArgs['IgProfPUCandles'],
01770 PerfSuiteArgs['CallgrindPUCandles'],
01771 PerfSuiteArgs['MemcheckPUCandles'],
01772 PerfSuiteArgs['PUInputFile'],
01773 PerfSuiteArgs['userInputFile'],
01774 PerfSuiteArgs['MailLogRecipients'],
01775 PerfSuiteArgs['tarball']
01776 ) = suite.optionParse(argv)
01777
01778 if PerfSuiteArgs['create']:
01779 suite.createIgVolume()
01780
01781 if not PerfSuiteArgs['logfile'] == None:
01782 if os.path.exists(PerfSuiteArgs['logfile']):
01783 oldlogfile=PerfSuiteArgs['logfile']+"_"+time.strftime("%d-%m-%Y_%H:%M:%S")
01784
01785 mvOldLogfile=subprocess.Popen("mv %s %s"%(PerfSuiteArgs['logfile'],oldlogfile), shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
01786 mvOldLogfileExitCode=mvOldLogfile.wait()
01787
01788 try:
01789 ActualLogfile = open(PerfSuiteArgs['logfile'],"w")
01790 if mvOldLogfileExitCode:
01791 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))
01792 else:
01793 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))
01794 except (OSError, IOError), detail:
01795 ActualLogfile.write("Failed to open the intended logfile %s, detail error:\n%s"%(PerfSuiteArgs['logfile'],detail))
01796
01797 else:
01798 try:
01799 ActualLogfile = open(PerfSuiteArgs['logfile'],"w")
01800 except (OSError, IOError), detail:
01801 ActualLogfile.write("Failed to open the intended logfile %s, detail error:\n%s"%(PerfSuiteArgs['logfile'],detail))
01802 ActualLogfile.flush()
01803
01804
01805 ActualLogfile.write("Performance suite invoked with command line:\n")
01806 cmdline=reduce(lambda x,y:x+" "+y,sys.argv)
01807 ActualLogfile.write(cmdline+"\n")
01808 ActualLogfile.flush()
01809
01810
01811 ActualLogfile.write("Initial PerfSuite Arguments:\n")
01812 for key in PerfSuiteArgs.keys():
01813 ActualLogfile.write("%s %s\n"%(key,PerfSuiteArgs[key]))
01814 ActualLogfile.flush()
01815
01816
01817 PerfSuiteArgs['cpu_list'] = PerfSuiteArgs['cpus']
01818
01819
01820 if len(PerfSuiteArgs['cpus']) > 1:
01821 ActualLogfile.write("More than 1 cpu: threading the Performance Suite!\n")
01822 outputdir=PerfSuiteArgs['perfsuitedir']
01823 runonspare=PerfSuiteArgs['runonspare']
01824 cpus=PerfSuiteArgs['cpus']
01825 cores=PerfSuiteArgs['cores']
01826 if runonspare:
01827 for core in range(PerfSuiteArgs['cores']):
01828 cmsScimarkLaunch_pslist={}
01829 if len(cpus) != cores:
01830 if (core not in cpus):
01831
01832 ActualLogfile.write("Submitting cmsScimarkLaunch.csh to run on core cpu "+str(core)+"\n")
01833 subcmd = "cd %s ; cmsScimarkLaunch.csh %s" % (outputdir, str(core))
01834 command="taskset -c %s sh -c \"%s\" &" % (str(core), subcmd)
01835
01836 ActualLogfile.write(command+"\n")
01837
01838
01839 cmsScimarkLaunch_pslist[core]=subprocess.Popen(command,shell=True,stdout=subprocess.PIPE,stderr=subprocess.PIPE)
01840 ActualLogfile.write("Spawned %s \n with PID %s"%(command,cmsScimarkLaunch_pslist[core].pid))
01841 ActualLogfile.flush()
01842 PerfSuiteArgs['runonspare']=False
01843 logfile=PerfSuiteArgs['logfile']
01844 suitethread={}
01845 for cpu in cpus:
01846
01847
01848
01849
01850
01851 cpudir = os.path.join(outputdir,"cpu_%s" % cpu)
01852 if not os.path.exists(cpudir):
01853 os.mkdir(cpudir)
01854 PerfSuiteArgs['perfsuitedir']=cpudir
01855 PerfSuiteArgs['cpus']=[cpu]
01856 if PerfSuiteArgs['logfile']:
01857 PerfSuiteArgs['logfile']=os.path.join(cpudir,os.path.basename(PerfSuiteArgs['logfile']))
01858 else:
01859 PerfSuiteArgs['logfile']=os.path.join(cpudir,"cmsPerfSuiteThread.log")
01860
01861 suitethread[cpu]=PerfThread(**PerfSuiteArgs)
01862
01863 ActualLogfile.write("Launching PerfSuite thread on cpu%s"%cpu)
01864 ActualLogfile.flush()
01865
01866
01867 suitethread[cpu].start()
01868
01869 while reduce(lambda x,y: x or y, map(lambda x: x.isAlive(),suitethread.values())):
01870 try:
01871 time.sleep(5.0)
01872 sys.stdout.flush()
01873 except (KeyboardInterrupt, SystemExit):
01874 raise
01875 ActualLogfile.write("All PerfSuite threads have completed!\n")
01876 ActualLogfile.flush()
01877
01878 else:
01879 suite.runPerfSuite(**PerfSuiteArgs)
01880