Add wasm tacle-bench targets

This commit is contained in:
2026-06-12 20:06:22 +02:00
parent 30daa8a00c
commit 08c2e9c13d
1122 changed files with 520422 additions and 0 deletions

View File

@ -0,0 +1,25 @@
# ~~~
# SPDX-License-Identifier: MIT
# SPDX-FileCopyrightText: 2026, Friedrich-Alexander-Universität Erlangen-Nürnberg (FAU)
# ~~~
cmake_minimum_required(VERSION 3.20)
project(bsort)
set(TACLEBENCH_ROOT_PATH "${CMAKE_CURRENT_LIST_DIR}/../../..")
set(REPOSITORY_ROOT_PATH "${CMAKE_CURRENT_LIST_DIR}/../../../..")
set(APP_TARGET_NAME "${CMAKE_PROJECT_NAME}")
if(DEFINED TACLEBENCH_VARIANT AND "${TACLEBENCH_VARIANT}" STREQUAL "inline")
set(APP_SOURCE_FILE_PATH
"generated/modified_sources/inline/bsort.c")
else()
set(APP_SOURCE_FILE_PATH
"generated/modified_sources/default/bsort.c")
endif()
include(${REPOSITORY_ROOT_PATH}/cmake/taclebench_wasm.cmake)

View File

@ -0,0 +1,42 @@
File: bsort.c
Original provenience: Mälardalen benchmark suite,
Source: http://www.mrtc.mdh.se/projects/wcet/wcet_bench/bsort100/bsort100.c
2017-04-18:
- Annotated bsort_main as entry-point for timing analysis.
2016-04-20:
- Check upon call of bsort_return that bsort_Array is sorted.
2016-03-15:
- Renamed file from bsort100.c to bsort.c.
- Introduced comments to split file in sections for forward
declarations, global variables, initialization-related and
return-value-related functions, core benchmark functions, and
main routine.
- Added functions bsort_init and bsort_main that call
bsort_Initialize and bsort_BubbleSort, respectively.
- Added function bsort_return that handles the return value.
- Renamed function Initialize to bsort_Initialize.
- Renamed function BubbleSort to bsort_BubbleSort.
- Replaced preprocessor defines NUMELEMS and MAXDIM by unificated
define bsort_SIZE, fixed bug that caused the first element of the
array to be ignored during sorting.
- Replaced preprocessor defines TRUE, FALSE, WORSTCASE and
KNOWN_VALUE by their values.
- Fixed compiler warning "unused variable 'Seed'" by removing the
offending variable.
- Fixed compiler warning "no previous extern declaration for
non-static variable" by making global variables static.
- Fixed compiler warning "unused variable 'LastIndex'" by removing
the offending variable.
- Fixed compiler warning "declaration shadows a variable in the
global scope" by renaming global variable Array to bsort_Array.
- Fixed compiler warning "// comments are not allowed in this
language" by removing dead code.
- Replaced comment describing purpose of benchmark with generic
TACLeBench header.
- Applied TACLeBench formatting rules via
astyle --options=doc/example/astylerc.txt
- Tested conformance to C90 via
clang -fsyntax-only -Weverything -Wno-unknown-pragmas -pedantic -std=c90

View File

