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(prime)
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/prime.c")
else()
set(APP_SOURCE_FILE_PATH
"generated/modified_sources/default/prime.c")
endif()
include(${REPOSITORY_ROOT_PATH}/cmake/taclebench_wasm.cmake)

View File

@ -0,0 +1,38 @@
File: prime.c
Original provenience: Mälardalen benchmark suite,
ww.mrtc.mdh.se/projects/wcet/wcet_bench/prime/prime.c
2015-12-21:
- Renamed each function FUNC to prime_FUNC
- Added functions prime_init, prime_return and main
- Added a global variable 'int prime_result' to introduce a
non-optimizable return value
- Added forward declarations of all functions before the declarations of global
variables
- Replaced typedefs bool and uint.
- Re-ordered functions to fit template-order
- Applied code formatting according to the following rules
(incomplete, to be discussed; I basically used astyle with the attached
options file):
- Lines shall not be wider than 80 characters; whenever possible, appropriate
line breaks shall be inserted to keep lines below 80 characters
- Indentation is done using whitespaces only, no tabs. Code is indented by
two whitespaces
- Two empty lines are put between any two functions
- In non-empty lists or index expressions, opening '(' and '[' are followed by
one whitespace, closing ')' and ']' are preceded by one whitespace
- In comma- or colon-separated argument lists, one whitespace is put after
each comma/colon
- Names of functions and global variables all start with a benchmark-specific
prefix (here: st_) followed by lowercase letter (e.g., st_square)
- For pointer types, one whitespace is put before the '*'
- Operators within expressions shall be preceded and followed by one
whitespace
- Code of then- and else-parts of if-then-else statements shall be put in
separate lines, not in the same lines as the if-condition or the keyword
"else"
- Opening braces '{' denoting the beginning of code for some if-else or loop
body shall be put at the end of the same line where the keywords "if",
"else", "for", "while" etc. occur
- Added general TACLeBench header to beginning of source code

Binary file not shown.

View File

