Redo tacle-bench integration (now much simpler but requires custom target wrapper)

This commit is contained in:
2026-07-06 21:59:47 +02:00
parent 65f34aa653
commit 557f541658
3 changed files with 77 additions and 4 deletions
+23
View File
@@ -327,4 +327,27 @@ sub select_experiment {
return $multi == 1 ? @selected_experiments : $selected_experiments[0]; return $multi == 1 ? @selected_experiments : $selected_experiments[0];
} }
sub module_is_tacle {
my ($module) = @_;
return $module =~ /^tacle-/;
}
sub find_tacle_sources {
my ($module) = @_;
return () unless $module =~ /^tacle-([^-]+)-(.+)$/;
my ( $category, $bench ) = ( $1, $2 );
# TODO: Also have modified_sources/inline
my $src_dir =
"targets/wasm-tacle/$category/$bench/generated/modified_sources/default";
die "TACLe source not found for '$module': $src_dir\n" unless -d $src_dir;
my @srcs = sort glob("$src_dir/*.c");
die "No sources found for '$module' in '$src_dir'\n" unless @srcs;
return ( \@srcs, $src_dir );
}
1; 1;
+29 -4
View File
@@ -232,8 +232,9 @@ sub copy_auxiliary {
my ( $module, $bd ) = @_; my ( $module, $bd ) = @_;
my @files = ( my @files = (
[ 'flake.nix', "$bd/flake.nix" ], [ 'flake.nix', "$bd/flake.nix" ],
[ 'scripts/runner.pl', "$bd/runner.pl" ], [ 'scripts/build.pl', "$bd/build.pl" ],
[ 'scripts/compile.pl', "$bd/compile.pl" ], [ 'scripts/compile.pl', "$bd/compile.pl" ],
[ 'scripts/runner.pl', "$bd/runner.pl" ],
[ 'targets/lib.h', "$bd/lib.h" ], [ 'targets/lib.h', "$bd/lib.h" ],
[ 'targets/linker.ld', "$bd/linker.ld" ], [ 'targets/linker.ld', "$bd/linker.ld" ],
[ 'targets/startup.s', "$bd/startup.s" ], [ 'targets/startup.s', "$bd/startup.s" ],
@@ -244,13 +245,37 @@ sub copy_auxiliary {
copy( $pair->[0], $pair->[1] ) copy( $pair->[0], $pair->[1] )
or die "failed to copy $pair->[0] -> $pair->[1]: $!"; or die "failed to copy $pair->[0] -> $pair->[1]: $!";
} }
# Copy tacle benchs if module is from tacle-bench
if ( Util::module_is_tacle($module) ) {
my ( undef, $src_dir ) = Util::find_tacle_sources($module);
my $dst_dir = "$bd/tacle-src";
make_path($dst_dir);
for my $file ( glob("$src_dir/*.c"), glob("$src_dir/*.h") ) {
my $base = ( File::Spec->splitpath($file) )[2];
copy( $file, "$dst_dir/$base" )
or die "failed to copy $file to $dst_dir/$base: $!";
}
}
} }
sub compile_wasm_module { sub compile_wasm_module {
my ( $module, $bd ) = @_; my ( $module, $bd ) = @_;
Util::run( "$wasi_root/bin/clang", @wasi_cflags, if ( Util::module_is_tacle($module) ) {
"targets/wasm-module/$module.cpp", my ( $srcs, $inc ) = Util::find_tacle_sources($module);
'-o', "$bd/wasm_module.wasm" ); Util::run(
"$wasi_root/bin/clang", @wasi_cflags,
"-Dmain=tacle_main_bullshit", "-I$inc",
"targets/wasm-module/$module.cpp", @$srcs,
'-o', "$bd/wasm_module.wasm"
);
}
else {
Util::run( "$wasi_root/bin/clang", @wasi_cflags,
"targets/wasm-module/$module.cpp",
'-o', "$bd/wasm_module.wasm" );
}
} }
sub compile_wasm_aot { sub compile_wasm_aot {
@@ -0,0 +1,25 @@
#include "../lib.h"
extern "C" {
void __pragma_loopbound(unsigned, unsigned) {}
void bsort_init(void);
void bsort_main(void);
int bsort_return(void);
EXPORT("wasm_module") int wasm_module(void) {
bsort_init();
fail_start_trace();
bsort_main();
fail_stop_trace();
int ret = bsort_return();
if (ret == 0) {
fail_marker_positive();
} else {
fail_marker_negative();
}
return ret;
}
}