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 data_volume_on = AVG_on[-1]
145 data_volume_off = AVG_off[-1]
147 elif datatype_input ==
"CACHE":
148 cache_req_on = AVG_on[1] / 1e12
149 cache_req_off = AVG_off[1] / 1e12
151 cache_miss_ratio_on = AVG_on[5]
152 cache_miss_ratio_off = AVG_off[5]
154 print(f
"Done Reading cvs data for datatype: {datatype_input}.")
159plt.rc(
"font", **font)
160plt.rc(
"font", family=
"serif")
161plt.rc(
"text", usetex=
False)
163fig = plt.figure(figsize=(10, 8))
164gs = gridspec.GridSpec(2, 2, wspace=0.30, hspace=0.25)
166ax0 = plt.subplot(gs[0])
179plt.plot(cores_array, runtime_on, c=
"r", lw=1.2)
180plt.scatter(cores_array, runtime_off, marker=
"^", c=
"b", s=25, zorder=10, label=
r"off")
181plt.plot(cores_array, runtime_off, c=
"b", lw=1.2, zorder=11)
184plt.ylabel(
r"Time per time step [s]")
185plt.xscale(
"log", base=2)
187plt.margins(0.05, 0.1)
188plt.tick_params(direction=
"in", top=
True, right=
True)
189plt.tick_params(direction=
"in", top=
True, right=
True)
190plt.gca().xaxis.set_major_formatter(mpl.ticker.ScalarFormatter())
191plt.gca().yaxis.set_major_formatter(mpl.ticker.ScalarFormatter())
192plt.xticks([1, 2, 4, 8, 16, 32, 64])
195leg = plt.legend(loc=
"upper right", fontsize=10)
198ax1 = plt.subplot(gs[1])
209plt.plot(cores_array, data_volume_on, c=
"r", lw=1.2, zorder=-1)
211 cores_array, data_volume_off, marker=
"^", c=
"b", s=25, zorder=10, label=
r"off"
213plt.plot(cores_array, data_volume_off, c=
"b", lw=1.2, zorder=11)
215plt.ylabel(
r"Memory data volume [GBytes]")
216plt.margins(0.05, 0.1)
217plt.xscale(
"log", base=2)
219plt.gca().xaxis.set_major_formatter(mpl.ticker.ScalarFormatter())
221plt.xticks([1, 2, 4, 8, 16, 32, 64])
222plt.tick_params(direction=
"in", top=
True, right=
True)
226ax1 = plt.subplot(gs[2])
237plt.plot(cores_array, cache_req_on, c=
"r", lw=1.2, zorder=-1)
239 cores_array, cache_req_off, marker=
"^", c=
"b", s=25, zorder=10, label=
r"off"
241plt.plot(cores_array, cache_req_off, c=
"b", lw=1.2, zorder=11)
243plt.ylabel(
r"L2 cache requests [$\times10^{12}$]")
244plt.margins(0.05, 0.1)
245plt.xscale(
"log", base=2)
247plt.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)
253ax2 = plt.subplot(gs[3])
256 100 * cache_miss_ratio_on,
264plt.plot(cores_array, 100 * cache_miss_ratio_on, c=
"r", lw=1.2)
267 100 * cache_miss_ratio_off,
274plt.plot(cores_array, 100 * cache_miss_ratio_off, c=
"b", lw=1.2)
276plt.ylabel(
r"L2 cache miss rate [%]")
277plt.margins(0.05, 0.1)
278plt.xscale(
"log", base=2)
279plt.gca().xaxis.set_major_formatter(mpl.ticker.ScalarFormatter())
280plt.xticks([1, 2, 4, 8, 16, 32, 64])
281plt.tick_params(direction=
"in", top=
True, right=
True)
284fig.savefig(
"plot_likwid_np_400" +
".pdf", bbox_inches=
"tight")