mirror of
https://github.com/openhwgroup/cvw
synced 2025-02-11 06:05:49 +00:00
Fancy plot for branch predictor.
This commit is contained in:
parent
f119b492bb
commit
c1c4024b4b
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
|
import matplotlib.pyplot as plt
|
||||||
|
|
||||||
def ComputeCPI(benchmark):
|
def ComputeCPI(benchmark):
|
||||||
'Computes and inserts CPI into benchmark stats.'
|
'Computes and inserts CPI into benchmark stats.'
|
||||||
@ -46,6 +47,15 @@ def ComputeDCacheMissRate(benchmark):
|
|||||||
DCacheMR = 100.0 * int(dataDict['D Cache Miss']) / int(dataDict['D Cache Access'])
|
DCacheMR = 100.0 * int(dataDict['D Cache Miss']) / int(dataDict['D Cache Access'])
|
||||||
dataDict['DCacheMR'] = DCacheMR
|
dataDict['DCacheMR'] = DCacheMR
|
||||||
|
|
||||||
|
def ComputeAll(benchmarks):
|
||||||
|
for benchmark in benchmarks:
|
||||||
|
ComputeCPI(benchmark)
|
||||||
|
ComputeBranchDirMissRate(benchmark)
|
||||||
|
ComputeBranchTargetMissRate(benchmark)
|
||||||
|
ComputeRASMissRate(benchmark)
|
||||||
|
ComputeInstrClassMissRate(benchmark)
|
||||||
|
ComputeICacheMissRate(benchmark)
|
||||||
|
ComputeDCacheMissRate(benchmark)
|
||||||
|
|
||||||
def printStats(benchmark):
|
def printStats(benchmark):
|
||||||
(nameString, opt, dataDict) = benchmark
|
(nameString, opt, dataDict) = benchmark
|
||||||
@ -64,20 +74,13 @@ def printStats(benchmark):
|
|||||||
print('D Cache Miss Rate %1.4f' % dataDict['DCacheMR'])
|
print('D Cache Miss Rate %1.4f' % dataDict['DCacheMR'])
|
||||||
print()
|
print()
|
||||||
|
|
||||||
|
def ProcessFile(fileName):
|
||||||
|
'''Extract preformance counters from a modelsim log. Outputs a list of tuples for each test/benchmark.
|
||||||
|
The tuple contains the test name, optimization characteristics, and dictionary of performance counters.'''
|
||||||
# 1 find lines with Read memfile and extract test name
|
# 1 find lines with Read memfile and extract test name
|
||||||
# 2 parse counters into a list of (name, value) tuples (dictionary maybe?)
|
# 2 parse counters into a list of (name, value) tuples (dictionary maybe?)
|
||||||
# 3 process into useful data
|
|
||||||
# cache hit rates
|
|
||||||
# cache fill time
|
|
||||||
# branch predictor status
|
|
||||||
# hazard counts
|
|
||||||
# CPI
|
|
||||||
# instruction distribution
|
|
||||||
|
|
||||||
# steps 1 and 2
|
|
||||||
benchmarks = []
|
benchmarks = []
|
||||||
transcript = open(sys.argv[1], 'r')
|
transcript = open(fileName, 'r')
|
||||||
HPMClist = { }
|
HPMClist = { }
|
||||||
testName = ''
|
testName = ''
|
||||||
for line in transcript.readlines():
|
for line in transcript.readlines():
|
||||||
@ -93,16 +96,70 @@ for line in transcript.readlines():
|
|||||||
HPMClist[name] = value
|
HPMClist[name] = value
|
||||||
elif ('is done' in line):
|
elif ('is done' in line):
|
||||||
benchmarks.append((testName, opt, HPMClist))
|
benchmarks.append((testName, opt, HPMClist))
|
||||||
|
return benchmarks
|
||||||
|
|
||||||
#print(benchmarks[0])
|
def FormatToPlot(currBenchmark):
|
||||||
|
names = []
|
||||||
|
values = []
|
||||||
|
for config in currBenchmark:
|
||||||
|
print ('config' , config)
|
||||||
|
names.append(config[0])
|
||||||
|
values.append(config[1])
|
||||||
|
return (names, values)
|
||||||
|
|
||||||
|
if(sys.argv[1] == '-b'):
|
||||||
|
configList = []
|
||||||
|
for config in sys.argv[2::]:
|
||||||
|
benchmarks = ProcessFile(config)
|
||||||
|
ComputeAll(benchmarks)
|
||||||
|
configList.append((config.split('.')[0], benchmarks))
|
||||||
|
|
||||||
|
# Merge all configruations into a single list
|
||||||
|
benchmarkAll = []
|
||||||
|
for (config, benchmarks) in configList:
|
||||||
|
print(config)
|
||||||
|
for benchmark in benchmarks:
|
||||||
|
(nameString, opt, dataDict) = benchmark
|
||||||
|
benchmarkAll.append((nameString, opt, config, dataDict))
|
||||||
|
|
||||||
|
# now extract all branch prediction direction miss rates for each
|
||||||
|
# namestring + opt, config
|
||||||
|
benchmarkDict = { }
|
||||||
|
for benchmark in benchmarkAll:
|
||||||
|
(name, opt, config, dataDict) = benchmark
|
||||||
|
if name+'_'+opt in benchmarkDict:
|
||||||
|
benchmarkDict[name+'_'+opt].append((config, dataDict['BDMR']))
|
||||||
|
else:
|
||||||
|
benchmarkDict[name+'_'+opt] = [(config, dataDict['BDMR'])]
|
||||||
|
|
||||||
|
size = len(benchmarkDict)
|
||||||
|
index = 1
|
||||||
|
print('Number of plots', size)
|
||||||
|
for benchmarkName in benchmarkDict:
|
||||||
|
currBenchmark = benchmarkDict[benchmarkName]
|
||||||
|
(names, values) = FormatToPlot(currBenchmark)
|
||||||
|
print(names, values)
|
||||||
|
plt.subplot(6, 7, index)
|
||||||
|
plt.bar(names, values)
|
||||||
|
plt.title(benchmarkName)
|
||||||
|
plt.ylabel('BR Dir Miss Rate (%)')
|
||||||
|
#plt.xlabel('Predictor')
|
||||||
|
index += 1
|
||||||
|
#plt.tight_layout()
|
||||||
|
plt.show()
|
||||||
|
|
||||||
|
|
||||||
|
else:
|
||||||
|
# steps 1 and 2
|
||||||
|
benchmarks = ProcessFile(sys.argv[1])
|
||||||
|
# 3 process into useful data
|
||||||
|
# cache hit rates
|
||||||
|
# cache fill time
|
||||||
|
# branch predictor status
|
||||||
|
# hazard counts
|
||||||
|
# CPI
|
||||||
|
# instruction distribution
|
||||||
|
ComputeAll(benchmarks)
|
||||||
for benchmark in benchmarks:
|
for benchmark in benchmarks:
|
||||||
ComputeCPI(benchmark)
|
|
||||||
ComputeBranchDirMissRate(benchmark)
|
|
||||||
ComputeBranchTargetMissRate(benchmark)
|
|
||||||
ComputeRASMissRate(benchmark)
|
|
||||||
ComputeInstrClassMissRate(benchmark)
|
|
||||||
ComputeICacheMissRate(benchmark)
|
|
||||||
ComputeDCacheMissRate(benchmark)
|
|
||||||
printStats(benchmark)
|
printStats(benchmark)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user