CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
Classes | Functions
cmsPerfSuite Namespace Reference

Classes

class  PerfSuite
 
class  PerfSuiteTimer
 
class  PerfThread
 

Functions

def _cleanup
 
def main
 

Function Documentation

def cmsPerfSuite._cleanup ( )
private

Definition at line 15 of file cmsPerfSuite.py.

15 
16 def _cleanup():
17  pass
18 #Override the function in subprocess
19 subprocess._cleanup=_cleanup
def cmsPerfSuite.main (   argv = [__name__])

Definition at line 1728 of file cmsPerfSuite.py.

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