CMS 3D CMS Logo

Classes | Functions
cmsPerfSuite Namespace Reference

Classes

class  PerfSuite
 
class  PerfSuiteTimer
 
class  PerfThread
 

Functions

def _cleanup ()
 
def main (argv=[__name__])
 

Function Documentation

def cmsPerfSuite._cleanup ( )
private

Definition at line 17 of file cmsPerfSuite.py.

17 def _cleanup():
18  pass
19 #Override the function in subprocess
20 subprocess._cleanup=_cleanup
21 
def _cleanup()
Definition: cmsPerfSuite.py:17
def cmsPerfSuite.main (   argv = [__name__])

Definition at line 1730 of file cmsPerfSuite.py.

1730 def main(argv=[__name__]): #argv is a list of arguments.
1731  #Valid ways to call main with arguments:
1732  #main(["--cmsScimark",10])
1733  #main(["-t100"]) #With the caveat that the options.timeSize will be of type string... so should avoid using this!
1734  #main(["-timeSize,100])
1735  #Invalid ways:
1736  #main(["One string with all options"])
1737 
1738  #Let's instatiate the class:
1739  suite=PerfSuite()
1740 
1741  #print suite
1742  #Uncomment this for tests with main() in inteactive python:
1743  #print suite.optionParse(argv)
1744 
1745  PerfSuiteArgs={}
1746  (PerfSuiteArgs['create'],
1747  PerfSuiteArgs['castordir'],
1748  PerfSuiteArgs['TimeSizeEvents'],
1749  PerfSuiteArgs['IgProfEvents'],
1750  PerfSuiteArgs['CallgrindEvents'],
1751  PerfSuiteArgs['MemcheckEvents'],
1752  PerfSuiteArgs['cmsScimark'],
1753  PerfSuiteArgs['cmsScimarkLarge'],
1754  PerfSuiteArgs['cmsdriverOptions'],
1755  PerfSuiteArgs['cmsdriverPUOptions'],
1756  PerfSuiteArgs['stepOptions'],
1757  PerfSuiteArgs['quicktest'],
1758  PerfSuiteArgs['profilers'],
1759  PerfSuiteArgs['cpus'],
1760  PerfSuiteArgs['cores'],
1761  PerfSuiteArgs['prevrel'],
1762  PerfSuiteArgs['bypasshlt'],
1763  PerfSuiteArgs['runonspare'],
1764  PerfSuiteArgs['perfsuitedir'],
1765  PerfSuiteArgs['logfile'],
1766  PerfSuiteArgs['TimeSizeCandles'],
1767  PerfSuiteArgs['IgProfCandles'],
1768  PerfSuiteArgs['CallgrindCandles'],
1769  PerfSuiteArgs['MemcheckCandles'],
1770  PerfSuiteArgs['TimeSizePUCandles'],
1771  PerfSuiteArgs['IgProfPUCandles'],
1772  PerfSuiteArgs['CallgrindPUCandles'],
1773  PerfSuiteArgs['MemcheckPUCandles'],
1774  PerfSuiteArgs['PUInputFile'],
1775  PerfSuiteArgs['userInputFile'],
1776  PerfSuiteArgs['MailLogRecipients'],
1777  PerfSuiteArgs['tarball']
1778  ) = suite.optionParse(argv)
1779 
1780  if PerfSuiteArgs['create']: # Before anything, request the AFS volume (it takes some time...)
1781  suite.createIgVolume()
1782 
1783  if not PerfSuiteArgs['logfile'] == None:
1784  if os.path.exists(PerfSuiteArgs['logfile']):
1785  oldlogfile=PerfSuiteArgs['logfile']+"_"+time.strftime("%d-%m-%Y_%H:%M:%S")
1786  #Move old logfile to a file with the same filename plus a timestamp appended
1787  mvOldLogfile=subprocess.Popen("mv %s %s"%(PerfSuiteArgs['logfile'],oldlogfile), shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
1788  mvOldLogfileExitCode=mvOldLogfile.wait()
1789  #Finally open the logfile and put the information above in it:
1790  try:
1791  ActualLogfile = open(PerfSuiteArgs['logfile'],"w")
1792  if mvOldLogfileExitCode:
1793  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))
1794  else:
1795  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))
1796  except (OSError, IOError) as detail:
1797  ActualLogfile.write("Failed to open the intended logfile %s, detail error:\n%s"%(PerfSuiteArgs['logfile'],detail))
1798 
1799  else:
1800  try:
1801  ActualLogfile = open(PerfSuiteArgs['logfile'],"w")
1802  except (OSError, IOError) as detail:
1803  ActualLogfile.write("Failed to open the intended logfile %s, detail error:\n%s"%(PerfSuiteArgs['logfile'],detail))
1804  ActualLogfile.flush()
1805 
1806  #Three lines to add the exact command line used to call the performance suite directly in the log.
1807  ActualLogfile.write("Performance suite invoked with command line:\n")
1808  cmdline=reduce(lambda x,y:x+" "+y,sys.argv)
1809  ActualLogfile.write(cmdline+"\n")
1810  ActualLogfile.flush()
1811 
1812  #Debug printout that we could silence...
1813  ActualLogfile.write("Initial PerfSuite Arguments:\n")
1814  for key in PerfSuiteArgs.keys():
1815  ActualLogfile.write("%s %s\n"%(key,PerfSuiteArgs[key]))
1816  ActualLogfile.flush()
1817  #print PerfSuiteArgs
1818 
1819  PerfSuiteArgs['cpu_list'] = PerfSuiteArgs['cpus'] #To access the actual number of cpus used inside the threads..
1820 
1821  #Handle in here the case of multiple cores and the loading of cores with cmsScimark:
1822  if len(PerfSuiteArgs['cpus']) > 1:
1823  ActualLogfile.write("More than 1 cpu: threading the Performance Suite!\n")
1824  outputdir=PerfSuiteArgs['perfsuitedir']
1825  runonspare=PerfSuiteArgs['runonspare'] #Save the original value of runonspare for cmsScimark stuff
1826  cpus=PerfSuiteArgs['cpus']
1827  cores=PerfSuiteArgs['cores']
1828  if runonspare:
1829  for core in range(PerfSuiteArgs['cores']):
1830  cmsScimarkLaunch_pslist={}
1831  if len(cpus) != cores: #In case of this (relval), don't load the others with cmsScimark
1832  if (core not in cpus):
1833  #self.logh.write("Submitting cmsScimarkLaunch.csh to run on core cpu "+str(core) + "\n")
1834  ActualLogfile.write("Submitting cmsScimarkLaunch.csh to run on core cpu "+str(core)+"\n")
1835  subcmd = "cd %s ; cmsScimarkLaunch.csh %s" % (outputdir, str(core))
1836  command="taskset -c %s sh -c \"%s\" &" % (str(core), subcmd)
1837  #self.logh.write(command + "\n")
1838  ActualLogfile.write(command+"\n")
1839  #cmsScimarkLaunch.csh is an infinite loop to spawn cmsScimark2 on the other
1840  #cpus so it makes no sense to try reading its stdout/err
1841  cmsScimarkLaunch_pslist[core]=subprocess.Popen(command,shell=True,stdout=subprocess.PIPE,stderr=subprocess.PIPE)
1842  ActualLogfile.write("Spawned %s \n with PID %s"%(command,cmsScimarkLaunch_pslist[core].pid))
1843  ActualLogfile.flush()
1844  PerfSuiteArgs['runonspare']=False #Set it to false to avoid cmsScimark being spawned by each thread
1845  logfile=PerfSuiteArgs['logfile']
1846  suitethread={}
1847  for cpu in cpus:
1848  #Make arguments "threaded" by setting for each instance of the suite:
1849  #1-A different output (sub)directory
1850  #2-Only 1 core on which to run
1851  #3-Automatically have a logfile... otherwise stdout is lost?
1852  #To be done:[3-A flag for Valgrind not to "thread" itself onto the other cores..]
1853  cpudir = os.path.join(outputdir,"cpu_%s" % cpu)
1854  if not os.path.exists(cpudir):
1855  os.mkdir(cpudir)
1856  PerfSuiteArgs['perfsuitedir']=cpudir
1857  PerfSuiteArgs['cpus']=[cpu] #Keeping the name cpus for now FIXME: change it to cpu in the whole code
1858  if PerfSuiteArgs['logfile']:
1859  PerfSuiteArgs['logfile']=os.path.join(cpudir,os.path.basename(PerfSuiteArgs['logfile']))
1860  else:
1861  PerfSuiteArgs['logfile']=os.path.join(cpudir,"cmsPerfSuiteThread.log")
1862  #Now spawn the thread with:
1863  suitethread[cpu]=PerfThread(**PerfSuiteArgs)
1864  #ActualLogfile.write(suitethread[cpu])
1865  ActualLogfile.write("Launching PerfSuite thread on cpu%s"%cpu)
1866  ActualLogfile.flush()
1867  #print "With arguments:"
1868  #print PerfSuiteArgs
1869  suitethread[cpu].start()
1870 
1871  while reduce(lambda x,y: x or y, map(lambda x: x.isAlive(),suitethread.values())):
1872  try:
1873  time.sleep(5.0)
1874  sys.stdout.flush()
1875  except (KeyboardInterrupt, SystemExit):
1876  raise
1877  ActualLogfile.write("All PerfSuite threads have completed!\n")
1878  ActualLogfile.flush()
1879 
1880  else: #No threading, just run the performance suite on the cpu core selected
1881  suite.runPerfSuite(**PerfSuiteArgs)
1882 
Definition: start.py:1
def main(argv=[__name__])
#define str(s)