@ -0,0 +1,132 @@
/*
This program is part of the TACLeBench benchmark suite.
Version 2.0
Name: bsort
Author: unknown
Function: A program for testing the basic loop constructs,
integer comparisons, and simple array handling by
sorting 100 integers
Source: MRTC
http://www.mrtc.mdh.se/projects/wcet/wcet_bench/bsort100/bsort100.c
Original name: bsort100
Changes: See ChangeLog.txt
License: May be used, modified, and re-distributed freely.
*/
/*
Forward declaration of functions
*/
void bsort_init( void );
void bsort_main( void );
int bsort_return( void );
int bsort_Initialize( int Array[] );
int bsort_BubbleSort( int Array[] );
/*
Declaration of global variables
*/
#define bsort_SIZE 100
static int bsort_Array[ bsort_SIZE ];
/*
Initialization- and return-value-related functions
*/
/* Initializes given array with randomly generated integers. */
int bsort_Initialize( int Array[] )
{
int Index;
_Pragma( "loopbound min 100 max 100" )
for ( Index = 0; Index < bsort_SIZE; Index ++ )
Array[ Index ] = ( Index + 1 ) * -1;
return 0;
}
void bsort_init( void )
{
bsort_Initialize( bsort_Array );
}
int bsort_return( void )
{
int Sorted = 1;
int Index;
_Pragma( "loopbound min 99 max 99" )
for ( Index = 0; Index < bsort_SIZE - 1; Index ++ )
Sorted = Sorted && ( bsort_Array[ Index ] < bsort_Array[ Index + 1 ] );
return 1 - Sorted;
}
/*
Core benchmark functions
*/
/* Sorts an array of integers of size bsort_SIZE in ascending
order with bubble sort. */
int bsort_BubbleSort( int Array[] )
{
int Sorted = 0;
int Temp, Index, i;
_Pragma( "loopbound min 99 max 99" )
for ( i = 0; i < bsort_SIZE - 1; i ++ ) {
Sorted = 1;
_Pragma( "loopbound min 3 max 99" )
for ( Index = 0; Index < bsort_SIZE - 1; Index ++ ) {
if ( Index > bsort_SIZE - i )
break;
if ( Array[ Index ] > Array[Index + 1] ) {
Temp = Array[ Index ];
Array[ Index ] = Array[ Index + 1 ];
Array[ Index + 1 ] = Temp;
Sorted = 0;
}
}
if ( Sorted )
break;
}
return 0;
}
void _Pragma( "entrypoint" ) bsort_main( void )
{
bsort_BubbleSort( bsort_Array );
}
/*
Main function
*/
int main( void )
{
bsort_init();
bsort_main();
return bsort_return();
}

Binary file not shown.

View File

@ -0,0 +1,246 @@
(module $bsort.wasm
(type (;0;) (func (param i32 i32)))
(type (;1;) (func))
(type (;2;) (func (result i32)))
(import "__pragma" "loopbound" (func $__pragma_loopbound (type 0)))
(func $__wasm_apply_data_relocs (type 1))
(func $bsort_main (type 1)
(local i32 i32 i32 i32 i32 i32 i32 i32)
i32.const 99
i32.const 99
call $__pragma_loopbound
i32.const 0
local.set 0
loop ;; label = @1
i32.const 3
i32.const 99
call $__pragma_loopbound
i32.const 100
local.get 0
i32.sub
local.set 1
i32.const 0
i32.load offset=1024
local.set 2
i32.const 0
local.set 3
i32.const 1
local.set 4
block ;; label = @2
block ;; label = @3
loop ;; label = @4
block ;; label = @5
block ;; label = @6
local.get 2
local.get 3
i32.const 1
i32.add
local.tee 5
i32.const 2
i32.shl
i32.const 1024
i32.add
i32.load
local.tee 6
i32.gt_s
br_if 0 (;@6;)
local.get 3
local.set 7
local.get 5
local.set 3
br 1 (;@5;)
end
local.get 3
i32.const 2
i32.shl
i32.const 1024
i32.add
local.set 7
loop ;; label = @6
local.get 7
local.get 6
i32.store
local.get 7
i32.const 4
i32.add
local.tee 6
local.get 2
i32.store
local.get 3
i32.const 97
i32.gt_u
br_if 3 (;@3;)
local.get 3
local.get 1
i32.ge_u
br_if 3 (;@3;)
local.get 3
i32.const 1
i32.add
local.set 3
local.get 7
i32.const 8
i32.add
local.set 5
local.get 6
local.set 7
local.get 2
local.get 5
i32.load
local.tee 6
i32.gt_s
br_if 0 (;@6;)
end
i32.const 0
local.set 4
local.get 3
local.set 7
local.get 3
i32.const 1
i32.add
local.set 3
end
local.get 6
local.set 2
block ;; label = @5
local.get 7
i32.const 97
i32.gt_u
br_if 0 (;@5;)
local.get 7
local.get 1
i32.lt_u
br_if 1 (;@4;)
end
end
local.get 4
br_if 1 (;@2;)
local.get 0
i32.const 1
i32.add
local.tee 0
i32.const 99
i32.ne
br_if 2 (;@1;)
br 1 (;@2;)
end
local.get 0
i32.const 1
i32.add
local.tee 0
i32.const 99
i32.ne
br_if 1 (;@1;)
end
end)
(func $__original_main (type 2) (result i32)
(local i32 i32)
i32.const 100
i32.const 100
call $__pragma_loopbound
i32.const 1024
local.set 0
i32.const -5
local.set 1
loop ;; label = @1
local.get 0
i32.const 16
i32.add
local.get 1
i32.store
local.get 0
i32.const 12
i32.add
local.get 1
i32.const 1
i32.add
i32.store
local.get 0
i32.const 8
i32.add
local.get 1
i32.const 2
i32.add
i32.store
local.get 0
i32.const 4
i32.add
local.get 1
i32.const 3
i32.add
i32.store
local.get 0
local.get 1
i32.const 4
i32.add
i32.store
local.get 0
i32.const 20
i32.add
local.set 0
local.get 1
i32.const -5
i32.add
local.tee 1
i32.const -105
i32.ne
br_if 0 (;@1;)
end
call $bsort_main
i32.const 99
i32.const 99
call $__pragma_loopbound
i32.const 0
local.set 0
i32.const 1
local.set 1
loop ;; label = @1
block ;; label = @2
block ;; label = @3
local.get 1
br_if 0 (;@3;)
local.get 0
i32.const 1
i32.add
local.set 0
i32.const 0
local.set 1
br 1 (;@2;)
end
local.get 0
i32.const 2
i32.shl
i32.const 1024
i32.add
i32.load
local.get 0
i32.const 1
i32.add
local.tee 0
i32.const 2
i32.shl
i32.const 1024
i32.add
i32.load
i32.lt_s
local.set 1
end
local.get 0
i32.const 99
i32.ne
br_if 0 (;@1;)
end
local.get 1
i32.const 1
i32.xor)
(table (;0;) 1 1 funcref)
(memory (;0;) 1)
(global $__stack_pointer (mut i32) (i32.const 5520))
(global (;1;) i32 (i32.const 1424))
(global (;2;) i32 (i32.const 5520))
(export "memory" (memory 0))
(export "__wasm_apply_data_relocs" (func $__wasm_apply_data_relocs))
(export "entrypoint" (func $bsort_main))
(export "main" (func $__original_main))
(export "__data_end" (global 1))
(export "__heap_base" (global 2)))

