Add wasm tacle-bench targets
This commit is contained in:
BIN
targets/wasm-tacle/kernel/st/generated/default/st.wasm
Executable file
BIN
targets/wasm-tacle/kernel/st/generated/default/st.wasm
Executable file
Binary file not shown.
754
targets/wasm-tacle/kernel/st/generated/default/st.wat
Normal file
754
targets/wasm-tacle/kernel/st/generated/default/st.wat
Normal file
@ -0,0 +1,754 @@
|
||||
(module $st.wasm
|
||||
(type (;0;) (func (param i32 i32)))
|
||||
(type (;1;) (func))
|
||||
(type (;2;) (func (param i32 i32 f32 f32 i32)))
|
||||
(type (;3;) (func (result i32)))
|
||||
(import "__pragma" "loopbound" (func $__pragma_loopbound (type 0)))
|
||||
(func $__wasm_apply_data_relocs (type 1))
|
||||
(func $st_calc_LinCorrCoef (type 2) (param i32 i32 f32 f32 i32)
|
||||
(local f32 i32 f32 f32 i32 f32 i32 f32 f32 f32)
|
||||
i32.const 1000
|
||||
i32.const 1000
|
||||
call $__pragma_loopbound
|
||||
f32.const 0x0p+0 (;=0;)
|
||||
local.set 5
|
||||
i32.const 0
|
||||
local.set 6
|
||||
f32.const 0x0p+0 (;=0;)
|
||||
local.set 7
|
||||
f32.const 0x0p+0 (;=0;)
|
||||
local.set 8
|
||||
loop ;; label = @1
|
||||
local.get 0
|
||||
local.get 6
|
||||
i32.add
|
||||
local.tee 9
|
||||
i32.const 4
|
||||
i32.add
|
||||
f32.load
|
||||
local.get 2
|
||||
f32.sub
|
||||
local.tee 10
|
||||
local.get 1
|
||||
local.get 6
|
||||
i32.add
|
||||
local.tee 11
|
||||
i32.const 4
|
||||
i32.add
|
||||
f32.load
|
||||
local.get 3
|
||||
f32.sub
|
||||
local.tee 12
|
||||
f32.mul
|
||||
local.get 9
|
||||
f32.load
|
||||
local.get 2
|
||||
f32.sub
|
||||
local.tee 13
|
||||
local.get 11
|
||||
f32.load
|
||||
local.get 3
|
||||
f32.sub
|
||||
local.tee 14
|
||||
f32.mul
|
||||
local.get 8
|
||||
f32.add
|
||||
f32.add
|
||||
local.set 8
|
||||
local.get 5
|
||||
local.get 14
|
||||
local.get 14
|
||||
f32.mul
|
||||
f32.add
|
||||
local.get 12
|
||||
local.get 12
|
||||
f32.mul
|
||||
f32.add
|
||||
local.set 5
|
||||
local.get 7
|
||||
local.get 13
|
||||
local.get 13
|
||||
f32.mul
|
||||
f32.add
|
||||
local.get 10
|
||||
local.get 10
|
||||
f32.mul
|
||||
f32.add
|
||||
local.set 7
|
||||
local.get 6
|
||||
i32.const 8
|
||||
i32.add
|
||||
local.tee 6
|
||||
i32.const 4000
|
||||
i32.ne
|
||||
br_if 0 (;@1;)
|
||||
end
|
||||
f32.const 0x0p+0 (;=0;)
|
||||
local.set 10
|
||||
f32.const 0x0p+0 (;=0;)
|
||||
local.set 12
|
||||
block ;; label = @1
|
||||
local.get 7
|
||||
f32.const 0x0p+0 (;=0;)
|
||||
f32.eq
|
||||
br_if 0 (;@1;)
|
||||
i32.const 19
|
||||
local.set 9
|
||||
i32.const 19
|
||||
i32.const 19
|
||||
call $__pragma_loopbound
|
||||
local.get 7
|
||||
f32.const 0x1.4p+3 (;=10;)
|
||||
f32.div
|
||||
local.set 12
|
||||
i32.const 0
|
||||
local.set 6
|
||||
loop ;; label = @2
|
||||
block ;; label = @3
|
||||
block ;; label = @4
|
||||
local.get 6
|
||||
br_if 0 (;@4;)
|
||||
i32.const 0
|
||||
local.set 6
|
||||
local.get 7
|
||||
local.get 12
|
||||
local.get 7
|
||||
local.get 12
|
||||
local.get 12
|
||||
f32.mul
|
||||
f32.sub
|
||||
local.get 12
|
||||
local.get 12
|
||||
f32.add
|
||||
f32.div
|
||||
f32.add
|
||||
local.tee 12
|
||||
local.get 12
|
||||
f32.mul
|
||||
f32.sub
|
||||
local.tee 13
|
||||
local.get 13
|
||||
f32.neg
|
||||
local.get 13
|
||||
f32.const 0x0p+0 (;=0;)
|
||||
f32.ge
|
||||
select
|
||||
f32.const 0x1.4f8b58p-17 (;=1e-05;)
|
||||
f32.le
|
||||
i32.eqz
|
||||
br_if 1 (;@3;)
|
||||
end
|
||||
i32.const 1
|
||||
local.set 6
|
||||
end
|
||||
local.get 9
|
||||
i32.const -1
|
||||
i32.add
|
||||
local.tee 9
|
||||
br_if 0 (;@2;)
|
||||
end
|
||||
end
|
||||
block ;; label = @1
|
||||
local.get 5
|
||||
f32.const 0x0p+0 (;=0;)
|
||||
f32.eq
|
||||
br_if 0 (;@1;)
|
||||
i32.const 19
|
||||
local.set 9
|
||||
i32.const 19
|
||||
i32.const 19
|
||||
call $__pragma_loopbound
|
||||
local.get 5
|
||||
f32.const 0x1.4p+3 (;=10;)
|
||||
f32.div
|
||||
local.set 10
|
||||
i32.const 0
|
||||
local.set 6
|
||||
loop ;; label = @2
|
||||
block ;; label = @3
|
||||
block ;; label = @4
|
||||
local.get 6
|
||||
br_if 0 (;@4;)
|
||||
i32.const 0
|
||||
local.set 6
|
||||
local.get 5
|
||||
local.get 10
|
||||
local.get 5
|
||||
local.get 10
|
||||
local.get 10
|
||||
f32.mul
|
||||
f32.sub
|
||||
local.get 10
|
||||
local.get 10
|
||||
f32.add
|
||||
f32.div
|
||||
f32.add
|
||||
local.tee 10
|
||||
local.get 10
|
||||
f32.mul
|
||||
f32.sub
|
||||
local.tee 13
|
||||
local.get 13
|
||||
f32.neg
|
||||
local.get 13
|
||||
f32.const 0x0p+0 (;=0;)
|
||||
f32.ge
|
||||
select
|
||||
f32.const 0x1.4f8b58p-17 (;=1e-05;)
|
||||
f32.le
|
||||
i32.eqz
|
||||
br_if 1 (;@3;)
|
||||
end
|
||||
i32.const 1
|
||||
local.set 6
|
||||
end
|
||||
local.get 9
|
||||
i32.const -1
|
||||
i32.add
|
||||
local.tee 9
|
||||
br_if 0 (;@2;)
|
||||
end
|
||||
end
|
||||
local.get 4
|
||||
local.get 8
|
||||
local.get 12
|
||||
local.get 10
|
||||
f32.mul
|
||||
f32.div
|
||||
f32.store)
|
||||
(func $st_main (type 1)
|
||||
(local f32 i32 f32 f32 i32)
|
||||
i32.const 0
|
||||
i32.const 0
|
||||
i32.store offset=9060
|
||||
i32.const 1000
|
||||
i32.const 1000
|
||||
call $__pragma_loopbound
|
||||
i32.const 0
|
||||
f32.load offset=9060
|
||||
local.set 0
|
||||
i32.const -4000
|
||||
local.set 1
|
||||
loop ;; label = @1
|
||||
local.get 0
|
||||
local.get 1
|
||||
i32.const 5040
|
||||
i32.add
|
||||
f32.load
|
||||
f32.add
|
||||
local.get 1
|
||||
i32.const 5044
|
||||
i32.add
|
||||
f32.load
|
||||
f32.add
|
||||
local.get 1
|
||||
i32.const 5048
|
||||
i32.add
|
||||
f32.load
|
||||
f32.add
|
||||
local.get 1
|
||||
i32.const 5052
|
||||
i32.add
|
||||
f32.load
|
||||
f32.add
|
||||
local.get 1
|
||||
i32.const 5056
|
||||
i32.add
|
||||
f32.load
|
||||
f32.add
|
||||
local.set 0
|
||||
local.get 1
|
||||
i32.const 20
|
||||
i32.add
|
||||
local.tee 1
|
||||
br_if 0 (;@1;)
|
||||
end
|
||||
i32.const 0
|
||||
local.get 0
|
||||
f32.store offset=9060
|
||||
i32.const 0
|
||||
local.get 0
|
||||
f32.const 0x1.f4p+9 (;=1000;)
|
||||
f32.div
|
||||
local.tee 0
|
||||
f32.store offset=9040
|
||||
i32.const 1000
|
||||
i32.const 1000
|
||||
call $__pragma_loopbound
|
||||
f32.const 0x0p+0 (;=0;)
|
||||
local.set 2
|
||||
i32.const -4000
|
||||
local.set 1
|
||||
loop ;; label = @1
|
||||
local.get 2
|
||||
local.get 1
|
||||
i32.const 5040
|
||||
i32.add
|
||||
f32.load
|
||||
local.get 0
|
||||
f32.sub
|
||||
local.tee 3
|
||||
local.get 3
|
||||
f32.mul
|
||||
f32.add
|
||||
local.get 1
|
||||
i32.const 5044
|
||||
i32.add
|
||||
f32.load
|
||||
local.get 0
|
||||
f32.sub
|
||||
local.tee 2
|
||||
local.get 2
|
||||
f32.mul
|
||||
f32.add
|
||||
local.get 1
|
||||
i32.const 5048
|
||||
i32.add
|
||||
f32.load
|
||||
local.get 0
|
||||
f32.sub
|
||||
local.tee 2
|
||||
local.get 2
|
||||
f32.mul
|
||||
f32.add
|
||||
local.get 1
|
||||
i32.const 5052
|
||||
i32.add
|
||||
f32.load
|
||||
local.get 0
|
||||
f32.sub
|
||||
local.tee 2
|
||||
local.get 2
|
||||
f32.mul
|
||||
f32.add
|
||||
local.set 2
|
||||
local.get 1
|
||||
i32.const 16
|
||||
i32.add
|
||||
local.tee 1
|
||||
br_if 0 (;@1;)
|
||||
end
|
||||
i32.const 0
|
||||
local.set 1
|
||||
i32.const 0
|
||||
local.get 2
|
||||
f32.const 0x1.f4p+9 (;=1000;)
|
||||
f32.div
|
||||
local.tee 3
|
||||
f32.store offset=9064
|
||||
f32.const 0x0p+0 (;=0;)
|
||||
local.set 0
|
||||
block ;; label = @1
|
||||
local.get 3
|
||||
f32.const 0x0p+0 (;=0;)
|
||||
f32.eq
|
||||
br_if 0 (;@1;)
|
||||
i32.const 19
|
||||
local.set 4
|
||||
i32.const 19
|
||||
i32.const 19
|
||||
call $__pragma_loopbound
|
||||
local.get 3
|
||||
f32.const 0x1.4p+3 (;=10;)
|
||||
f32.div
|
||||
local.set 0
|
||||
loop ;; label = @2
|
||||
block ;; label = @3
|
||||
block ;; label = @4
|
||||
local.get 1
|
||||
br_if 0 (;@4;)
|
||||
i32.const 0
|
||||
local.set 1
|
||||
local.get 3
|
||||
local.get 0
|
||||
local.get 3
|
||||
local.get 0
|
||||
local.get 0
|
||||
f32.mul
|
||||
f32.sub
|
||||
local.get 0
|
||||
local.get 0
|
||||
f32.add
|
||||
f32.div
|
||||
f32.add
|
||||
local.tee 0
|
||||
local.get 0
|
||||
f32.mul
|
||||
f32.sub
|
||||
local.tee 2
|
||||
local.get 2
|
||||
f32.neg
|
||||
local.get 2
|
||||
f32.const 0x0p+0 (;=0;)
|
||||
f32.ge
|
||||
select
|
||||
f32.const 0x1.4f8b58p-17 (;=1e-05;)
|
||||
f32.le
|
||||
i32.eqz
|
||||
br_if 1 (;@3;)
|
||||
end
|
||||
i32.const 1
|
||||
local.set 1
|
||||
end
|
||||
local.get 4
|
||||
i32.const -1
|
||||
i32.add
|
||||
local.tee 4
|
||||
br_if 0 (;@2;)
|
||||
end
|
||||
end
|
||||
i32.const 0
|
||||
local.get 0
|
||||
f32.store offset=9048
|
||||
i32.const 0
|
||||
i32.const 0
|
||||
i32.store offset=9068
|
||||
i32.const 1000
|
||||
i32.const 1000
|
||||
call $__pragma_loopbound
|
||||
i32.const 0
|
||||
f32.load offset=9068
|
||||
local.set 0
|
||||
i32.const -4000
|
||||
local.set 1
|
||||
loop ;; label = @1
|
||||
local.get 0
|
||||
local.get 1
|
||||
i32.const 9040
|
||||
i32.add
|
||||
f32.load
|
||||
f32.add
|
||||
local.get 1
|
||||
i32.const 9044
|
||||
i32.add
|
||||
f32.load
|
||||
f32.add
|
||||
local.get 1
|
||||
i32.const 9048
|
||||
i32.add
|
||||
f32.load
|
||||
f32.add
|
||||
local.get 1
|
||||
i32.const 9052
|
||||
i32.add
|
||||
f32.load
|
||||
f32.add
|
||||
local.get 1
|
||||
i32.const 9056
|
||||
i32.add
|
||||
f32.load
|
||||
f32.add
|
||||
local.set 0
|
||||
local.get 1
|
||||
i32.const 20
|
||||
i32.add
|
||||
local.tee 1
|
||||
br_if 0 (;@1;)
|
||||
end
|
||||
i32.const 0
|
||||
local.get 0
|
||||
f32.store offset=9068
|
||||
i32.const 0
|
||||
local.get 0
|
||||
f32.const 0x1.f4p+9 (;=1000;)
|
||||
f32.div
|
||||
local.tee 0
|
||||
f32.store offset=9044
|
||||
i32.const 1000
|
||||
i32.const 1000
|
||||
call $__pragma_loopbound
|
||||
f32.const 0x0p+0 (;=0;)
|
||||
local.set 2
|
||||
i32.const -4000
|
||||
local.set 1
|
||||
loop ;; label = @1
|
||||
local.get 2
|
||||
local.get 1
|
||||
i32.const 9040
|
||||
i32.add
|
||||
f32.load
|
||||
local.get 0
|
||||
f32.sub
|
||||
local.tee 3
|
||||
local.get 3
|
||||
f32.mul
|
||||
f32.add
|
||||
local.get 1
|
||||
i32.const 9044
|
||||
i32.add
|
||||
f32.load
|
||||
local.get 0
|
||||
f32.sub
|
||||
local.tee 2
|
||||
local.get 2
|
||||
f32.mul
|
||||
f32.add
|
||||
local.get 1
|
||||
i32.const 9048
|
||||
i32.add
|
||||
f32.load
|
||||
local.get 0
|
||||
f32.sub
|
||||
local.tee 2
|
||||
local.get 2
|
||||
f32.mul
|
||||
f32.add
|
||||
local.get 1
|
||||
i32.const 9052
|
||||
i32.add
|
||||
f32.load
|
||||
local.get 0
|
||||
f32.sub
|
||||
local.tee 2
|
||||
local.get 2
|
||||
f32.mul
|
||||
f32.add
|
||||
local.set 2
|
||||
local.get 1
|
||||
i32.const 16
|
||||
i32.add
|
||||
local.tee 1
|
||||
br_if 0 (;@1;)
|
||||
end
|
||||
i32.const 0
|
||||
local.set 1
|
||||
i32.const 0
|
||||
local.get 2
|
||||
f32.const 0x1.f4p+9 (;=1000;)
|
||||
f32.div
|
||||
local.tee 3
|
||||
f32.store offset=9072
|
||||
f32.const 0x0p+0 (;=0;)
|
||||
local.set 0
|
||||
block ;; label = @1
|
||||
local.get 3
|
||||
f32.const 0x0p+0 (;=0;)
|
||||
f32.eq
|
||||
br_if 0 (;@1;)
|
||||
i32.const 19
|
||||
local.set 4
|
||||
i32.const 19
|
||||
i32.const 19
|
||||
call $__pragma_loopbound
|
||||
local.get 3
|
||||
f32.const 0x1.4p+3 (;=10;)
|
||||
f32.div
|
||||
local.set 0
|
||||
loop ;; label = @2
|
||||
block ;; label = @3
|
||||
block ;; label = @4
|
||||
local.get 1
|
||||
br_if 0 (;@4;)
|
||||
i32.const 0
|
||||
local.set 1
|
||||
local.get 3
|
||||
local.get 0
|
||||
local.get 3
|
||||
local.get 0
|
||||
local.get 0
|
||||
f32.mul
|
||||
f32.sub
|
||||
local.get 0
|
||||
local.get 0
|
||||
f32.add
|
||||
f32.div
|
||||
f32.add
|
||||
local.tee 0
|
||||
local.get 0
|
||||
f32.mul
|
||||
f32.sub
|
||||
local.tee 2
|
||||
local.get 2
|
||||
f32.neg
|
||||
local.get 2
|
||||
f32.const 0x0p+0 (;=0;)
|
||||
f32.ge
|
||||
select
|
||||
f32.const 0x1.4f8b58p-17 (;=1e-05;)
|
||||
f32.le
|
||||
i32.eqz
|
||||
br_if 1 (;@3;)
|
||||
end
|
||||
i32.const 1
|
||||
local.set 1
|
||||
end
|
||||
local.get 4
|
||||
i32.const -1
|
||||
i32.add
|
||||
local.tee 4
|
||||
br_if 0 (;@2;)
|
||||
end
|
||||
end
|
||||
i32.const 0
|
||||
local.get 0
|
||||
f32.store offset=9052
|
||||
i32.const 1040
|
||||
i32.const 5040
|
||||
i32.const 0
|
||||
f32.load offset=9040
|
||||
i32.const 0
|
||||
f32.load offset=9044
|
||||
i32.const 9056
|
||||
call $st_calc_LinCorrCoef)
|
||||
(func $__original_main (type 3) (result i32)
|
||||
(local i32 i32 i32)
|
||||
i32.const 0
|
||||
i32.const 0
|
||||
i32.store offset=1024
|
||||
i32.const 1000
|
||||
i32.const 1000
|
||||
call $__pragma_loopbound
|
||||
i32.const 1
|
||||
local.set 0
|
||||
i32.const 1040
|
||||
local.set 1
|
||||
loop ;; label = @1
|
||||
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 2
|
||||
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
|
||||
local.get 1
|
||||
local.get 0
|
||||
local.get 2
|
||||
i32.add
|
||||
i32.const -1
|
||||
i32.add
|
||||
f32.convert_i32_s
|
||||
f32.store
|
||||
local.get 1
|
||||
i32.const 4
|
||||
i32.add
|
||||
local.get 0
|
||||
i32.const 0
|
||||
i32.load offset=1024
|
||||
i32.add
|
||||
f32.convert_i32_s
|
||||
f32.store
|
||||
local.get 1
|
||||
i32.const 8
|
||||
i32.add
|
||||
local.set 1
|
||||
local.get 0
|
||||
i32.const 2
|
||||
i32.add
|
||||
local.tee 0
|
||||
i32.const 1001
|
||||
i32.ne
|
||||
br_if 0 (;@1;)
|
||||
end
|
||||
i32.const 1000
|
||||
i32.const 1000
|
||||
call $__pragma_loopbound
|
||||
i32.const 1
|
||||
local.set 0
|
||||
i32.const 5040
|
||||
local.set 1
|
||||
loop ;; label = @1
|
||||
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 2
|
||||
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
|
||||
local.get 1
|
||||
local.get 0
|
||||
local.get 2
|
||||
i32.add
|
||||
i32.const -1
|
||||
i32.add
|
||||
f32.convert_i32_s
|
||||
f32.store
|
||||
local.get 1
|
||||
i32.const 4
|
||||
i32.add
|
||||
local.get 0
|
||||
i32.const 0
|
||||
i32.load offset=1024
|
||||
i32.add
|
||||
f32.convert_i32_s
|
||||
f32.store
|
||||
local.get 1
|
||||
i32.const 8
|
||||
i32.add
|
||||
local.set 1
|
||||
local.get 0
|
||||
i32.const 2
|
||||
i32.add
|
||||
local.tee 0
|
||||
i32.const 1001
|
||||
i32.ne
|
||||
br_if 0 (;@1;)
|
||||
end
|
||||
call $st_main
|
||||
i32.const 0
|
||||
i32.const -1
|
||||
i32.const 0
|
||||
f32.load offset=9040
|
||||
i32.const 0
|
||||
f32.load offset=9044
|
||||
f32.add
|
||||
i32.const 0
|
||||
f32.load offset=9048
|
||||
f32.add
|
||||
i32.const 0
|
||||
f32.load offset=9052
|
||||
f32.add
|
||||
i32.const 0
|
||||
f32.load offset=9056
|
||||
f32.add
|
||||
f64.promote_f32
|
||||
f64.const -0x1.abffe3ffef391p+13 (;=-13696;)
|
||||
f64.add
|
||||
f32.demote_f64
|
||||
f32.abs
|
||||
f64.promote_f32
|
||||
f64.const 0x1.0c6f7a0b5ed8dp-20 (;=1e-06;)
|
||||
f64.lt
|
||||
select)
|
||||
(table (;0;) 1 1 funcref)
|
||||
(memory (;0;) 1)
|
||||
(global $__stack_pointer (mut i32) (i32.const 13184))
|
||||
(global (;1;) i32 (i32.const 9076))
|
||||
(global (;2;) i32 (i32.const 13184))
|
||||
(export "memory" (memory 0))
|
||||
(export "__wasm_apply_data_relocs" (func $__wasm_apply_data_relocs))
|
||||
(export "entrypoint" (func $st_main))
|
||||
(export "main" (func $__original_main))
|
||||
(export "__data_end" (global 1))
|
||||
(export "__heap_base" (global 2)))
|
||||
@ -0,0 +1,217 @@
|
||||
/*
|
||||
|
||||
This program is part of the TACLeBench benchmark suite.
|
||||
Version V 2.0
|
||||
|
||||
Name: st
|
||||
|
||||
Author: unknown
|
||||
|
||||
Function: st is a statistics program.
|
||||
This program computes for two arrays of numbers the sum, the mean,
|
||||
the variance, and standard deviation. It then determines the
|
||||
correlation coefficient between the two arrays.
|
||||
|
||||
Source: MRTC
|
||||
http://www.mrtc.mdh.se/projects/wcet/wcet_bench/st/st.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 st_initSeed(void);
|
||||
long st_randomInteger();
|
||||
void st_initialize(float *);
|
||||
void st_init(void);
|
||||
int st_return(void);
|
||||
float st_fabs(float);
|
||||
float st_sqrtf(float);
|
||||
float st_square(float);
|
||||
void st_calc_Sum_Mean(float *, float *, float *);
|
||||
void st_calc_Var_Stddev(float *, float, float *, float *);
|
||||
void st_calc_LinCorrCoef(float *, float *, float, float, float *);
|
||||
__attribute__((noinline)) __attribute__((export_name("entrypoint"))) void
|
||||
st_main(void);
|
||||
__attribute__((noinline)) __attribute__((export_name("main"))) int main(void);
|
||||
|
||||
/*
|
||||
Declaration of global variables
|
||||
*/
|
||||
|
||||
volatile int st_seed;
|
||||
float st_arrayA[1000], st_arrayB[1000];
|
||||
float st_sumA, st_sumB;
|
||||
float st_meanA, st_meanB, st_varA, st_varB, st_stddevA, st_stddevB, st_coef;
|
||||
|
||||
/*
|
||||
Initialization- and return-value-related functions
|
||||
*/
|
||||
|
||||
/*
|
||||
st_initSeed initializes the seed used in the "random" number generator.
|
||||
*/
|
||||
void
|
||||
st_initSeed() {
|
||||
st_seed = 0;
|
||||
}
|
||||
|
||||
/*
|
||||
st_RandomInteger generates random integers between 0 and 8094.
|
||||
*/
|
||||
long
|
||||
st_randomInteger() {
|
||||
st_seed = ((st_seed * 133) + 81) % 8095;
|
||||
return (st_seed);
|
||||
}
|
||||
|
||||
void
|
||||
st_initialize(float *array) {
|
||||
register int i;
|
||||
|
||||
__pragma_loopbound(1000, 1000);
|
||||
for (i = 0; i < 1000; i++)
|
||||
array[i] = i + st_randomInteger();
|
||||
}
|
||||
|
||||
void
|
||||
st_init() {
|
||||
st_initSeed();
|
||||
st_initialize(st_arrayA);
|
||||
st_initialize(st_arrayB);
|
||||
}
|
||||
|
||||
int
|
||||
st_return() {
|
||||
float checksum = st_meanA + st_meanB + st_stddevA + st_stddevB + st_coef;
|
||||
/* allow rounding errors for the checksum */
|
||||
checksum -= 13695.986328;
|
||||
return ((checksum < 0.000001 && checksum > -0.000001) ? 0 : -1);
|
||||
}
|
||||
|
||||
/*
|
||||
Arithmetic math functions
|
||||
*/
|
||||
|
||||
float
|
||||
st_fabs(float n) {
|
||||
float f;
|
||||
|
||||
if (n >= 0)
|
||||
f = n;
|
||||
else
|
||||
f = -n;
|
||||
|
||||
return (f);
|
||||
}
|
||||
|
||||
float
|
||||
st_sqrtf(float val) {
|
||||
float x = val / 10;
|
||||
float dx;
|
||||
float diff;
|
||||
float min_tol = 0.00001f;
|
||||
|
||||
int i, flag = 0;
|
||||
|
||||
if (val == 0)
|
||||
x = 0;
|
||||
else {
|
||||
__pragma_loopbound(19, 19);
|
||||
for (i = 1; i < 20; i++) {
|
||||
if (!flag) {
|
||||
dx = (val - (x * x)) / (2.0f * x);
|
||||
x = x + dx;
|
||||
diff = val - (x * x);
|
||||
|
||||
if (st_fabs(diff) <= min_tol)
|
||||
flag = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return (x);
|
||||
}
|
||||
|
||||
float
|
||||
st_square(float x) {
|
||||
return (x * x);
|
||||
}
|
||||
|
||||
/*
|
||||
Algorithm core functions
|
||||
*/
|
||||
|
||||
void
|
||||
st_calc_Sum_Mean(float *array, float *sum, float *mean) {
|
||||
int i;
|
||||
|
||||
*sum = 0;
|
||||
|
||||
__pragma_loopbound(1000, 1000);
|
||||
for (i = 0; i < 1000; i++)
|
||||
*sum += array[i];
|
||||
*mean = *sum / 1000;
|
||||
}
|
||||
|
||||
void
|
||||
st_calc_Var_Stddev(float *array, float mean, float *var, float *stddev) {
|
||||
int i;
|
||||
float diffs = 0.0f;
|
||||
|
||||
__pragma_loopbound(1000, 1000);
|
||||
for (i = 0; i < 1000; i++)
|
||||
diffs += st_square(array[i] - mean);
|
||||
|
||||
*var = diffs / 1000;
|
||||
*stddev = st_sqrtf(*var);
|
||||
}
|
||||
|
||||
void
|
||||
st_calc_LinCorrCoef(float *arrayA, float *arrayB, float meanA, float meanB,
|
||||
float *coef) {
|
||||
int i;
|
||||
float numerator = 0.0f, Aterm = 0.0f, Bterm = 0.0f;
|
||||
|
||||
__pragma_loopbound(1000, 1000);
|
||||
for (i = 0; i < 1000; i++) {
|
||||
numerator += (arrayA[i] - meanA) * (arrayB[i] - meanB);
|
||||
Aterm += st_square(arrayA[i] - meanA);
|
||||
Bterm += st_square(arrayB[i] - meanB);
|
||||
}
|
||||
|
||||
*coef = numerator / (st_sqrtf(Aterm) * st_sqrtf(Bterm));
|
||||
}
|
||||
|
||||
/*
|
||||
Main functions
|
||||
*/
|
||||
|
||||
__attribute__((noinline)) __attribute__((export_name("entrypoint"))) void
|
||||
st_main(void) {
|
||||
st_calc_Sum_Mean(st_arrayA, &st_sumA, &st_meanA);
|
||||
st_calc_Var_Stddev(st_arrayA, st_meanA, &st_varA, &st_stddevA);
|
||||
|
||||
st_calc_Sum_Mean(st_arrayB, &st_sumB, &st_meanB);
|
||||
st_calc_Var_Stddev(st_arrayB, st_meanB, &st_varB, &st_stddevB);
|
||||
|
||||
st_calc_LinCorrCoef(st_arrayA, st_arrayB, st_meanA, st_meanB, &st_coef);
|
||||
}
|
||||
|
||||
__attribute__((noinline)) __attribute__((export_name("main"))) int
|
||||
main(void) {
|
||||
st_init();
|
||||
st_main();
|
||||
|
||||
return (st_return());
|
||||
}
|
||||
@ -0,0 +1,228 @@
|
||||
/*
|
||||
|
||||
This program is part of the TACLeBench benchmark suite.
|
||||
Version V 2.0
|
||||
|
||||
Name: st
|
||||
|
||||
Author: unknown
|
||||
|
||||
Function: st is a statistics program.
|
||||
This program computes for two arrays of numbers the sum, the mean,
|
||||
the variance, and standard deviation. It then determines the
|
||||
correlation coefficient between the two arrays.
|
||||
|
||||
Source: MRTC
|
||||
http://www.mrtc.mdh.se/projects/wcet/wcet_bench/st/st.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 st_initSeed(void);
|
||||
__attribute__((always_inline)) static inline long st_randomInteger();
|
||||
__attribute__((always_inline)) static inline void st_initialize(float *);
|
||||
__attribute__((always_inline)) static inline void st_init(void);
|
||||
__attribute__((always_inline)) static inline int st_return(void);
|
||||
__attribute__((always_inline)) static inline float st_fabs(float);
|
||||
__attribute__((always_inline)) static inline float st_sqrtf(float);
|
||||
__attribute__((always_inline)) static inline float st_square(float);
|
||||
__attribute__((always_inline)) static inline void
|
||||
st_calc_Sum_Mean(float *, float *, float *);
|
||||
__attribute__((always_inline)) static inline void
|
||||
st_calc_Var_Stddev(float *, float, float *, float *);
|
||||
__attribute__((always_inline)) static inline void
|
||||
st_calc_LinCorrCoef(float *, float *, float, float, float *);
|
||||
__attribute__((noinline)) __attribute__((export_name("entrypoint")))
|
||||
__attribute__((noinline)) __attribute__((export_name("entrypoint"))) void
|
||||
st_main(void);
|
||||
__attribute__((noinline)) __attribute__((export_name("main")))
|
||||
__attribute__((noinline)) __attribute__((export_name("main"))) int
|
||||
main(void);
|
||||
|
||||
/*
|
||||
Declaration of global variables
|
||||
*/
|
||||
|
||||
volatile int st_seed;
|
||||
float st_arrayA[1000], st_arrayB[1000];
|
||||
float st_sumA, st_sumB;
|
||||
float st_meanA, st_meanB, st_varA, st_varB, st_stddevA, st_stddevB, st_coef;
|
||||
|
||||
/*
|
||||
Initialization- and return-value-related functions
|
||||
*/
|
||||
|
||||
/*
|
||||
st_initSeed initializes the seed used in the "random" number generator.
|
||||
*/
|
||||
__attribute__((always_inline)) static inline void
|
||||
st_initSeed() {
|
||||
st_seed = 0;
|
||||
}
|
||||
|
||||
/*
|
||||
st_RandomInteger generates random integers between 0 and 8094.
|
||||
*/
|
||||
__attribute__((always_inline)) static inline long
|
||||
st_randomInteger() {
|
||||
st_seed = ((st_seed * 133) + 81) % 8095;
|
||||
return (st_seed);
|
||||
}
|
||||
|
||||
__attribute__((always_inline)) static inline void
|
||||
st_initialize(float *array) {
|
||||
register int i;
|
||||
|
||||
__pragma_loopbound(1000, 1000);
|
||||
for (i = 0; i < 1000; i++)
|
||||
array[i] = i + st_randomInteger();
|
||||
}
|
||||
|
||||
__attribute__((always_inline)) static inline void
|
||||
st_init() {
|
||||
st_initSeed();
|
||||
st_initialize(st_arrayA);
|
||||
st_initialize(st_arrayB);
|
||||
}
|
||||
|
||||
__attribute__((always_inline)) static inline int
|
||||
st_return() {
|
||||
float checksum = st_meanA + st_meanB + st_stddevA + st_stddevB + st_coef;
|
||||
/* allow rounding errors for the checksum */
|
||||
checksum -= 13695.986328;
|
||||
return ((checksum < 0.000001 && checksum > -0.000001) ? 0 : -1);
|
||||
}
|
||||
|
||||
/*
|
||||
Arithmetic math functions
|
||||
*/
|
||||
|
||||
__attribute__((always_inline)) static inline float
|
||||
st_fabs(float n) {
|
||||
float f;
|
||||
|
||||
if (n >= 0)
|
||||
f = n;
|
||||
else
|
||||
f = -n;
|
||||
|
||||
return (f);
|
||||
}
|
||||
|
||||
__attribute__((always_inline)) static inline float
|
||||
st_sqrtf(float val) {
|
||||
float x = val / 10;
|
||||
float dx;
|
||||
float diff;
|
||||
float min_tol = 0.00001f;
|
||||
|
||||
int i, flag = 0;
|
||||
|
||||
if (val == 0)
|
||||
x = 0;
|
||||
else {
|
||||
__pragma_loopbound(19, 19);
|
||||
for (i = 1; i < 20; i++) {
|
||||
if (!flag) {
|
||||
dx = (val - (x * x)) / (2.0f * x);
|
||||
x = x + dx;
|
||||
diff = val - (x * x);
|
||||
|
||||
if (st_fabs(diff) <= min_tol)
|
||||
flag = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return (x);
|
||||
}
|
||||
|
||||
__attribute__((always_inline)) static inline float
|
||||
st_square(float x) {
|
||||
return (x * x);
|
||||
}
|
||||
|
||||
/*
|
||||
Algorithm core functions
|
||||
*/
|
||||
|
||||
__attribute__((always_inline)) static inline void
|
||||
st_calc_Sum_Mean(float *array, float *sum, float *mean) {
|
||||
int i;
|
||||
|
||||
*sum = 0;
|
||||
|
||||
__pragma_loopbound(1000, 1000);
|
||||
for (i = 0; i < 1000; i++)
|
||||
*sum += array[i];
|
||||
*mean = *sum / 1000;
|
||||
}
|
||||
|
||||
__attribute__((always_inline)) static inline void
|
||||
st_calc_Var_Stddev(float *array, float mean, float *var, float *stddev) {
|
||||
int i;
|
||||
float diffs = 0.0f;
|
||||
|
||||
__pragma_loopbound(1000, 1000);
|
||||
for (i = 0; i < 1000; i++)
|
||||
diffs += st_square(array[i] - mean);
|
||||
|
||||
*var = diffs / 1000;
|
||||
*stddev = st_sqrtf(*var);
|
||||
}
|
||||
|
||||
__attribute__((always_inline)) static inline void
|
||||
st_calc_LinCorrCoef(float *arrayA, float *arrayB, float meanA, float meanB,
|
||||
float *coef) {
|
||||
int i;
|
||||
float numerator = 0.0f, Aterm = 0.0f, Bterm = 0.0f;
|
||||
|
||||
__pragma_loopbound(1000, 1000);
|
||||
for (i = 0; i < 1000; i++) {
|
||||
numerator += (arrayA[i] - meanA) * (arrayB[i] - meanB);
|
||||
Aterm += st_square(arrayA[i] - meanA);
|
||||
Bterm += st_square(arrayB[i] - meanB);
|
||||
}
|
||||
|
||||
*coef = numerator / (st_sqrtf(Aterm) * st_sqrtf(Bterm));
|
||||
}
|
||||
|
||||
/*
|
||||
Main functions
|
||||
*/
|
||||
|
||||
__attribute__((noinline)) __attribute__((export_name("entrypoint")))
|
||||
__attribute__((noinline)) __attribute__((export_name("entrypoint"))) void
|
||||
st_main(void) {
|
||||
st_calc_Sum_Mean(st_arrayA, &st_sumA, &st_meanA);
|
||||
st_calc_Var_Stddev(st_arrayA, st_meanA, &st_varA, &st_stddevA);
|
||||
|
||||
st_calc_Sum_Mean(st_arrayB, &st_sumB, &st_meanB);
|
||||
st_calc_Var_Stddev(st_arrayB, st_meanB, &st_varB, &st_stddevB);
|
||||
|
||||
st_calc_LinCorrCoef(st_arrayA, st_arrayB, st_meanA, st_meanB, &st_coef);
|
||||
}
|
||||
|
||||
__attribute__((noinline)) __attribute__((export_name("main")))
|
||||
__attribute__((noinline)) __attribute__((export_name("main"))) int
|
||||
main(void) {
|
||||
st_init();
|
||||
st_main();
|
||||
|
||||
return (st_return());
|
||||
}
|
||||
Reference in New Issue
Block a user