Skip to content

Commit bf27e77

Browse files
committed
adjust simde path; add wasm2c base
1 parent f4cc71a commit bf27e77

12 files changed

+343
-284
lines changed

.vscode/c_cpp_properties.json

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"configurations": [
3+
{
4+
"name": "Linux",
5+
"includePath": [
6+
"${workspaceFolder}/**",
7+
"/opt/wasm2c_sandbox_compiler/wasm2c",
8+
"/opt/simde"
9+
],
10+
"defines": [],
11+
"compilerPath": "/opt/wasi-sdk/wasi-sdk-14.0/bin/clang",
12+
"cStandard": "c17",
13+
"cppStandard": "c++14",
14+
"intelliSenseMode": "linux-clang-x64"
15+
}
16+
],
17+
"version": 4
18+
}

.vscode/settings.json

+4-2
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
"pngpriv.h": "c",
88
"mmintrin.h": "c",
99
"time.h": "c",
10-
"timer_t.h": "c"
11-
}
10+
"timer_t.h": "c",
11+
"math.h": "c"
12+
},
13+
"cmake.configureOnOpen": false
1214
}

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ The `wamr_decode.sh` script compiles a `decode.c` file to WebAssembly. Then, usi
2020
decode.c -> decode.wasm -> decode.aot
2121
```
2222

23-
The `wasm2c_decode.sh` script compiles a `decode.c` file to WebAssembly and then utilizes the `wasm2c` compiler provided by the [wasm2c_sandbox_compiler](https://github.com/wrv/wasm2c_sandbox_compiler/tree/simdeverywhere). This generates C code which can be compiled to native code with `gcc`.
23+
The `wasm2c_decode.sh` script compiles a `decode.c` file to WebAssembly and then utilizes the `wasm2c` compiler provided by the [wasm2c_sandbox_compiler](https://github.com/wrv/wasm2c_sandbox_compiler/tree/simdeverywhere). This generates C code which can be compiled to native code with `gcc` and the `main.c` file. *This step is currently non-functional.*
2424

2525
```
2626
decode.c -> decode.wasm -> decode.c -> native code

build.sh

+2-2
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ if [[ "$simd" = true && "$wasm" = true ]]; then # SIMD instructions and WASM tar
4343
-D_WASI_EMULATED_SIGNAL \
4444
-O3" \
4545
LIBS=-lwasi-emulated-signal \
46-
CPPFLAGS="-I${SIMDE_PATH}/wasm"
46+
CPPFLAGS="-I${SIMDE_PATH}/simde/wasm"
4747
LDFLAGS="-L${WASI_SDK_PATH}/share/wasi-sysroot/lib \
4848
-Wl,--no-entry \
4949
-Wl,--export-all \
@@ -60,7 +60,7 @@ if [[ "$simd" = true && "$wasm" = true ]]; then # SIMD instructions and WASM tar
6060
make
6161
make install
6262
elif [[ "$simd" = true ]]; then # SSE and native target
63-
CPPFLAGS="-I${SIMDE_PATH}/wasm" \
63+
CPPFLAGS="-I${SIMDE_PATH}/simde/wasm" \
6464
./configure --enable-intel-sse=yes
6565

6666
make

decode.c

+18-8
Original file line numberDiff line numberDiff line change
@@ -15,22 +15,17 @@
1515
#define BILLION 1000000000.0
1616
#define __USE_POSIX199309
1717

18-
int main(int argc, char *argv[]) {
18+
double timed_decode(char *png_fn, char *out_fn) {
1919
struct timespec start, end;
2020
double dt;
2121

22-
if (argc < 2) {
23-
printf("Not enough arguments provided.\n");
24-
exit(1);
25-
}
26-
27-
FILE *fp = fopen(argv[1], "rb");
22+
FILE *fp = fopen(png_fn, "rb");
2823
if (!fp) {
2924
printf("Invalid file provided.\n");
3025
exit(1);
3126
}
3227

33-
FILE *out = fopen(argv[2], "a");
28+
FILE *out = fopen(out_fn, "a");
3429
if (!out) {
3530
printf("Invalid file provided.\n");
3631
exit(1);
@@ -70,8 +65,23 @@ int main(int argc, char *argv[]) {
7065
fprintf(out, "%f\n", dt);
7166

7267
fclose(fp);
68+
fclose(out);
7369
for(int y = 0; y < height; y++) {
7470
free(row_pointers[y]);
7571
}
7672
free(row_pointers);
73+
74+
return dt;
75+
}
76+
77+
/**
78+
* argv[1]: png image filename to decode
79+
* argv[2]: output csv file for timing information
80+
*/
81+
int main(int argc, char *argv[]) {
82+
if (argc < 2) {
83+
printf("Not enough arguments provided.\n");
84+
exit(1);
85+
}
86+
timed_decode(argv[1], argv[2]);
7787
}

full_test.sh

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
#!/bin/bash
22
set -e
33

4+
# Currently this file is nonoperational - decode.c is temporarily changed to use wasm2c
5+
46
help() {
57
echo "Run benchmark test after building libpng library"
68
echo "Note: For WASM Target, wasm_decode.sh should be run before"
@@ -48,7 +50,7 @@ if [[ "$simd" = true && "$wasm" = true ]]; then # SIMD instructions and WASM tar
4850
elif [[ "$simd" = true ]]; then # SSE and native target
4951
cp /dev/null results/native_with_sse.csv
5052

51-
gcc -I/usr/local/include/libpng16 -I${SIMDE_PATH}/wasm \
53+
gcc -I/usr/local/include/libpng16 -I${SIMDE_PATH}/simde/wasm \
5254
-L/usr/local/lib -o out/decode decode.c -lpng16
5355

5456
for i in $(seq 1 $N)

main.c

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#include <stdio.h>
2+
#include <stdlib.h>
3+
#include <decode_mod.h>
4+
5+
/**
6+
* argv[1]: png image filename to decode
7+
* argv[2]: output csv file for timing information
8+
*/
9+
int main(int argc, char *argv[]) {
10+
wasm2c_sandbox_funcs_t sbx_details = get_wasm2c_sandbox_info();
11+
sbx_details.wasm_rt_sys_init();
12+
int max_wasm_page = 0;
13+
wasm2c_sandbox_t* sbx_instance = (wasm2c_sandbox_t*) sbx_details.create_wasm2c_sandbox(max_wasm_page);
14+
double dt = w2c_timed_decode(sbx_instance, argv[1], argv[2]);
15+
printf("time: %f\n", dt);
16+
sbx_details.destroy_wasm2c_sandbox(sbx_instance);
17+
return 0;
18+
}

results/TEST.txt

Whitespace-only changes.

results/comparative_results copy.txt

-18
This file was deleted.

0 commit comments

Comments
 (0)