@ -0,0 +1,184 @@
(module $prime.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 $prime_main (type 1)
(local i32 i32 i32)
i32.const 0
i32.load offset=1028
local.set 0
i32.const 0
i32.const 0
i32.load offset=1032
local.tee 1
i32.store offset=1028
i32.const 0
local.get 0
i32.store offset=1032
i32.const 1
local.set 2
block ;; label = @1
block ;; label = @2
block ;; label = @3
local.get 1
i32.const 1
i32.and
br_if 0 (;@3;)
local.get 1
i32.const 2
i32.ne
br_if 1 (;@2;)
br 2 (;@1;)
end
i32.const 0
i32.const 16
call $__pragma_loopbound
block ;; label = @3
block ;; label = @4
local.get 1
i32.const 9
i32.lt_u
br_if 0 (;@4;)
i32.const 5
local.set 2
loop ;; label = @5
local.get 1
local.get 2
i32.const -2
i32.add
i32.rem_u
i32.eqz
br_if 2 (;@3;)
local.get 2
local.get 2
i32.mul
local.set 0
local.get 2
i32.const 2
i32.add
local.set 2
local.get 0
local.get 1
i32.le_u
br_if 0 (;@5;)
end
end
i32.const 1
local.set 2
local.get 1
i32.const 1
i32.gt_u
br_if 2 (;@1;)
end
i32.const 0
i32.load offset=1032
local.set 0
end
block ;; label = @2
local.get 0
i32.const 1
i32.and
br_if 0 (;@2;)
local.get 0
i32.const 2
i32.eq
local.set 2
br 1 (;@1;)
end
i32.const 0
i32.const 16
call $__pragma_loopbound
block ;; label = @2
local.get 0
i32.const 9
i32.lt_u
br_if 0 (;@2;)
i32.const 5
local.set 2
block ;; label = @3
loop ;; label = @4
local.get 0
local.get 2
i32.const -2
i32.add
i32.rem_u
i32.eqz
br_if 1 (;@3;)
local.get 2
local.get 2
i32.mul
local.set 1
local.get 2
i32.const 2
i32.add
local.set 2
local.get 1
local.get 0
i32.gt_u
br_if 2 (;@2;)
br 0 (;@4;)
end
end
i32.const 0
local.set 2
br 1 (;@1;)
end
local.get 0
i32.const 1
i32.gt_u
local.set 2
end
i32.const 0
local.get 2
i32.store offset=1036)
(func $__original_main (type 2) (result i32)
(local i32)
i32.const 0
i32.const 0
i32.store offset=1024
i32.const 0
i32.const 0
i32.load offset=1024
i32.const 133
i32.mul
i32.const 81
i32.add
i32.const 8095
i32.rem_s
i32.store offset=1024
i32.const 0
i32.load offset=1024
local.set 0
i32.const 0
i32.const 0
i32.load offset=1024
i32.const 133
i32.mul
i32.const 81
i32.add
i32.const 8095
i32.rem_s
i32.store offset=1024
i32.const 0
local.get 0
i32.store offset=1028
i32.const 0
i32.const 0
i32.load offset=1024
i32.store offset=1032
call $prime_main
i32.const 0
i32.load offset=1036)
(table (;0;) 1 1 funcref)
(memory (;0;) 1)
(global $__stack_pointer (mut i32) (i32.const 5136))
(global (;1;) i32 (i32.const 1040))
(global (;2;) i32 (i32.const 5136))
(export "memory" (memory 0))
(export "__wasm_apply_data_relocs" (func $__wasm_apply_data_relocs))
(export "entrypoint" (func $prime_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 V 2.0
Name: prime
Author: unknown
Function: prime calculates whether numbers are prime.
Source: MRTC
http://www.mrtc.mdh.se/projects/wcet/wcet_bench/prime/prime.c
Changes: no major functional changes
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);
unsigned char prime_divides(unsigned int n, unsigned int m);
unsigned char prime_even(unsigned int n);
unsigned char prime_prime(unsigned int n);
void prime_swap(unsigned int *a, unsigned int *b);
unsigned int prime_randomInteger();
void prime_initSeed();
void prime_init();
int prime_return();
__attribute__((noinline)) __attribute__((export_name("entrypoint"))) void
prime_main();
__attribute__((noinline)) __attribute__((export_name("main"))) int main(void);
/*
Declaration of global variables
*/
unsigned int prime_x;
unsigned int prime_y;
int prime_result;
volatile int prime_seed;
/*
Initialization- and return-value-related functions
*/
void
prime_initSeed() {
prime_seed = 0;
}
unsigned int
prime_randomInteger() {
prime_seed = ((prime_seed * 133) + 81) % 8095;
return (prime_seed);
}
void
prime_init() {
prime_initSeed();
prime_x = prime_randomInteger();
prime_y = prime_randomInteger();
}
int
prime_return() {
return prime_result;
}
/*
Algorithm core functions
*/
unsigned char
prime_divides(unsigned int n, unsigned int m) {
return (m % n == 0);
}
unsigned char
prime_even(unsigned int n) {
return (prime_divides(2, n));
}
unsigned char
prime_prime(unsigned int n) {
unsigned int i;
if (prime_even(n))
return (n == 2);
__pragma_loopbound(0, 16);
for (i = 3; i * i <= n; i += 2) {
if (prime_divides(i, n)) /* ai: loop here min 0 max 357 end; */
return 0;
}
return (n > 1);
}
void
prime_swap(unsigned int *a, unsigned int *b) {
unsigned int tmp = *a;
*a = *b;
*b = tmp;
}
/*
Main functions
*/
__attribute__((noinline)) __attribute__((export_name("entrypoint"))) void
prime_main() {
prime_swap(&prime_x, &prime_y);
prime_result = !(!prime_prime(prime_x) && !prime_prime(prime_y));
}
__attribute__((noinline)) __attribute__((export_name("main"))) int
main(void) {
prime_init();
prime_main();
return (prime_return());
}

View File

@ -0,0 +1,142 @@
/*
This program is part of the TACLeBench benchmark suite.
Version V 2.0
Name: prime
Author: unknown
Function: prime calculates whether numbers are prime.
Source: MRTC
http://www.mrtc.mdh.se/projects/wcet/wcet_bench/prime/prime.c
Changes: no major functional changes
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 unsigned char
prime_divides(unsigned int n, unsigned int m);
__attribute__((always_inline)) static inline unsigned char
prime_even(unsigned int n);
__attribute__((always_inline)) static inline unsigned char
prime_prime(unsigned int n);
__attribute__((always_inline)) static inline void prime_swap(unsigned int *a,
unsigned int *b);
__attribute__((always_inline)) static inline unsigned int prime_randomInteger();
__attribute__((always_inline)) static inline void prime_initSeed();
__attribute__((always_inline)) static inline void prime_init();
__attribute__((always_inline)) static inline int prime_return();
__attribute__((noinline)) __attribute__((export_name("entrypoint")))
__attribute__((noinline)) __attribute__((export_name("entrypoint"))) void
prime_main();
__attribute__((noinline)) __attribute__((export_name("main")))
__attribute__((noinline)) __attribute__((export_name("main"))) int
main(void);
/*
Declaration of global variables
*/
unsigned int prime_x;
unsigned int prime_y;
int prime_result;
volatile int prime_seed;
/*
Initialization- and return-value-related functions
*/
__attribute__((always_inline)) static inline void
prime_initSeed() {
prime_seed = 0;
}
__attribute__((always_inline)) static inline unsigned int
prime_randomInteger() {
prime_seed = ((prime_seed * 133) + 81) % 8095;
return (prime_seed);
}
__attribute__((always_inline)) static inline void
prime_init() {
prime_initSeed();
prime_x = prime_randomInteger();
prime_y = prime_randomInteger();
}
__attribute__((always_inline)) static inline int
prime_return() {
return prime_result;
}
/*
Algorithm core functions
*/
__attribute__((always_inline)) static inline unsigned char
prime_divides(unsigned int n, unsigned int m) {
return (m % n == 0);
}
__attribute__((always_inline)) static inline unsigned char
prime_even(unsigned int n) {
return (prime_divides(2, n));
}
__attribute__((always_inline)) static inline unsigned char
prime_prime(unsigned int n) {
unsigned int i;
if (prime_even(n))
return (n == 2);
__pragma_loopbound(0, 16);
for (i = 3; i * i <= n; i += 2) {
if (prime_divides(i, n)) /* ai: loop here min 0 max 357 end; */
return 0;
}
return (n > 1);
}
__attribute__((always_inline)) static inline void
prime_swap(unsigned int *a, unsigned int *b) {
unsigned int tmp = *a;
*a = *b;
*b = tmp;
}
/*
Main functions
*/
__attribute__((noinline)) __attribute__((export_name("entrypoint")))
__attribute__((noinline)) __attribute__((export_name("entrypoint"))) void
prime_main() {
prime_swap(&prime_x, &prime_y);
prime_result = !(!prime_prime(prime_x) && !prime_prime(prime_y));
}
__attribute__((noinline)) __attribute__((export_name("main")))
__attribute__((noinline)) __attribute__((export_name("main"))) int
main(void) {
prime_init();
prime_main();
return (prime_return());
}

View File

@ -0,0 +1,139 @@
/*
This program is part of the TACLeBench benchmark suite.
Version V 2.0
Name: prime
Author: unknown
Function: prime calculates whether numbers are prime.
Source: MRTC
http://www.mrtc.mdh.se/projects/wcet/wcet_bench/prime/prime.c
Changes: no major functional changes
License: may be used, modified, and re-distributed freely
*/
/*
Forward declaration of functions
*/
unsigned char prime_divides ( unsigned int n, unsigned int m );
unsigned char prime_even ( unsigned int n );
unsigned char prime_prime ( unsigned int n );
void prime_swap ( unsigned int *a, unsigned int *b );
unsigned int prime_randomInteger();
void prime_initSeed();
void prime_init ();
int prime_return ();
void prime_main ();
int main( void );
/*
Declaration of global variables
*/
unsigned int prime_x;
unsigned int prime_y;
int prime_result;
volatile int prime_seed;
/*
Initialization- and return-value-related functions
*/
void prime_initSeed()
{
prime_seed = 0;
}
unsigned int prime_randomInteger()
{
prime_seed = ( ( prime_seed * 133 ) + 81 ) % 8095;
return ( prime_seed );
}
void prime_init ()
{
prime_initSeed();
prime_x = prime_randomInteger();
prime_y = prime_randomInteger();
}
int prime_return ()
{
return prime_result;
}
/*
Algorithm core functions
*/
unsigned char prime_divides ( unsigned int n, unsigned int m )
{
return ( m % n == 0 );
}
unsigned char prime_even ( unsigned int n )
{
return ( prime_divides ( 2, n ) );
}
unsigned char prime_prime ( unsigned int n )
{
unsigned int i;
if ( prime_even ( n ) )
return ( n == 2 );
_Pragma( "loopbound min 0 max 16" )
for ( i = 3; i * i <= n; i += 2 ) {
if ( prime_divides ( i, n ) ) /* ai: loop here min 0 max 357 end; */
return 0;
}
return ( n > 1 );
}
void prime_swap ( unsigned int *a, unsigned int *b )
{
unsigned int tmp = *a;
*a = *b;
*b = tmp;
}
/*
Main functions
*/
void _Pragma( "entrypoint" ) prime_main()
{
prime_swap ( &prime_x, &prime_y );
prime_result = !( !prime_prime( prime_x ) && !prime_prime( prime_y ) );
}
int main( void )
{
prime_init();
prime_main();
return ( prime_return() ) ;
}