Advertisement
Guest User

Untitled

a guest
Jan 22nd, 2017
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.57 KB | None | 0 0
  1. import subprocess
  2. import matplotlib as mpl
  3. mpl.use('Agg')
  4. import matplotlib.pyplot as plt
  5. import time
  6.  
  7. dim = [1024, 4096, 16384, 65536, 262144, 1048576, 4194304, 16777216]
  8. #dim = [1024, 4096, 16384]
  9. #groups = {'MEM':'MBytes', 'CACHE':'data cache miss ratio', 'FLOPS_DP':'MFLOP', 'Tempo':'Tempo'}
  10. groups = {'Tempo':'Tempo'}
  11. bandas = [7, 27]
  12. result_t1 = {}
  13. result_t2 = {}
  14.  
  15. for b in bandas:
  16. for k, v in groups.items():
  17. if not k in result_t1:
  18. result_t1[k] = {}
  19. result_t1[k][b] = {}
  20. for d in dim:
  21. result_t1[k][b][d] = {}
  22. if 'Tempo' in k:
  23. command = "t1/cgSolver %s %s -i 10 -o exitFile.txt | grep '%s'" % (d,b,v)
  24. else:
  25. command = "likwid-perfctr -C 0 -f -g %s -m t1/cgSolver %s %s -i 10 -o exitFile.txt | grep '%s'" % (k,d,b,v)
  26. print command
  27. output = subprocess.check_output(command, shell = True )
  28. if 'Tempo' in k:
  29. output = output.split('|')
  30. tempoG = output[0].split(':')
  31. tempoMVV = output[1].split(':')
  32. tempoMMV = output[2].split(':')
  33. result_t1[k][b][d]['timeG'] = tempoG[1].replace(" ", "").replace("\n", "")
  34. result_t1[k][b][d]['timeMVV'] = tempoMVV[1].replace(" ", "").replace("\n", "")
  35. result_t1[k][b][d]['timeMMV'] = tempoMMV[1].replace(" ", "").replace("\n", "")
  36. else:
  37. result_t1[k][b][d]['MVV'] = output.split('|')[2].replace(" ", "")
  38. result_t1[k][b][d]['MMV'] = output.split('|')[5].replace(" ", "")
  39. time.sleep(2)
  40.  
  41. for b in bandas:
  42. for k, v in groups.items():
  43. if not k in result_t2:
  44. result_t2[k] = {}
  45. result_t2[k][b] = {}
  46. for d in dim:
  47. result_t2[k][b][d] = {}
  48. if 'Tempo' in k:
  49. command = "t2/cgSolver %s %s -i 10 -o exitFile.txt | grep '%s'" % (d,b,v)
  50. else:
  51. command = "likwid-perfctr -C 0 -f -g %s -m t2/cgSolver %s %s -i 10 -o exitFile.txt | grep '%s'" % (k,d,b,v)
  52. print command
  53. output = subprocess.check_output(command, shell = True )
  54. if 'Tempo' in k:
  55. output = output.split('|')
  56. tempoG = output[0].split(':')
  57. tempoMVV = output[1].split(':')
  58. tempoMMV = output[2].split(':')
  59. result_t2[k][b][d]['timeG'] = tempoG[1].replace(" ", "").replace("\n", "")
  60. result_t2[k][b][d]['timeMVV'] = tempoMVV[1].replace(" ", "").replace("\n", "")
  61. result_t2[k][b][d]['timeMMV'] = tempoMMV[1].replace(" ", "").replace("\n", "")
  62. else:
  63. result_t2[k][b][d]['MVV'] = output.split('|')[2].replace(" ", "")
  64. result_t2[k][b][d]['MMV'] = output.split('|')[5].replace(" ", "")
  65. time.sleep(2)
  66.  
  67.  
  68.  
  69. lineG_t1 = []
  70. lineMMV_t1 = []
  71. lineMVV_t1 = []
  72. lineG_t2 = []
  73. lineMMV_t2 = []
  74. lineMVV_t2 = []
  75.  
  76. for g in result_t1:
  77. for b in result_t1[g]:
  78. for d in result_t1[g][b]:
  79. if 'Tempo' in g:
  80. lineMMV_t1.append(result_t1[g][b][d]['timeMMV'])
  81. lineMVV_t1.append(result_t1[g][b][d]['timeMVV'])
  82. lineG_t1.append(result_t2[g][b][d]['timeG'])
  83. lineMMV_t2.append(result_t2[g][b][d]['timeMMV'])
  84. lineMVV_t2.append(result_t2[g][b][d]['timeMVV'])
  85. lineG_t2.append(result_t2[g][b][d]['timeG'])
  86. else:
  87. lineMMV_t1.append(result_t1[g][b][d]['MMV'])
  88. lineMVV_t1.append(result_t1[g][b][d]['MVV'])
  89. lineMMV_t2.append(result_t2[g][b][d]['MMV'])
  90. lineMVV_t2.append(result_t2[g][b][d]['MVV'])
  91. plt.xlabel('Matrix Size')
  92.  
  93. if g == "MEM":
  94. plt.ylabel('MBytes/s')
  95. plt.title('Memory bandwidth [MBytes/s]')
  96.  
  97. if g == "CACHE":
  98. plt.ylabel('data cache miss ratio')
  99. plt.title('Data Cache Miss Ratio')
  100.  
  101. if g == "FLOPS_DP":
  102. plt.ylabel('MFLOP/s')
  103. plt.title('MFLOP per second')
  104.  
  105. if g == 'Tempo':
  106. plt.ylabel('Tempo')
  107. plt.title('Tempo de execucao')
  108.  
  109. print g, b, d
  110. print lineMMV_t1
  111. print lineMVV_t1
  112. print lineG_t1
  113. print lineMMV_t2
  114. print lineMVV_t2
  115. print lineG_t2
  116. marker_style = dict(color='cornflowerblue', linestyle=':', marker='o',
  117. markersize=5, markerfacecoloralt='gray')
  118. line1 = plt.plot(dim, lineMMV_t1, '-o', label='T1 MMV %s' % b)
  119. line3 = plt.plot(dim, lineMMV_t2, '-o', label='T2 MMV %s' % b)
  120. line2 = plt.plot(dim, lineMVV_t1, '-o', label='T1 MVV %s' % b)
  121. line4 = plt.plot(dim, lineMVV_t2, '-o', label='T2 MVV %s' % b)
  122. if g == 'Tempo':
  123. line5 = plt.plot(dim, lineG_t1, '-o', label='T1 Metodo %s' % b)
  124. line6 = plt.plot(dim, lineG_t2, '-o', label='T2 Metodo %s' % b)
  125.  
  126.  
  127. plt.setp(line1, color='r', linewidth=1.5)
  128. plt.setp(line3, color='b', linewidth=1.5)
  129. plt.setp(line2, color='g', linewidth=1.5)
  130. plt.setp(line4, color='m', linewidth=1.5)
  131.  
  132. if g == 'Tempo':
  133. plt.setp(line5, color='c', linewidth=1.5)
  134. plt.setp(line6, color='k', linewidth=1.5)
  135.  
  136. plt.legend( loc=0, borderaxespad=0., fontsize=10, framealpha=60)
  137. plt.xticks(dim)
  138. plt.xscale("log")
  139. plt.yscale("log")
  140. figName = "%s-%s.png" % (g, b)
  141. plt.savefig(figName)
  142. lineMMV_t1 = []
  143. lineMVV_t1 = []
  144. lineMMV_t2 = []
  145. lineMVV_t2 = []
  146. lineG_t1 = []
  147. lineG_t2 = []
  148. plt.clf()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement