Compare commits
3 Commits
738f753248
...
c16a503828
Author | SHA1 | Date | |
---|---|---|---|
c16a503828 | |||
cb8615d064 | |||
436e336e0c |
2
.gitignore
vendored
2
.gitignore
vendored
@ -6,6 +6,7 @@
|
|||||||
#Cargo.lock
|
#Cargo.lock
|
||||||
# These are backup files generated by rustfmt
|
# These are backup files generated by rustfmt
|
||||||
**/*.rs.bk
|
**/*.rs.bk
|
||||||
|
.vscode
|
||||||
bootimage-kernel.iso
|
bootimage-kernel.iso
|
||||||
bootimage-kerneliso
|
bootimage-kerneliso
|
||||||
kernel.sym
|
kernel.sym
|
||||||
@ -22,4 +23,5 @@ pxelinux.cfg
|
|||||||
serial.out
|
serial.out
|
||||||
memdisk
|
memdisk
|
||||||
**/venv
|
**/venv
|
||||||
|
**/.venv
|
||||||
cache_utils/results*/
|
cache_utils/results*/
|
@ -213,23 +213,29 @@ def ha_dist(core, is_QPI):
|
|||||||
"""
|
"""
|
||||||
if is_QPI:
|
if is_QPI:
|
||||||
if core < 4:
|
if core < 4:
|
||||||
return core
|
return core, 0
|
||||||
return 7-core
|
return 7-core, 1 # +1 for PCI
|
||||||
|
|
||||||
if core < 4:
|
if core < 4:
|
||||||
return 3-core
|
return 3-core, 0
|
||||||
return core-4
|
return core-4, 0
|
||||||
|
|
||||||
|
def cclockwise_dist(source, dest):
|
||||||
|
base = (dest+8-source)%8
|
||||||
|
side_jump = 0
|
||||||
|
if source < 4 and dest >= 4:
|
||||||
|
side_jump = 1
|
||||||
|
elif source >= 4 and dest < 4:
|
||||||
|
side_jump = 2
|
||||||
|
return base, side_jump
|
||||||
|
|
||||||
def cclockwise_ha_dist(core, is_QPI):
|
def cclockwise_ha_dist(core, is_QPI):
|
||||||
"""
|
"""
|
||||||
counter-clockwise distance to Home Agent
|
counter-clockwise distance to Home Agent
|
||||||
"""
|
"""
|
||||||
if is_QPI:
|
if is_QPI:
|
||||||
return 7-core
|
return cclockwise_dist(core, 7)
|
||||||
|
return cclockwise_dist(core, 3)
|
||||||
if core < 4:
|
|
||||||
return 3-core
|
|
||||||
return 11-core
|
|
||||||
|
|
||||||
def miss_topology(main_core, slice_group, h, down_jump, top_jump, ini, ha_h):
|
def miss_topology(main_core, slice_group, h, down_jump, top_jump, ini, ha_h):
|
||||||
core, ring = slice_msg_distance(slice_group, main_core%8)
|
core, ring = slice_msg_distance(slice_group, main_core%8)
|
||||||
@ -237,95 +243,81 @@ def miss_topology(main_core, slice_group, h, down_jump, top_jump, ini, ha_h):
|
|||||||
side_jump = 0
|
side_jump = 0
|
||||||
side_jump += top_jump if ring == 2 else 0
|
side_jump += top_jump if ring == 2 else 0
|
||||||
side_jump += down_jump if ring == 1 else 0
|
side_jump += down_jump if ring == 1 else 0
|
||||||
return (cclockwise_ha_dist(slice_group, False)//2)*ha_h+h*core + side_jump + ini
|
return (cclockwise_ha_dist(slice_group, False))*ha_h+h*core + side_jump + ini
|
||||||
|
|
||||||
def miss_topology_df(x, h, down_jump, top_jump, ini, ha_h):
|
def miss_topology_df(x, h, down_jump, top_jump, ini, ha_h):
|
||||||
func = lambda x, h, down_jump, top_jump, ini, ha_h: miss_topology(x["main_core_fixed"], x["slice_group"], h, down_jump, top_jump, ini, ha_h)
|
func = lambda x, h, down_jump, top_jump, ini, ha_h: miss_topology(x["main_core_fixed"], x["slice_group"], h, down_jump, top_jump, ini, ha_h)
|
||||||
return x.apply(func, args=(h, down_jump, top_jump, ini, ha_h), axis=1)
|
return x.apply(func, args=(h, down_jump, top_jump, ini, ha_h), axis=1)
|
||||||
|
|
||||||
|
|
||||||
def remote_hit_topology(main_core, helper_core, slice_group, C, h, H):
|
def remote_hit_topology(main_core, helper_core, slice_group, const, core_jump, HA_jump):
|
||||||
core0, ring0, _ = slice_msg_distance(main_core, slice_group)
|
"""
|
||||||
core1, ring1, _ = slice_msg_distance(helper_core, slice_group)
|
main_core
|
||||||
return C + h*(core0+core1) + H*(ring0+ring1)
|
-> local_slice
|
||||||
|
-> remote_slice
|
||||||
|
-> helper_core
|
||||||
|
-> remote_slice
|
||||||
|
-> local_slice
|
||||||
|
-> main_core
|
||||||
|
"""
|
||||||
|
if main_core // 8 == helper_core // 8:
|
||||||
|
print("Can only do hit predictions for different socket", file=sys.stderr)
|
||||||
|
raise NotImplementedError
|
||||||
|
|
||||||
def remote_hit_topology_df(x, C, h, H):
|
helper, main = helper_core%8, main_core%8
|
||||||
func = lambda x, C, h, H: remote_hit_topology(x["main_core_fixed"], x["helper_core_fixed"], x["slice_group"], C, h, H)
|
main_slice_local = slice_msg_distance(slice_group, main)
|
||||||
return x.apply(func, args=(C, h, H), axis=1)
|
slice_QPI = cclockwise_dist(0, slice_group) # clockwise
|
||||||
|
QPI_slice_r = cclockwise_dist(0, slice_group)
|
||||||
|
slice_r_helper = slice_msg_distance(slice_group, helper)
|
||||||
|
|
||||||
|
costs = (main_slice_local[0]+slice_QPI[0]+QPI_slice_r[0]+slice_r_helper[0], main_slice_local[1]+slice_QPI[1]+QPI_slice_r[1]+slice_r_helper[1])
|
||||||
|
return const+costs[0]*core_jump+costs[1]*HA_jump # may need some adjustments
|
||||||
|
|
||||||
|
def remote_hit_topology_df(x, const, core_jump, HA_jump):
|
||||||
|
func = lambda x, const, core_jump, HA_jump: remote_hit_topology(x["main_core_fixed"], x["helper_core_fixed"], x["slice_group"], const, core_jump, HA_jump)
|
||||||
|
return x.apply(func, args=(const, core_jump, HA_jump), axis=1)
|
||||||
|
|
||||||
|
|
||||||
def do_predictions(df):
|
def do_predictions(df):
|
||||||
def plot_predicted_topo(col, row, x_ax, target, pred, df=df):
|
def plot_predicted_topo(col, row, x_ax, target, pred, df=df):
|
||||||
title_letter = {
|
titles = {
|
||||||
"main_core_fixed": "A",
|
"main_core_fixed": "A",
|
||||||
"helper_core_fixed": "V",
|
"helper_core_fixed": "V",
|
||||||
"slice_group": "S"
|
"slice_group": "S",
|
||||||
}.get(col, col[0])
|
None: "None"
|
||||||
|
}
|
||||||
|
|
||||||
figure_A0 = sns.FacetGrid(df, col=col, row=row)
|
figure_A0 = sns.FacetGrid(df, col=col, row=row)
|
||||||
figure_A0.map(sns.scatterplot, x_ax, pred, color="r")
|
figure_A0.map(sns.scatterplot, x_ax, target, color="g")
|
||||||
figure_A0.map(sns.scatterplot, x_ax, target, color="g", marker="+")
|
figure_A0.map(sns.scatterplot, x_ax, pred, color="r", marker="+")
|
||||||
figure_A0.set_titles(col_template="$"+title_letter+"$ = {col_name}")
|
figure_A0.set_titles(
|
||||||
|
col_template="$"+titles.get(col, col[0])+"$ = {col_name}",
|
||||||
|
row_template="$"+titles.get(row, row[0])+"$ = {row_name}"
|
||||||
|
)
|
||||||
plot(f"medians_{pred}_{col}.png")
|
plot(f"medians_{pred}_{col}.png")
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
values = []
|
|
||||||
main_socket, helper_socket = 0, 0
|
main_socket, helper_socket = 0, 0
|
||||||
dfc = df[(df["main_socket"] == main_socket) & (df["helper_socket"] == helper_socket)]
|
dfc = df[(df["main_socket"] == main_socket) & (df["helper_socket"] == helper_socket)]
|
||||||
cores = sorted(list(dfc["main_core_fixed"].unique()))
|
|
||||||
slices = sorted(list(dfc["slice_group"].unique()))
|
|
||||||
res_miss = optimize.curve_fit(
|
res_miss = optimize.curve_fit(
|
||||||
miss_topology_df, dfc[["main_core_fixed", "slice_group"]], dfc["clflush_miss_n"]
|
miss_topology_df, dfc[["main_core_fixed", "slice_group"]], dfc["clflush_miss_n"]
|
||||||
)
|
)
|
||||||
print("Miss topology:")
|
print("Miss topology:")
|
||||||
print(res_miss)
|
print(res_miss)
|
||||||
values.append(res_miss[0])
|
|
||||||
|
|
||||||
|
|
||||||
dfc["predicted_miss"] = miss_topology_df(dfc, *(res_miss[0]))
|
dfc["predicted_miss"] = miss_topology_df(dfc, *(res_miss[0]))
|
||||||
plot_predicted_topo("slice_group", None, "main_core_fixed", "clflush_miss_n", "predicted_miss", df=dfc)
|
plot_predicted_topo("slice_group", None, "main_core_fixed", "clflush_miss_n", "predicted_miss", df=dfc)
|
||||||
plot_predicted_topo("main_core_fixed", None, "slice_group", "clflush_miss_n", "predicted_miss", df=dfc)
|
plot_predicted_topo("main_core_fixed", None, "slice_group", "clflush_miss_n", "predicted_miss", df=dfc)
|
||||||
|
|
||||||
for slice_ in slices:
|
main_socket, helper_socket = 0, 1
|
||||||
dfc = df[(df["slice_group"] == slice_) & (df["main_socket"] == main_socket) & (df["helper_socket"] == helper_socket)]
|
dfc = df[(df["main_socket"] == main_socket) & (df["helper_socket"] == helper_socket)]
|
||||||
res_miss = optimize.curve_fit(
|
|
||||||
miss_topology_df, dfc[["main_core_fixed", "slice_group"]], dfc["clflush_miss_n"]
|
|
||||||
)
|
|
||||||
values.append(res_miss[0])
|
|
||||||
|
|
||||||
dfc[f"predicted_miss_{slice_}"] = miss_topology_df(dfc, *(res_miss[0]))
|
|
||||||
plot_predicted_topo("slice_group", None, "main_core_fixed", "clflush_miss_n", f"predicted_miss_{slice_}", df=dfc)
|
|
||||||
|
|
||||||
|
|
||||||
print(list(values[0]))
|
|
||||||
print()
|
|
||||||
for i in values[1:]:
|
|
||||||
print(list(i))
|
|
||||||
|
|
||||||
values = []
|
|
||||||
for core in cores:
|
|
||||||
dfc = df[(df["main_core_fixed"] == core) & (df["main_socket"] == main_socket) & (df["helper_socket"] == helper_socket)]
|
|
||||||
res_miss = optimize.curve_fit(
|
|
||||||
miss_topology_df, dfc[["main_core_fixed", "slice_group"]], dfc["clflush_miss_n"]
|
|
||||||
)
|
|
||||||
values.append(res_miss[0])
|
|
||||||
|
|
||||||
dfc[f"predicted_miss_core{core}"] = miss_topology_df(dfc, *(res_miss[0]))
|
|
||||||
plot_predicted_topo("main_core_fixed", None, "slice_group", "clflush_miss_n", f"predicted_miss_core{core}", df=dfc)
|
|
||||||
|
|
||||||
for i in values:
|
|
||||||
print(list(i))
|
|
||||||
return
|
|
||||||
|
|
||||||
res_remote_hit = optimize.curve_fit(
|
res_remote_hit = optimize.curve_fit(
|
||||||
remote_hit_topology_df, df[["main_core_fixed", "helper_core_fixed", "slice_group"]], df["clflush_remote_hit"]
|
remote_hit_topology_df, dfc[["main_core_fixed", "helper_core_fixed", "slice_group"]], dfc["clflush_remote_hit"]
|
||||||
)
|
)
|
||||||
print("Remote hit topology:")
|
print("Remote hit topology:")
|
||||||
print(res_remote_hit)
|
print(res_remote_hit)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
df["diff_miss"] = df["clflush_miss_n"] - df["predicted_miss"]
|
df["diff_miss"] = df["clflush_miss_n"] - df["predicted_miss"]
|
||||||
facet_grid(
|
facet_grid(
|
||||||
df, None, "main_core_fixed", "slice_group",
|
df, None, "main_core_fixed", "slice_group",
|
||||||
@ -339,10 +331,20 @@ def do_predictions(df):
|
|||||||
shown=["diff_miss"],
|
shown=["diff_miss"],
|
||||||
separate_hthreads=True
|
separate_hthreads=True
|
||||||
)
|
)
|
||||||
|
dfc["predicted_remote_hit"] = remote_hit_topology_df(dfc, *(res_remote_hit[0]))
|
||||||
|
plot_predicted_topo("slice_group", "helper_core_fixed", "main_core_fixed", "clflush_remote_hit", "predicted_remote_hit", df=dfc)
|
||||||
|
plot_predicted_topo("main_core_fixed", "slice_group", "helper_core_fixed", "clflush_remote_hit", "predicted_remote_hit", df=dfc)
|
||||||
|
plot_predicted_topo("helper_core_fixed", "main_core_fixed", "slice_group", "clflush_remote_hit", "predicted_remote_hit", df=dfc)
|
||||||
|
|
||||||
# df["predicted_remote_hit"] = remote_hit_topology_df(df, *(res_remote_hit[0]))
|
for col in ["slice_group", "helper_core_fixed", "main_core_fixed"]:
|
||||||
# plot_predicted_topo("slice_group", "helper_core_fixed", "main_core_fixed", "clflush_remote_hit", "predicted_remote_hit")
|
for val in sorted(list(dfc[col].unique())):
|
||||||
# plot_predicted_topo("main_core_fixed", "helper_core_fixed", "slice_group", "clflush_remote_hit", "predicted_remote_hit")
|
df_temp = dfc[(dfc[col] == val)]
|
||||||
|
res_remote_hit = optimize.curve_fit(
|
||||||
|
remote_hit_topology_df, df_temp[["main_core_fixed", "helper_core_fixed", "slice_group"]], df_temp["clflush_remote_hit"]
|
||||||
|
)
|
||||||
|
df_temp[f"predicted_remote_hit_{col}={val}"] = remote_hit_topology_df(df_temp, *(res_remote_hit[0]))
|
||||||
|
plot_predicted_topo("slice_group", "helper_core_fixed", "main_core_fixed", "clflush_remote_hit", f"predicted_remote_hit_{col}={val}", df=df_temp)
|
||||||
|
plot_predicted_topo("main_core_fixed", "helper_core_fixed", "slice_group", "clflush_remote_hit", f"predicted_remote_hit_{col}={val}", df=df_temp)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -374,6 +376,7 @@ def facet_grid(
|
|||||||
colors=["y", "r", "g", "b"],
|
colors=["y", "r", "g", "b"],
|
||||||
separate_hthreads=False,
|
separate_hthreads=False,
|
||||||
title=None,
|
title=None,
|
||||||
|
letters=None
|
||||||
):
|
):
|
||||||
"""
|
"""
|
||||||
Creates a facet grid showing all points
|
Creates a facet grid showing all points
|
||||||
@ -400,6 +403,10 @@ def facet_grid(
|
|||||||
else:
|
else:
|
||||||
grid.map(draw_fn, third, el, color=colors[i % len(colors)], marker='+')
|
grid.map(draw_fn, third, el, color=colors[i % len(colors)], marker='+')
|
||||||
|
|
||||||
|
if letters is not None:
|
||||||
|
grid.set_titles(col_template="$"+letters[0]+"$ = {row_name}", row_template="$"+letters[1]+"$ = {col_name}")
|
||||||
|
|
||||||
|
|
||||||
if title is not None:
|
if title is not None:
|
||||||
plot(title, g=grid)
|
plot(title, g=grid)
|
||||||
return grid
|
return grid
|
||||||
@ -465,27 +472,66 @@ if args.rslice:
|
|||||||
rslice()
|
rslice()
|
||||||
|
|
||||||
do_predictions(stats)
|
do_predictions(stats)
|
||||||
#all_facets(stats, shown=["clflush_remote_hit"], colors=["r"], pre="hit")
|
all_facets(stats, shown=["clflush_remote_hit"], colors=["r"], pre="hit_")
|
||||||
#all_facets(stats, shown=["clflush_miss_n"], colors=["b"], pre="miss")
|
all_facets(stats, shown=["clflush_miss_n"], colors=["b"], pre="miss_")
|
||||||
|
|
||||||
#df=stats
|
def compare_facing():
|
||||||
#for m, h, s in itertools.product((0, 1), (0, 1), df["slice_group"].unique()):
|
df=stats
|
||||||
# dfc = df[(df["main_socket"] == m) & (df["main_core_fixed"]%8é == s) & (df["helper_socket"] == h)]
|
for m, h, s in itertools.product((0, 1), (0, 1), df["slice_group"].unique()):
|
||||||
#
|
dfc = df[(df["main_socket"] == m) & (df["main_core_fixed"]%8 == s) & (df["helper_socket"] == h)]
|
||||||
# grid = sns.FacetGrid(dfc, row=None, col=None)
|
|
||||||
# grid.map(sns.scatterplot, "slice_group", "clflush_miss_n", marker="+")
|
grid = sns.FacetGrid(dfc, row=None, col=None)
|
||||||
#
|
grid.map(sns.scatterplot, "slice_group", "clflush_miss_n", marker="+")
|
||||||
# plot(f"miss_m{m}h{h}m{s}", g=grid)
|
|
||||||
|
plot(f"miss_m{m}h{h}m{s}", g=grid)
|
||||||
|
|
||||||
|
|
||||||
#with Pool(8) as pool:
|
def isolate_sockets():
|
||||||
# pool.starmap(
|
with Pool(8) as pool:
|
||||||
# do_facet,
|
pool.starmap(
|
||||||
# itertools.product(
|
do_facet,
|
||||||
# stats["main_socket"].unique(),
|
itertools.product(
|
||||||
# stats["helper_socket"].unique(),
|
stats["main_socket"].unique(),
|
||||||
# (False, ),
|
stats["helper_socket"].unique(),
|
||||||
# ("hit", "miss")
|
(False, ),
|
||||||
# )
|
("hit", "miss")
|
||||||
# )
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
def superpose_sockets():
|
||||||
|
for main, same_socket in itertools.product(sorted(stats["main_core_fixed"].unique()), (True, False)):
|
||||||
|
df = stats[
|
||||||
|
(stats["slice_group"] == (main%8))
|
||||||
|
& (stats["main_core_fixed"] == main)
|
||||||
|
& ((stats["main_socket"] == stats["helper_socket"]) == same_socket)
|
||||||
|
]
|
||||||
|
ax = sns.scatterplot(df, x="helper_core_fixed", y="clflush_remote_hit", marker="+", color="r")
|
||||||
|
ax.set_title(f"$S = {main%8}, V = {main}$")
|
||||||
|
plot(f"hit_{same_socket}_main{main:02d}.png")
|
||||||
|
|
||||||
|
df = stats[
|
||||||
|
(stats["slice_group"] == (stats["main_core_fixed"]%8))
|
||||||
|
& ((stats["main_core_fixed"]%8) == (stats["helper_core_fixed"]%8))
|
||||||
|
& (stats["main_socket"] != stats["helper_socket"])
|
||||||
|
]
|
||||||
|
ax = sns.scatterplot(df, x="slice_group", y="clflush_remote_hit", marker="+", color="r")
|
||||||
|
plot(f"hit_same_slice.png")
|
||||||
|
|
||||||
|
stats["main_core_nosock"] = stats["main_core_fixed"]%8
|
||||||
|
stats["helper_core_nosock"] = stats["helper_core_fixed"]%8
|
||||||
|
|
||||||
|
facet_grid(
|
||||||
|
stats[(stats["main_socket"] != stats["helper_socket"])], "helper_core_nosock", "main_core_nosock", "slice_group",
|
||||||
|
title=f"hit_facet_slice_diff_socket.png",
|
||||||
|
separate_hthreads=True,
|
||||||
|
shown=["clflush_remote_hit"],
|
||||||
|
letters="VA"
|
||||||
|
)
|
||||||
|
|
||||||
|
facet_grid(
|
||||||
|
stats[(stats["main_socket"] == stats["helper_socket"])], "helper_core_nosock", "main_core_nosock", "slice_group",
|
||||||
|
title=f"hit_facet_slice_same_socket.png",
|
||||||
|
separate_hthreads=True,
|
||||||
|
letters="VA",
|
||||||
|
shown=["clflush_remote_hit"]
|
||||||
|
)
|
@ -1,189 +0,0 @@
|
|||||||
"""
|
|
||||||
Try some models and see what they look like
|
|
||||||
Following this die could help https://en.wikichip.org/w/images/4/48/E5_v4_LCC.png
|
|
||||||
Using the following naming convention:
|
|
||||||
|
|
||||||
------
|
|
||||||
0 7
|
|
||||||
1 6
|
|
||||||
2 5
|
|
||||||
3 4
|
|
||||||
------
|
|
||||||
"""
|
|
||||||
import matplotlib.pyplot as plt
|
|
||||||
import seaborn as sns
|
|
||||||
import pandas as pd
|
|
||||||
import numpy as np
|
|
||||||
import itertools
|
|
||||||
import os
|
|
||||||
|
|
||||||
nb_cores = 8
|
|
||||||
nb_slices = 8
|
|
||||||
num_core = nb_cores
|
|
||||||
|
|
||||||
cores = list(range(nb_cores))
|
|
||||||
slices = list(range(nb_slices))
|
|
||||||
|
|
||||||
img_dir = os.getenv("PWD")+"/"
|
|
||||||
def plot(filename, g=None):
|
|
||||||
if g is not None:
|
|
||||||
g.savefig(img_dir + filename)
|
|
||||||
else:
|
|
||||||
plt.savefig(img_dir + filename)
|
|
||||||
# tikzplotlib.save(
|
|
||||||
# img_dir+filename+".tex",
|
|
||||||
# axis_width=r'0.175\textwidth',
|
|
||||||
# axis_height=r'0.25\textwidth'
|
|
||||||
# )
|
|
||||||
print(img_dir + filename, "saved")
|
|
||||||
plt.close()
|
|
||||||
|
|
||||||
def ring_distance(x0, x1):
|
|
||||||
"""
|
|
||||||
return (a, b) where `a` is the core distance and `b` the larger "ring step"
|
|
||||||
it is possible that going from 0->7 costs one more than 3->4
|
|
||||||
"""
|
|
||||||
dist = abs(x0-x1)
|
|
||||||
if x0 // (num_core/2) != x1 // (num_core/2):
|
|
||||||
# côté du coeur différent
|
|
||||||
return min((num_core-1-dist, 2), (dist-1, 1))
|
|
||||||
else:
|
|
||||||
return dist, 0
|
|
||||||
|
|
||||||
def slice_msg_distance(source, dest):
|
|
||||||
"""
|
|
||||||
Si l'expéditeur est à l'extrémité d'une des lignes, il envoie toujours dans le même sens
|
|
||||||
(vers toute sa ligne d'abord), sinon, il prend le chemin le plus court
|
|
||||||
le bonus correspond au fait que 0->7 puisse coûter 1 de plus que 3->4
|
|
||||||
"""
|
|
||||||
dist = abs(source-dest)
|
|
||||||
if source // (num_core/2) == dest // (num_core/2):
|
|
||||||
return (dist, 0)
|
|
||||||
|
|
||||||
# Pour aller de l'autre côté
|
|
||||||
up, down = (num_core-1-dist, 2), (dist-1, 1)
|
|
||||||
if source in [0, 7]:
|
|
||||||
return down
|
|
||||||
if source in [3, 4] or source in [2, 5]:
|
|
||||||
return up
|
|
||||||
if source in [1, 6]:
|
|
||||||
return min(up, down)
|
|
||||||
|
|
||||||
raise IndexError
|
|
||||||
|
|
||||||
def ha_dist(core, is_QPI):
|
|
||||||
"""
|
|
||||||
distance to Home Agent
|
|
||||||
"""
|
|
||||||
if is_QPI:
|
|
||||||
if core < 4:
|
|
||||||
return core, 0
|
|
||||||
return 7-core, 1 # +1 for PCI
|
|
||||||
|
|
||||||
if core < 4:
|
|
||||||
return 3-core, 0
|
|
||||||
return core-4, 0
|
|
||||||
|
|
||||||
def cclockwise_dist(source, dest):
|
|
||||||
base = (dest+8-source)%8
|
|
||||||
side_jump = 0
|
|
||||||
if source < 4 and dest >= 4:
|
|
||||||
side_jump = 1
|
|
||||||
elif source >= 4 and dest < 4:
|
|
||||||
side_jump = 2
|
|
||||||
return base, side_jump
|
|
||||||
|
|
||||||
def cclockwise_ha_dist(core, is_QPI):
|
|
||||||
"""
|
|
||||||
counter-clockwise distance to Home Agent
|
|
||||||
"""
|
|
||||||
if is_QPI:
|
|
||||||
return cclockwise_dist(core, 7)
|
|
||||||
return cclockwise_dist(core, 3)
|
|
||||||
|
|
||||||
def no_QPI_dist(source, dest):
|
|
||||||
"""
|
|
||||||
Path not using QPI hop
|
|
||||||
"""
|
|
||||||
return abs(source-dest), 1 if source // 4 != dest //4 else 0
|
|
||||||
|
|
||||||
|
|
||||||
def miss():
|
|
||||||
"""
|
|
||||||
- ini : initial cost
|
|
||||||
- core_step : cost to go from one core to the following (eg 0 to 1)
|
|
||||||
- ring_step : cost to go from one line to the other (eg 0 to 7)
|
|
||||||
|
|
||||||
Issue: on a same socket, we observe always the first 4 or last 4 patterns, but not mixed
|
|
||||||
"""
|
|
||||||
def miss_topo(main_core, slice, i, c, l, k):
|
|
||||||
x, y, z = slice_msg_distance(main_core, slice)
|
|
||||||
return i+c*x+l*y+k*z
|
|
||||||
|
|
||||||
ini, core_step, ring_step, other_ring_step = 4, 1, 5, 2
|
|
||||||
fig, axs = plt.subplots(nrows=1, ncols=8, figsize=(15, 5))
|
|
||||||
|
|
||||||
for i, slice in enumerate(range(8)):
|
|
||||||
axs[i].plot(cores, [miss_topo(main_core, slice, ini, core_step, ring_step, other_ring_step) for main_core in cores], "ro")
|
|
||||||
axs[i].set_title(f"slice_group = {slice}")
|
|
||||||
axs[i].set_ylabel("clflush_miss_n")
|
|
||||||
axs[i].set_xlabel("main_core_fixed")
|
|
||||||
axs[i].set_ylim([0, 25])
|
|
||||||
|
|
||||||
plt.tight_layout()
|
|
||||||
plt.show()
|
|
||||||
|
|
||||||
|
|
||||||
def hit():
|
|
||||||
"""
|
|
||||||
- ini : initial cost
|
|
||||||
- core_step : cost to go from one core to the following (eg 0 to 1)
|
|
||||||
- ring_step : cost to go from one line to the other (eg 0 to 7)
|
|
||||||
|
|
||||||
Issue: on a same socket, we observe always the first 4 or last 4 patterns, but not mixed
|
|
||||||
"""
|
|
||||||
def hit_topo(main, helper, slice_g, i, c, l):
|
|
||||||
helper = helper%8
|
|
||||||
|
|
||||||
main_slice_local = slice_msg_distance(slice_g, main)
|
|
||||||
slice_QPI = cclockwise_dist(0, slice_g) # clockwise
|
|
||||||
QPI_slice_r = cclockwise_dist(0, slice_g)
|
|
||||||
slice_r_helper = slice_msg_distance(slice_g, helper)
|
|
||||||
|
|
||||||
costs = (main_slice_local[0]+slice_QPI[0]+QPI_slice_r[0]+slice_r_helper[0], main_slice_local[1]+slice_QPI[1]+QPI_slice_r[1]+slice_r_helper[1])
|
|
||||||
return ini+costs[0]*c+costs[1]*l
|
|
||||||
|
|
||||||
|
|
||||||
ini, core_step, ring_step = 12, 1, 1.5
|
|
||||||
fig, axs = plt.subplots(nrows=1, ncols=8, figsize=(15, 5))
|
|
||||||
|
|
||||||
# Define the ranges for x, y, z
|
|
||||||
main = range(8)
|
|
||||||
helper = range(8, 16)
|
|
||||||
slice_g = range(8)
|
|
||||||
|
|
||||||
# Create a DataFrame with all combinations of x, y, and z
|
|
||||||
data = pd.DataFrame([
|
|
||||||
(x, y, z) for z in slice_g
|
|
||||||
for x, y in itertools.product(main, helper)
|
|
||||||
],
|
|
||||||
columns=['main', 'helper', 'slice_group']
|
|
||||||
)
|
|
||||||
|
|
||||||
# Define the function
|
|
||||||
def my_function(x):
|
|
||||||
return hit_topo(x["main"], x["helper"], x["slice_group"], ini, core_step, ring_step)
|
|
||||||
|
|
||||||
# Apply the function to create a new column
|
|
||||||
data['predicted_hit'] = data.apply(my_function, axis=1)
|
|
||||||
|
|
||||||
fig = sns.FacetGrid(data, col="main", row="helper")
|
|
||||||
fig.map(sns.scatterplot, "slice_group", "predicted_hit", color="r", marker="+")
|
|
||||||
fig.map(sns.scatterplot, "slice_group", "predicted_hit", color="r", marker="x")
|
|
||||||
fig.set_titles(col_template="$A$ = {col_name}", row_template="$V$ = {row_name}")
|
|
||||||
|
|
||||||
plot("model_hit.png", g=fig)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
hit()
|
|
Loading…
Reference in New Issue
Block a user