View File

@ -0,0 +1,130 @@
/*
This program is part of the TACLeBench benchmark suite.
Version 2.0
Name: bsort
Author: unknown
Function: A program for testing the basic loop constructs,
integer comparisons, and simple array handling by
sorting 100 integers
Source: MRTC
http://www.mrtc.mdh.se/projects/wcet/wcet_bench/bsort100/bsort100.c
Original name: bsort100
Changes: See ChangeLog.txt
License: May be used, modified, and re-distributed freely.
*/
/*
Forward declaration of functions
*/
// Wasm loop bounds
__attribute__((import_module("__pragma"), import_name("loopbound"))) extern void
__pragma_loopbound(unsigned int min_bound, unsigned int max_bound);
void bsort_init(void);
__attribute__((noinline)) __attribute__((export_name("entrypoint"))) void
bsort_main(void);
int bsort_return(void);
int bsort_Initialize(int Array[]);
int bsort_BubbleSort(int Array[]);
/*
Declaration of global variables
*/
#define bsort_SIZE 100
static int bsort_Array[bsort_SIZE];
/*
Initialization- and return-value-related functions
*/
/* Initializes given array with randomly generated integers. */
int
bsort_Initialize(int Array[]) {
int Index;
__pragma_loopbound(100, 100);
for (Index = 0; Index < bsort_SIZE; Index++)
Array[Index] = (Index + 1) * -1;
return 0;
}
void
bsort_init(void) {
bsort_Initialize(bsort_Array);
}
int
bsort_return(void) {
int Sorted = 1;
int Index;
__pragma_loopbound(99, 99);
for (Index = 0; Index < bsort_SIZE - 1; Index++)
Sorted = Sorted && (bsort_Array[Index] < bsort_Array[Index + 1]);
return 1 - Sorted;
}
/*
Core benchmark functions
*/
/* Sorts an array of integers of size bsort_SIZE in ascending
order with bubble sort. */
int
bsort_BubbleSort(int Array[]) {
int Sorted = 0;
int Temp, Index, i;
__pragma_loopbound(99, 99);
for (i = 0; i < bsort_SIZE - 1; i++) {
Sorted = 1;
__pragma_loopbound(3, 99);
for (Index = 0; Index < bsort_SIZE - 1; Index++) {
if (Index > bsort_SIZE - i)
break;
if (Array[Index] > Array[Index + 1]) {
Temp = Array[Index];
Array[Index] = Array[Index + 1];
Array[Index + 1] = Temp;
Sorted = 0;
}
}
if (Sorted)
break;
}
return 0;
}
__attribute__((noinline)) __attribute__((export_name("entrypoint"))) void
bsort_main(void) {
bsort_BubbleSort(bsort_Array);
}
/*
Main function
*/
__attribute__((noinline)) __attribute__((export_name("main"))) int
main(void) {
bsort_init();
bsort_main();
return bsort_return();
}

