7from matplotlib
import gridspec
8import matplotlib.pyplot
as plt
9import matplotlib
as mpl
14Script to read the likwid output data and make plots.
15Read likwid cvs files using Pandas.
19folder_input =
"/home/cristianbarrahinojosa/Overleaf/paper-llvm2022/experiments/18_sph_simulation/hamilton8/Noh_2D/output_np_400_et_0.01/likwid/"
21datatype_inputs = [
"MEM",
"CACHE"]
23for datatype_input
in datatype_inputs:
24 filename_template =
"output_" + datatype_input +
"_cores_*_*.cvs"
25 filename_template_regex =
"output_" + datatype_input +
"_cores_(.*)_(.*)"
27 cores_array = [1, 2, 4, 8, 16, 20, 24, 28, 32, 36, 40, 44, 48, 52, 56, 60, 64]
30 if datatype_input ==
"MEM":
33 "Runtime (RDTSC) [s] STAT",
34 "Runtime unhalted [s] STAT",
37 "Memory bandwidth [MBytes/s] STAT",
38 "Memory data volume [GBytes] STAT",
43 "Runtime (RDTSC) [s] STAT",
44 "Runtime unhalted [s] STAT",
47 "Memory bandwidth [MBytes/s] STAT",
48 "Memory data volume [GBytes] STAT",
51 elif datatype_input ==
"CACHE":
55 "data cache requests STAT",
56 "data cache request STAT ",
57 "data cache misses STAT",
58 "data cache miss rate STAT",
59 "data cache miss ratio STAT",
65 "data cache requests STAT",
66 "data cache request rate STAT",
67 "data cache misses STAT",
68 "data cache miss rate STAT",
69 "data cache miss ratio STAT",
74 data_SUM_on = pd.DataFrame(data_template_SUM)
75 data_SUM_off = pd.DataFrame(data_template_SUM)
76 data_AVG_on = pd.DataFrame(data_template_AVG)
77 data_AVG_off = pd.DataFrame(data_template_AVG)
80 N_metrics = len(data_SUM_on)
81 offset_row = -N_metrics
84 path = glob.glob(folder_input + filename_template)
85 path = Tcl().call(
"lsort",
"-dict", path)
87 assert path !=
"",
"No matching file found in path. Check input data."
91 tempname = os.path.basename(absfilename)
92 filename = os.path.splitext(tempname)[0]
95 pf = re.compile(filename_template_regex)
97 match = pf.search(filename)
98 cores = match.group(1)
99 clang = match.group(2)
102 df_input = pd.read_csv(file, index_col=0, header=0, on_bad_lines=
"skip")
105 SUM = df_input[
"Info"].iloc[offset_row:]
109 AVG = df_input[
"Unnamed: 4"].iloc[offset_row:]
114 data_SUM_on[
"cores " + str(cores)] = SUM.values
115 data_AVG_on[
"cores " + str(cores)] = AVG.values
117 data_SUM_off[
"cores " + str(cores)] = SUM.values
118 data_AVG_off[
"cores " + str(cores)] = AVG.values
121 SUM_on = np.zeros((N_metrics, len(cores_array)))
122 AVG_on = np.zeros((N_metrics, len(cores_array)))
124 SUM_off = np.zeros((N_metrics, len(cores_array)))
125 AVG_off = np.zeros((N_metrics, len(cores_array)))
127 for i, cores
in enumerate(cores_array):
128 for metric
in range(N_metrics):
129 SUM_on[metric, i] = float(data_SUM_on[
"cores " + str(cores)][metric])
130 AVG_on[metric, i] = float(data_AVG_on[
"cores " + str(cores)][metric])
132 SUM_off[metric, i] = float(data_SUM_off[
"cores " + str(cores)][metric])
133 AVG_off[metric, i] = float(data_AVG_off[
"cores " + str(cores)][metric])
136 if datatype_input ==
"MEM":
138 runtime_on = AVG_on[0] / N_dt
139 runtime_off = AVG_off[0] / N_dt
141 clock_speed_on = AVG_on[2]
142 clock_speed_off = AVG_off[2]
144 elif datatype_input ==
"CACHE":
145 cache_req_on = AVG_on[1] / 1e12
146 cache_req_off = AVG_off[1] / 1e12
148 cache_miss_ratio_on = AVG_on[5]
149 cache_miss_ratio_off = AVG_off[5]
151 print(f
"Done Reading cvs data for datatype: {datatype_input}.")
156plt.rc(
"font", **font)
157plt.rc(
"font", family=
"serif")
158plt.rc(
"text", usetex=
False)
160fig = plt.figure(figsize=(14, 4))
161gs = gridspec.GridSpec(1, 3, wspace=0.2)
163ax0 = plt.subplot(gs[0])
176plt.plot(cores_array, runtime_on, c=
"r", lw=1.2)
177plt.scatter(cores_array, runtime_off, marker=
"^", c=
"b", s=25, zorder=10, label=
r"off")
178plt.plot(cores_array, runtime_off, c=
"b", lw=1.2, zorder=11)
181plt.ylabel(
r"Time per time step [s]")
182plt.xscale(
"log", base=2)
184plt.margins(0.05, 0.1)
185plt.tick_params(direction=
"in", top=
True, right=
True)
186plt.tick_params(direction=
"in", top=
True, right=
True)
187plt.gca().xaxis.set_major_formatter(mpl.ticker.ScalarFormatter())
188plt.gca().yaxis.set_major_formatter(mpl.ticker.ScalarFormatter())
189plt.xticks([1, 2, 4, 8, 16, 32, 64])
192leg = plt.legend(loc=
"upper right", fontsize=10)
195ax1 = plt.subplot(gs[1])
206plt.plot(cores_array, cache_req_on, c=
"r", lw=1.2, zorder=-1)
208 cores_array, cache_req_off, marker=
"^", c=
"b", s=25, zorder=10, label=
r"off"
210plt.plot(cores_array, cache_req_off, c=
"b", lw=1.2, zorder=11)
212plt.ylabel(
r"Average cache requests [$\times10^{12}$]")
213plt.margins(0.05, 0.1)
214plt.xscale(
"log", base=2)
216plt.gca().xaxis.set_major_formatter(mpl.ticker.ScalarFormatter())
218plt.xticks([1, 2, 4, 8, 16, 32, 64])
219plt.tick_params(direction=
"in", top=
True, right=
True)
222ax2 = plt.subplot(gs[2])
225 100 * cache_miss_ratio_on,
233plt.plot(cores_array, 100 * cache_miss_ratio_on, c=
"r", lw=1.2)
236 100 * cache_miss_ratio_off,
243plt.plot(cores_array, 100 * cache_miss_ratio_off, c=
"b", lw=1.2)
245plt.ylabel(
r"Average cache miss rate [%]")
246plt.margins(0.05, 0.1)
247plt.xscale(
"log", base=2)
248plt.gca().xaxis.set_major_formatter(mpl.ticker.ScalarFormatter())
249plt.xticks([1, 2, 4, 8, 16, 32, 64])
250plt.tick_params(direction=
"in", top=
True, right=
True)
253fig.savefig(
"plot_likwid_np_400" +
".pdf", bbox_inches=
"tight")