Add wasm tacle-bench targets
This commit is contained in:
25
targets/wasm-tacle/test/duff/CMakeLists.txt
Normal file
25
targets/wasm-tacle/test/duff/CMakeLists.txt
Normal 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(duff)
|
||||
|
||||
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/duff.c")
|
||||
else()
|
||||
set(APP_SOURCE_FILE_PATH
|
||||
"generated/modified_sources/default/duff.c")
|
||||
endif()
|
||||
|
||||
include(${REPOSITORY_ROOT_PATH}/cmake/taclebench_wasm.cmake)
|
||||
|
||||
|
||||
40
targets/wasm-tacle/test/duff/changeLog.txt
Executable file
40
targets/wasm-tacle/test/duff/changeLog.txt
Executable file
@ -0,0 +1,40 @@
|
||||
File: duff.c
|
||||
Original provenience: Mälardalen benchmark suite,
|
||||
ww.mrtc.mdh.se/projects/wcet/wcet_bench/duff/duff.c
|
||||
|
||||
|
||||
2015-12-21:
|
||||
- Susbstituted #define ARRAYSIZE 100
|
||||
- Susbstituted #define INVOCATION_COUNT 43
|
||||
- Renamed each function FUNC to duff_FUNC
|
||||
- Changed the order of parameters in the functio call
|
||||
duff_copy( duff_target, duff_source, 43 ). Original version was not working.
|
||||
- Added functions duff_init, duff_return and main
|
||||
- Added forward declarations of all functions before the declarations of global
|
||||
variables
|
||||
- Used duff_target[0] as the return value
|
||||
- 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
|
||||
133
targets/wasm-tacle/test/duff/duff.c
Executable file
133
targets/wasm-tacle/test/duff/duff.c
Executable file
@ -0,0 +1,133 @@
|
||||
/*
|
||||
|
||||
This program is part of the TACLeBench benchmark suite.
|
||||
Version V 2.0
|
||||
|
||||
Name: duff
|
||||
|
||||
Author: Jakob Engblom
|
||||
|
||||
Function: Duff's device
|
||||
|
||||
Source: MRTC
|
||||
http://www.mrtc.mdh.se/projects/wcet/wcet_bench/duff/duff.c
|
||||
|
||||
Changes: no major functional changes
|
||||
|
||||
License: may be used, modified, and re-distributed freely
|
||||
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
Forward declaration of functions
|
||||
*/
|
||||
|
||||
void duff_copy( char *to, char *from, int count );
|
||||
void duff_initialize( char *arr, int length );
|
||||
void duff_init();
|
||||
void duff_main( void );
|
||||
int duff_return( void );
|
||||
int main( void );
|
||||
|
||||
|
||||
/*
|
||||
Declaration of global variables
|
||||
*/
|
||||
|
||||
char duff_source[ 100 ];
|
||||
char duff_target[ 100 ];
|
||||
|
||||
|
||||
/*
|
||||
Initialization- and return-value-related functions
|
||||
*/
|
||||
|
||||
void duff_init()
|
||||
{
|
||||
unsigned int i;
|
||||
unsigned char *p;
|
||||
volatile char bitmask = 0;
|
||||
|
||||
duff_initialize( duff_source, 100 );
|
||||
|
||||
/*
|
||||
Apply volatile XOR-bitmask to entire input array.
|
||||
*/
|
||||
p = ( unsigned char * ) &duff_source[ 0 ];
|
||||
_Pragma( "loopbound min 400 max 400" )
|
||||
for ( i = 0; i < sizeof( duff_source ); ++i, ++p )
|
||||
*p ^= bitmask;
|
||||
}
|
||||
|
||||
|
||||
int duff_return( void )
|
||||
{
|
||||
return ( duff_target[ 28 ] - 72 != 0 );
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
Algorithm core functions
|
||||
*/
|
||||
|
||||
void duff_initialize( char *arr, int length )
|
||||
{
|
||||
int i;
|
||||
|
||||
_Pragma( "loopbound min 100 max 100" )
|
||||
for ( i = 0; i < length; i++ )
|
||||
arr[ i ] = length - i;
|
||||
}
|
||||
|
||||
|
||||
void duff_copy( char *to, char *from, int count )
|
||||
{
|
||||
int n = ( count + 7 ) / 8;
|
||||
|
||||
_Pragma( "marker outside" )
|
||||
switch ( count % 8 ) {
|
||||
case 0:
|
||||
do {
|
||||
*to++ = *from++;
|
||||
case 7:
|
||||
*to++ = *from++;
|
||||
case 6:
|
||||
*to++ = *from++;
|
||||
case 5:
|
||||
*to++ = *from++;
|
||||
case 4:
|
||||
*to++ = *from++;
|
||||
case 3:
|
||||
*to++ = *from++;
|
||||
case 2:
|
||||
*to++ = *from++;
|
||||
case 1:
|
||||
_Pragma( "marker inside" )
|
||||
*to++ = *from++;
|
||||
|
||||
|
||||
} while ( --n > 0 );
|
||||
}
|
||||
_Pragma( "flowrestriction 1*inside <= 6*outside" )
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
Main functions
|
||||
*/
|
||||
|
||||
void _Pragma( "entrypoint" ) duff_main( void )
|
||||
{
|
||||
duff_copy( duff_target, duff_source, 43 );
|
||||
}
|
||||
|
||||
|
||||
int main( void )
|
||||
{
|
||||
duff_init();
|
||||
duff_main();
|
||||
|
||||
return ( duff_return() );
|
||||
}
|
||||
|
||||
BIN
targets/wasm-tacle/test/duff/generated/default/duff.wasm
Executable file
BIN
targets/wasm-tacle/test/duff/generated/default/duff.wasm
Executable file
Binary file not shown.
172
targets/wasm-tacle/test/duff/generated/default/duff.wat
Normal file
172
targets/wasm-tacle/test/duff/generated/default/duff.wat
Normal file
@ -0,0 +1,172 @@
|
||||
(module $duff.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 $duff_main (type 1)
|
||||
i32.const 0
|
||||
i32.const 0
|
||||
i32.load8_u offset=1024
|
||||
i32.store8 offset=1136
|
||||
i32.const 0
|
||||
i32.const 0
|
||||
i32.load offset=1025 align=1
|
||||
i32.store offset=1137 align=1
|
||||
i32.const 0
|
||||
i32.const 0
|
||||
i64.load offset=1029 align=1
|
||||
i64.store offset=1141 align=1
|
||||
i32.const 0
|
||||
i32.const 0
|
||||
i64.load offset=1037 align=1
|
||||
i64.store offset=1149 align=1
|
||||
i32.const 0
|
||||
i32.const 0
|
||||
i64.load offset=1045 align=1
|
||||
i64.store offset=1157 align=1
|
||||
i32.const 0
|
||||
i32.const 0
|
||||
i64.load offset=1053 align=1
|
||||
i64.store offset=1165 align=1
|
||||
i32.const 0
|
||||
i32.const 0
|
||||
i32.load offset=1061 align=1
|
||||
i32.store offset=1173 align=1
|
||||
i32.const 0
|
||||
i32.const 0
|
||||
i32.load16_u offset=1065 align=1
|
||||
i32.store16 offset=1177 align=1)
|
||||
(func $__original_main (type 2) (result i32)
|
||||
(local i32 i32 i32)
|
||||
global.get $__stack_pointer
|
||||
i32.const 16
|
||||
i32.sub
|
||||
local.tee 0
|
||||
global.set $__stack_pointer
|
||||
i32.const 0
|
||||
local.set 1
|
||||
local.get 0
|
||||
i32.const 0
|
||||
i32.store8 offset=15
|
||||
i32.const 100
|
||||
i32.const 100
|
||||
call $__pragma_loopbound
|
||||
loop ;; label = @1
|
||||
local.get 1
|
||||
i32.const 1028
|
||||
i32.add
|
||||
i32.const 96
|
||||
local.get 1
|
||||
i32.sub
|
||||
i32.store8
|
||||
local.get 1
|
||||
i32.const 1027
|
||||
i32.add
|
||||
i32.const 97
|
||||
local.get 1
|
||||
i32.sub
|
||||
i32.store8
|
||||
local.get 1
|
||||
i32.const 1026
|
||||
i32.add
|
||||
i32.const 98
|
||||
local.get 1
|
||||
i32.sub
|
||||
i32.store8
|
||||
local.get 1
|
||||
i32.const 1025
|
||||
i32.add
|
||||
i32.const 99
|
||||
local.get 1
|
||||
i32.sub
|
||||
i32.store8
|
||||
local.get 1
|
||||
i32.const 1024
|
||||
i32.add
|
||||
i32.const 100
|
||||
local.get 1
|
||||
i32.sub
|
||||
i32.store8
|
||||
local.get 1
|
||||
i32.const 5
|
||||
i32.add
|
||||
local.tee 1
|
||||
i32.const 100
|
||||
i32.ne
|
||||
br_if 0 (;@1;)
|
||||
end
|
||||
i32.const 400
|
||||
i32.const 400
|
||||
call $__pragma_loopbound
|
||||
i32.const -100
|
||||
local.set 1
|
||||
loop ;; label = @1
|
||||
local.get 1
|
||||
i32.const 1124
|
||||
i32.add
|
||||
local.tee 2
|
||||
local.get 2
|
||||
i32.load8_u
|
||||
local.get 0
|
||||
i32.load8_u offset=15
|
||||
i32.xor
|
||||
i32.store8
|
||||
local.get 1
|
||||
i32.const 1125
|
||||
i32.add
|
||||
local.tee 2
|
||||
local.get 2
|
||||
i32.load8_u
|
||||
local.get 0
|
||||
i32.load8_u offset=15
|
||||
i32.xor
|
||||
i32.store8
|
||||
local.get 1
|
||||
i32.const 1126
|
||||
i32.add
|
||||
local.tee 2
|
||||
local.get 2
|
||||
i32.load8_u
|
||||
local.get 0
|
||||
i32.load8_u offset=15
|
||||
i32.xor
|
||||
i32.store8
|
||||
local.get 1
|
||||
i32.const 1127
|
||||
i32.add
|
||||
local.tee 2
|
||||
local.get 2
|
||||
i32.load8_u
|
||||
local.get 0
|
||||
i32.load8_u offset=15
|
||||
i32.xor
|
||||
i32.store8
|
||||
local.get 1
|
||||
i32.const 4
|
||||
i32.add
|
||||
local.tee 1
|
||||
br_if 0 (;@1;)
|
||||
end
|
||||
call $duff_main
|
||||
i32.const 0
|
||||
i32.load8_u offset=1164
|
||||
local.set 1
|
||||
local.get 0
|
||||
i32.const 16
|
||||
i32.add
|
||||
global.set $__stack_pointer
|
||||
local.get 1
|
||||
i32.const 72
|
||||
i32.ne)
|
||||
(table (;0;) 1 1 funcref)
|
||||
(memory (;0;) 1)
|
||||
(global $__stack_pointer (mut i32) (i32.const 5344))
|
||||
(global (;1;) i32 (i32.const 1236))
|
||||
(global (;2;) i32 (i32.const 5344))
|
||||
(export "memory" (memory 0))
|
||||
(export "__wasm_apply_data_relocs" (func $__wasm_apply_data_relocs))
|
||||
(export "entrypoint" (func $duff_main))
|
||||
(export "main" (func $__original_main))
|
||||
(export "__data_end" (global 1))
|
||||
(export "__heap_base" (global 2)))
|
||||
@ -0,0 +1,127 @@
|
||||
/*
|
||||
|
||||
This program is part of the TACLeBench benchmark suite.
|
||||
Version V 2.0
|
||||
|
||||
Name: duff
|
||||
|
||||
Author: Jakob Engblom
|
||||
|
||||
Function: Duff's device
|
||||
|
||||
Source: MRTC
|
||||
http://www.mrtc.mdh.se/projects/wcet/wcet_bench/duff/duff.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);
|
||||
|
||||
void duff_copy(char *to, char *from, int count);
|
||||
void duff_initialize(char *arr, int length);
|
||||
void duff_init();
|
||||
__attribute__((noinline)) __attribute__((export_name("entrypoint"))) void
|
||||
duff_main(void);
|
||||
int duff_return(void);
|
||||
__attribute__((noinline)) __attribute__((export_name("main"))) int main(void);
|
||||
|
||||
/*
|
||||
Declaration of global variables
|
||||
*/
|
||||
|
||||
char duff_source[100];
|
||||
char duff_target[100];
|
||||
|
||||
/*
|
||||
Initialization- and return-value-related functions
|
||||
*/
|
||||
|
||||
void
|
||||
duff_init() {
|
||||
unsigned int i;
|
||||
unsigned char *p;
|
||||
volatile char bitmask = 0;
|
||||
|
||||
duff_initialize(duff_source, 100);
|
||||
|
||||
/*
|
||||
Apply volatile XOR-bitmask to entire input array.
|
||||
*/
|
||||
p = (unsigned char *) &duff_source[0];
|
||||
__pragma_loopbound(400, 400);
|
||||
for (i = 0; i < sizeof(duff_source); ++i, ++p)
|
||||
*p ^= bitmask;
|
||||
}
|
||||
|
||||
int
|
||||
duff_return(void) {
|
||||
return (duff_target[28] - 72 != 0);
|
||||
}
|
||||
|
||||
/*
|
||||
Algorithm core functions
|
||||
*/
|
||||
|
||||
void
|
||||
duff_initialize(char *arr, int length) {
|
||||
int i;
|
||||
|
||||
__pragma_loopbound(100, 100);
|
||||
for (i = 0; i < length; i++)
|
||||
arr[i] = length - i;
|
||||
}
|
||||
|
||||
void
|
||||
duff_copy(char *to, char *from, int count) {
|
||||
int n = (count + 7) / 8;
|
||||
|
||||
_Pragma("marker outside") switch (count % 8) {
|
||||
case 0:
|
||||
do {
|
||||
*to++ = *from++;
|
||||
case 7:
|
||||
*to++ = *from++;
|
||||
case 6:
|
||||
*to++ = *from++;
|
||||
case 5:
|
||||
*to++ = *from++;
|
||||
case 4:
|
||||
*to++ = *from++;
|
||||
case 3:
|
||||
*to++ = *from++;
|
||||
case 2:
|
||||
*to++ = *from++;
|
||||
case 1:
|
||||
_Pragma("marker inside") *to++ = *from++;
|
||||
|
||||
} while (--n > 0);
|
||||
}
|
||||
_Pragma("flowrestriction 1*inside <= 6*outside")
|
||||
}
|
||||
|
||||
/*
|
||||
Main functions
|
||||
*/
|
||||
|
||||
__attribute__((noinline)) __attribute__((export_name("entrypoint"))) void
|
||||
duff_main(void) {
|
||||
duff_copy(duff_target, duff_source, 43);
|
||||
}
|
||||
|
||||
__attribute__((noinline)) __attribute__((export_name("main"))) int
|
||||
main(void) {
|
||||
duff_init();
|
||||
duff_main();
|
||||
|
||||
return (duff_return());
|
||||
}
|
||||
@ -0,0 +1,137 @@
|
||||
/*
|
||||
|
||||
This program is part of the TACLeBench benchmark suite.
|
||||
Version V 2.0
|
||||
|
||||
Name: duff
|
||||
|
||||
Author: Jakob Engblom
|
||||
|
||||
Function: Duff's device
|
||||
|
||||
Source: MRTC
|
||||
http://www.mrtc.mdh.se/projects/wcet/wcet_bench/duff/duff.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 void
|
||||
duff_copy(char *to, char *from, int count);
|
||||
__attribute__((always_inline)) static inline void duff_initialize(char *arr,
|
||||
int length);
|
||||
__attribute__((always_inline)) static inline void duff_init();
|
||||
__attribute__((noinline)) __attribute__((export_name("entrypoint")))
|
||||
__attribute__((noinline)) __attribute__((export_name("entrypoint"))) void
|
||||
duff_main(void);
|
||||
__attribute__((always_inline)) static inline int duff_return(void);
|
||||
__attribute__((noinline)) __attribute__((export_name("main")))
|
||||
__attribute__((noinline)) __attribute__((export_name("main"))) int
|
||||
main(void);
|
||||
|
||||
/*
|
||||
Declaration of global variables
|
||||
*/
|
||||
|
||||
char duff_source[100];
|
||||
char duff_target[100];
|
||||
|
||||
/*
|
||||
Initialization- and return-value-related functions
|
||||
*/
|
||||
|
||||
__attribute__((always_inline)) static inline void
|
||||
duff_init() {
|
||||
unsigned int i;
|
||||
unsigned char *p;
|
||||
volatile char bitmask = 0;
|
||||
|
||||
duff_initialize(duff_source, 100);
|
||||
|
||||
/*
|
||||
Apply volatile XOR-bitmask to entire input array.
|
||||
*/
|
||||
p = (unsigned char *) &duff_source[0];
|
||||
__pragma_loopbound(400, 400);
|
||||
for (i = 0; i < sizeof(duff_source); ++i, ++p)
|
||||
*p ^= bitmask;
|
||||
}
|
||||
|
||||
__attribute__((always_inline)) static inline int
|
||||
duff_return(void) {
|
||||
return (duff_target[28] - 72 != 0);
|
||||
}
|
||||
|
||||
/*
|
||||
Algorithm core functions
|
||||
*/
|
||||
|
||||
__attribute__((always_inline)) static inline void
|
||||
duff_initialize(char *arr, int length) {
|
||||
int i;
|
||||
|
||||
__pragma_loopbound(100, 100);
|
||||
for (i = 0; i < length; i++)
|
||||
arr[i] = length - i;
|
||||
}
|
||||
|
||||
__attribute__((always_inline)) static inline void
|
||||
duff_copy(char *to, char *from, int count) {
|
||||
int n = (count + 7) / 8;
|
||||
|
||||
_Pragma("marker outside") switch (count % 8) {
|
||||
case 0:
|
||||
do {
|
||||
*to++ = *from++;
|
||||
case 7:
|
||||
*to++ = *from++;
|
||||
case 6:
|
||||
*to++ = *from++;
|
||||
case 5:
|
||||
*to++ = *from++;
|
||||
case 4:
|
||||
*to++ = *from++;
|
||||
case 3:
|
||||
*to++ = *from++;
|
||||
case 2:
|
||||
*to++ = *from++;
|
||||
case 1:
|
||||
_Pragma("marker inside") *to++ = *from++;
|
||||
|
||||
} while (--n > 0);
|
||||
}
|
||||
_Pragma("flowrestriction 1*inside <= 6*outside")
|
||||
}
|
||||
|
||||
/*
|
||||
Main functions
|
||||
*/
|
||||
|
||||
__attribute__((noinline)) __attribute__((export_name("entrypoint")))
|
||||
__attribute__((noinline)) __attribute__((export_name("entrypoint"))) void
|
||||
duff_main(void) {
|
||||
duff_copy(duff_target, duff_source, 43);
|
||||
}
|
||||
|
||||
__attribute__((noinline)) __attribute__((export_name("main")))
|
||||
__attribute__((noinline)) __attribute__((export_name("main"))) int
|
||||
main(void) {
|
||||
duff_init();
|
||||
duff_main();
|
||||
|
||||
return (duff_return());
|
||||
}
|
||||
Reference in New Issue
Block a user