Skip to content

Commit

Permalink
updated scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
imrn99 committed Dec 8, 2023
1 parent 6d39ab2 commit 1238a8d
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 8 deletions.
9 changes: 5 additions & 4 deletions scripts/cache-miss-rates.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,16 +32,17 @@ def main():
percentsMore=[]
for i in range(len(sizes)):
percentsMore.append( 100 * (usualLayoutRates[i] - bestLayoutRates[i]) / bestLayoutRates[i])

# plot
plt.title("GEMM: L1 Cache Miss-Rate Evolution = f(Data Size)")
plt.xlabel("Square Matrix Size (float)")
plt.xlabel("Square Matrix Dimension (# of rows/cols)")
plt.ylabel("Miss-Rate (%)")

plt.semilogx(base=2.0)
plt.grid(visible=True, axis='y')
plt.scatter(sizes, usualLayoutRates, marker='+', color='r')
plt.scatter(sizes, bestLayoutRates, marker='x', color='b')
plt.scatter(sizes, usualLayoutRates, marker='+', color='r', label="usual-layout")
plt.scatter(sizes, bestLayoutRates, marker='x', color='b', label="best-layout")
plt.legend()
plt.savefig(fname="cache-miss-rates.svg", format="svg")


Expand Down
55 changes: 55 additions & 0 deletions scripts/cache-sizes.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# This script is used to generate a speedup graph from the output
# of the layout-size benchmark (criterion group gemm-sizes).
#
# The script expects a single csv file, containing 3 lines:
# - 1st line: data size (used as the X coordinate)
# - 2nd line: execution times using the usual (i.e. naive) layout
# - 3rd line: execution times using ideal layout

import sys
import csv
import matplotlib.pyplot as plt

def main():
# read input
fileName = sys.argv[1]
tmp = []
with open(fileName, newline='') as csvfile:
reader = csv.reader(csvfile)
for row in reader:
tmp.append(row)

# parse values
sizes = []
usualLayoutTimes = []
bestLayoutTimes = []
for size in tmp[0]:
sizes.append(int(size)) # matrix size = dim1 * dim2 * sizeof(double)
for time in tmp[1]:
usualLayoutTimes.append(float(time))
for time in tmp[2]:
bestLayoutTimes.append(float(time))
tmp.clear()

# compute relative change
percentsSlower=[]
for i in range(len(sizes)):
percentLonger = (usualLayoutTimes[i] - bestLayoutTimes[i]) / bestLayoutTimes[i]
percentsSlower.append(- 100*100 * percentLonger / (100.0 + percentLonger))

# plot
plt.title("GEMM: Speed Gain = f(Data Size)")
plt.xlabel("Square Matrix Dimension (# of rows/cols)")
plt.ylabel("Gain (%)")
plt.ylim([-175, 10])
plt.semilogx(base=2.0)
plt.axvline(x=64*6**0.5, label="Exceed L1 Total Size", color='r', ymax=0.95, ymin=0.05)
plt.axvline(x=512*3**0.5, label="Exceed L2 Total Size", color='g', ymax=0.95, ymin=0.05)
plt.axvline(x=2048, label="Exceed L3 Total Size", color='b', ymax=0.95, ymin=0.15)
plt.legend(loc="center left")
plt.grid(visible=True, axis='y')
plt.scatter(sizes, percentsSlower, marker='+', color='r')
plt.savefig(fname="gemm-sizes-plot.svg", format="svg")


main()
8 changes: 4 additions & 4 deletions scripts/gemm-sizes.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,13 @@ def main():

# plot
plt.title("GEMM: Speed Gain = f(Data Size)")
plt.xlabel("Square Matrix Size (float)")
plt.ylabel("Percents (%)")
plt.ylim([-150, 10])
plt.xlabel("Square Matrix Dimension (# of rows/cols)")
plt.ylabel("Gain (%)")
plt.ylim([-175, 10])
plt.semilogx(base=2.0)
plt.grid(visible=True, axis='y')
plt.scatter(sizes, percentsSlower, marker='+', color='r')
plt.savefig(fname="gemm-sizes-plot.svg", format="svg")


main()
main()

0 comments on commit 1238a8d

Please sign in to comment.