Add wasm tacle-bench targets
This commit is contained in:
25
targets/wasm-tacle/kernel/insertsort/CMakeLists.txt
Normal file
25
targets/wasm-tacle/kernel/insertsort/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(insertsort)
|
||||
|
||||
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/insertsort.c")
|
||||
else()
|
||||
set(APP_SOURCE_FILE_PATH
|
||||
"generated/modified_sources/default/insertsort.c")
|
||||
endif()
|
||||
|
||||
include(${REPOSITORY_ROOT_PATH}/cmake/taclebench_wasm.cmake)
|
||||
|
||||
|
||||
10
targets/wasm-tacle/kernel/insertsort/ChangeLog.txt
Executable file
10
targets/wasm-tacle/kernel/insertsort/ChangeLog.txt
Executable file
@ -0,0 +1,10 @@
|
||||
- Added general TACLeBench header to beginning of source code
|
||||
- Removed #ifdef DEBUG till #endif
|
||||
- Declaration of global variable unsigned int a[11] changed the variable name to insertion_a[11] as well as for iters_i, min_i, max_i, iters_a, min_a, max_a;
|
||||
- Created insertsort_initialize(), insertsort_init() and insertsort_return();
|
||||
- Removed all PROFILINGs
|
||||
- Made i volatile for the initialization of the data array
|
||||
- Added a checksum in the return function
|
||||
|
||||
|
||||
|
||||
BIN
targets/wasm-tacle/kernel/insertsort/generated/default/insertsort.wasm
Executable file
BIN
targets/wasm-tacle/kernel/insertsort/generated/default/insertsort.wasm
Executable file
Binary file not shown.
@ -0,0 +1,280 @@
|
||||
(module $insertsort.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 $insertsort_main (type 1)
|
||||
(local i32 i32 i32 i32 i32 i32)
|
||||
i32.const 0
|
||||
i32.const 0
|
||||
i32.store offset=1116
|
||||
i32.const 9
|
||||
i32.const 9
|
||||
call $__pragma_loopbound
|
||||
i32.const 1072
|
||||
local.set 0
|
||||
i32.const 2
|
||||
local.set 1
|
||||
loop ;; label = @1
|
||||
i32.const 0
|
||||
i32.const 0
|
||||
i32.load offset=1116
|
||||
i32.const 1
|
||||
i32.add
|
||||
i32.store offset=1116
|
||||
i32.const 0
|
||||
i32.const 0
|
||||
i32.store offset=1128
|
||||
i32.const 1
|
||||
i32.const 9
|
||||
call $__pragma_loopbound
|
||||
i32.const 0
|
||||
i32.load offset=1128
|
||||
local.set 2
|
||||
block ;; label = @2
|
||||
local.get 1
|
||||
i32.const 2
|
||||
i32.shl
|
||||
local.tee 3
|
||||
i32.const 1072
|
||||
i32.add
|
||||
i32.load
|
||||
local.tee 4
|
||||
local.get 3
|
||||
i32.const 1068
|
||||
i32.add
|
||||
i32.load
|
||||
local.tee 5
|
||||
i32.ge_u
|
||||
br_if 0 (;@2;)
|
||||
local.get 0
|
||||
local.set 3
|
||||
loop ;; label = @3
|
||||
local.get 3
|
||||
i32.const 4
|
||||
i32.add
|
||||
local.get 4
|
||||
i32.store
|
||||
local.get 3
|
||||
i32.const 8
|
||||
i32.add
|
||||
local.get 5
|
||||
i32.store
|
||||
local.get 2
|
||||
i32.const 1
|
||||
i32.add
|
||||
local.set 2
|
||||
local.get 3
|
||||
i32.load
|
||||
local.set 5
|
||||
local.get 3
|
||||
i32.const -4
|
||||
i32.add
|
||||
local.set 3
|
||||
local.get 4
|
||||
local.get 5
|
||||
i32.lt_u
|
||||
br_if 0 (;@3;)
|
||||
end
|
||||
i32.const 0
|
||||
local.get 2
|
||||
i32.store offset=1128
|
||||
end
|
||||
block ;; label = @2
|
||||
local.get 2
|
||||
i32.const 0
|
||||
i32.load offset=1132
|
||||
i32.ge_s
|
||||
br_if 0 (;@2;)
|
||||
i32.const 0
|
||||
local.get 2
|
||||
i32.store offset=1132
|
||||
end
|
||||
block ;; label = @2
|
||||
local.get 2
|
||||
i32.const 0
|
||||
i32.load offset=1136
|
||||
i32.le_s
|
||||
br_if 0 (;@2;)
|
||||
i32.const 0
|
||||
local.get 2
|
||||
i32.store offset=1136
|
||||
end
|
||||
local.get 0
|
||||
i32.const 4
|
||||
i32.add
|
||||
local.set 0
|
||||
local.get 1
|
||||
i32.const 1
|
||||
i32.add
|
||||
local.tee 1
|
||||
i32.const 11
|
||||
i32.ne
|
||||
br_if 0 (;@1;)
|
||||
end
|
||||
block ;; label = @1
|
||||
i32.const 0
|
||||
i32.load offset=1116
|
||||
local.tee 3
|
||||
i32.const 0
|
||||
i32.load offset=1120
|
||||
i32.ge_s
|
||||
br_if 0 (;@1;)
|
||||
i32.const 0
|
||||
local.get 3
|
||||
i32.store offset=1120
|
||||
end
|
||||
block ;; label = @1
|
||||
local.get 3
|
||||
i32.const 0
|
||||
i32.load offset=1124
|
||||
i32.le_s
|
||||
br_if 0 (;@1;)
|
||||
i32.const 0
|
||||
local.get 3
|
||||
i32.store offset=1124
|
||||
end)
|
||||
(func $__original_main (type 2) (result i32)
|
||||
(local i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32)
|
||||
global.get $__stack_pointer
|
||||
i32.const 16
|
||||
i32.sub
|
||||
local.tee 0
|
||||
global.set $__stack_pointer
|
||||
i32.const 0
|
||||
i32.const 100000
|
||||
i32.store offset=1120
|
||||
i32.const 0
|
||||
i32.const 100000
|
||||
i32.store offset=1132
|
||||
i32.const 0
|
||||
i32.const 0
|
||||
i32.store offset=1116
|
||||
i32.const 0
|
||||
i32.const 0
|
||||
i32.store offset=1124
|
||||
i32.const 0
|
||||
i32.const 0
|
||||
i32.store offset=1128
|
||||
i32.const 0
|
||||
i32.const 0
|
||||
i32.store offset=1136
|
||||
i32.const 11
|
||||
i32.const 11
|
||||
call $__pragma_loopbound
|
||||
local.get 0
|
||||
i32.const 0
|
||||
i32.store offset=12
|
||||
block ;; label = @1
|
||||
local.get 0
|
||||
i32.load offset=12
|
||||
i32.const 10
|
||||
i32.gt_s
|
||||
br_if 0 (;@1;)
|
||||
loop ;; label = @2
|
||||
local.get 0
|
||||
i32.load offset=12
|
||||
local.set 1
|
||||
local.get 0
|
||||
i32.load offset=12
|
||||
i32.const 2
|
||||
i32.shl
|
||||
i32.const 1072
|
||||
i32.add
|
||||
local.get 1
|
||||
i32.const 2
|
||||
i32.shl
|
||||
i32.const 1024
|
||||
i32.add
|
||||
i32.load
|
||||
i32.store
|
||||
local.get 0
|
||||
local.get 0
|
||||
i32.load offset=12
|
||||
i32.const 1
|
||||
i32.add
|
||||
i32.store offset=12
|
||||
local.get 0
|
||||
i32.load offset=12
|
||||
i32.const 11
|
||||
i32.lt_s
|
||||
br_if 0 (;@2;)
|
||||
end
|
||||
end
|
||||
call $insertsort_main
|
||||
i32.const 11
|
||||
i32.const 11
|
||||
call $__pragma_loopbound
|
||||
i32.const 0
|
||||
i32.load offset=1072
|
||||
local.set 1
|
||||
i32.const 0
|
||||
i32.load offset=1076
|
||||
local.set 2
|
||||
i32.const 0
|
||||
i32.load offset=1080
|
||||
local.set 3
|
||||
i32.const 0
|
||||
i32.load offset=1084
|
||||
local.set 4
|
||||
i32.const 0
|
||||
i32.load offset=1088
|
||||
local.set 5
|
||||
i32.const 0
|
||||
i32.load offset=1092
|
||||
local.set 6
|
||||
i32.const 0
|
||||
i32.load offset=1096
|
||||
local.set 7
|
||||
i32.const 0
|
||||
i32.load offset=1100
|
||||
local.set 8
|
||||
i32.const 0
|
||||
i32.load offset=1104
|
||||
local.set 9
|
||||
i32.const 0
|
||||
i32.load offset=1108
|
||||
local.set 10
|
||||
i32.const 0
|
||||
i32.load offset=1112
|
||||
local.set 11
|
||||
local.get 0
|
||||
i32.const 16
|
||||
i32.add
|
||||
global.set $__stack_pointer
|
||||
local.get 11
|
||||
local.get 10
|
||||
local.get 9
|
||||
local.get 8
|
||||
local.get 7
|
||||
local.get 6
|
||||
local.get 5
|
||||
local.get 4
|
||||
local.get 3
|
||||
local.get 2
|
||||
local.get 1
|
||||
i32.add
|
||||
i32.add
|
||||
i32.add
|
||||
i32.add
|
||||
i32.add
|
||||
i32.add
|
||||
i32.add
|
||||
i32.add
|
||||
i32.add
|
||||
i32.add
|
||||
i32.const 65
|
||||
i32.ne)
|
||||
(table (;0;) 1 1 funcref)
|
||||
(memory (;0;) 1)
|
||||
(global $__stack_pointer (mut i32) (i32.const 5248))
|
||||
(global (;1;) i32 (i32.const 1140))
|
||||
(global (;2;) i32 (i32.const 5248))
|
||||
(export "memory" (memory 0))
|
||||
(export "__wasm_apply_data_relocs" (func $__wasm_apply_data_relocs))
|
||||
(export "entrypoint" (func $insertsort_main))
|
||||
(export "main" (func $__original_main))
|
||||
(export "__data_end" (global 1))
|
||||
(export "__heap_base" (global 2))
|
||||
(data $.rodata (i32.const 1024) "\00\00\00\00\0b\00\00\00\0a\00\00\00\09\00\00\00\08\00\00\00\07\00\00\00\06\00\00\00\05\00\00\00\04\00\00\00\03\00\00\00\02\00\00\00"))
|
||||
@ -0,0 +1,140 @@
|
||||
/*
|
||||
|
||||
This program is part of the TACLeBench benchmark suite.
|
||||
Version V 1.x
|
||||
|
||||
Name: insertsort
|
||||
|
||||
Author: Sung-Soo Lim
|
||||
|
||||
Function: Insertion sort for 10 integer numbers.
|
||||
The integer array insertsort_a[ ] is initialized in main function.
|
||||
Input-data dependent nested loop with worst-case of
|
||||
(n^2)/2 iterations (triangular loop).
|
||||
|
||||
Source: MRTC
|
||||
http://www.mrtc.mdh.se/projects/wcet/wcet_bench/insertsort/insertsort.c
|
||||
|
||||
Changes: a brief summary of major functional changes (not formatting)
|
||||
|
||||
License: may be used, modified, and re-distributed freely, but
|
||||
the SNU-RT Benchmark Suite must be acknowledged
|
||||
|
||||
*/
|
||||
|
||||
/*
|
||||
This program is derived from the SNU-RT Benchmark Suite for Worst
|
||||
Case Timing Analysis by Sung-Soo Lim
|
||||
*/
|
||||
|
||||
/*
|
||||
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 insertsort_initialize(unsigned int *array);
|
||||
void insertsort_init(void);
|
||||
int insertsort_return(void);
|
||||
__attribute__((noinline)) __attribute__((export_name("entrypoint"))) void
|
||||
insertsort_main(void);
|
||||
__attribute__((noinline)) __attribute__((export_name("main"))) int main(void);
|
||||
|
||||
/*
|
||||
Declaration of global variables
|
||||
*/
|
||||
unsigned int insertsort_a[11];
|
||||
int insertsort_iters_i, insertsort_min_i, insertsort_max_i;
|
||||
int insertsort_iters_a, insertsort_min_a, insertsort_max_a;
|
||||
|
||||
/*
|
||||
Initialization- and return-value-related functions
|
||||
*/
|
||||
|
||||
void
|
||||
insertsort_initialize(unsigned int *array) {
|
||||
|
||||
register volatile int i;
|
||||
__pragma_loopbound(11, 11);
|
||||
for (i = 0; i < 11; i++)
|
||||
insertsort_a[i] = array[i];
|
||||
}
|
||||
|
||||
void
|
||||
insertsort_init() {
|
||||
unsigned int a[11] = {0, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2};
|
||||
|
||||
insertsort_iters_i = 0;
|
||||
insertsort_min_i = 100000;
|
||||
insertsort_max_i = 0;
|
||||
insertsort_iters_a = 0;
|
||||
insertsort_min_a = 100000;
|
||||
insertsort_max_a = 0;
|
||||
|
||||
insertsort_initialize(a);
|
||||
}
|
||||
|
||||
int
|
||||
insertsort_return() {
|
||||
int i, returnValue = 0;
|
||||
|
||||
__pragma_loopbound(11, 11);
|
||||
for (i = 0; i < 11; i++)
|
||||
returnValue += insertsort_a[i];
|
||||
|
||||
return (returnValue + (-65)) != 0;
|
||||
}
|
||||
|
||||
/*
|
||||
Main functions
|
||||
*/
|
||||
|
||||
__attribute__((noinline)) __attribute__((export_name("entrypoint"))) void
|
||||
insertsort_main() {
|
||||
int i, j, temp;
|
||||
i = 2;
|
||||
|
||||
insertsort_iters_i = 0;
|
||||
|
||||
__pragma_loopbound(9, 9);
|
||||
while (i <= 10) {
|
||||
|
||||
insertsort_iters_i++;
|
||||
|
||||
j = i;
|
||||
|
||||
insertsort_iters_a = 0;
|
||||
|
||||
__pragma_loopbound(1, 9);
|
||||
while (insertsort_a[j] < insertsort_a[j - 1]) {
|
||||
insertsort_iters_a++;
|
||||
|
||||
temp = insertsort_a[j];
|
||||
insertsort_a[j] = insertsort_a[j - 1];
|
||||
insertsort_a[j - 1] = temp;
|
||||
j--;
|
||||
}
|
||||
|
||||
if (insertsort_iters_a < insertsort_min_a)
|
||||
insertsort_min_a = insertsort_iters_a;
|
||||
if (insertsort_iters_a > insertsort_max_a)
|
||||
insertsort_max_a = insertsort_iters_a;
|
||||
|
||||
i++;
|
||||
}
|
||||
|
||||
if (insertsort_iters_i < insertsort_min_i)
|
||||
insertsort_min_i = insertsort_iters_i;
|
||||
if (insertsort_iters_i > insertsort_max_i)
|
||||
insertsort_max_i = insertsort_iters_i;
|
||||
}
|
||||
|
||||
__attribute__((noinline)) __attribute__((export_name("main"))) int
|
||||
main(void) {
|
||||
insertsort_init();
|
||||
insertsort_main();
|
||||
return (insertsort_return());
|
||||
}
|
||||
@ -0,0 +1,149 @@
|
||||
/*
|
||||
|
||||
This program is part of the TACLeBench benchmark suite.
|
||||
Version V 1.x
|
||||
|
||||
Name: insertsort
|
||||
|
||||
Author: Sung-Soo Lim
|
||||
|
||||
Function: Insertion sort for 10 integer numbers.
|
||||
The integer array insertsort_a[ ] is initialized in main function.
|
||||
Input-data dependent nested loop with worst-case of
|
||||
(n^2)/2 iterations (triangular loop).
|
||||
|
||||
Source: MRTC
|
||||
http://www.mrtc.mdh.se/projects/wcet/wcet_bench/insertsort/insertsort.c
|
||||
|
||||
Changes: a brief summary of major functional changes (not formatting)
|
||||
|
||||
License: may be used, modified, and re-distributed freely, but
|
||||
the SNU-RT Benchmark Suite must be acknowledged
|
||||
|
||||
*/
|
||||
|
||||
/*
|
||||
This program is derived from the SNU-RT Benchmark Suite for Worst
|
||||
Case Timing Analysis by Sung-Soo Lim
|
||||
*/
|
||||
|
||||
/*
|
||||
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
|
||||
insertsort_initialize(unsigned int *array);
|
||||
__attribute__((always_inline)) static inline void insertsort_init(void);
|
||||
__attribute__((always_inline)) static inline int insertsort_return(void);
|
||||
__attribute__((noinline)) __attribute__((export_name("entrypoint")))
|
||||
__attribute__((noinline)) __attribute__((export_name("entrypoint"))) void
|
||||
insertsort_main(void);
|
||||
__attribute__((noinline)) __attribute__((export_name("main")))
|
||||
__attribute__((noinline)) __attribute__((export_name("main"))) int
|
||||
main(void);
|
||||
|
||||
/*
|
||||
Declaration of global variables
|
||||
*/
|
||||
unsigned int insertsort_a[11];
|
||||
int insertsort_iters_i, insertsort_min_i, insertsort_max_i;
|
||||
int insertsort_iters_a, insertsort_min_a, insertsort_max_a;
|
||||
|
||||
/*
|
||||
Initialization- and return-value-related functions
|
||||
*/
|
||||
|
||||
__attribute__((always_inline)) static inline void
|
||||
insertsort_initialize(unsigned int *array) {
|
||||
|
||||
register volatile int i;
|
||||
__pragma_loopbound(11, 11);
|
||||
for (i = 0; i < 11; i++)
|
||||
insertsort_a[i] = array[i];
|
||||
}
|
||||
|
||||
__attribute__((always_inline)) static inline void
|
||||
insertsort_init() {
|
||||
unsigned int a[11] = {0, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2};
|
||||
|
||||
insertsort_iters_i = 0;
|
||||
insertsort_min_i = 100000;
|
||||
insertsort_max_i = 0;
|
||||
insertsort_iters_a = 0;
|
||||
insertsort_min_a = 100000;
|
||||
insertsort_max_a = 0;
|
||||
|
||||
insertsort_initialize(a);
|
||||
}
|
||||
|
||||
__attribute__((always_inline)) static inline int
|
||||
insertsort_return() {
|
||||
int i, returnValue = 0;
|
||||
|
||||
__pragma_loopbound(11, 11);
|
||||
for (i = 0; i < 11; i++)
|
||||
returnValue += insertsort_a[i];
|
||||
|
||||
return (returnValue + (-65)) != 0;
|
||||
}
|
||||
|
||||
/*
|
||||
Main functions
|
||||
*/
|
||||
|
||||
__attribute__((noinline)) __attribute__((export_name("entrypoint")))
|
||||
__attribute__((noinline)) __attribute__((export_name("entrypoint"))) void
|
||||
insertsort_main() {
|
||||
int i, j, temp;
|
||||
i = 2;
|
||||
|
||||
insertsort_iters_i = 0;
|
||||
|
||||
__pragma_loopbound(9, 9);
|
||||
while (i <= 10) {
|
||||
|
||||
insertsort_iters_i++;
|
||||
|
||||
j = i;
|
||||
|
||||
insertsort_iters_a = 0;
|
||||
|
||||
__pragma_loopbound(1, 9);
|
||||
while (insertsort_a[j] < insertsort_a[j - 1]) {
|
||||
insertsort_iters_a++;
|
||||
|
||||
temp = insertsort_a[j];
|
||||
insertsort_a[j] = insertsort_a[j - 1];
|
||||
insertsort_a[j - 1] = temp;
|
||||
j--;
|
||||
}
|
||||
|
||||
if (insertsort_iters_a < insertsort_min_a)
|
||||
insertsort_min_a = insertsort_iters_a;
|
||||
if (insertsort_iters_a > insertsort_max_a)
|
||||
insertsort_max_a = insertsort_iters_a;
|
||||
|
||||
i++;
|
||||
}
|
||||
|
||||
if (insertsort_iters_i < insertsort_min_i)
|
||||
insertsort_min_i = insertsort_iters_i;
|
||||
if (insertsort_iters_i > insertsort_max_i)
|
||||
insertsort_max_i = insertsort_iters_i;
|
||||
}
|
||||
|
||||
__attribute__((noinline)) __attribute__((export_name("main")))
|
||||
__attribute__((noinline)) __attribute__((export_name("main"))) int
|
||||
main(void) {
|
||||
insertsort_init();
|
||||
insertsort_main();
|
||||
return (insertsort_return());
|
||||
}
|
||||
139
targets/wasm-tacle/kernel/insertsort/insertsort.c
Executable file
139
targets/wasm-tacle/kernel/insertsort/insertsort.c
Executable file
@ -0,0 +1,139 @@
|
||||
/*
|
||||
|
||||
This program is part of the TACLeBench benchmark suite.
|
||||
Version V 1.x
|
||||
|
||||
Name: insertsort
|
||||
|
||||
Author: Sung-Soo Lim
|
||||
|
||||
Function: Insertion sort for 10 integer numbers.
|
||||
The integer array insertsort_a[ ] is initialized in main function.
|
||||
Input-data dependent nested loop with worst-case of
|
||||
(n^2)/2 iterations (triangular loop).
|
||||
|
||||
Source: MRTC
|
||||
http://www.mrtc.mdh.se/projects/wcet/wcet_bench/insertsort/insertsort.c
|
||||
|
||||
Changes: a brief summary of major functional changes (not formatting)
|
||||
|
||||
License: may be used, modified, and re-distributed freely, but
|
||||
the SNU-RT Benchmark Suite must be acknowledged
|
||||
|
||||
*/
|
||||
|
||||
/*
|
||||
This program is derived from the SNU-RT Benchmark Suite for Worst
|
||||
Case Timing Analysis by Sung-Soo Lim
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
Forward declaration of functions
|
||||
*/
|
||||
void insertsort_initialize( unsigned int *array );
|
||||
void insertsort_init( void );
|
||||
int insertsort_return( void );
|
||||
void insertsort_main( void );
|
||||
int main( void );
|
||||
|
||||
/*
|
||||
Declaration of global variables
|
||||
*/
|
||||
unsigned int insertsort_a[ 11 ];
|
||||
int insertsort_iters_i, insertsort_min_i, insertsort_max_i;
|
||||
int insertsort_iters_a, insertsort_min_a, insertsort_max_a;
|
||||
|
||||
/*
|
||||
Initialization- and return-value-related functions
|
||||
*/
|
||||
|
||||
void insertsort_initialize( unsigned int *array )
|
||||
{
|
||||
|
||||
register volatile int i;
|
||||
_Pragma( "loopbound min 11 max 11" )
|
||||
for ( i = 0; i < 11; i++ )
|
||||
insertsort_a[ i ] = array[ i ];
|
||||
|
||||
}
|
||||
|
||||
|
||||
void insertsort_init()
|
||||
{
|
||||
unsigned int a[ 11 ] = {0, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2};
|
||||
|
||||
insertsort_iters_i = 0;
|
||||
insertsort_min_i = 100000;
|
||||
insertsort_max_i = 0;
|
||||
insertsort_iters_a = 0;
|
||||
insertsort_min_a = 100000;
|
||||
insertsort_max_a = 0;
|
||||
|
||||
insertsort_initialize( a );
|
||||
}
|
||||
|
||||
int insertsort_return()
|
||||
{
|
||||
int i, returnValue = 0;
|
||||
|
||||
_Pragma( "loopbound min 11 max 11" )
|
||||
for ( i = 0; i < 11; i++ )
|
||||
returnValue += insertsort_a[ i ];
|
||||
|
||||
return ( returnValue + ( -65 ) ) != 0;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
Main functions
|
||||
*/
|
||||
|
||||
|
||||
void _Pragma( "entrypoint" ) insertsort_main()
|
||||
{
|
||||
int i, j, temp;
|
||||
i = 2;
|
||||
|
||||
insertsort_iters_i = 0;
|
||||
|
||||
_Pragma( "loopbound min 9 max 9" )
|
||||
while ( i <= 10 ) {
|
||||
|
||||
insertsort_iters_i++;
|
||||
|
||||
j = i;
|
||||
|
||||
insertsort_iters_a = 0;
|
||||
|
||||
_Pragma( "loopbound min 1 max 9" )
|
||||
while ( insertsort_a[ j ] < insertsort_a[ j - 1 ] ) {
|
||||
insertsort_iters_a++;
|
||||
|
||||
temp = insertsort_a[ j ];
|
||||
insertsort_a[ j ] = insertsort_a[ j - 1 ];
|
||||
insertsort_a[ j - 1 ] = temp;
|
||||
j--;
|
||||
}
|
||||
|
||||
if ( insertsort_iters_a < insertsort_min_a )
|
||||
insertsort_min_a = insertsort_iters_a;
|
||||
if ( insertsort_iters_a > insertsort_max_a )
|
||||
insertsort_max_a = insertsort_iters_a;
|
||||
|
||||
i++;
|
||||
}
|
||||
|
||||
if ( insertsort_iters_i < insertsort_min_i )
|
||||
insertsort_min_i = insertsort_iters_i;
|
||||
if ( insertsort_iters_i > insertsort_max_i )
|
||||
insertsort_max_i = insertsort_iters_i;
|
||||
}
|
||||
|
||||
int main( void )
|
||||
{
|
||||
insertsort_init();
|
||||
insertsort_main();
|
||||
return ( insertsort_return() );
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user