cpistack-collect.py 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. #!/usr/bin/env python
  2. import sys, os, env_setup
  3. sys.path.append(os.path.join(env_setup.benchmarks_root(), 'tools', 'scheduler'))
  4. import getopt, intelqueue, iqclient, iqlib, cpistack, buildstack, gnuplot
  5. ic = iqclient.IntelClient()
  6. age = 0 # in days, 0 == get all
  7. use_simple = False
  8. groupname = 'iiswc2011'
  9. outputpath = 'cpistack-collect'
  10. jobids = {}
  11. errors_seen = 0
  12. jobs_processed = 0
  13. for job in ic.job_list(groupname, age*86400, intelqueue.JobState.DONE):
  14. iqlib.job_annotate(job)
  15. # Store the most recently completed jobid
  16. jobids[job['name']] = job['jobid']
  17. # Sort the jobs
  18. jobids_x = sorted(jobids.iteritems(), key=lambda (name, jobid): (name.split('-')[1], name.split('-')[2], name.split('-')[3], int(name.split('-')[4])))
  19. html_file = open(os.path.join(outputpath, 'index.html'), 'w')
  20. html_file.write(r'''
  21. <html>
  22. <head>
  23. <script type="text/javascript" src="jquery.js"></script>
  24. <script type="text/javascript">
  25. function showDiv(objectID) {
  26. var theElementStyle = document.getElementById(objectID);
  27. if(theElementStyle.style.display == "none")
  28. {
  29. theElementStyle.style.display = "block";
  30. }
  31. else
  32. {
  33. theElementStyle.style.display = "none";
  34. }
  35. }
  36. function showAllDiv() {
  37. $('[id^=cpistack-]').each(function() {
  38. this.style.display = "block";
  39. });
  40. }
  41. function hideAllDiv() {
  42. $('[id^=cpistack-]').each(function() {
  43. this.style.display = "none";
  44. });
  45. }
  46. </script>
  47. </head>
  48. <body>
  49. <a href="#" onClick="showAllDiv();return false;">Show All</a></br>
  50. <a href="#" onClick="hideAllDiv();return false;">Hide All</a></br>
  51. ''')
  52. # Start with a fresh CSV file
  53. file(os.path.join(outputpath, 'cpi-stack.csv'), 'w').write('')
  54. csv_print_header = True # Only print the header one time
  55. for (jobname, jobid) in jobids_x:
  56. print jobname, jobid
  57. def output(jobname, threads):
  58. global csv_print_header, jobs_processed, errors_seen
  59. outputfile = 'cpistack-%d-%s' % ( jobid, jobname )
  60. try:
  61. cpistack.cpistack(jobid = jobid, job_name = jobname, outputfile = outputfile + '-cpi', outputdir = outputpath, use_simple_mem = False, gen_text_stack = False, use_cpi = True, threads = threads)
  62. cpistack.cpistack(jobid = jobid, job_name = jobname, outputfile = outputfile + '-cycle', outputdir = outputpath, use_simple_mem = False, gen_text_stack = False, use_cpi = False, threads = threads)
  63. cpistack.cpistack(jobid = jobid, job_name = jobname, outputfile = outputfile + '-nocollapse', outputdir = outputpath, use_simple_mem = False, gen_text_stack = False, use_cpi = False, no_collapse = True, gen_csv_stack = True, csv_print_header = csv_print_header, threads = threads)
  64. csv_print_header = False
  65. jobs_processed += 1
  66. except (KeyError, ZeroDivisionError), e:
  67. raise
  68. errors_seen += 1
  69. # For debugging
  70. #sys.stderr.write(str(jobid) + '\n');
  71. return
  72. html_file.write(r'''
  73. <div>
  74. <a href="#" onClick="showDiv('%s');return false;">%s</a>
  75. <div id="%s" style='display: none'>
  76. <table style="width: 100%%" cellspacing="0" cellpadding="0">
  77. <tr>
  78. <td><img src="%s-cpi.jpg"/></td>
  79. <td><img src="%s-cycle.jpg"/></td>
  80. <td><img src="%s-nocollapse.jpg"/></td>
  81. </tr>
  82. </table>
  83. </div>
  84. </div>
  85. ''' % (outputfile, outputfile, outputfile, outputfile, outputfile, outputfile) )
  86. if 'parsec-dedup' in jobname:
  87. nthreads = int(jobname.split('-')[-1]) / 4
  88. names = ['ChunkProcess', 'FindAllAnchors', 'Compress']
  89. ttt = [range(1,1+nthreads),range(1+nthreads,1+2*nthreads),range(1+2*nthreads,1+3*nthreads)]
  90. for name, threads in zip(names, ttt):
  91. output(jobname.replace('dedup', 'dedup_%s' % name), threads)
  92. elif 'parsec-ferret' in jobname:
  93. nthreads = (int(jobname.split('-')[-1]) - 3) / 4
  94. names = ['vec', 'rank']
  95. ttt = [range(2+2*nthreads,2+3*nthreads),range(2+3*nthreads,2+4*nthreads)]
  96. for name, threads in zip(names, ttt):
  97. output(jobname.replace('ferret', 'ferret_%s' % name), threads)
  98. else:
  99. output(jobname, None)
  100. html_file.write(r'''
  101. </body>
  102. </html>
  103. ''')
  104. html_file.close()
  105. print '\nJobs successfully processed = %d' % jobs_processed
  106. if errors_seen > 0:
  107. print 'Errors seen = %d' % errors_seen