Compare commits

...

3 Commits

Author SHA1 Message Date
ead00b5e8a Add all columns back 2024-06-05 11:55:10 +02:00
e8cb44663c Fix some python script issues
- removed tikzplotlib uses
- hide warnings
- modify unhashable types
2024-06-05 11:54:44 +02:00
2a5a2a0e18 Update config files 2024-06-05 11:50:17 +02:00
6 changed files with 48 additions and 17 deletions

2
.gitignore vendored
View File

@ -21,3 +21,5 @@ tftpboot
pxelinux.cfg pxelinux.cfg
serial.out serial.out
memdisk memdisk
**/venv
cache_utils/results*/

View File

@ -7,13 +7,24 @@ import pandas as pd
import matplotlib.pyplot as plt import matplotlib.pyplot as plt
import seaborn as sns import seaborn as sns
#import tikzplotlib #import tikzplotlib
from sys import exit
import wquantiles as wq import wquantiles as wq
import numpy as np import numpy as np
from functools import partial from functools import partial
import sys import sys
import os
import json
import warnings
warnings.filterwarnings('ignore')
print("warnings are filtered, enable them back if you are having some trouble")
def dict_to_json(d):
if isinstance(d, dict):
return json.dumps(d)
return d
# For cyber cobay sanity check : # For cyber cobay sanity check :
# from gmpy2 import popcount # from gmpy2 import popcount
@ -41,6 +52,10 @@ def convert8(x):
return np.array(int(x, base=16)).astype(np.int64) return np.array(int(x, base=16)).astype(np.int64)
# return np.int8(int(x, base=16)) # return np.int8(int(x, base=16))
assert os.path.exists(sys.argv[1] + ".slices.csv")
assert os.path.exists(sys.argv[1] + ".cores.csv")
assert os.path.exists(sys.argv[1] + "-results_lite.csv.bz2")
df = pd.read_csv(sys.argv[1] + "-results_lite.csv.bz2", df = pd.read_csv(sys.argv[1] + "-results_lite.csv.bz2",
dtype={ dtype={
"main_core": np.int8, "main_core": np.int8,
@ -61,6 +76,8 @@ df = pd.read_csv(sys.argv[1] + "-results_lite.csv.bz2",
converters={'address': convert64, 'hash': convert8}, converters={'address': convert64, 'hash': convert8},
) )
print(f"Loaded columns : {list(df.keys())}")
sample_columns = [ sample_columns = [
"clflush_remote_hit", "clflush_remote_hit",
"clflush_shared_hit", "clflush_shared_hit",
@ -117,13 +134,11 @@ print(*[bin(a) for a in addresses], sep='\n')
print(df.head()) print(df.head())
print(df["hash"].unique())
min_time = df["time"].min() min_time = df["time"].min()
max_time = df["time"].max() max_time = df["time"].max()
q10s = [wq.quantile(df["time"], df[col], 0.1) for col in sample_flush_columns] q10s = [wq.quantile(df["time"], df[col], 0.1) for col in sample_flush_columns if col in df]
q90s = [wq.quantile(df["time"], df[col], 0.9) for col in sample_flush_columns] q90s = [wq.quantile(df["time"], df[col], 0.9) for col in sample_flush_columns if col in df]
graph_upper = int(((max(q90s) + 19) // 10) * 10) graph_upper = int(((max(q90s) + 19) // 10) * 10)
graph_lower = int(((min(q10s) - 10) // 10) * 10) graph_lower = int(((min(q10s) - 10) // 10) * 10)
@ -168,6 +183,9 @@ custom_hist(df_ax_vx_sx["time"], df_ax_vx_sx["clflush_miss_n"], df_ax_vx_sx["clf
#tikzplotlib.save("fig-hist-bad-A{}V{}S{}.tex".format(attacker,victim,slice))#, axis_width=r'0.175\textwidth', axis_height=r'0.25\textwidth') #tikzplotlib.save("fig-hist-bad-A{}V{}S{}.tex".format(attacker,victim,slice))#, axis_width=r'0.175\textwidth', axis_height=r'0.25\textwidth')
plt.show() plt.show()
# Fix np.darray is unhashable
df_main_core_0.loc[:, ('hash',)] = df_main_core_0['hash'].apply(dict_to_json)
df.loc[:, ('hash',)] = df['hash'].apply(dict_to_json)
g = sns.FacetGrid(df_main_core_0, col="helper_core", row="hash", legend_out=True) g = sns.FacetGrid(df_main_core_0, col="helper_core", row="hash", legend_out=True)
g2 = sns.FacetGrid(df, col="main_core", row="hash", legend_out=True) g2 = sns.FacetGrid(df, col="main_core", row="hash", legend_out=True)
@ -194,7 +212,7 @@ g2.map(custom_hist, "time", "clflush_miss_n", "clflush_remote_hit", "clflush_loc
#g3.map(custom_hist, "time", "clflush_miss_n", "clflush_remote_hit", "clflush_local_hit_n", "clflush_shared_hit") #g3.map(custom_hist, "time", "clflush_miss_n", "clflush_remote_hit", "clflush_local_hit_n", "clflush_shared_hit")
#g4 = sns.FacetGrid(df_mcf6_slg7, row="helper_core_fixed", col="helper_ht") #g4 = sns.FacetGrid(df_mcf6_slg7, row="helper_core_fixed", col="helper_ht")
g#4.map(custom_hist, "time", "clflush_miss_n", "clflush_remote_hit", "clflush_local_hit_n", "clflush_shared_hit") #g4.map(custom_hist, "time", "clflush_miss_n", "clflush_remote_hit", "clflush_local_hit_n", "clflush_shared_hit")
def stat(x, key): def stat(x, key):
return wq.median(x["time"], x[key]) return wq.median(x["time"], x[key])
@ -216,7 +234,7 @@ stats.to_csv(sys.argv[1] + ".stats.csv", index=False)
#print(stats.to_string()) #print(stats.to_string())
plt.show() plt.show()
exit(0) sys.exit(0)
g = sns.FacetGrid(stats, row="Core") g = sns.FacetGrid(stats, row="Core")
g.map(sns.distplot, 'Miss', bins=range(100, 480), color="r") g.map(sns.distplot, 'Miss', bins=range(100, 480), color="r")
@ -232,4 +250,4 @@ plt.show()
# plt.figure() # plt.figure()
# sns.distplot(test["value"], hist_kws={"weights": test["weight"]}, kde=False) # sns.distplot(test["value"], hist_kws={"weights": test["weight"]}, kde=False)
exit(0) sys.exit(0)

View File

@ -10,6 +10,12 @@ from sys import exit
import numpy as np import numpy as np
from scipy import optimize from scipy import optimize
import sys import sys
import os
import warnings
warnings.filterwarnings('ignore')
print("warnings are filtered, enable them back if you are having some trouble")
# TODO # TODO
# sys.argv[1] should be the root # sys.argv[1] should be the root
@ -23,6 +29,9 @@ import sys
# each row is an origin core # each row is an origin core
# each column a helper core if applicable # each column a helper core if applicable
assert os.path.exists(sys.argv[1] + ".stats.csv")
assert os.path.exists(sys.argv[1] + ".slices.csv")
assert os.path.exists(sys.argv[1] + ".cores.csv")
stats = pd.read_csv(sys.argv[1] + ".stats.csv", stats = pd.read_csv(sys.argv[1] + ".stats.csv",
dtype={ dtype={
@ -234,9 +243,9 @@ figure_median_I.map(sns.lineplot, 'slice_group', 'predicted_miss', color="b")
figure_median_I.set_titles(col_template="$A$ = {col_name}") figure_median_I.set_titles(col_template="$A$ = {col_name}")
figure_median_I.tight_layout() figure_median_I.tight_layout()
import tikzplotlib # import tikzplotlib
tikzplotlib.save("fig-median-I.tex", axis_width=r'0.175\textwidth', axis_height=r'0.25\textwidth') # tikzplotlib.save("fig-median-I.tex", axis_width=r'0.175\textwidth', axis_height=r'0.25\textwidth')
plt.show() plt.show()
#stats["predicted_remote_hit_no_gpu"] = exclusive_hit_topology_nogpu_df(stats, *(res_no_gpu[0])) #stats["predicted_remote_hit_no_gpu"] = exclusive_hit_topology_nogpu_df(stats, *(res_no_gpu[0]))
@ -250,7 +259,7 @@ figure_median_E_A0.map(sns.scatterplot, 'helper_core_fixed', 'clflush_remote_hit
figure_median_E_A0.map(sns.lineplot, 'helper_core_fixed', 'predicted_remote_hit_gpu', color="r") figure_median_E_A0.map(sns.lineplot, 'helper_core_fixed', 'predicted_remote_hit_gpu', color="r")
figure_median_E_A0.set_titles(col_template="$S$ = {col_name}") figure_median_E_A0.set_titles(col_template="$S$ = {col_name}")
tikzplotlib.save("fig-median-E-A0.tex", axis_width=r'0.175\textwidth', axis_height=r'0.25\textwidth') # tikzplotlib.save("fig-median-E-A0.tex", axis_width=r'0.175\textwidth', axis_height=r'0.25\textwidth')
plt.show() plt.show()
g = sns.FacetGrid(stats, row="main_core_fixed") g = sns.FacetGrid(stats, row="main_core_fixed")

View File

@ -111,9 +111,10 @@ fn main() {
let core_per_socket_str = from_utf8(&core_per_socket_out.stdout).unwrap(); let core_per_socket_str = from_utf8(&core_per_socket_out.stdout).unwrap();
//println!("Number of cores per socket: {}", cps_str); //println!("Number of cores per socket (str): {}", core_per_socket_str);
let core_per_socket: u8 = core_per_socket_str[0..(core_per_socket_str.len() - 1)] let core_per_socket: u8 = core_per_socket_str[0..(core_per_socket_str.len() - 1)]
.trim()
.parse() .parse()
.unwrap_or(0); .unwrap_or(0);
@ -156,7 +157,7 @@ fn main() {
display_name: "clflush remote hit", display_name: "clflush remote hit",
t: &(), t: &(),
}, },
/* CalibrateOperation2T { CalibrateOperation2T {
prepare: maccess::<u8>, prepare: maccess::<u8>,
op: load_and_flush_wrap, op: load_and_flush_wrap,
name: "clflush_shared_hit", name: "clflush_shared_hit",
@ -176,7 +177,7 @@ fn main() {
name: "clflush_local_hit_f", name: "clflush_local_hit_f",
display_name: "clflush local hit - f", display_name: "clflush local hit - f",
t: &(), t: &(),
},*/ },
CalibrateOperation2T { CalibrateOperation2T {
prepare: noop::<u8>, prepare: noop::<u8>,
op: only_flush_wrap, op: only_flush_wrap,
@ -184,7 +185,7 @@ fn main() {
display_name: "clflush miss - n", display_name: "clflush miss - n",
t: &(), t: &(),
}, },
/* CalibrateOperation2T { CalibrateOperation2T {
prepare: noop::<u8>, prepare: noop::<u8>,
op: load_and_flush_wrap, op: load_and_flush_wrap,
name: "clflush_local_hit_n", name: "clflush_local_hit_n",
@ -218,7 +219,7 @@ fn main() {
name: "reload_local_hit", name: "reload_local_hit",
display_name: "reload local hit", display_name: "reload local hit",
t: &(), t: &(),
},*/ },
]; ];
let r = unsafe { let r = unsafe {

View File

@ -4,5 +4,6 @@ wquantiles==0.5
matplotlib~=3.2.1 matplotlib~=3.2.1
numpy~=1.18.2 numpy~=1.18.2
gmpy2~=2.0.8 #gmpy2~=2.0.8
scipy~=1.4.1 scipy~=1.4.1
PyQt5