Compare commits

...

7 Commits

13 changed files with 392 additions and 151 deletions

View File

@ -1,4 +1,4 @@
package Modules::Filters; package Filters;
use strict; use strict;
use warnings; use warnings;
@ -9,30 +9,93 @@ use lib $FindBin::Bin;
use Util; use Util;
my %CONFIGS = ( my %CONFIGS = (
no_aot => { no_aot_instr => {
label => "Exclude WAMR AOT array", label => "Exclude WAMR AOT array (instr)",
regions => [ [ '_wamr_aot_start', '_wamr_aot_end' ] ], regions => [
[
'_wamr_aot_start', '_wamr_aot_end',
'p.injection_instr_absolute'
]
],
}, },
no_mmap => { no_aot_data => {
label => "Exclude WAMR mmap", label => "Exclude WAMR AOT array (data)",
regions => [ [ '_wamr_mmap_start', '_wamr_mmap_end' ] ], regions =>
[ [ '_wamr_aot_start', '_wamr_aot_end', 'g.data_physical_address' ] ],
}, },
no_runtime_pool => { no_mmap_instr => {
label => "Exclude WAMR runtime pool", label => "Exclude WAMR mmap (instr)",
regions => [ [ '_wamr_runtime_pool_start', '_wamr_runtime_pool_end' ] ], regions => [
[
'_wamr_mmap_start', '_wamr_mmap_end',
'p.injection_instr_absolute'
]
],
}, },
no_linear_pool => { no_mmap_data => {
label => "Exclude WAMR linear pool", label => "Exclude WAMR mmap (data)",
regions => [ [ '_wamr_linear_pool_start', '_wamr_linear_pool_end' ] ], regions => [
[ '_wamr_mmap_start', '_wamr_mmap_end', 'g.data_physical_address' ]
],
}, },
no_global_heap => { no_runtime_pool_instr => {
label => "Exclude WAMR global heap", label => "Exclude WAMR runtime pool (instr)",
regions => [ [ '_wamr_global_heap_start', '_wamr_global_heap_end' ] ], regions => [
[
'_wamr_runtime_pool_start', '_wamr_runtime_pool_end',
'p.injection_instr_absolute'
]
],
},
no_runtime_pool_data => {
label => "Exclude WAMR runtime pool (data)",
regions => [
[
'_wamr_runtime_pool_start', '_wamr_runtime_pool_end',
'g.data_physical_address'
]
],
},
no_linear_pool_instr => {
label => "Exclude WAMR linear pool (instr)",
regions => [
[
'_wamr_linear_pool_start', '_wamr_linear_pool_end',
'p.injection_instr_absolute'
]
],
},
no_linear_pool_data => {
label => "Exclude WAMR linear pool (data)",
regions => [
[
'_wamr_linear_pool_start', '_wamr_linear_pool_end',
'g.data_physical_address'
]
],
},
no_global_heap_instr => {
label => "Exclude WAMR global heap (instr)",
regions => [
[
'_wamr_global_heap_start', '_wamr_global_heap_end',
'p.injection_instr_absolute'
]
],
},
no_global_heap_data => {
label => "Exclude WAMR global heap (data)",
regions => [
[
'_wamr_global_heap_start', '_wamr_global_heap_end',
'g.data_physical_address'
]
],
}, },
); );
# Those will be executed automatically by runner.pl (+ no filter at all) # Those will be executed automatically by runner.pl (+ no filter at all)
my @DEFAULT_CONFIGS = ('no_aot'); my @DEFAULT_CONFIGS = ('no_aot_data');
sub get_configs { sub get_configs {
return \%CONFIGS; return \%CONFIGS;
@ -55,13 +118,12 @@ sub build_filter_clause {
my @filters; my @filters;
for my $pair (@$regions) { for my $pair (@$regions) {
my ( $start_sym, $end_sym ) = @$pair; my ( $start_sym, $end_sym, $col ) = @$pair;
my $start = my $start =
Util::elf_sym_addr( "$experiment_dir/system.elf", $start_sym ); Util::elf_sym_addr( "$experiment_dir/system.elf", $start_sym );
my $end = Util::elf_sym_addr( "$experiment_dir/system.elf", $end_sym ); my $end = Util::elf_sym_addr( "$experiment_dir/system.elf", $end_sym );
next unless defined $start && defined $end && $end > $start; next unless defined $start && defined $end && $end > $start;
push @filters, push @filters, "$col NOT BETWEEN $start AND @{[$end - 1]}";
"p.injection_instr_absolute NOT BETWEEN $start AND @{[$end - 1]}";
} }
return "" unless @filters; return "" unless @filters;

View File

@ -5,6 +5,13 @@ use warnings;
use diagnostics; use diagnostics;
use DateTime; use DateTime;
use FindBin;
# Include this for running from runner.pl
use lib "$FindBin::Bin/../../scripts/Queries";
# Include this for running from menu.pl
use lib "$FindBin::Bin/Queries";
use feature 'say'; use feature 'say';
@ -130,7 +137,7 @@ sub execute_query {
$filter_config_name ) $filter_config_name )
= @_; = @_;
my $module = "Queries::$queryname"; my $module = "$queryname";
my $file = "$module.pm"; my $file = "$module.pm";
$file =~ s/::/\//g; $file =~ s/::/\//g;
@ -138,7 +145,7 @@ sub execute_query {
my $query = $module->can('query') or die "$module can't query()"; my $query = $module->can('query') or die "$module can't query()";
my $args = $module->can('args') or die "$module can't args()"; my $args = $module->can('args') or die "$module can't args()";
my $filename = $module->can('filename') or die "$module can't filanem()"; my $filename = $module->can('filename') or die "$module can't filename()";
my $postprocess = $module->can('postprocess') my $postprocess = $module->can('postprocess')
or die "$module can't postprocess()"; or die "$module can't postprocess()";
@ -175,7 +182,7 @@ sub format_number_sep {
} }
sub elf_sym_addr { sub elf_sym_addr {
my ($elffile, $sym) = @_; my ( $elffile, $sym ) = @_;
my $line = qx{nm "$elffile" 2>/dev/null | grep " $sym\$"}; my $line = qx{nm "$elffile" 2>/dev/null | grep " $sym\$"};
return undef unless $line =~ /^([0-9a-f]+)/i; return undef unless $line =~ /^([0-9a-f]+)/i;
return hex($1); return hex($1);
@ -274,6 +281,27 @@ sub delete_marker_info {
"$local_archive_dir/$experiment/markers/$benchmark-$address.info" ); "$local_archive_dir/$experiment/markers/$benchmark-$address.info" );
} }
sub pick_data_file {
my ( $dir, $prefix ) = @_;
# \Q...\E treats ... as literal string
my @files = sort grep { /^\Q$prefix\E.*\.csv$/ } find_files($dir);
return "$prefix.csv" unless @files > 1;
# Make sure the unfiltered file is at the top
my @sorted = sort {
( $a eq "$prefix.csv" ) ? -1
: ( $b eq "$prefix.csv" ) ? 1
: $a cmp $b
} @files;
my @selected =
TUI::select_from_list( "Select $prefix CSV file", 0, @sorted );
die "No $prefix CSV file selected" unless @selected;
return $selected[0];
}
sub select_experiment { sub select_experiment {
my ($multi) = @_; my ($multi) = @_;

View File

@ -1,13 +1,12 @@
package Queries::Faults; package Faults;
use strict; use strict;
use warnings; use warnings;
use diagnostics; use diagnostics;
use FindBin; use FindBin;
use lib "$FindBin::Bin/..";
use lib "$FindBin::Bin/../Modules"; use lib "$FindBin::Bin/../Modules";
use Modules::Filters; use Filters;
use feature 'say'; use feature 'say';
@ -15,8 +14,8 @@ sub query {
my ( $experiment, $experiment_dir, $filter_config_name ) = @_; my ( $experiment, $experiment_dir, $filter_config_name ) = @_;
$filter_config_name //= ''; $filter_config_name //= '';
my $filters = Modules::Filters::build_filter_clause( $experiment_dir, my $filters =
$filter_config_name ); Filters::build_filter_clause( $experiment_dir, $filter_config_name );
my $querystring = "SELECT my $querystring = "SELECT
benchmark, resulttype, SUM(t.time2 - t.time1 + 1) AS faults, benchmark, resulttype, SUM(t.time2 - t.time1 + 1) AS faults,

View File

@ -1,13 +1,12 @@
package Queries::Results; package Results;
use strict; use strict;
use warnings; use warnings;
use diagnostics; use diagnostics;
use FindBin; use FindBin;
use lib "$FindBin::Bin/..";
use lib "$FindBin::Bin/../Modules"; use lib "$FindBin::Bin/../Modules";
use Modules::Filters; use Filters;
use feature 'say'; use feature 'say';
@ -15,8 +14,8 @@ sub query {
my ( $experiment, $experiment_dir, $filter_config_name ) = @_; my ( $experiment, $experiment_dir, $filter_config_name ) = @_;
$filter_config_name //= ''; $filter_config_name //= '';
my $extra = Modules::Filters::build_filter_clause( $experiment_dir, my $extra =
$filter_config_name ); Filters::build_filter_clause( $experiment_dir, $filter_config_name );
my $querystring = "SELECT my $querystring = "SELECT
benchmark, resulttype, sum(t.time2 - t.time1 + 1) AS faults benchmark, resulttype, sum(t.time2 - t.time1 + 1) AS faults
@ -39,7 +38,7 @@ sub args { return "-t"; }
sub filename { sub filename {
my ($filter_config_name) = @_; my ($filter_config_name) = @_;
$filter_config_name //= ''; $filter_config_name //= '';
my $suffix = length($filter_config_name) ? "_filtered_$filter_config_name" : ""; my $suffix = length($filter_config_name) ? "_$filter_config_name" : "";
return "results${suffix}.txt"; return "results${suffix}.txt";
} }

View File

@ -1,13 +1,12 @@
package Queries::ResultsData; package ResultsData;
use strict; use strict;
use warnings; use warnings;
use diagnostics; use diagnostics;
use FindBin; use FindBin;
use lib "$FindBin::Bin/..";
use lib "$FindBin::Bin/../Modules"; use lib "$FindBin::Bin/../Modules";
use Modules::Filters; use Filters;
use feature 'say'; use feature 'say';
@ -15,8 +14,8 @@ sub query {
my ( $experiment, $experiment_dir, $filter_config_name ) = @_; my ( $experiment, $experiment_dir, $filter_config_name ) = @_;
$filter_config_name //= ''; $filter_config_name //= '';
my $extra = Modules::Filters::build_filter_clause( $experiment_dir, my $extra =
$filter_config_name ); Filters::build_filter_clause( $experiment_dir, $filter_config_name );
my $querystring = "SELECT my $querystring = "SELECT
benchmark, resulttype, sum(t.time2 - t.time1 + 1) AS faults benchmark, resulttype, sum(t.time2 - t.time1 + 1) AS faults
@ -39,7 +38,7 @@ sub args { return "--batch --raw"; }
sub filename { sub filename {
my ($filter_config_name) = @_; my ($filter_config_name) = @_;
$filter_config_name //= ''; $filter_config_name //= '';
my $suffix = length($filter_config_name) ? "_filtered_$filter_config_name" : ""; my $suffix = length($filter_config_name) ? "_$filter_config_name" : "";
return "resultsdata${suffix}.csv"; return "resultsdata${suffix}.csv";
} }

View File

@ -6,13 +6,16 @@ library(ggalluvial)
args <- commandArgs(trailingOnly = TRUE) args <- commandArgs(trailingOnly = TRUE)
argc <- length(args) argc <- length(args)
if (argc != 2) { if (argc < 2 || argc > 3) {
print("Expecting two input files") print("Expecting two or three arguments: exp1 exp2 [faults_file]")
stop() stop()
} }
for (experiment in args) { faults_file <- if (argc == 3) args[3] else "faults.csv"
datafile <- paste(experiment, "/faults.csv", sep = "") suffix <- gsub("^faults|\\.csv$", "", faults_file)
for (experiment in args[1:2]) {
datafile <- file.path(experiment, faults_file)
if (!file.exists(datafile)) { if (!file.exists(datafile)) {
print(paste("Input file", datafile, "is missing")) print(paste("Input file", datafile, "is missing"))
stop() stop()
@ -30,13 +33,13 @@ resulttype_labels <- c(
) )
# Read data # Read data
datafile1 <- paste(args[1], "/faults.csv", sep = "") datafile1 <- file.path(args[1], faults_file)
data1 <- readr::read_csv(datafile1) data1 <- readr::read_csv(datafile1)
data1$fault_address <- strtoi(data1$fault_address) data1$fault_address <- strtoi(data1$fault_address)
data1$resulttype <- resulttype_labels[data1$resulttype] data1$resulttype <- resulttype_labels[data1$resulttype]
# tibble::glimpse(data1) # tibble::glimpse(data1)
datafile2 <- paste(args[2], "/faults.csv", sep = "") datafile2 <- file.path(args[2], faults_file)
data2 <- readr::read_csv(datafile2) data2 <- readr::read_csv(datafile2)
data2$fault_address <- strtoi(data2$fault_address) data2$fault_address <- strtoi(data2$fault_address)
data2$resulttype <- resulttype_labels[data2$resulttype] data2$resulttype <- resulttype_labels[data2$resulttype]
@ -75,6 +78,6 @@ plot <- ggplot(
# TODO: Name the file according to the benchmarks # TODO: Name the file according to the benchmarks
ggsave( ggsave(
paste(args[2], "/../sankey.svg", sep = ""), paste0(args[2], "/../sankey", suffix, ".svg"),
plot = plot, plot = plot,
) )

View File

@ -29,27 +29,84 @@ max_tile <- 0.5
# Generate all heatmaps with crossproduct of this # Generate all heatmaps with crossproduct of this
benchmarks <- c("ip", "mem", "regs") benchmarks <- c("ip", "mem", "regs")
markers <- c( markers <- c(
"OK_MARKER", "FAIL_MARKER", "DETECTED_MARKER", "OK_MARKER",
"ACCESS_OUTERSPACE", "WRITE_TEXTSEGMENT", "FAIL_MARKER",
"GROUP1_MARKER", "TRAP", "TIMEOUT" "DETECTED_MARKER",
"ACCESS_OUTERSPACE",
"WRITE_TEXTSEGMENT",
"GROUP1_MARKER",
"TRAP",
"TIMEOUT"
) )
# Labels for _start/_end symbols from linker.ld # Labels for _start/_end symbols from linker.ld
regions <- list( regions <- list(
list(label = "WAMR AOT", start = "_wamr_aot_start", end = "_wamr_aot_end"), list(label = "WAMR AOT", start = "_wamr_aot_start", end = "_wamr_aot_end"),
list(label = "WAMR os_mmap", start = "_wamr_mmap_start", end = "_wamr_mmap_end"), list(
list(label = "WAMR runtime mem", start = "_wamr_runtime_pool_start", end = "_wamr_runtime_pool_end"), label = "WAMR os_mmap",
list(label = "WAMR linear mem", start = "_wamr_linear_pool_start", end = "_wamr_linear_pool_end"), start = "_wamr_mmap_start",
list(label = "WAMR global heap", start = "_wamr_global_heap_start", end = "_wamr_global_heap_end"), end = "_wamr_mmap_end"
list(label = "IWASM AOT runtime", start = "_iwasm_aot_runtime_start", end = "_iwasm_aot_runtime_end"), ),
list(label = "IWASM bh/util", start = "_iwasm_bh_start", end = "_iwasm_bh_end"), list(
list(label = "IWASM mem_alloc", start = "_iwasm_mem_alloc_start", end = "_iwasm_mem_alloc_end"), label = "WAMR runtime mem",
list(label = "IWASM platform", start = "_iwasm_platform_init_start", end = "_iwasm_platform_init_end"), start = "_wamr_runtime_pool_start",
list(label = "IWASM exec_env", start = "_iwasm_exec_env_start", end = "_iwasm_exec_env_end"), end = "_wamr_runtime_pool_end"
list(label = "IWASM interp", start = "_iwasm_interp_classic_start", end = "_iwasm_interp_classic_end"), ),
list(label = "IWASM memory", start = "_iwasm_memory_start", end = "_iwasm_memory_end"), list(
list(label = "IWASM native", start = "_iwasm_native_start", end = "_iwasm_native_end"), label = "WAMR linear mem",
list(label = "IWASM runtime", start = "_iwasm_runtime_start", end = "_iwasm_runtime_end"), start = "_wamr_linear_pool_start",
end = "_wamr_linear_pool_end"
),
list(
label = "WAMR global heap",
start = "_wamr_global_heap_start",
end = "_wamr_global_heap_end"
),
list(
label = "IWASM AOT runtime",
start = "_iwasm_aot_runtime_start",
end = "_iwasm_aot_runtime_end"
),
list(
label = "IWASM bh/util",
start = "_iwasm_bh_start",
end = "_iwasm_bh_end"
),
list(
label = "IWASM mem_alloc",
start = "_iwasm_mem_alloc_start",
end = "_iwasm_mem_alloc_end"
),
list(
label = "IWASM platform",
start = "_iwasm_platform_init_start",
end = "_iwasm_platform_init_end"
),
list(
label = "IWASM exec_env",
start = "_iwasm_exec_env_start",
end = "_iwasm_exec_env_end"
),
list(
label = "IWASM interp",
start = "_iwasm_interp_classic_start",
end = "_iwasm_interp_classic_end"
),
list(
label = "IWASM memory",
start = "_iwasm_memory_start",
end = "_iwasm_memory_end"
),
list(
label = "IWASM native",
start = "_iwasm_native_start",
end = "_iwasm_native_end"
),
list(
label = "IWASM runtime",
start = "_iwasm_runtime_start",
end = "_iwasm_runtime_end"
),
list(label = "TEXT", start = "_text_start", end = "_text_end"), list(label = "TEXT", start = "_text_start", end = "_text_end"),
list(label = "BSS", start = "_sbss", end = "_ebss") list(label = "BSS", start = "_sbss", end = "_ebss")
) )
@ -75,22 +132,27 @@ if (length(args) < 1) {
} }
experiment <- args[1] experiment <- args[1]
faults_file <- if (length(args) >= 2) args[2] else "faults.csv"
suffix <- gsub("^faults|\\.csv$", "", faults_file)
# ============================================================================= # =============================================================================
# INPUT DATA (read once) # INPUT DATA (read once)
# ============================================================================= # =============================================================================
datafile <- file.path(experiment, "faults.csv") datafile <- file.path(experiment, faults_file)
if (!file.exists(datafile)) { if (!file.exists(datafile)) {
stop(paste("Input file not found:", datafile)) stop(paste("Input file not found:", datafile))
} }
raw <- read_csv(datafile, col_types = cols( raw <- read_csv(
datafile,
col_types = cols(
benchmark = col_character(), benchmark = col_character(),
resulttype = col_character(), resulttype = col_character(),
faults = col_double(), faults = col_double(),
fault_address = col_character() # hex string "0x10001A"; converted below fault_address = col_character() # hex string "0x10001A"; converted below
)) )
)
# ============================================================================= # =============================================================================
# ELF SYMBOLS (parsed once) # ELF SYMBOLS (parsed once)
@ -155,10 +217,12 @@ make_heatmap <- function(target_resulttype, target_benchmark) {
# "0x10001A" -> substr strips "0x" -> strtoi parses base-16 -> integer # "0x10001A" -> substr strips "0x" -> strtoi parses base-16 -> integer
aggregated <- aggregated |> aggregated <- aggregated |>
mutate(addr_int = strtoi( mutate(
addr_int = strtoi(
substr(.data$fault_address, 3L, nchar(.data$fault_address)), substr(.data$fault_address, 3L, nchar(.data$fault_address)),
16L 16L
)) )
)
# =========================================================================== # ===========================================================================
# SCALE ROWS # SCALE ROWS
@ -168,17 +232,24 @@ make_heatmap <- function(target_resulttype, target_benchmark) {
row_width <- row_width_init row_width <- row_width_init
# Double row_width until occupied rows <= max_rows # Double row_width until occupied rows <= max_rows
while (row_width < 65536L && n_occupied_rows( while (
aggregated$addr_int, row_width row_width < 65536L &&
) > max_rows) { n_occupied_rows(
aggregated$addr_int,
row_width
) >
max_rows
) {
row_width <- row_width * 2L row_width <- row_width * 2L
} }
if (row_width > row_width_init) { if (row_width > row_width_init) {
message(sprintf( message(sprintf(
"Note: [%s/%s] row_width auto-scaled to %d (%d occupied rows)", "Note: [%s/%s] row_width auto-scaled to %d (%d occupied rows)",
target_resulttype, target_benchmark, target_resulttype,
row_width, n_occupied_rows(aggregated$addr_int, row_width) target_benchmark,
row_width,
n_occupied_rows(aggregated$addr_int, row_width)
)) ))
} }
@ -256,7 +327,8 @@ make_heatmap <- function(target_resulttype, target_benchmark) {
# Row with base address r covers bytes r ... r + row_width - 1. # Row with base address r covers bytes r ... r + row_width - 1.
# Overlap if r < e && r + row_width > s # Overlap if r < e && r + row_width > s
overlapping <- row_order[ overlapping <- row_order[
row_order$row < e & (row_order$row + row_width) > s, , row_order$row < e & (row_order$row + row_width) > s,
,
drop = FALSE drop = FALSE
] ]
@ -310,9 +382,14 @@ make_heatmap <- function(target_resulttype, target_benchmark) {
# PLOT # PLOT
# =========================================================================== # ===========================================================================
plot <- ggplot(grid_complete, aes( plot <- ggplot(
x = col, y = .data$row_idx, fill = .data$faults grid_complete,
)) + aes(
x = col,
y = .data$row_idx,
fill = .data$faults
)
) +
# One rectangle per (col, row_idx) tuple # One rectangle per (col, row_idx) tuple
geom_tile(width = 1, height = 1, colour = NA) + geom_tile(width = 1, height = 1, colour = NA) +
@ -355,10 +432,13 @@ make_heatmap <- function(target_resulttype, target_benchmark) {
# Title + axis labels # Title + axis labels
labs( labs(
title = paste(target_resulttype, "/", target_benchmark), title = paste(target_resulttype, "/", target_benchmark),
subtitle = paste("Total:", format( subtitle = paste(
"Total:",
format(
sum(aggregated$faults, na.rm = TRUE), sum(aggregated$faults, na.rm = TRUE),
big.mark = "," big.mark = ","
)), )
),
x = "Byte Offset", x = "Byte Offset",
y = "Base Address" y = "Base Address"
) + ) +
@ -367,7 +447,10 @@ make_heatmap <- function(target_resulttype, target_benchmark) {
theme_minimal() + theme_minimal() +
theme( theme(
axis.text.x = element_text( axis.text.x = element_text(
family = "mono", angle = 45, hjust = 1, size = 9 family = "mono",
angle = 45,
hjust = 1,
size = 9
), ),
axis.text.y = element_text(family = "mono", size = 9), axis.text.y = element_text(family = "mono", size = 9),
panel.grid = element_blank(), panel.grid = element_blank(),
@ -399,9 +482,17 @@ make_heatmap <- function(target_resulttype, target_benchmark) {
fig_w <- row_width * tile_size + 4.5 fig_w <- row_width * tile_size + 4.5
fig_h <- total_slots * tile_size + 2.5 fig_h <- total_slots * tile_size + 2.5
outfile <- file.path(experiment, paste0( outfile <- file.path(
"heatmap_", target_resulttype, "_", target_benchmark, ".svg" experiment,
)) paste0(
"heatmap_",
target_resulttype,
"_",
target_benchmark,
suffix,
".svg"
)
)
ggsave(outfile, plot = plot, width = fig_w, height = fig_h, units = "in") ggsave(outfile, plot = plot, width = fig_w, height = fig_h, units = "in")
message(sprintf("Saved: %s", basename(outfile))) message(sprintf("Saved: %s", basename(outfile)))

View File

@ -1,10 +1,12 @@
library(ggplot2) library(ggplot2)
# Usage: Rscript single_result.r exp_abspath # Usage: Rscript single_result.r exp_abspath [resultsdata_file]
args <- commandArgs(trailingOnly = TRUE) args <- commandArgs(trailingOnly = TRUE)
experiment <- args[1] experiment <- args[1]
datafile <- paste(experiment, "/resultsdata.csv", sep = "") resultsdata_file <- if (length(args) >= 2) args[2] else "resultsdata.csv"
suffix <- gsub("^resultsdata|\\.csv$", "", resultsdata_file)
datafile <- file.path(experiment, resultsdata_file)
if (!file.exists(datafile)) { if (!file.exists(datafile)) {
print(paste("Input file", datafile, "is missing")) print(paste("Input file", datafile, "is missing"))
@ -21,6 +23,6 @@ plot <- ggplot(data, aes(x = benchmark, y = faults, fill = resulttype)) +
theme_minimal() theme_minimal()
ggsave( ggsave(
paste(experiment, "/single_result.svg", sep = ""), paste0(experiment, "/single_result", suffix, ".svg"),
plot = plot, plot = plot,
) )

View File

@ -6,7 +6,9 @@ library(ggplot2)
args <- commandArgs(trailingOnly = TRUE) args <- commandArgs(trailingOnly = TRUE)
experiment <- args[1] experiment <- args[1]
datafile <- paste(experiment, "/faults.csv", sep = "") faults_file <- if (length(args) >= 2) args[2] else "faults.csv"
suffix <- gsub("^faults|\\.csv$", "", faults_file)
datafile <- file.path(experiment, faults_file)
if (!file.exists(datafile)) { if (!file.exists(datafile)) {
print(paste("Input file", datafile, "is missing")) print(paste("Input file", datafile, "is missing"))
@ -27,6 +29,6 @@ plot <- ggplot(data, aes(x = fault_address, y = faults)) +
theme_minimal() theme_minimal()
ggsave( ggsave(
paste(experiment, "/scatter.svg", sep = ""), paste0(experiment, "/scatter", suffix, ".svg"),
plot = plot, plot = plot,
) )

View File

@ -36,9 +36,12 @@ my $use_aot_in_text = ( $ENV{WAMR_USE_AOT_IN_TEXT} // 'false' )
my $use_mmap_in_text = ( $ENV{WAMR_USE_MMAP_IN_TEXT} // 'false' ) eq 'true'; my $use_mmap_in_text = ( $ENV{WAMR_USE_MMAP_IN_TEXT} // 'false' ) eq 'true';
my $use_xip = ( $ENV{WAMR_USE_XIP} // 'false' ) eq 'true'; my $use_xip = ( $ENV{WAMR_USE_XIP} // 'false' ) eq 'true';
my $use_allocator = ( $ENV{WAMR_USE_ALLOCATOR} // 'false' ) eq 'true'; my $use_allocator = ( $ENV{WAMR_USE_ALLOCATOR} // 'false' ) eq 'true';
my $use_global_heap_in_text = ( $ENV{WAMR_USE_GLOBAL_HEAP_IN_TEXT} // 'false' ) eq 'true'; my $use_global_heap_in_text =
my $use_runtime_pool_in_text = ( $ENV{WAMR_USE_RUNTIME_POOL_IN_TEXT} // 'false' ) eq 'true'; ( $ENV{WAMR_USE_GLOBAL_HEAP_IN_TEXT} // 'false' ) eq 'true';
my $use_linear_pool_in_text = ( $ENV{WAMR_USE_LINEAR_POOL_IN_TEXT} // 'false' ) eq 'true'; my $use_runtime_pool_in_text =
( $ENV{WAMR_USE_RUNTIME_POOL_IN_TEXT} // 'false' ) eq 'true';
my $use_linear_pool_in_text =
( $ENV{WAMR_USE_LINEAR_POOL_IN_TEXT} // 'false' ) eq 'true';
# ========================================================================================= # # ========================================================================================= #
# WAMR cmake configuration # WAMR cmake configuration
@ -66,7 +69,8 @@ my @wamr_cmake_linux = ( '-DWAMR_BUILD_PLATFORM=linux', );
# Variant defines passed as CMAKE_C_FLAGS # Variant defines passed as CMAKE_C_FLAGS
my @variant_cflags = my @variant_cflags =
( '-Wno-error=implicit-function-declaration', '-O0', '-ggdb3' ); ( '-Wno-error=implicit-function-declaration', '-O0', '-ggdb3' );
push @variant_cflags, $use_mmap_in_text ? '-DWAMR_MMAP_IN_TEXT=1' : '-DWAMR_MMAP_IN_TEXT=0'; push @variant_cflags,
$use_mmap_in_text ? '-DWAMR_MMAP_IN_TEXT=1' : '-DWAMR_MMAP_IN_TEXT=0';
push @variant_cflags, '-DWASM_MEM_ALLOC_WITH_USAGE=1' if $use_allocator; push @variant_cflags, '-DWASM_MEM_ALLOC_WITH_USAGE=1' if $use_allocator;
my $cmake_c_flags = join( ' ', @variant_cflags ); my $cmake_c_flags = join( ' ', @variant_cflags );
@ -78,9 +82,18 @@ push @variant_cmake_flags, '-DWAMR_BUILD_ALLOC_WITH_USAGE=1' if $use_allocator;
# WASM_MEM_ALLOC_WITH_USAGE value as libiwasm.a was built with. # WASM_MEM_ALLOC_WITH_USAGE value as libiwasm.a was built with.
my @host_variant_cflags; my @host_variant_cflags;
push @host_variant_cflags, '-DWASM_MEM_ALLOC_WITH_USAGE=1' if $use_allocator; push @host_variant_cflags, '-DWASM_MEM_ALLOC_WITH_USAGE=1' if $use_allocator;
push @host_variant_cflags, $use_global_heap_in_text ? '-DWAMR_GLOBAL_HEAP_IN_TEXT=1' : '-DWAMR_GLOBAL_HEAP_IN_TEXT=0'; push @host_variant_cflags,
push @host_variant_cflags, $use_runtime_pool_in_text ? '-DWAMR_RUNTIME_POOL_IN_TEXT=1' : '-DWAMR_RUNTIME_POOL_IN_TEXT=0'; $use_global_heap_in_text
push @host_variant_cflags, $use_linear_pool_in_text ? '-DWAMR_LINEAR_POOL_IN_TEXT=1' : '-DWAMR_LINEAR_POOL_IN_TEXT=0'; ? '-DWAMR_GLOBAL_HEAP_IN_TEXT=1'
: '-DWAMR_GLOBAL_HEAP_IN_TEXT=0';
push @host_variant_cflags,
$use_runtime_pool_in_text
? '-DWAMR_RUNTIME_POOL_IN_TEXT=1'
: '-DWAMR_RUNTIME_POOL_IN_TEXT=0';
push @host_variant_cflags,
$use_linear_pool_in_text
? '-DWAMR_LINEAR_POOL_IN_TEXT=1'
: '-DWAMR_LINEAR_POOL_IN_TEXT=0';
# ========================================================================================= # # ========================================================================================= #
# Compiler / linker flags # Compiler / linker flags
@ -243,7 +256,8 @@ sub compile_wasm_module {
sub compile_wasm_aot { sub compile_wasm_aot {
my ( $module, $bd, $target ) = @_; my ( $module, $bd, $target ) = @_;
my @flags = ( $target eq 'linux' ) ? @linux_wamrcflags : @cross_wamrcflags; my @flags = ( $target eq 'linux' ) ? @linux_wamrcflags : @cross_wamrcflags;
Util::run( 'wamrc', @flags, '-o', "$bd/wasm_module.aot", "$bd/wasm_module.wasm" ); Util::run( 'wamrc', @flags, '-o', "$bd/wasm_module.aot",
"$bd/wasm_module.wasm" );
} }
sub make_aot_array { sub make_aot_array {
@ -302,7 +316,8 @@ sub compile_wasm_host {
$cross_cc, '-I./targets/wasm-host', $cross_cc, '-I./targets/wasm-host',
@cross_cflags, @host_variant_cflags, @cross_cflags, @host_variant_cflags,
@wamr_inc_baremetal, '-DTARGET_FAIL', @wamr_inc_baremetal, '-DTARGET_FAIL',
'-c', "$bd/module_host.c", '-o', "$bd/system.o" '-c', "$bd/module_host.c",
'-o', "$bd/system.o"
); );
} }
elsif ( $target eq 'linux' ) { elsif ( $target eq 'linux' ) {
@ -310,7 +325,8 @@ sub compile_wasm_host {
$linux_cc, '-I./targets/wasm-host', $linux_cc, '-I./targets/wasm-host',
@linux_cflags, @host_variant_cflags, @linux_cflags, @host_variant_cflags,
@wamr_inc_linux, '-DTARGET_LINUX', @wamr_inc_linux, '-DTARGET_LINUX',
'-c', "$bd/module_host.c", '-o', "$bd/system.o" '-c', "$bd/module_host.c",
'-o', "$bd/system.o"
); );
} }
elsif ( $target eq 'linux-baremetal' ) { elsif ( $target eq 'linux-baremetal' ) {
@ -318,7 +334,8 @@ sub compile_wasm_host {
$cross_cc, '-I./targets/wasm-host', $cross_cc, '-I./targets/wasm-host',
@linux_baremetal_cflags, @host_variant_cflags, @linux_baremetal_cflags, @host_variant_cflags,
@wamr_inc_baremetal, '-DTARGET_LINUX_BAREMETAL', @wamr_inc_baremetal, '-DTARGET_LINUX_BAREMETAL',
'-c', "$bd/module_host.c", '-o', "$bd/system.o" '-c', "$bd/module_host.c",
'-o', "$bd/system.o"
); );
} }
else { else {
@ -342,15 +359,16 @@ sub compile_c_host {
( $target eq 'linux' ) ( $target eq 'linux' )
? ( $linux_cc, @linux_cflags, '-DTARGET_LINUX' ) ? ( $linux_cc, @linux_cflags, '-DTARGET_LINUX' )
: ( $cross_cc, @cross_cflags, '-DTARGET_FAIL' ); : ( $cross_cc, @cross_cflags, '-DTARGET_FAIL' );
Util::run( $cc, @flags, '-c', 'targets/c-host/c_host.c', '-o', "$bd/c_host.o" ); Util::run( $cc, @flags, '-c', 'targets/c-host/c_host.c', '-o',
"$bd/c_host.o" );
copy( 'targets/c-host/c_host.c', "$bd/module_host.c" ); copy( 'targets/c-host/c_host.c', "$bd/module_host.c" );
} }
sub compile_startup { sub compile_startup {
my ( $module, $bd, $target ) = @_; my ( $module, $bd, $target ) = @_;
return unless $target eq 'fail'; return unless $target eq 'fail';
Util::run( $cross_cc, 'targets/startup.s', '-I./targets/wasm-host', @cross_cflags, Util::run( $cross_cc, 'targets/startup.s', '-I./targets/wasm-host',
'-c', '-o', "$bd/startup.o" ); @cross_cflags, '-c', '-o', "$bd/startup.o" );
} }
sub compile_syscalls { sub compile_syscalls {
@ -380,12 +398,12 @@ sub link_wasm {
); );
} }
elsif ( $target eq 'linux' ) { elsif ( $target eq 'linux' ) {
Util::run( $linux_cc, "$bd/system.o", "$bd/libiwasm.a", @linux_ldflags_base, Util::run( $linux_cc, "$bd/system.o", "$bd/libiwasm.a",
'-o', "$bd/system.elf" ); @linux_ldflags_base, '-o', "$bd/system.elf" );
} }
elsif ( $target eq 'linux-baremetal' ) { elsif ( $target eq 'linux-baremetal' ) {
Util::run( $cross_cc, "$bd/system.o", "$bd/syscalls.o", "$bd/libiwasm.a", Util::run( $cross_cc, "$bd/system.o", "$bd/syscalls.o",
@baremetal_ldflags_base, '-o', "$bd/system.elf" ); "$bd/libiwasm.a", @baremetal_ldflags_base, '-o', "$bd/system.elf" );
} }
else { else {
die "Unknown target '$target'\n"; die "Unknown target '$target'\n";
@ -404,8 +422,8 @@ sub link_c {
); );
} }
elsif ( $target eq 'linux' ) { elsif ( $target eq 'linux' ) {
Util::run( $linux_cc, "$bd/c_host.o", "$bd/c_module.o", @linux_ldflags_nowasm, Util::run( $linux_cc, "$bd/c_host.o", "$bd/c_module.o",
'-o', "$bd/system.elf" ); @linux_ldflags_nowasm, '-o', "$bd/system.elf" );
} }
else { else {
die "C mode is not supported for target '$target'\n"; die "C mode is not supported for target '$target'\n";

View File

@ -23,6 +23,9 @@ my $local_archive_dir = "$local_root/injections";
# Select experiment to open # Select experiment to open
my $selected_experiment = Util::select_experiment(0); my $selected_experiment = Util::select_experiment(0);
my $selected_faults_csv =
Util::pick_data_file( "$local_archive_dir/$selected_experiment", "faults" );
my $cui = TUI::init_cui(); my $cui = TUI::init_cui();
# TODO: Add a TextEditor panel beside the experiment selection for notes. # TODO: Add a TextEditor panel beside the experiment selection for notes.
@ -95,7 +98,7 @@ sub load_faults_csv {
# Schema: benchmark, resulttype, faults, fault_address # Schema: benchmark, resulttype, faults, fault_address
my $data = Text::CSV_XS::csv( my $data = Text::CSV_XS::csv(
in => "$local_archive_dir/$selected_experiment/faults.csv", in => "$local_archive_dir/$selected_experiment/$selected_faults_csv",
headers => 'auto' headers => 'auto'
); );

View File

@ -5,13 +5,12 @@ use warnings;
use diagnostics; use diagnostics;
use FindBin; use FindBin;
use lib $FindBin::Bin;
use lib "$FindBin::Bin/Modules"; use lib "$FindBin::Bin/Modules";
use Util; use Util;
use Mars; use Mars;
use TUI; use TUI;
use Modules::Filters; use Filters;
use Text::CSV_XS; use Text::CSV_XS;
use feature 'say'; use feature 'say';
@ -90,7 +89,7 @@ my %handlers = (
my @filter_choices = ("None"); my @filter_choices = ("None");
my %filter_label_name; my %filter_label_name;
my @filter_configs; my @filter_configs;
my $configs = Modules::Filters::get_configs(); my $configs = Filters::get_configs();
foreach my $name ( sort keys %$configs ) { foreach my $name ( sort keys %$configs ) {
my $label = $configs->{$name}{label}; my $label = $configs->{$name}{label};
push @filter_choices, $label; push @filter_choices, $label;
@ -242,13 +241,18 @@ my %handlers = (
my @selected_experiments = Util::select_experiment(1); my @selected_experiments = Util::select_experiment(1);
# TODO: Fails silently if not every selected experiment has this datafile
my $resultsdata_csv =
Util::pick_data_file( "$local_archive_dir/$selected_experiments[0]",
"resultsdata" );
# Read results # Read results
my %all_results; my %all_results;
foreach my $experiment (@selected_experiments) { foreach my $experiment (@selected_experiments) {
# Schema: benchmark, resulttype, faults # Schema: benchmark, resulttype, faults
my $data = Text::CSV_XS::csv( my $data = Text::CSV_XS::csv(
in => "$local_archive_dir/$experiment/resultsdata.csv", in => "$local_archive_dir/$experiment/$resultsdata_csv",
headers => 'auto' headers => 'auto'
); );
@ -480,15 +484,38 @@ my %handlers = (
TUI::select_from_list( "Select Plots to Generate", 1, @charts ); TUI::select_from_list( "Select Plots to Generate", 1, @charts );
die "No plot selected" unless @selected_charts; die "No plot selected" unless @selected_charts;
# Need to know which chart uses which datafile
my @faults_charts = grep { /heatmap|scatter|sankey/ } @selected_charts;
my @resultsdata_charts =
grep { /result$|combined_comparison/ } @selected_charts;
my $faults_csv;
my $resultsdata_csv;
if (@faults_charts) {
$faults_csv = Util::pick_data_file(
"$local_archive_dir/$selected_experiments[0]", "faults" );
}
if (@resultsdata_charts) {
$resultsdata_csv = Util::pick_data_file(
"$local_archive_dir/$selected_experiments[0]",
"resultsdata" );
}
my @single_charts = grep { /single/ } @selected_charts; my @single_charts = grep { /single/ } @selected_charts;
foreach my $experiment (@selected_experiments) { foreach my $experiment (@selected_experiments) {
foreach my $chart (@single_charts) { foreach my $chart (@single_charts) {
say " - Generating plot $chart for $experiment..."; say " - Generating plot $chart for $experiment...";
system( my @r_args = (
'Rscript', 'Rscript',
"$local_charts_dir/$chart.r", "$local_charts_dir/$chart.r",
"$local_archive_dir/$experiment" "$local_archive_dir/$experiment"
); );
push @r_args, $faults_csv
if defined $faults_csv && $chart =~ /heatmap|scatter|sankey/;
push @r_args, $resultsdata_csv
if defined $resultsdata_csv
&& $chart =~ /result$|combined_comparison/;
system(@r_args);
} }
} }
@ -498,8 +525,14 @@ my %handlers = (
map { "$local_archive_dir/$_" } @selected_experiments; map { "$local_archive_dir/$_" } @selected_experiments;
foreach my $chart (@combined_charts) { foreach my $chart (@combined_charts) {
say " - Generating plot $chart for ($print_experiments)..."; say " - Generating plot $chart for ($print_experiments)...";
system( 'Rscript', "$local_charts_dir/$chart.r", my @r_args =
@path_experiments ); ( 'Rscript', "$local_charts_dir/$chart.r", @path_experiments );
push @r_args, $faults_csv
if defined $faults_csv && $chart =~ /heatmap|scatter|sankey/;
push @r_args, $resultsdata_csv
if defined $resultsdata_csv
&& $chart =~ /result$|combined_comparison/;
system(@r_args);
} }
}, },

View File

@ -5,11 +5,13 @@ use warnings;
use diagnostics; use diagnostics;
use FindBin; use FindBin;
use lib $FindBin::Bin;
# runner.pl is executed from the build dir
use lib "$FindBin::Bin/../../scripts/Modules";
use lib "$FindBin::Bin/Modules"; use lib "$FindBin::Bin/Modules";
use Modules::Filters; use Filters;
use Modules::Util; use Util;
use feature 'say'; use feature 'say';
@ -275,7 +277,7 @@ sub results {
my @queries = my @queries =
map { s/\.pm//gr } Util::find_files("$remote_root/scripts/Queries"); map { s/\.pm//gr } Util::find_files("$remote_root/scripts/Queries");
my @configs = ( '', Modules::Filters::get_default_configs() ); my @configs = ( '', Filters::get_default_configs() );
for my $query (@queries) { for my $query (@queries) {
for my $config (@configs) { for my $config (@configs) {