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

View File

@ -0,0 +1,29 @@
File: countnegative.c
Original provenience: Mälardalen benchmark suite, www.mrtc.....
2015-11-26:
- Changed return type of InitSeed, Initialize, and Test to void
because the result was ignored anyway
- Prefixed all functions and global variables with "countnegative_"
- Added new function countnegative_return computing a checksum as
return value
- Separated initialization (called from countnegative_init) from
actual computation (called from countnegative_main), remove
pointless function countnegative_test afterwards
- Reordered functions in source code: initialization- and
return-value-related functions first, followed by algorithm core
function, followed by main functions
- Eliminated definition of macro WORSTCASE and kept only the relevant
part of the related #ifdef block
- Removed comments that referred to MAXSIZE being 100 (instead of 20)
- Made countnegative_seed volatile
- Changed C++ style comments to C style comments
- Applied code formatting with astyle as in the example
- Added general TACLeBench header to beginning of source code
2016-03-15:
- Return 0 if checksum is as expected, -1 otherwise
- Add entrypoint pragma
2016-04-20:
- Cast "expected" return value to int for comparison

View File

@ -0,0 +1,140 @@
/*
This program is part of the TACLeBench benchmark suite.
Version V 2.0
Name: countnegative
Author: unknown
Function: Counts negative and non-negative numbers in a
matrix. Features nested loops, well-structured code.
Source: MRTC
http://www.mrtc.mdh.se/projects/wcet/wcet_bench/cnt/cnt.c
Changes: Changed split between initialization and computation
License: May be used, modified, and re-distributed freely
*/
/*
The dimension of the matrix
*/
#define MAXSIZE 20
/*
Type definition for the matrix
*/
typedef int matrix [ MAXSIZE ][ MAXSIZE ];
/*
Forward declaration of functions
*/
void countnegative_initSeed( void );
int countnegative_randomInteger( void );
void countnegative_initialize( matrix );
void countnegative_init( void );
int countnegative_return( void );
void countnegative_sum( matrix );
void countnegative_main( void );
int main( void );
/*
Globals
*/
volatile int countnegative_seed;
matrix countnegative_array;
int countnegative_postotal, countnegative_negtotal;
int countnegative_poscnt, countnegative_negcnt;
/*
Initializes the seed used in the random number generator.
*/
void countnegative_initSeed ( void )
{
countnegative_seed = 0;
}
/*
Generates random integers between 0 and 8094
*/
int countnegative_randomInteger( void )
{
countnegative_seed = ( ( countnegative_seed * 133 ) + 81 ) % 8095;
return countnegative_seed;
}
/*
Initializes the given array with random integers.
*/
void countnegative_initialize( matrix Array )
{
register int OuterIndex, InnerIndex;
_Pragma( "loopbound min 20 max 20" )
for ( OuterIndex = 0; OuterIndex < MAXSIZE; OuterIndex++ )
_Pragma( "loopbound min 20 max 20" )
for ( InnerIndex = 0; InnerIndex < MAXSIZE; InnerIndex++ )
Array[ OuterIndex ][ InnerIndex ] = countnegative_randomInteger();
}
void countnegative_init( void )
{
countnegative_initSeed();
countnegative_initialize( countnegative_array );
}
int countnegative_return( void )
{
int checksum = ( countnegative_postotal +
countnegative_poscnt +
countnegative_negtotal +
countnegative_negcnt );
return ( ( checksum == ( int )0x1778de ) ? 0 : -1 );
}
void countnegative_sum( matrix Array )
{
register int Outer, Inner;
int Ptotal = 0; /* changed these to locals in order to drive worst case */
int Ntotal = 0;
int Pcnt = 0;
int Ncnt = 0;
_Pragma( "loopbound min 20 max 20" )
for ( Outer = 0; Outer < MAXSIZE; Outer++ )
_Pragma( "loopbound min 20 max 20" )
for ( Inner = 0; Inner < MAXSIZE; Inner++ )
if ( Array[ Outer ][ Inner ] >= 0 ) {
Ptotal += Array[ Outer ][ Inner ];
Pcnt++;
} else {
Ntotal += Array[ Outer ][ Inner ];
Ncnt++;
}
countnegative_postotal = Ptotal;
countnegative_poscnt = Pcnt;
countnegative_negtotal = Ntotal;
countnegative_negcnt = Ncnt;
}
/*
The main function
*/
void _Pragma( "entrypoint" ) countnegative_main ( void )
{
countnegative_sum( countnegative_array );
}
int main( void )
{
countnegative_init();
countnegative_main();
return ( countnegative_return() );
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,147 @@
/*
This program is part of the TACLeBench benchmark suite.
Version V 2.0
Name: countnegative
Author: unknown
Function: Counts negative and non-negative numbers in a
matrix. Features nested loops, well-structured code.
Source: MRTC
http://www.mrtc.mdh.se/projects/wcet/wcet_bench/cnt/cnt.c
Changes: Changed split between initialization and computation
License: May be used, modified, and re-distributed freely
*/
/*
The dimension of the matrix
*/
// Wasm loop bounds
__attribute__((import_module("__pragma"), import_name("loopbound"))) extern void
__pragma_loopbound(unsigned int min_bound, unsigned int max_bound);
#define MAXSIZE 20
/*
Type definition for the matrix
*/
typedef int matrix[MAXSIZE][MAXSIZE];
/*
Forward declaration of functions
*/
void countnegative_initSeed(void);
int countnegative_randomInteger(void);
void countnegative_initialize(matrix);
void countnegative_init(void);
int countnegative_return(void);
void countnegative_sum(matrix);
__attribute__((noinline)) __attribute__((export_name("entrypoint"))) void
countnegative_main(void);
__attribute__((noinline)) __attribute__((export_name("main"))) int main(void);
/*
Globals
*/
volatile int countnegative_seed;
matrix countnegative_array;
int countnegative_postotal, countnegative_negtotal;
int countnegative_poscnt, countnegative_negcnt;
/*
Initializes the seed used in the random number generator.
*/
void
countnegative_initSeed(void) {
countnegative_seed = 0;
}
/*
Generates random integers between 0 and 8094
*/
int
countnegative_randomInteger(void) {
countnegative_seed = ((countnegative_seed * 133) + 81) % 8095;
return countnegative_seed;
}
/*
Initializes the given array with random integers.
*/
void
countnegative_initialize(matrix Array) {
register int OuterIndex, InnerIndex;
__pragma_loopbound(20, 20);
for (OuterIndex = 0; OuterIndex < MAXSIZE; OuterIndex++)
__pragma_loopbound(20, 20);
for (InnerIndex = 0; InnerIndex < MAXSIZE; InnerIndex++)
Array[OuterIndex][InnerIndex] = countnegative_randomInteger();
}
void
countnegative_init(void) {
countnegative_initSeed();
countnegative_initialize(countnegative_array);
}
int
countnegative_return(void) {
int checksum = (countnegative_postotal + countnegative_poscnt +
countnegative_negtotal + countnegative_negcnt);
return ((checksum == (int) 0x1778de) ? 0 : -1);
}
void
countnegative_sum(matrix Array) {
register int Outer, Inner;
int Ptotal = 0; /* changed these to locals in order to drive worst case */
int Ntotal = 0;
int Pcnt = 0;
int Ncnt = 0;
__pragma_loopbound(20, 20);
for (Outer = 0; Outer < MAXSIZE; Outer++)
_Pragma(
"loopbound min 20 max 20") for (Inner = 0; Inner < MAXSIZE;
Inner++) if (Array[Outer][Inner] >=
0) {
Ptotal += Array[Outer][Inner];
Pcnt++;
}
else {
Ntotal += Array[Outer][Inner];
Ncnt++;
}
countnegative_postotal = Ptotal;
countnegative_poscnt = Pcnt;
countnegative_negtotal = Ntotal;
countnegative_negcnt = Ncnt;
}
/*
The main function
*/
__attribute__((noinline)) __attribute__((export_name("entrypoint"))) void
countnegative_main(void) {
countnegative_sum(countnegative_array);
}
__attribute__((noinline)) __attribute__((export_name("main"))) int
main(void) {
countnegative_init();
countnegative_main();
return (countnegative_return());
}

View File

@ -0,0 +1,157 @@
/*
This program is part of the TACLeBench benchmark suite.
Version V 2.0
Name: countnegative
Author: unknown
Function: Counts negative and non-negative numbers in a
matrix. Features nested loops, well-structured code.
Source: MRTC
http://www.mrtc.mdh.se/projects/wcet/wcet_bench/cnt/cnt.c
Changes: Changed split between initialization and computation
License: May be used, modified, and re-distributed freely
*/
/*
The dimension of the matrix
*/
// Wasm loop bounds
__attribute__((import_module("__pragma"), import_name("loopbound"))) extern void
__pragma_loopbound(unsigned int min_bound, unsigned int max_bound);
#define MAXSIZE 20
/*
Type definition for the matrix
*/
typedef int matrix[MAXSIZE][MAXSIZE];
/*
Forward declaration of functions
*/
__attribute__((always_inline)) static inline void countnegative_initSeed(void);
__attribute__((always_inline)) static inline int
countnegative_randomInteger(void);
__attribute__((always_inline)) static inline void
countnegative_initialize(matrix);
__attribute__((always_inline)) static inline void countnegative_init(void);
__attribute__((always_inline)) static inline int countnegative_return(void);
__attribute__((always_inline)) static inline void countnegative_sum(matrix);
__attribute__((noinline)) __attribute__((export_name("entrypoint")))
__attribute__((noinline)) __attribute__((export_name("entrypoint"))) void
countnegative_main(void);
__attribute__((noinline)) __attribute__((export_name("main")))
__attribute__((noinline)) __attribute__((export_name("main"))) int
main(void);
/*
Globals
*/
volatile int countnegative_seed;
matrix countnegative_array;
int countnegative_postotal, countnegative_negtotal;
int countnegative_poscnt, countnegative_negcnt;
/*
Initializes the seed used in the random number generator.
*/
__attribute__((always_inline)) static inline void
countnegative_initSeed(void) {
countnegative_seed = 0;
}
/*
Generates random integers between 0 and 8094
*/
__attribute__((always_inline)) static inline int
countnegative_randomInteger(void) {
countnegative_seed = ((countnegative_seed * 133) + 81) % 8095;
return countnegative_seed;
}
/*
Initializes the given array with random integers.
*/
__attribute__((always_inline)) static inline void
countnegative_initialize(matrix Array) {
register int OuterIndex, InnerIndex;
__pragma_loopbound(20, 20);
for (OuterIndex = 0; OuterIndex < MAXSIZE; OuterIndex++)
__pragma_loopbound(20, 20);
for (InnerIndex = 0; InnerIndex < MAXSIZE; InnerIndex++)
Array[OuterIndex][InnerIndex] = countnegative_randomInteger();
}
__attribute__((always_inline)) static inline void
countnegative_init(void) {
countnegative_initSeed();
countnegative_initialize(countnegative_array);
}
__attribute__((always_inline)) static inline int
countnegative_return(void) {
int checksum = (countnegative_postotal + countnegative_poscnt +
countnegative_negtotal + countnegative_negcnt);
return ((checksum == (int) 0x1778de) ? 0 : -1);
}
__attribute__((always_inline)) static inline void
countnegative_sum(matrix Array) {
register int Outer, Inner;
int Ptotal = 0; /* changed these to locals in order to drive worst case */
int Ntotal = 0;
int Pcnt = 0;
int Ncnt = 0;
__pragma_loopbound(20, 20);
for (Outer = 0; Outer < MAXSIZE; Outer++)
_Pragma(
"loopbound min 20 max 20") for (Inner = 0; Inner < MAXSIZE;
Inner++) if (Array[Outer][Inner] >=
0) {
Ptotal += Array[Outer][Inner];
Pcnt++;
}
else {
Ntotal += Array[Outer][Inner];
Ncnt++;
}
countnegative_postotal = Ptotal;
countnegative_poscnt = Pcnt;
countnegative_negtotal = Ntotal;
countnegative_negcnt = Ncnt;
}
/*
The main function
*/
__attribute__((noinline)) __attribute__((export_name("entrypoint")))
__attribute__((noinline)) __attribute__((export_name("entrypoint"))) void
countnegative_main(void) {
countnegative_sum(countnegative_array);
}
__attribute__((noinline)) __attribute__((export_name("main")))
__attribute__((noinline)) __attribute__((export_name("main"))) int
main(void) {
countnegative_init();
countnegative_main();
return (countnegative_return());
}