Compare commits
4
Commits
167c3a1290
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
86e6037e59
|
||
|
|
aad3b85d8f
|
||
|
|
df83623101
|
||
|
|
7a3d1610ba
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
Binary file not shown.
Binary file not shown.
BIN
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
+36
-10
@@ -1,8 +1,11 @@
|
||||
library(ggplot2)
|
||||
library(dplyr)
|
||||
library(readr)
|
||||
library(stringr)
|
||||
|
||||
# Usage: Rscript combined_comparison.r exp_abspath1 exp_abspath2 ... [resultsdata_file]
|
||||
# One coordinate system per base experiment (facet); c/aot/interp variants
|
||||
# share each facet, coloured by variant.
|
||||
|
||||
args <- commandArgs(trailingOnly = TRUE)
|
||||
if (length(args) < 1) {
|
||||
@@ -20,17 +23,36 @@ exp_args <- if (grepl("\\.csv$", args[length(args)])) {
|
||||
args
|
||||
}
|
||||
|
||||
extract_info <- function(path) {
|
||||
dir_name <- basename(path)
|
||||
match <- str_match(
|
||||
dir_name,
|
||||
"^\\d{2}-\\d{2}_\\d{2}-\\d{2}-\\d{2}_(.+?)_(c|aot|interp)_"
|
||||
)
|
||||
if (is.na(match[1, 1])) {
|
||||
warning(paste("Could not parse:", dir_name))
|
||||
return(NULL)
|
||||
}
|
||||
list(base_name = match[1, 2], variant = match[1, 3], path = path)
|
||||
}
|
||||
|
||||
all_data <- data.frame()
|
||||
|
||||
for (arg in exp_args) {
|
||||
csv_file <- file.path(arg, csv_suffix)
|
||||
info <- extract_info(arg)
|
||||
if (is.null(info)) {
|
||||
next
|
||||
}
|
||||
|
||||
csv_file <- file.path(info$path, csv_suffix)
|
||||
if (!file.exists(csv_file)) {
|
||||
warning(paste("Missing:", csv_file))
|
||||
next
|
||||
}
|
||||
|
||||
df <- read_csv(csv_file, col_types = cols())
|
||||
df$experiment <- basename(arg)
|
||||
df$base_name <- info$base_name
|
||||
df$variant <- info$variant
|
||||
all_data <- bind_rows(all_data, df)
|
||||
}
|
||||
|
||||
@@ -39,7 +61,7 @@ if (nrow(all_data) == 0) {
|
||||
}
|
||||
|
||||
totals <- all_data |>
|
||||
group_by(experiment, resulttype) |>
|
||||
group_by(base_name, variant, resulttype) |>
|
||||
summarise(faults = sum(faults, na.rm = TRUE), .groups = "drop") |>
|
||||
ungroup()
|
||||
|
||||
@@ -57,21 +79,25 @@ totals$resulttype <- factor(totals$resulttype, levels = marker_order)
|
||||
|
||||
plot <- ggplot(
|
||||
totals,
|
||||
aes(x = resulttype, y = faults, colour = experiment, group = experiment)
|
||||
aes(x = resulttype, y = faults, colour = variant, group = variant)
|
||||
) +
|
||||
geom_point(size = 2) +
|
||||
geom_line() +
|
||||
facet_wrap(~base_name) +
|
||||
scale_y_log10() +
|
||||
labs(
|
||||
x = "Marker",
|
||||
y = "Faults",
|
||||
title = "Combined Comparison",
|
||||
color = "Experiment"
|
||||
x = "Fault Type",
|
||||
y = "Fault Count",
|
||||
title = "Fault Count Comparison",
|
||||
color = "Variant"
|
||||
) +
|
||||
theme_minimal() +
|
||||
theme(axis.text.x = element_text(angle = 45, hjust = 1))
|
||||
theme(
|
||||
axis.text.x = element_text(angle = 90, hjust = 1),
|
||||
plot.title = element_text(size = 14, face = "bold")
|
||||
)
|
||||
|
||||
suffix <- gsub("^resultsdata|\\.csv$", "", csv_suffix)
|
||||
outfile <- paste0("injections/combined_comparison", suffix, ".svg")
|
||||
outfile <- paste0("injections/fault_count_comparison", suffix, ".svg")
|
||||
ggsave(outfile, plot = plot, width = 12, height = 6)
|
||||
print(paste("Saved", outfile))
|
||||
+38
-32
@@ -4,8 +4,8 @@ library(readr)
|
||||
library(stringr)
|
||||
library(tidyr)
|
||||
|
||||
# Usage: Rscript ratio_correlation.r exp_abspath1 exp_abspath2 ... [resultsdata_file]
|
||||
# Plots correlation between aot/c and interp/c ratios
|
||||
# Usage: Rscript combined_fault_correlation.r exp_abspath1 exp_abspath2 ... [resultsdata_file]
|
||||
# Plots correlation between raw aot and interp fault counts (no C baseline).
|
||||
|
||||
args <- commandArgs(trailingOnly = TRUE)
|
||||
if (length(args) < 2) {
|
||||
@@ -69,48 +69,52 @@ all_data <- all_data |>
|
||||
group_by(base_name, variant, benchmark, resulttype) |>
|
||||
summarise(faults = sum(faults), .groups = "drop")
|
||||
|
||||
baseline <- all_data |> filter(variant == "c")
|
||||
comparisons <- all_data |> filter(variant != "c")
|
||||
# Only aot/interp matter; C is not used as a baseline here.
|
||||
counts <- all_data |> filter(variant %in% c("aot", "interp"))
|
||||
|
||||
ratios <- comparisons |>
|
||||
left_join(
|
||||
baseline |> select(base_name, benchmark, resulttype, faults),
|
||||
by = c("base_name", "benchmark", "resulttype"),
|
||||
suffix = c("", "_baseline")
|
||||
) |>
|
||||
filter(!is.na(faults_baseline), faults_baseline > 0) |>
|
||||
mutate(ratio = faults / faults_baseline)
|
||||
|
||||
if (nrow(ratios) == 0) {
|
||||
stop("No ratios computed (missing baseline or zero values)")
|
||||
}
|
||||
|
||||
# Pivot to get aot and interp ratios side by side
|
||||
ratio_wide <- ratios |>
|
||||
select(base_name, benchmark, resulttype, variant, ratio) |>
|
||||
pivot_wider(names_from = variant, values_from = ratio) |>
|
||||
# Pivot to get aot and interp fault counts side by side
|
||||
counts_wide <- counts |>
|
||||
select(base_name, benchmark, resulttype, variant, faults) |>
|
||||
pivot_wider(names_from = variant, values_from = faults) |>
|
||||
filter(!is.na(aot), !is.na(interp))
|
||||
|
||||
if (nrow(ratio_wide) == 0) {
|
||||
stop("No paired aot/interp ratios found")
|
||||
if (nrow(counts_wide) == 0) {
|
||||
stop("No paired aot/interp fault counts found")
|
||||
}
|
||||
|
||||
# Compute correlation
|
||||
cor_result <- cor(ratio_wide$aot, ratio_wide$interp, method = "pearson")
|
||||
cat(sprintf("Pearson correlation: %.4f\n", cor_result))
|
||||
cor_raw <- cor(counts_wide$aot, counts_wide$interp, method = "pearson")
|
||||
cor_log <- cor(
|
||||
log10(counts_wide$aot),
|
||||
log10(counts_wide$interp),
|
||||
method = "pearson"
|
||||
)
|
||||
cat(sprintf("Pearson correlation (raw): %.4f\n", cor_raw))
|
||||
cat(sprintf("Pearson correlation (log10): %.4f\n", cor_log))
|
||||
|
||||
# Create plot
|
||||
plot <- ggplot(
|
||||
ratio_wide,
|
||||
counts_wide,
|
||||
aes(x = aot, y = interp, color = base_name, shape = resulttype)
|
||||
) +
|
||||
# geom_abline(
|
||||
# slope = 1,
|
||||
# intercept = 0,
|
||||
# colour = "grey70",
|
||||
# linetype = "dotted"
|
||||
# ) +
|
||||
geom_point(size = 3, alpha = 0.7) +
|
||||
scale_x_log10(name = "AOT / C Ratio") +
|
||||
scale_y_log10(name = "Interpreter / C Ratio") +
|
||||
scale_x_log10(name = "AOT Fault Count") +
|
||||
scale_y_log10(name = "Interpreter Fault Count") +
|
||||
labs(
|
||||
title = sprintf("Ratio Correlation (r = %.4f)", cor_result),
|
||||
# title = sprintf(
|
||||
# "Fault Count Correlation (r_raw = %.4f, r_log = %.4f)",
|
||||
# cor_raw,
|
||||
# cor_log
|
||||
# ),
|
||||
title = "Fault Count Correlation",
|
||||
color = "Experiment",
|
||||
shape = "Marker"
|
||||
shape = "Fault Type"
|
||||
) +
|
||||
theme_minimal() +
|
||||
theme(
|
||||
@@ -118,5 +122,7 @@ plot <- ggplot(
|
||||
plot.title = element_text(size = 14, face = "bold")
|
||||
)
|
||||
|
||||
ggsave("injections/ratio_correlation.svg", plot = plot, width = 10, height = 8)
|
||||
print("Saved ratio_correlation.svg")
|
||||
suffix <- gsub("^resultsdata|\\.csv$", "", csv_suffix)
|
||||
outfile <- paste0("injections/fault_count_correlation", suffix, ".svg")
|
||||
ggsave(outfile, plot = plot, width = 10, height = 8)
|
||||
print(paste("Saved", outfile))
|
||||
@@ -0,0 +1,115 @@
|
||||
library(ggplot2)
|
||||
library(dplyr)
|
||||
library(readr)
|
||||
library(stringr)
|
||||
|
||||
# Usage: Rscript combined_fault_rates.r exp_abspath1 exp_abspath2 ... [faults_file]
|
||||
|
||||
args <- commandArgs(trailingOnly = TRUE)
|
||||
if (length(args) < 1) {
|
||||
stop("Need at least 1 experiment")
|
||||
}
|
||||
|
||||
csv_suffix <- if (grepl("\\.csv$", args[length(args)])) {
|
||||
args[length(args)]
|
||||
} else {
|
||||
"faults.csv"
|
||||
}
|
||||
exp_args <- if (grepl("\\.csv$", args[length(args)])) {
|
||||
args[-length(args)]
|
||||
} else {
|
||||
args
|
||||
}
|
||||
|
||||
# Faults / instruction count, per experiment
|
||||
rates <- data.frame()
|
||||
|
||||
for (arg in exp_args) {
|
||||
faults_file <- file.path(arg, csv_suffix)
|
||||
mnem_file <- file.path(arg, "mnemonics.csv")
|
||||
|
||||
if (!file.exists(faults_file)) {
|
||||
warning(paste("Missing:", faults_file))
|
||||
next
|
||||
}
|
||||
if (!file.exists(mnem_file)) {
|
||||
warning(paste("Missing:", mnem_file))
|
||||
next
|
||||
}
|
||||
|
||||
df <- read_csv(faults_file, col_types = cols())
|
||||
mdf <- read_csv(mnem_file, col_types = cols())
|
||||
|
||||
total_faults <- df |>
|
||||
filter(resulttype != "OK_MARKER") |>
|
||||
summarise(faults = sum(faults, na.rm = TRUE)) |>
|
||||
pull(faults)
|
||||
|
||||
total_instrs <- sum(mdf$count, na.rm = TRUE)
|
||||
|
||||
if (is.na(total_instrs) || total_instrs == 0) {
|
||||
warning(paste("Zero instruction count for", arg))
|
||||
next
|
||||
}
|
||||
|
||||
match <- str_match(
|
||||
basename(arg),
|
||||
"^\\d{2}-\\d{2}_\\d{2}-\\d{2}-\\d{2}_(.+?)_(c|aot|interp)_"
|
||||
)
|
||||
if (is.na(match[1, 1])) {
|
||||
base_name <- basename(arg)
|
||||
variant <- "unknown"
|
||||
} else {
|
||||
base_name <- match[1, 2]
|
||||
variant <- match[1, 3]
|
||||
}
|
||||
|
||||
rates <- bind_rows(
|
||||
rates,
|
||||
data.frame(
|
||||
base_name = base_name,
|
||||
variant = variant,
|
||||
fault_rate = total_faults / total_instrs
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
if (nrow(rates) == 0) {
|
||||
stop("No data loaded")
|
||||
}
|
||||
|
||||
# Order base_names by their max fault rate
|
||||
base_order <- rates |>
|
||||
group_by(base_name) |>
|
||||
summarise(max_rate = max(fault_rate), .groups = "drop") |>
|
||||
arrange(desc(max_rate)) |>
|
||||
pull(base_name)
|
||||
|
||||
rates <- rates |>
|
||||
mutate(
|
||||
base_name = factor(base_name, levels = base_order),
|
||||
variant = factor(variant, levels = c("c", "aot", "interp", "unknown"))
|
||||
)
|
||||
|
||||
plot <- ggplot(
|
||||
rates,
|
||||
aes(x = base_name, y = fault_rate, fill = variant)
|
||||
) +
|
||||
geom_col(position = position_dodge(preserve = "single")) +
|
||||
scale_y_log10() +
|
||||
labs(
|
||||
title = "Fault Rate per Instruction",
|
||||
x = "Experiment",
|
||||
y = "Faults / Instruction Count",
|
||||
fill = "Variant"
|
||||
) +
|
||||
theme_minimal() +
|
||||
theme(
|
||||
axis.text.x = element_text(angle = 90, hjust = 1),
|
||||
plot.title = element_text(size = 14, face = "bold")
|
||||
)
|
||||
|
||||
suffix <- gsub("^faults|\\.csv$", "", csv_suffix)
|
||||
outfile <- paste0("injections/fault_rates_per_instruction", suffix, ".svg")
|
||||
ggsave(outfile, plot = plot, width = 12, height = 6)
|
||||
print(paste("Saved", outfile))
|
||||
@@ -0,0 +1,133 @@
|
||||
library(ggplot2)
|
||||
library(dplyr)
|
||||
library(readr)
|
||||
|
||||
# Usage: Rscript combined_instr_fault_correlation.r exp_abspath1 exp_abspath2 ... [faults_file]
|
||||
|
||||
args <- commandArgs(trailingOnly = TRUE)
|
||||
if (length(args) < 1) {
|
||||
stop("Need at least 1 experiment")
|
||||
}
|
||||
|
||||
# TODO: I should probably stop duplicating this each time
|
||||
csv_suffix <- if (grepl("\\.csv$", args[length(args)])) {
|
||||
args[length(args)]
|
||||
} else {
|
||||
"faults.csv"
|
||||
}
|
||||
exp_args <- if (grepl("\\.csv$", args[length(args)])) {
|
||||
args[-length(args)]
|
||||
} else {
|
||||
args
|
||||
}
|
||||
|
||||
# Don't use counts from faults.csv, as that would correlate completely
|
||||
# because only mnemonics with faults are listed there
|
||||
# NOTE: Doesn't match selected filters for faults.csv
|
||||
mnemonics_file <- "mnemonics.csv"
|
||||
|
||||
freq_data <- data.frame()
|
||||
faults_data <- data.frame()
|
||||
|
||||
# TODO: I should probably stop duplicating this each time
|
||||
for (arg in exp_args) {
|
||||
mnem_path <- file.path(arg, mnemonics_file)
|
||||
faults_path <- file.path(arg, csv_suffix)
|
||||
|
||||
if (!file.exists(mnem_path)) {
|
||||
warning(paste("Missing:", mnem_path))
|
||||
next
|
||||
}
|
||||
if (!file.exists(faults_path)) {
|
||||
warning(paste("Missing:", faults_path))
|
||||
next
|
||||
}
|
||||
|
||||
mdf <- read_csv(mnem_path, col_types = cols())
|
||||
mdf$experiment <- basename(arg)
|
||||
freq_data <- bind_rows(freq_data, mdf)
|
||||
|
||||
fdf <- read_csv(faults_path, col_types = cols())
|
||||
fdf$experiment <- basename(arg)
|
||||
faults_data <- bind_rows(faults_data, fdf)
|
||||
}
|
||||
|
||||
if (nrow(freq_data) == 0 || nrow(faults_data) == 0) {
|
||||
stop("No data loaded")
|
||||
}
|
||||
|
||||
# x-axis: mnemonics.csv counts
|
||||
instr_freq <- freq_data |>
|
||||
filter(!is.na(mnemonic), mnemonic != "NULL") |>
|
||||
group_by(mnemonic) |>
|
||||
summarise(instr_count = sum(count, na.rm = TRUE), .groups = "drop")
|
||||
|
||||
# y-axis: no OK_MARKERs, sum GROUP1_MARKER + TRAP.
|
||||
marker_count <- faults_data |>
|
||||
filter(!is.na(mnemonic), mnemonic != "NULL") |>
|
||||
filter(resulttype != "OK_MARKER") |>
|
||||
mutate(
|
||||
resulttype = ifelse(resulttype == "GROUP1_MARKER", "TRAP", resulttype)
|
||||
) |>
|
||||
group_by(mnemonic) |>
|
||||
summarise(marker_count = sum(faults, na.rm = TRUE), .groups = "drop")
|
||||
|
||||
correlation <- instr_freq |>
|
||||
inner_join(marker_count, by = "mnemonic") |>
|
||||
filter(instr_count > 0, marker_count > 0)
|
||||
|
||||
if (nrow(correlation) < 2) {
|
||||
stop("Not enough mnemonics to compute a correlation")
|
||||
}
|
||||
|
||||
cor_raw <- cor(
|
||||
correlation$instr_count,
|
||||
correlation$marker_count,
|
||||
method = "pearson"
|
||||
)
|
||||
cor_log <- cor(
|
||||
log10(correlation$instr_count),
|
||||
log10(correlation$marker_count),
|
||||
method = "pearson"
|
||||
)
|
||||
cat(sprintf("Pearson correlation (raw): %.4f\n", cor_raw))
|
||||
cat(sprintf("Pearson correlation (log10): %.4f\n", cor_log))
|
||||
|
||||
plot <- ggplot(
|
||||
correlation,
|
||||
aes(x = instr_count, y = marker_count)
|
||||
) +
|
||||
geom_smooth(
|
||||
method = "lm",
|
||||
se = FALSE,
|
||||
colour = "grey50",
|
||||
linetype = "dashed"
|
||||
) +
|
||||
geom_point(aes(colour = mnemonic), size = 3, alpha = 0.8) +
|
||||
geom_text(
|
||||
aes(label = mnemonic),
|
||||
size = 3,
|
||||
vjust = -0.8,
|
||||
check_overlap = TRUE
|
||||
) +
|
||||
scale_x_log10(name = "Instruction Executions") +
|
||||
scale_y_log10(name = "Fault Count") +
|
||||
labs(
|
||||
# title = sprintf(
|
||||
# "Instruction / Fault Correlation (r_raw = %.4f, r_log = %.4f)",
|
||||
# cor_raw,
|
||||
# cor_log
|
||||
# ),
|
||||
title = "Instruction / Fault Correlation",
|
||||
colour = "Mnemonic"
|
||||
) +
|
||||
theme_minimal() +
|
||||
theme(
|
||||
legend.position = "none",
|
||||
plot.title = element_text(size = 14, face = "bold")
|
||||
)
|
||||
|
||||
suffix <- gsub("^faults|\\.csv$", "", csv_suffix)
|
||||
outfile <- paste0("injections/instr_fault_correlation", suffix, ".svg")
|
||||
ggsave(outfile, plot = plot, width = 10, height = 8)
|
||||
print(paste("Saved", outfile))
|
||||
@@ -0,0 +1,120 @@
|
||||
library(ggplot2)
|
||||
library(dplyr)
|
||||
library(readr)
|
||||
library(viridisLite)
|
||||
|
||||
# Usage: Rscript combined_instr_fault_correlation_heatmap.r exp_abspath1 ... [faults_file]
|
||||
|
||||
args <- commandArgs(trailingOnly = TRUE)
|
||||
if (length(args) < 1) {
|
||||
stop("Need at least 1 experiment")
|
||||
}
|
||||
|
||||
csv_suffix <- if (grepl("\\.csv$", args[length(args)])) {
|
||||
args[length(args)]
|
||||
} else {
|
||||
"faults.csv"
|
||||
}
|
||||
exp_args <- if (grepl("\\.csv$", args[length(args)])) {
|
||||
args[-length(args)]
|
||||
} else {
|
||||
args
|
||||
}
|
||||
|
||||
all_data <- data.frame()
|
||||
all_mnem <- data.frame()
|
||||
|
||||
for (arg in exp_args) {
|
||||
csv_file <- file.path(arg, csv_suffix)
|
||||
if (!file.exists(csv_file)) {
|
||||
warning(paste("Missing:", csv_file))
|
||||
next
|
||||
}
|
||||
|
||||
df <- read_csv(csv_file, col_types = cols())
|
||||
df$experiment <- basename(arg)
|
||||
all_data <- bind_rows(all_data, df)
|
||||
|
||||
# TODO: This is ignoring any filters currently
|
||||
mnem_file <- file.path(arg, "mnemonics.csv")
|
||||
if (!file.exists(mnem_file)) {
|
||||
warning(paste("Missing:", mnem_file))
|
||||
next
|
||||
}
|
||||
mdf <- read_csv(mnem_file, col_types = cols())
|
||||
all_mnem <- bind_rows(all_mnem, mdf)
|
||||
}
|
||||
|
||||
if (nrow(all_data) == 0) {
|
||||
stop("No faults.csv data loaded")
|
||||
}
|
||||
|
||||
if (nrow(all_mnem) == 0) {
|
||||
stop("No mnemonics.csv data loaded")
|
||||
}
|
||||
|
||||
# no OK_MARKER, sum GROUP1 + TRAP.
|
||||
all_data <- all_data |>
|
||||
filter(!is.na(mnemonic), mnemonic != "NULL") |>
|
||||
filter(resulttype != "OK_MARKER") |>
|
||||
mutate(
|
||||
resulttype = ifelse(resulttype == "GROUP1_MARKER", "TRAP", resulttype)
|
||||
)
|
||||
|
||||
if (nrow(all_data) == 0) {
|
||||
stop("No failure-marker data to plot")
|
||||
}
|
||||
|
||||
# Sum faults per (mnemonic, marker) pair for all experiments
|
||||
heat <- all_data |>
|
||||
group_by(mnemonic, resulttype) |>
|
||||
summarise(faults = sum(faults, na.rm = TRUE), .groups = "drop")
|
||||
|
||||
# Sum mnemonic counts for all experiments
|
||||
mnem_counts <- all_mnem |>
|
||||
filter(!is.na(mnemonic), mnemonic != "NULL") |>
|
||||
group_by(mnemonic) |>
|
||||
summarise(count = sum(count, na.rm = TRUE), .groups = "drop")
|
||||
|
||||
# Normalize by mnemonic count
|
||||
heat <- heat |>
|
||||
left_join(mnem_counts, by = "mnemonic") |>
|
||||
filter(!is.na(count), count > 0) |>
|
||||
mutate(fault_rate = faults / count)
|
||||
|
||||
if (nrow(heat) == 0) {
|
||||
stop("Heat join failed")
|
||||
}
|
||||
|
||||
# Order by fault rate
|
||||
mnem_order <- heat |>
|
||||
group_by(mnemonic) |>
|
||||
summarise(total = sum(fault_rate), .groups = "drop") |>
|
||||
arrange(desc(total)) |>
|
||||
pull(mnemonic)
|
||||
|
||||
heat <- heat |>
|
||||
mutate(mnemonic = factor(mnemonic, levels = mnem_order))
|
||||
|
||||
plot <- ggplot(
|
||||
heat,
|
||||
aes(x = mnemonic, y = resulttype, fill = fault_rate)
|
||||
) +
|
||||
geom_tile(colour = "white") +
|
||||
scale_fill_viridis_c(name = "Fault rate", trans = "log10") +
|
||||
labs(
|
||||
title = "Instruction / Fault Rate Heatmap (Normalized)",
|
||||
x = "Instruction",
|
||||
y = "Fault Type"
|
||||
) +
|
||||
theme_minimal() +
|
||||
theme(
|
||||
axis.text.x = element_text(angle = 90, hjust = 1),
|
||||
panel.grid = element_blank(),
|
||||
plot.title = element_text(size = 14, face = "bold")
|
||||
)
|
||||
|
||||
suffix <- gsub("^faults|\\.csv$", "", csv_suffix)
|
||||
outfile <- paste0("injections/instr_fault_rate_heatmap", suffix, ".svg")
|
||||
ggsave(outfile, plot = plot, width = 12, height = 6)
|
||||
print(paste("Saved", outfile))
|
||||
@@ -83,12 +83,18 @@ plot <- ggplot(
|
||||
) +
|
||||
geom_point(size = 2) +
|
||||
geom_line() +
|
||||
facet_wrap(~base_name, scales = "free_x") +
|
||||
facet_wrap(~base_name) +
|
||||
scale_y_log10(name = "Ratio (to C)") +
|
||||
scale_x_discrete(name = "Marker") +
|
||||
labs(color = "Variant") +
|
||||
scale_x_discrete(name = "Fault Type") +
|
||||
labs(
|
||||
title = "Fault Count Ratios",
|
||||
color = "Variant"
|
||||
) +
|
||||
theme_minimal() +
|
||||
theme(axis.text.x = element_text(angle = 45, hjust = 1))
|
||||
theme(
|
||||
axis.text.x = element_text(angle = 90, hjust = 1),
|
||||
plot.title = element_text(size = 14, face = "bold")
|
||||
)
|
||||
|
||||
ggsave("injections/ratio_comparison.svg", plot = plot, width = 12, height = 8)
|
||||
print("Saved ratio_comparison.svg")
|
||||
|
||||
@@ -3,8 +3,8 @@ library(dplyr)
|
||||
library(readr)
|
||||
library(stringr)
|
||||
|
||||
# Usage: Rscript ratio_comparison_merged.r exp_abspath1 exp_abspath2 ... [resultsdata_file]
|
||||
# Sums all benchmarks
|
||||
# Usage: Rscript ratio_comparison_merged_trap.r exp_abspath1 exp_abspath2 ... [resultsdata_file]
|
||||
# Sums all benchmarks, merges GROUP1_MARKER into TRAP
|
||||
|
||||
args <- commandArgs(trailingOnly = TRUE)
|
||||
if (length(args) < 2) {
|
||||
@@ -59,7 +59,9 @@ if (nrow(all_data) == 0) {
|
||||
stop("No data loaded")
|
||||
}
|
||||
|
||||
# Add all benchs together (per marker type)
|
||||
all_data <- all_data |>
|
||||
mutate(resulttype = ifelse(resulttype == "GROUP1_MARKER", "TRAP", resulttype))
|
||||
|
||||
merged_data <- all_data |>
|
||||
group_by(base_name, variant, resulttype) |>
|
||||
summarise(faults = sum(faults), .groups = "drop")
|
||||
@@ -88,15 +90,21 @@ plot <- ggplot(
|
||||
geom_line() +
|
||||
facet_wrap(~base_name) +
|
||||
scale_y_log10(name = "Ratio (to C)") +
|
||||
scale_x_discrete(name = "Marker") +
|
||||
labs(color = "Variant") +
|
||||
scale_x_discrete(name = "Fault Type") +
|
||||
labs(
|
||||
color = "Variant",
|
||||
title = "Fault Count Ratios"
|
||||
) +
|
||||
theme_minimal() +
|
||||
theme(axis.text.x = element_text(angle = 45, hjust = 1))
|
||||
theme(
|
||||
axis.text.x = element_text(angle = 90, hjust = 1),
|
||||
plot.title = element_text(size = 14, face = "bold")
|
||||
)
|
||||
|
||||
ggsave(
|
||||
"injections/ratio_comparison_merged.svg",
|
||||
"injections/ratio_comparison_merged_trap.svg",
|
||||
plot = plot,
|
||||
width = 12,
|
||||
height = 8
|
||||
)
|
||||
print("Saved ratio_comparison_merged.svg")
|
||||
print("Saved ratio_comparison_merged_trap.svg")
|
||||
|
||||
@@ -1,100 +0,0 @@
|
||||
library(ggplot2)
|
||||
library(dplyr)
|
||||
library(readr)
|
||||
library(stringr)
|
||||
|
||||
# Usage: Rscript ratio_comparison_merged_trap.r exp_abspath1 exp_abspath2 ... [resultsdata_file]
|
||||
# Sums all benchmarks, merges GROUP1_MARKER into TRAP
|
||||
|
||||
args <- commandArgs(trailingOnly = TRUE)
|
||||
if (length(args) < 2) {
|
||||
stop("Need at least 2 experiments")
|
||||
}
|
||||
|
||||
csv_suffix <- if (grepl("\\.csv$", args[length(args)])) {
|
||||
args[length(args)]
|
||||
} else {
|
||||
"resultsdata.csv"
|
||||
}
|
||||
exp_args <- if (grepl("\\.csv$", args[length(args)])) args[-length(args)] else args
|
||||
|
||||
extract_info <- function(path) {
|
||||
dir_name <- basename(path)
|
||||
match <- str_match(
|
||||
dir_name,
|
||||
"^\\d{2}-\\d{2}_\\d{2}-\\d{2}-\\d{2}_(.+?)_(c|aot|interp)_"
|
||||
)
|
||||
if (is.na(match[1, 1])) {
|
||||
warning(paste("Could not parse:", dir_name))
|
||||
return(NULL)
|
||||
}
|
||||
list(base_name = match[1, 2], variant = match[1, 3], path = path)
|
||||
}
|
||||
|
||||
all_data <- data.frame()
|
||||
|
||||
for (arg in exp_args) {
|
||||
info <- extract_info(arg)
|
||||
if (is.null(info)) {
|
||||
next
|
||||
}
|
||||
|
||||
csv_file <- file.path(info$path, csv_suffix)
|
||||
if (!file.exists(csv_file)) {
|
||||
warning(paste("Missing:", csv_file))
|
||||
next
|
||||
}
|
||||
|
||||
df <- read_csv(csv_file, col_types = cols())
|
||||
df$base_name <- info$base_name
|
||||
df$variant <- info$variant
|
||||
all_data <- bind_rows(all_data, df)
|
||||
}
|
||||
|
||||
if (nrow(all_data) == 0) {
|
||||
stop("No data loaded")
|
||||
}
|
||||
|
||||
all_data <- all_data |>
|
||||
mutate(resulttype = ifelse(resulttype == "GROUP1_MARKER", "TRAP", resulttype))
|
||||
|
||||
merged_data <- all_data |>
|
||||
group_by(base_name, variant, resulttype) |>
|
||||
summarise(faults = sum(faults), .groups = "drop")
|
||||
|
||||
baseline <- merged_data |> filter(variant == "c")
|
||||
comparisons <- merged_data |> filter(variant != "c")
|
||||
|
||||
ratios <- comparisons |>
|
||||
left_join(
|
||||
baseline |> select(base_name, resulttype, faults),
|
||||
by = c("base_name", "resulttype"),
|
||||
suffix = c("", "_baseline")
|
||||
) |>
|
||||
filter(!is.na(faults_baseline), faults_baseline > 0) |>
|
||||
mutate(ratio = faults / faults_baseline)
|
||||
|
||||
if (nrow(ratios) == 0) {
|
||||
stop("No ratios computed (missing baseline or zero values)")
|
||||
}
|
||||
|
||||
plot <- ggplot(
|
||||
ratios,
|
||||
aes(x = resulttype, y = ratio, color = variant, group = variant)
|
||||
) +
|
||||
geom_point(size = 2) +
|
||||
geom_line() +
|
||||
facet_wrap(~base_name) +
|
||||
scale_y_log10(name = "Ratio (to C)") +
|
||||
scale_x_discrete(name = "Marker") +
|
||||
labs(color = "Variant") +
|
||||
theme_minimal() +
|
||||
theme(axis.text.x = element_text(angle = 45, hjust = 1))
|
||||
|
||||
ggsave(
|
||||
"injections/ratio_comparison_merged_trap.svg",
|
||||
plot = plot,
|
||||
width = 12,
|
||||
height = 8
|
||||
)
|
||||
print("Saved ratio_comparison_merged_trap.svg")
|
||||
@@ -1,129 +0,0 @@
|
||||
library(ggplot2)
|
||||
library(dplyr)
|
||||
library(readr)
|
||||
library(stringr)
|
||||
library(tidyr)
|
||||
|
||||
# Usage: Rscript ratio_correlation_no_mem.r exp_abspath1 exp_abspath2 ... [resultsdata_file]
|
||||
# Plots correlation between aot/c and interp/c ratios, ignoring mem benchmark
|
||||
# NOTE: Just a copy of the ratio_correlation.r script where I've changed the filter in line 67
|
||||
|
||||
args <- commandArgs(trailingOnly = TRUE)
|
||||
if (length(args) < 2) {
|
||||
stop("Need at least 2 experiments")
|
||||
}
|
||||
|
||||
csv_suffix <- if (grepl("\\.csv$", args[length(args)])) {
|
||||
args[length(args)]
|
||||
} else {
|
||||
"resultsdata.csv"
|
||||
}
|
||||
exp_args <- if (grepl("\\.csv$", args[length(args)])) {
|
||||
args[-length(args)]
|
||||
} else {
|
||||
args
|
||||
}
|
||||
|
||||
extract_info <- function(path) {
|
||||
dir_name <- basename(path)
|
||||
match <- str_match(
|
||||
dir_name,
|
||||
"^\\d{2}-\\d{2}_\\d{2}-\\d{2}-\\d{2}_(.+?)_(c|aot|interp)_"
|
||||
)
|
||||
if (is.na(match[1, 1])) {
|
||||
warning(paste("Could not parse:", dir_name))
|
||||
return(NULL)
|
||||
}
|
||||
list(base_name = match[1, 2], variant = match[1, 3], path = path)
|
||||
}
|
||||
|
||||
all_data <- data.frame()
|
||||
|
||||
for (arg in exp_args) {
|
||||
info <- extract_info(arg)
|
||||
if (is.null(info)) {
|
||||
next
|
||||
}
|
||||
|
||||
csv_file <- file.path(info$path, csv_suffix)
|
||||
if (!file.exists(csv_file)) {
|
||||
warning(paste("Missing:", csv_file))
|
||||
next
|
||||
}
|
||||
|
||||
df <- read_csv(csv_file, col_types = cols())
|
||||
df$base_name <- info$base_name
|
||||
df$variant <- info$variant
|
||||
all_data <- bind_rows(all_data, df)
|
||||
}
|
||||
|
||||
if (nrow(all_data) == 0) {
|
||||
stop("No data loaded")
|
||||
}
|
||||
|
||||
# Ignore OK_MARKER (only plot failures) and sum GROUP1_MARKER with TRAP
|
||||
# Also ignore mem benchmark
|
||||
all_data <- all_data |>
|
||||
filter(resulttype %in% c("TRAP", "GROUP1_MARKER"), benchmark == "ip") |>
|
||||
mutate(resulttype = ifelse(resulttype == "GROUP1_MARKER", "TRAP", resulttype))
|
||||
|
||||
all_data <- all_data |>
|
||||
group_by(base_name, variant, benchmark, resulttype) |>
|
||||
summarise(faults = sum(faults), .groups = "drop")
|
||||
|
||||
baseline <- all_data |> filter(variant == "c")
|
||||
comparisons <- all_data |> filter(variant != "c")
|
||||
|
||||
ratios <- comparisons |>
|
||||
left_join(
|
||||
baseline |> select(base_name, benchmark, resulttype, faults),
|
||||
by = c("base_name", "benchmark", "resulttype"),
|
||||
suffix = c("", "_baseline")
|
||||
) |>
|
||||
filter(!is.na(faults_baseline), faults_baseline > 0) |>
|
||||
mutate(ratio = faults / faults_baseline)
|
||||
|
||||
if (nrow(ratios) == 0) {
|
||||
stop("No ratios computed (missing baseline or zero values)")
|
||||
}
|
||||
|
||||
# Pivot to get aot and interp ratios side by side
|
||||
ratio_wide <- ratios |>
|
||||
select(base_name, benchmark, resulttype, variant, ratio) |>
|
||||
pivot_wider(names_from = variant, values_from = ratio) |>
|
||||
filter(!is.na(aot), !is.na(interp))
|
||||
|
||||
if (nrow(ratio_wide) == 0) {
|
||||
stop("No paired aot/interp ratios found")
|
||||
}
|
||||
|
||||
# Compute correlation
|
||||
cor_result <- cor(ratio_wide$aot, ratio_wide$interp, method = "pearson")
|
||||
cat(sprintf("Pearson correlation: %.4f\n", cor_result))
|
||||
|
||||
# Create plot
|
||||
plot <- ggplot(
|
||||
ratio_wide,
|
||||
aes(x = aot, y = interp, color = base_name, shape = resulttype)
|
||||
) +
|
||||
geom_point(size = 3, alpha = 0.7) +
|
||||
scale_x_log10(name = "AOT / C Ratio") +
|
||||
scale_y_log10(name = "Interpreter / C Ratio") +
|
||||
labs(
|
||||
title = sprintf("Ratio Correlation (r = %.4f)", cor_result),
|
||||
color = "Experiment",
|
||||
shape = "Marker"
|
||||
) +
|
||||
theme_minimal() +
|
||||
theme(
|
||||
legend.position = "right",
|
||||
plot.title = element_text(size = 14, face = "bold")
|
||||
)
|
||||
|
||||
ggsave(
|
||||
"injections/ratio_correlation_customized.svg",
|
||||
plot = plot,
|
||||
width = 10,
|
||||
height = 8
|
||||
)
|
||||
print("Saved ratio_correlation_customized.svg")
|
||||
+6
-3
@@ -631,10 +631,13 @@ my %handlers = (
|
||||
|
||||
# Need to know which chart uses which datafile
|
||||
my @faults_charts =
|
||||
grep { /heatmap|scatter|sankey|instr_fault_correlation/ }
|
||||
@selected_charts;
|
||||
grep {
|
||||
/_heatmap|_scatter|_sankey|_instr_fault_correlation|_instr_fault_rate_heatmap|fault_rates_per_instruction/
|
||||
} @selected_charts;
|
||||
my @resultsdata_charts =
|
||||
grep { /result|combined_comparison|combined_ratio/ } @selected_charts;
|
||||
grep {
|
||||
/_result|_fault_count_comparison|_ratio_comparison|_fault_count_correlation/
|
||||
} @selected_charts;
|
||||
|
||||
# Select if faults.csv or a filtered variant should be used
|
||||
my $faults_csv;
|
||||
|
||||
+1
-1
@@ -39,7 +39,7 @@
|
||||
#endif
|
||||
|
||||
#ifdef TARGET_LINUX
|
||||
#include "stdio.h"
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#define MAIN int main(int argc, char *argv[])
|
||||
#define PRINT(fmt, ...) fprintf(stdout, fmt, ##__VA_ARGS__)
|
||||
|
||||
Reference in New Issue
Block a user