View File

@ -0,0 +1,136 @@
/*
This program is part of the TACLeBench benchmark suite.
Version 2.0
Name: bsort
Author: unknown
Function: A program for testing the basic loop constructs,
integer comparisons, and simple array handling by
sorting 100 integers
Source: MRTC
http://www.mrtc.mdh.se/projects/wcet/wcet_bench/bsort100/bsort100.c
Original name: bsort100
Changes: See ChangeLog.txt
License: May be used, modified, and re-distributed freely.
*/
/*
Forward declaration of functions
*/
// Wasm loop bounds
__attribute__((import_module("__pragma"), import_name("loopbound"))) extern void
__pragma_loopbound(unsigned int min_bound, unsigned int max_bound);
__attribute__((always_inline)) static inline void bsort_init(void);
__attribute__((noinline)) __attribute__((export_name("entrypoint")))
__attribute__((noinline)) __attribute__((export_name("entrypoint"))) void
bsort_main(void);
__attribute__((always_inline)) static inline int bsort_return(void);
__attribute__((always_inline)) static inline int bsort_Initialize(int Array[]);
__attribute__((always_inline)) static inline int bsort_BubbleSort(int Array[]);
/*
Declaration of global variables
*/
#define bsort_SIZE 100
static int bsort_Array[bsort_SIZE];
/*
Initialization- and return-value-related functions
*/
/* Initializes given array with randomly generated integers. */
__attribute__((always_inline)) static inline int
bsort_Initialize(int Array[]) {
int Index;
__pragma_loopbound(100, 100);
for (Index = 0; Index < bsort_SIZE; Index++)
Array[Index] = (Index + 1) * -1;
return 0;
}
__attribute__((always_inline)) static inline void
bsort_init(void) {
bsort_Initialize(bsort_Array);
}
__attribute__((always_inline)) static inline int
bsort_return(void) {
int Sorted = 1;
int Index;
__pragma_loopbound(99, 99);
for (Index = 0; Index < bsort_SIZE - 1; Index++)
Sorted = Sorted && (bsort_Array[Index] < bsort_Array[Index + 1]);
return 1 - Sorted;
}
/*
Core benchmark functions
*/
/* Sorts an array of integers of size bsort_SIZE in ascending
order with bubble sort. */
__attribute__((always_inline)) static inline int
bsort_BubbleSort(int Array[]) {
int Sorted = 0;
int Temp, Index, i;
__pragma_loopbound(99, 99);
for (i = 0; i < bsort_SIZE - 1; i++) {
Sorted = 1;
__pragma_loopbound(3, 99);
for (Index = 0; Index < bsort_SIZE - 1; Index++) {
if (Index > bsort_SIZE - i)
break;
if (Array[Index] > Array[Index + 1]) {
Temp = Array[Index];
Array[Index] = Array[Index + 1];
Array[Index + 1] = Temp;
Sorted = 0;
}
}
if (Sorted)
break;
}
return 0;
}
__attribute__((noinline)) __attribute__((export_name("entrypoint")))
__attribute__((noinline)) __attribute__((export_name("entrypoint"))) void
bsort_main(void) {
bsort_BubbleSort(bsort_Array);
}
/*
Main function
*/
__attribute__((noinline)) __attribute__((export_name("main")))
__attribute__((noinline)) __attribute__((export_name("main"))) int
main(void) {
bsort_init();
bsort_main();
return bsort_return();
}