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 warnings;
@ -9,30 +9,93 @@ use lib $FindBin::Bin;
use Util;
my %CONFIGS = (
no_aot => {
label => "Exclude WAMR AOT array",
regions => [ [ '_wamr_aot_start', '_wamr_aot_end' ] ],
no_aot_instr => {
label => "Exclude WAMR AOT array (instr)",
regions => [
[
'_wamr_aot_start', '_wamr_aot_end',
'p.injection_instr_absolute'
]
],
},
no_mmap => {
label => "Exclude WAMR mmap",
regions => [ [ '_wamr_mmap_start', '_wamr_mmap_end' ] ],
no_aot_data => {
label => "Exclude WAMR AOT array (data)",
regions =>
[ [ '_wamr_aot_start', '_wamr_aot_end', 'g.data_physical_address' ] ],
},
no_runtime_pool => {
label => "Exclude WAMR runtime pool",
regions => [ [ '_wamr_runtime_pool_start', '_wamr_runtime_pool_end' ] ],
no_mmap_instr => {
label => "Exclude WAMR mmap (instr)",
regions => [
[
'_wamr_mmap_start', '_wamr_mmap_end',
'p.injection_instr_absolute'
]
],
},
no_linear_pool => {
label => "Exclude WAMR linear pool",
regions => [ [ '_wamr_linear_pool_start', '_wamr_linear_pool_end' ] ],
no_mmap_data => {
label => "Exclude WAMR mmap (data)",
regions => [
[ '_wamr_mmap_start', '_wamr_mmap_end', 'g.data_physical_address' ]
],
},
no_global_heap => {
label => "Exclude WAMR global heap",
regions => [ [ '_wamr_global_heap_start', '_wamr_global_heap_end' ] ],
no_runtime_pool_instr => {
label => "Exclude WAMR runtime pool (instr)",
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)
my @DEFAULT_CONFIGS = ('no_aot');
my @DEFAULT_CONFIGS = ('no_aot_data');
sub get_configs {
return \%CONFIGS;
@ -55,13 +118,12 @@ sub build_filter_clause {
my @filters;
for my $pair (@$regions) {
my ( $start_sym, $end_sym ) = @$pair;
my ( $start_sym, $end_sym, $col ) = @$pair;
my $start =
Util::elf_sym_addr( "$experiment_dir/system.elf", $start_sym );
my $end = Util::elf_sym_addr( "$experiment_dir/system.elf", $end_sym );
next unless defined $start && defined $end && $end > $start;
push @filters,
"p.injection_instr_absolute NOT BETWEEN $start AND @{[$end - 1]}";
push @filters, "$col NOT BETWEEN $start AND @{[$end - 1]}";
}
return "" unless @filters;

View File

@ -5,6 +5,13 @@ use warnings;
use diagnostics;
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';
@ -130,15 +137,15 @@ sub execute_query {
$filter_config_name )
= @_;
my $module = "Queries::$queryname";
my $module = "$queryname";
my $file = "$module.pm";
$file =~ s/::/\//g;
require $file;
my $query = $module->can('query') or die "$module can't query()";
my $args = $module->can('args') or die "$module can't args()";
my $filename = $module->can('filename') or die "$module can't filanem()";
my $query = $module->can('query') or die "$module can't query()";
my $args = $module->can('args') or die "$module can't args()";
my $filename = $module->can('filename') or die "$module can't filename()";
my $postprocess = $module->can('postprocess')
or die "$module can't postprocess()";
@ -175,7 +182,7 @@ sub format_number_sep {
}
sub elf_sym_addr {
my ($elffile, $sym) = @_;
my ( $elffile, $sym ) = @_;
my $line = qx{nm "$elffile" 2>/dev/null | grep " $sym\$"};
return undef unless $line =~ /^([0-9a-f]+)/i;
return hex($1);
@ -274,6 +281,27 @@ sub delete_marker_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 {
my ($multi) = @_;

View File

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

View File

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

View File

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

View File

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

View File

@ -29,27 +29,84 @@ max_tile <- 0.5
# Generate all heatmaps with crossproduct of this
benchmarks <- c("ip", "mem", "regs")
markers <- c(
"OK_MARKER", "FAIL_MARKER", "DETECTED_MARKER",
"ACCESS_OUTERSPACE", "WRITE_TEXTSEGMENT",
"GROUP1_MARKER", "TRAP", "TIMEOUT"
"OK_MARKER",
"FAIL_MARKER",
"DETECTED_MARKER",
"ACCESS_OUTERSPACE",
"WRITE_TEXTSEGMENT",
"GROUP1_MARKER",
"TRAP",
"TIMEOUT"
)
# Labels for _start/_end symbols from linker.ld
regions <- list(
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(label = "WAMR runtime mem", start = "_wamr_runtime_pool_start", end = "_wamr_runtime_pool_end"),
list(label = "WAMR linear mem", 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 = "WAMR os_mmap",
start = "_wamr_mmap_start",
end = "_wamr_mmap_end"
),
list(
label = "WAMR runtime mem",
start = "_wamr_runtime_pool_start",
end = "_wamr_runtime_pool_end"
),
list(
label = "WAMR linear mem",
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 = "BSS", start = "_sbss", end = "_ebss")
)
@ -75,22 +132,27 @@ if (length(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)
# =============================================================================
datafile <- file.path(experiment, "faults.csv")
datafile <- file.path(experiment, faults_file)
if (!file.exists(datafile)) {
stop(paste("Input file not found:", datafile))
}
raw <- read_csv(datafile, col_types = cols(
benchmark = col_character(),
resulttype = col_character(),
faults = col_double(),
fault_address = col_character() # hex string "0x10001A"; converted below
))
raw <- read_csv(
datafile,
col_types = cols(
benchmark = col_character(),
resulttype = col_character(),
faults = col_double(),
fault_address = col_character() # hex string "0x10001A"; converted below
)
)
# =============================================================================
# ELF SYMBOLS (parsed once)
@ -155,10 +217,12 @@ make_heatmap <- function(target_resulttype, target_benchmark) {
# "0x10001A" -> substr strips "0x" -> strtoi parses base-16 -> integer
aggregated <- aggregated |>
mutate(addr_int = strtoi(
substr(.data$fault_address, 3L, nchar(.data$fault_address)),
16L
))
mutate(
addr_int = strtoi(
substr(.data$fault_address, 3L, nchar(.data$fault_address)),
16L
)
)
# ===========================================================================
# SCALE ROWS
@ -168,17 +232,24 @@ make_heatmap <- function(target_resulttype, target_benchmark) {
row_width <- row_width_init
# Double row_width until occupied rows <= max_rows
while (row_width < 65536L && n_occupied_rows(
aggregated$addr_int, row_width
) > max_rows) {
while (
row_width < 65536L &&
n_occupied_rows(
aggregated$addr_int,
row_width
) >
max_rows
) {
row_width <- row_width * 2L
}
if (row_width > row_width_init) {
message(sprintf(
"Note: [%s/%s] row_width auto-scaled to %d (%d occupied rows)",
target_resulttype, target_benchmark,
row_width, n_occupied_rows(aggregated$addr_int, row_width)
target_resulttype,
target_benchmark,
row_width,
n_occupied_rows(aggregated$addr_int, row_width)
))
}
@ -210,8 +281,8 @@ make_heatmap <- function(target_resulttype, target_benchmark) {
# - Adding that offset to 1...n gives the row_idx values with gap slots
cumulative_gaps <- cumsum(has_gap_before)
row_order <- tibble(
row = rows_sorted,
row_idx = seq_len(n_data_rows) + cumulative_gaps,
row = rows_sorted,
row_idx = seq_len(n_data_rows) + cumulative_gaps,
has_gap_before = has_gap_before
)
@ -240,8 +311,8 @@ make_heatmap <- function(target_resulttype, target_benchmark) {
region_rects <- data.frame(
label = character(0),
ymin = numeric(0),
ymax = numeric(0)
ymin = numeric(0),
ymax = numeric(0)
)
if (length(sym_addr) > 0) {
@ -256,7 +327,8 @@ make_heatmap <- function(target_resulttype, target_benchmark) {
# Row with base address r covers bytes r ... r + row_width - 1.
# Overlap if r < e && r + row_width > s
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
]
@ -266,8 +338,8 @@ make_heatmap <- function(target_resulttype, target_benchmark) {
data.frame(
label = reg$label,
ymin = min(overlapping$row_idx) - 0.5,
ymax = max(overlapping$row_idx) + 0.5
ymin = min(overlapping$row_idx) - 0.5,
ymax = max(overlapping$row_idx) + 0.5
)
})
@ -310,9 +382,14 @@ make_heatmap <- function(target_resulttype, target_benchmark) {
# PLOT
# ===========================================================================
plot <- ggplot(grid_complete, aes(
x = col, y = .data$row_idx, fill = .data$faults
)) +
plot <- ggplot(
grid_complete,
aes(
x = col,
y = .data$row_idx,
fill = .data$faults
)
) +
# One rectangle per (col, row_idx) tuple
geom_tile(width = 1, height = 1, colour = NA) +
@ -330,10 +407,10 @@ make_heatmap <- function(target_resulttype, target_benchmark) {
# Heatmap color ramp
scale_fill_viridis_c(
name = "Faults",
trans = "log1p",
name = "Faults",
trans = "log1p",
na.value = "grey85",
option = "viridis"
option = "viridis"
) +
# X-axis hex labels
@ -355,10 +432,13 @@ make_heatmap <- function(target_resulttype, target_benchmark) {
# Title + axis labels
labs(
title = paste(target_resulttype, "/", target_benchmark),
subtitle = paste("Total:", format(
sum(aggregated$faults, na.rm = TRUE),
big.mark = ","
)),
subtitle = paste(
"Total:",
format(
sum(aggregated$faults, na.rm = TRUE),
big.mark = ","
)
),
x = "Byte Offset",
y = "Base Address"
) +
@ -367,7 +447,10 @@ make_heatmap <- function(target_resulttype, target_benchmark) {
theme_minimal() +
theme(
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),
panel.grid = element_blank(),
@ -399,9 +482,17 @@ make_heatmap <- function(target_resulttype, target_benchmark) {
fig_w <- row_width * tile_size + 4.5
fig_h <- total_slots * tile_size + 2.5
outfile <- file.path(experiment, paste0(
"heatmap_", target_resulttype, "_", target_benchmark, ".svg"
))
outfile <- file.path(
experiment,
paste0(
"heatmap_",
target_resulttype,
"_",
target_benchmark,
suffix,
".svg"
)
)
ggsave(outfile, plot = plot, width = fig_w, height = fig_h, units = "in")
message(sprintf("Saved: %s", basename(outfile)))

View File

@ -1,10 +1,12 @@
library(ggplot2)
# Usage: Rscript single_result.r exp_abspath
# Usage: Rscript single_result.r exp_abspath [resultsdata_file]
args <- commandArgs(trailingOnly = TRUE)
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)) {
print(paste("Input file", datafile, "is missing"))
@ -21,6 +23,6 @@ plot <- ggplot(data, aes(x = benchmark, y = faults, fill = resulttype)) +
theme_minimal()
ggsave(
paste(experiment, "/single_result.svg", sep = ""),
paste0(experiment, "/single_result", suffix, ".svg"),
plot = plot,
)

View File

@ -6,7 +6,9 @@ library(ggplot2)
args <- commandArgs(trailingOnly = TRUE)
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)) {
print(paste("Input file", datafile, "is missing"))
@ -27,6 +29,6 @@ plot <- ggplot(data, aes(x = fault_address, y = faults)) +
theme_minimal()
ggsave(
paste(experiment, "/scatter.svg", sep = ""),
paste0(experiment, "/scatter", suffix, ".svg"),
plot = plot,
)

View File

@ -32,13 +32,16 @@ my $wamr_root = require_env('WAMR_ROOT');
my $cross_cc = require_env('CROSS_CC');
my $linux_cc = require_env('LINUX_CC');
my $use_aot_in_text = ( $ENV{WAMR_USE_AOT_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_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_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';
my $use_aot_in_text = ( $ENV{WAMR_USE_AOT_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_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_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
@ -66,7 +69,8 @@ my @wamr_cmake_linux = ( '-DWAMR_BUILD_PLATFORM=linux', );
# Variant defines passed as CMAKE_C_FLAGS
my @variant_cflags =
( '-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;
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.
my @host_variant_cflags;
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, $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';
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,
$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
@ -243,7 +256,8 @@ sub compile_wasm_module {
sub compile_wasm_aot {
my ( $module, $bd, $target ) = @_;
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 {
@ -299,26 +313,29 @@ sub compile_wasm_host {
my ( $module, $bd, $target ) = @_;
if ( $target eq 'fail' ) {
Util::run(
$cross_cc, '-I./targets/wasm-host',
@cross_cflags, @host_variant_cflags,
@wamr_inc_baremetal, '-DTARGET_FAIL',
'-c', "$bd/module_host.c", '-o', "$bd/system.o"
$cross_cc, '-I./targets/wasm-host',
@cross_cflags, @host_variant_cflags,
@wamr_inc_baremetal, '-DTARGET_FAIL',
'-c', "$bd/module_host.c",
'-o', "$bd/system.o"
);
}
elsif ( $target eq 'linux' ) {
Util::run(
$linux_cc, '-I./targets/wasm-host',
@linux_cflags, @host_variant_cflags,
@wamr_inc_linux, '-DTARGET_LINUX',
'-c', "$bd/module_host.c", '-o', "$bd/system.o"
$linux_cc, '-I./targets/wasm-host',
@linux_cflags, @host_variant_cflags,
@wamr_inc_linux, '-DTARGET_LINUX',
'-c', "$bd/module_host.c",
'-o', "$bd/system.o"
);
}
elsif ( $target eq 'linux-baremetal' ) {
Util::run(
$cross_cc, '-I./targets/wasm-host',
$cross_cc, '-I./targets/wasm-host',
@linux_baremetal_cflags, @host_variant_cflags,
@wamr_inc_baremetal, '-DTARGET_LINUX_BAREMETAL',
'-c', "$bd/module_host.c", '-o', "$bd/system.o"
@wamr_inc_baremetal, '-DTARGET_LINUX_BAREMETAL',
'-c', "$bd/module_host.c",
'-o', "$bd/system.o"
);
}
else {
@ -342,15 +359,16 @@ sub compile_c_host {
( $target eq 'linux' )
? ( $linux_cc, @linux_cflags, '-DTARGET_LINUX' )
: ( $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" );
}
sub compile_startup {
my ( $module, $bd, $target ) = @_;
return unless $target eq 'fail';
Util::run( $cross_cc, 'targets/startup.s', '-I./targets/wasm-host', @cross_cflags,
'-c', '-o', "$bd/startup.o" );
Util::run( $cross_cc, 'targets/startup.s', '-I./targets/wasm-host',
@cross_cflags, '-c', '-o', "$bd/startup.o" );
}
sub compile_syscalls {
@ -380,12 +398,12 @@ sub link_wasm {
);
}
elsif ( $target eq 'linux' ) {
Util::run( $linux_cc, "$bd/system.o", "$bd/libiwasm.a", @linux_ldflags_base,
'-o', "$bd/system.elf" );
Util::run( $linux_cc, "$bd/system.o", "$bd/libiwasm.a",
@linux_ldflags_base, '-o', "$bd/system.elf" );
}
elsif ( $target eq 'linux-baremetal' ) {
Util::run( $cross_cc, "$bd/system.o", "$bd/syscalls.o", "$bd/libiwasm.a",
@baremetal_ldflags_base, '-o', "$bd/system.elf" );
Util::run( $cross_cc, "$bd/system.o", "$bd/syscalls.o",
"$bd/libiwasm.a", @baremetal_ldflags_base, '-o', "$bd/system.elf" );
}
else {
die "Unknown target '$target'\n";
@ -404,8 +422,8 @@ sub link_c {
);
}
elsif ( $target eq 'linux' ) {
Util::run( $linux_cc, "$bd/c_host.o", "$bd/c_module.o", @linux_ldflags_nowasm,
'-o', "$bd/system.elf" );
Util::run( $linux_cc, "$bd/c_host.o", "$bd/c_module.o",
@linux_ldflags_nowasm, '-o', "$bd/system.elf" );
}
else {
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
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();
# 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
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'
);

View File

@ -5,13 +5,12 @@ use warnings;
use diagnostics;
use FindBin;
use lib $FindBin::Bin;
use lib "$FindBin::Bin/Modules";
use Util;
use Mars;
use TUI;
use Modules::Filters;
use Filters;
use Text::CSV_XS;
use feature 'say';
@ -90,7 +89,7 @@ my %handlers = (
my @filter_choices = ("None");
my %filter_label_name;
my @filter_configs;
my $configs = Modules::Filters::get_configs();
my $configs = Filters::get_configs();
foreach my $name ( sort keys %$configs ) {
my $label = $configs->{$name}{label};
push @filter_choices, $label;
@ -242,13 +241,18 @@ my %handlers = (
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
my %all_results;
foreach my $experiment (@selected_experiments) {
# Schema: benchmark, resulttype, faults
my $data = Text::CSV_XS::csv(
in => "$local_archive_dir/$experiment/resultsdata.csv",
in => "$local_archive_dir/$experiment/$resultsdata_csv",
headers => 'auto'
);
@ -480,15 +484,38 @@ my %handlers = (
TUI::select_from_list( "Select Plots to Generate", 1, @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;
foreach my $experiment (@selected_experiments) {
foreach my $chart (@single_charts) {
say " - Generating plot $chart for $experiment...";
system(
my @r_args = (
'Rscript',
"$local_charts_dir/$chart.r",
"$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;
foreach my $chart (@combined_charts) {
say " - Generating plot $chart for ($print_experiments)...";
system( 'Rscript', "$local_charts_dir/$chart.r",
@path_experiments );
my @r_args =
( '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 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 Modules::Filters;
use Modules::Util;
use Filters;
use Util;
use feature 'say';
@ -275,7 +277,7 @@ sub results {
my @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 $config (@configs) {