Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import subprocess
- import matplotlib as mpl
- mpl.use('Agg')
- import matplotlib.pyplot as plt
- import time
- dim = [1024, 4096, 16384, 65536, 262144, 1048576, 4194304, 16777216]
- #dim = [1024, 4096, 16384]
- #groups = {'MEM':'MBytes', 'CACHE':'data cache miss ratio', 'FLOPS_DP':'MFLOP', 'Tempo':'Tempo'}
- groups = {'Tempo':'Tempo'}
- bandas = [7, 27]
- result_t1 = {}
- result_t2 = {}
- for b in bandas:
- for k, v in groups.items():
- if not k in result_t1:
- result_t1[k] = {}
- result_t1[k][b] = {}
- for d in dim:
- result_t1[k][b][d] = {}
- if 'Tempo' in k:
- command = "t1/cgSolver %s %s -i 10 -o exitFile.txt | grep '%s'" % (d,b,v)
- else:
- command = "likwid-perfctr -C 0 -f -g %s -m t1/cgSolver %s %s -i 10 -o exitFile.txt | grep '%s'" % (k,d,b,v)
- print command
- output = subprocess.check_output(command, shell = True )
- if 'Tempo' in k:
- output = output.split('|')
- tempoG = output[0].split(':')
- tempoMVV = output[1].split(':')
- tempoMMV = output[2].split(':')
- result_t1[k][b][d]['timeG'] = tempoG[1].replace(" ", "").replace("\n", "")
- result_t1[k][b][d]['timeMVV'] = tempoMVV[1].replace(" ", "").replace("\n", "")
- result_t1[k][b][d]['timeMMV'] = tempoMMV[1].replace(" ", "").replace("\n", "")
- else:
- result_t1[k][b][d]['MVV'] = output.split('|')[2].replace(" ", "")
- result_t1[k][b][d]['MMV'] = output.split('|')[5].replace(" ", "")
- time.sleep(2)
- for b in bandas:
- for k, v in groups.items():
- if not k in result_t2:
- result_t2[k] = {}
- result_t2[k][b] = {}
- for d in dim:
- result_t2[k][b][d] = {}
- if 'Tempo' in k:
- command = "t2/cgSolver %s %s -i 10 -o exitFile.txt | grep '%s'" % (d,b,v)
- else:
- command = "likwid-perfctr -C 0 -f -g %s -m t2/cgSolver %s %s -i 10 -o exitFile.txt | grep '%s'" % (k,d,b,v)
- print command
- output = subprocess.check_output(command, shell = True )
- if 'Tempo' in k:
- output = output.split('|')
- tempoG = output[0].split(':')
- tempoMVV = output[1].split(':')
- tempoMMV = output[2].split(':')
- result_t2[k][b][d]['timeG'] = tempoG[1].replace(" ", "").replace("\n", "")
- result_t2[k][b][d]['timeMVV'] = tempoMVV[1].replace(" ", "").replace("\n", "")
- result_t2[k][b][d]['timeMMV'] = tempoMMV[1].replace(" ", "").replace("\n", "")
- else:
- result_t2[k][b][d]['MVV'] = output.split('|')[2].replace(" ", "")
- result_t2[k][b][d]['MMV'] = output.split('|')[5].replace(" ", "")
- time.sleep(2)
- lineG_t1 = []
- lineMMV_t1 = []
- lineMVV_t1 = []
- lineG_t2 = []
- lineMMV_t2 = []
- lineMVV_t2 = []
- for g in result_t1:
- for b in result_t1[g]:
- for d in result_t1[g][b]:
- if 'Tempo' in g:
- lineMMV_t1.append(result_t1[g][b][d]['timeMMV'])
- lineMVV_t1.append(result_t1[g][b][d]['timeMVV'])
- lineG_t1.append(result_t2[g][b][d]['timeG'])
- lineMMV_t2.append(result_t2[g][b][d]['timeMMV'])
- lineMVV_t2.append(result_t2[g][b][d]['timeMVV'])
- lineG_t2.append(result_t2[g][b][d]['timeG'])
- else:
- lineMMV_t1.append(result_t1[g][b][d]['MMV'])
- lineMVV_t1.append(result_t1[g][b][d]['MVV'])
- lineMMV_t2.append(result_t2[g][b][d]['MMV'])
- lineMVV_t2.append(result_t2[g][b][d]['MVV'])
- plt.xlabel('Matrix Size')
- if g == "MEM":
- plt.ylabel('MBytes/s')
- plt.title('Memory bandwidth [MBytes/s]')
- if g == "CACHE":
- plt.ylabel('data cache miss ratio')
- plt.title('Data Cache Miss Ratio')
- if g == "FLOPS_DP":
- plt.ylabel('MFLOP/s')
- plt.title('MFLOP per second')
- if g == 'Tempo':
- plt.ylabel('Tempo')
- plt.title('Tempo de execucao')
- print g, b, d
- print lineMMV_t1
- print lineMVV_t1
- print lineG_t1
- print lineMMV_t2
- print lineMVV_t2
- print lineG_t2
- marker_style = dict(color='cornflowerblue', linestyle=':', marker='o',
- markersize=5, markerfacecoloralt='gray')
- line1 = plt.plot(dim, lineMMV_t1, '-o', label='T1 MMV %s' % b)
- line3 = plt.plot(dim, lineMMV_t2, '-o', label='T2 MMV %s' % b)
- line2 = plt.plot(dim, lineMVV_t1, '-o', label='T1 MVV %s' % b)
- line4 = plt.plot(dim, lineMVV_t2, '-o', label='T2 MVV %s' % b)
- if g == 'Tempo':
- line5 = plt.plot(dim, lineG_t1, '-o', label='T1 Metodo %s' % b)
- line6 = plt.plot(dim, lineG_t2, '-o', label='T2 Metodo %s' % b)
- plt.setp(line1, color='r', linewidth=1.5)
- plt.setp(line3, color='b', linewidth=1.5)
- plt.setp(line2, color='g', linewidth=1.5)
- plt.setp(line4, color='m', linewidth=1.5)
- if g == 'Tempo':
- plt.setp(line5, color='c', linewidth=1.5)
- plt.setp(line6, color='k', linewidth=1.5)
- plt.legend( loc=0, borderaxespad=0., fontsize=10, framealpha=60)
- plt.xticks(dim)
- plt.xscale("log")
- plt.yscale("log")
- figName = "%s-%s.png" % (g, b)
- plt.savefig(figName)
- lineMMV_t1 = []
- lineMVV_t1 = []
- lineMMV_t2 = []
- lineMVV_t2 = []
- lineG_t1 = []
- lineG_t2 = []
- plt.clf()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement