This contains my bachelors thesis and associated tex files, code snippets and maybe more. Topic: Data Movement in Heterogeneous Memories with Intel Data Streaming Accelerator
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

142 lines
4.8 KiB

  1. import os
  2. import csv
  3. import numpy as np
  4. import pandas as pd
  5. import seaborn as sns
  6. import matplotlib.pyplot as plt
  7. output_path = "./plots"
  8. hbm_result = "./evaluation-results/current/qdp-xeonmax-hbm-tca4-tcb0-tcj1-tmul32-wl4294967296-cs2097152.csv"
  9. dram_result = "./evaluation-results/current/qdp-xeonmax-dram-tca2-tcb0-tcj1-tmul32-wl4294967296-cs2097152.csv"
  10. prefetch_result = "./evaluation-results/current/qdp-xeonmax-prefetch-tca1-tcb1-tcj1-tmul32-wl4294967296-cs8388608.csv"
  11. distprefetch_result = "./evaluation-results/current/qdp-xeonmax-distprefetch-tca1-tcb1-tcj1-tmul32-wl4294967296-cs8388608.csv"
  12. tt_name = "rt-ns"
  13. function_names = [ "scana-run", "scanb-run", "aggrj-run" ]
  14. fn_nice = [ "Scan A", "Scan B", "Aggregate" ]
  15. def read_timings_from_csv(fname) -> tuple[list[float], list[str]]:
  16. t = {}
  17. row_count = 0
  18. with open(fname, newline='') as csvfile:
  19. reader = csv.DictReader(csvfile, delimiter=';')
  20. for row in reader:
  21. row_count = row_count + 1
  22. for i in range(len(function_names)):
  23. t[fn_nice[i]] = t.get(fn_nice[i], 0) + int(row[function_names[i]])
  24. t = {key: value / (1000 * 1000 * row_count) for key, value in t.items() if value != 0}
  25. return list(t.values()), list(t.keys())
  26. def read_total_time_from_csv(fname) -> float:
  27. time = 0
  28. row_count = 0
  29. with open(fname, newline='') as csvfile:
  30. reader = csv.DictReader(csvfile, delimiter=';')
  31. for row in reader:
  32. row_count = row_count + 1
  33. time += int(row["rt-ns"])
  34. return time / (1000 * 1000 * row_count)
  35. def read_cache_hitrate_from_csv(fname) -> float:
  36. hitrate = 0
  37. row_count = 0
  38. with open(fname, newline='') as csvfile:
  39. reader = csv.DictReader(csvfile, delimiter=';')
  40. for row in reader:
  41. row_count = row_count + 1
  42. hitrate += float(row["cache-hr"])
  43. return (hitrate * 100) / row_count
  44. def generate_speedup_table():
  45. baseline = read_total_time_from_csv(dram_result)
  46. columns = [ "Configuration", "Speedup", "Cache Hitrate" ]
  47. names = [
  48. "DDR-SDRAM (Baseline)",
  49. "HBM (Upper Limit)",
  50. "Prefetching",
  51. "Prefetching, Distributed Columns"
  52. ]
  53. rawtime = [
  54. read_total_time_from_csv(dram_result),
  55. read_total_time_from_csv(hbm_result),
  56. read_total_time_from_csv(prefetch_result),
  57. read_total_time_from_csv(distprefetch_result),
  58. ]
  59. speedup = [
  60. baseline / rawtime[0],
  61. baseline / rawtime[1],
  62. baseline / rawtime[2],
  63. baseline / rawtime[3]
  64. ]
  65. cachehr = [
  66. 0,
  67. 0,
  68. read_cache_hitrate_from_csv(prefetch_result),
  69. read_cache_hitrate_from_csv(distprefetch_result)
  70. ]
  71. data = [
  72. [ names[0], f"x{speedup[0]:1.2f}", r" \textemdash " ],
  73. [ names[1], f"x{speedup[1]:1.2f}", r" \textemdash " ],
  74. [ names[2], f"x{speedup[2]:1.2f}", f"{cachehr[2]:2.2f} \%" ],
  75. [ names[3], f"x{speedup[3]:1.2f}", f"{cachehr[3]:2.2f} \%" ]
  76. ]
  77. return pd.DataFrame(data, columns=columns)
  78. def tex_table(df, fname):
  79. with open(os.path.join(output_path, fname), "w") as of:
  80. of.write(df.to_latex(index=False))
  81. # loops over all possible configuration combinations and calls
  82. # process_file_to_dataset for them in order to build a dataframe
  83. # which is then displayed and saved
  84. def donut_plot(data: tuple[list[float], list[str]], fname):
  85. palette_color = sns.color_palette('mako_r')
  86. fig, ax = plt.subplots(figsize=(6, 3), subplot_kw=dict(aspect="equal"))
  87. wedges, texts = ax.pie(data[0], wedgeprops=dict(width=0.5), startangle=-40, colors=palette_color)
  88. bbox_props = dict(boxstyle="square,pad=0.3", fc="w", ec="k", lw=0.72)
  89. kw = dict(arrowprops=dict(arrowstyle="-"), bbox=bbox_props, zorder=0, va="center")
  90. for i, p in enumerate(wedges):
  91. ang = (p.theta2 - p.theta1)/2. + p.theta1
  92. y = np.sin(np.deg2rad(ang))
  93. x = np.cos(np.deg2rad(ang))
  94. horizontalalignment = {-1: "right", 1: "left"}[int(np.sign(x))]
  95. connectionstyle = f"angle,angleA=0,angleB={ang}"
  96. kw["arrowprops"].update({"connectionstyle": connectionstyle})
  97. ax.annotate(f"{data[1][i]} - {data[0][i]:2.2f} ms", xy=(x, y), xytext=(1.35*np.sign(x), 1.4*y), horizontalalignment=horizontalalignment, **kw)
  98. plt.rcParams.update({'font.size': 18})
  99. fig.savefig(os.path.join(output_path, fname), bbox_inches='tight')
  100. def main():
  101. donut_plot(read_timings_from_csv(prefetch_result), "plot-timing-prefetch.pdf")
  102. donut_plot(read_timings_from_csv(distprefetch_result), "plot-timing-distprefetch.pdf")
  103. donut_plot(read_timings_from_csv(dram_result), "plot-timing-dram.pdf")
  104. donut_plot(read_timings_from_csv(hbm_result), "plot-timing-hbm.pdf")
  105. tex_table(generate_speedup_table(), "table-qdpspeedup.tex")
  106. if __name__ == "__main__":
  107. main()