-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmake.generic.config
93 lines (71 loc) · 4.78 KB
/
make.generic.config
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
# A generic set of make rules.
CONFIG=../make.config
include ${CONFIG}
.PHONY: all
all: out/$(BENCHMARK)_bespoke.cwasm out/$(BENCHMARK)_asyncify.cwasm out/$(BENCHMARK)_wasmfx.cwasm
out/$(BENCHMARK)_bespoke.wasm: $(BENCHMARK)_bespoke.c
mkdir -p out
$(WASICC) $(WASICC_FLAGS) -o out/$(BENCHMARK)_bespoke.wasm $(BENCHMARK)_bespoke.c
out/$(BENCHMARK)_bespoke.cwasm: out/$(BENCHMARK)_bespoke.wasm
$(WASMTIMEC) -o out/$(BENCHMARK)_bespoke.cwasm out/$(BENCHMARK)_bespoke.wasm
out/$(BENCHMARK)_asyncify.wasm: $(BENCHMARK).c fiber_impl.c
mkdir -p out
$(WASICC) $(WASICC_FLAGS) -I ../vendor/fiber-c/inc -o out/$(BENCHMARK)_asyncify.pre.wasm ../vendor/fiber-c/src/asyncify/asyncify_impl.c fiber_impl.c $(BENCHMARK).c
$(ASYNCIFY) out/$(BENCHMARK)_asyncify.pre.wasm -o out/$(BENCHMARK)_asyncify.wasm
out/$(BENCHMARK)_asyncify.cwasm: out/$(BENCHMARK)_asyncify.wasm
$(WASMTIMEC) -o out/$(BENCHMARK)_asyncify.cwasm out/$(BENCHMARK)_asyncify.wasm
out/$(BENCHMARK)_wasmfx.wasm: $(BENCHMARK).c wasmfx_import.wast
mkdir -p out
$(WASICC) $(WASICC_FLAGS) -I ../vendor/fiber-c/inc -o out/$(BENCHMARK)_wasmfx.pre.wasm ../fiber_wasmfx_compat.c $(BENCHMARK).c
$(WASM_INTERP) -d -i wasmfx_import.wast -o out/wasmfx_import.wasm
$(WASMFX_MERGE) out/wasmfx_import.wasm "impl" out/$(BENCHMARK)_wasmfx.pre.wasm "main" -o out/$(BENCHMARK)_wasmfx-merged.wasm
mv out/$(BENCHMARK)_wasmfx-merged.wasm out/$(BENCHMARK)_wasmfx.wasm # TODO(dhil): use wasm-opt once it supports WasmFX instructions.
out/wasmfx_fiber_imports.wat: ../vendor/fiber-c/src/wasmfx/imports.wat.pp
mkdir -p out
$(WASICC) -xc -DWASMFX_CONT_TABLE_INITIAL_CAPACITY=$(WASMFX_CONT_TABLE_INITIAL_CAPACITY) -E ../vendor/fiber-c/src/wasmfx/imports.wat.pp | sed 's/.*#.*//g' > out/wasmfx_fiber_imports.wat
out/$(BENCHMARK)_wasmfx_fiber.wasm: out/wasmfx_fiber_imports.wat $(BENCHMARK).c
mkdir -p out
# Custom flags to wasm-ld:
# --export-table: Exports the funcref table. This forces clang to populate it and not optimize it away
# --export-memory: Export the memory, so that the fiber_wasmfx_imports.wat can import it, creating one unified heap.
$(WASICC) $(WASICC_FLAGS) -Wl,--export-table,--export-memory -DWASMFX_CONT_TABLE_INITIAL_CAPACITY=$(WASMFX_CONT_TABLE_INITIAL_CAPACITY) \
-I ../vendor/fiber-c/inc -o out/$(BENCHMARK)_wasmfx_fiber.pre.wasm ../vendor/fiber-c/src/wasmfx/wasmfx_impl.c fiber_impl.c $(BENCHMARK).c
# For debugging: create binaryen compatible wat for wasm
# $(WASMFX_DIS) out/$(BENCHMARK)_wasmfx_fiber.pre.wasm -o out/$(BENCHMARK)_wasmfx_fiber.pre.wat
$(WASM_INTERP) -d -i out/wasmfx_fiber_imports.wat -o out/fiber_wasmfx_imports.wasm
$(WASMFX_MERGE) out/fiber_wasmfx_imports.wasm "fiber_wasmfx_imports" out/$(BENCHMARK)_wasmfx_fiber.pre.wasm "main" -o out/$(BENCHMARK)_wasmfx.merged.wasm
# for debugging: create binaryen compatible wat for wasm
# $(WASMFX_DIS) out/$(BENCHMARK)_wasmfx.merged.wasm -o out/$(BENCHMARK)_wasmfx.merged.wat
# for debugging: create ref interpreter compatible wat for wasm
# $(WASM_INTERP) -d -i out/$(BENCHMARK)_wasmfx.merged.wasm -o out/$(BENCHMARK)_wasmfx.merged.refint.wat
# TODO(use wasm-opt once it supports WasmFX instructions.
cp out/$(BENCHMARK)_wasmfx.merged.wasm out/$(BENCHMARK)_wasmfx_fiber.wasm
out/$(BENCHMARK)_wasmfx.cwasm: out/$(BENCHMARK)_wasmfx.wasm
$(WASMFXTIMEC) -o out/$(BENCHMARK)_wasmfx.cwasm out/$(BENCHMARK)_wasmfx.wasm
.PHONY: bench
bench: out/$(BENCHMARK)_bespoke.cwasm out/$(BENCHMARK)_asyncify.cwasm out/$(BENCHMARK)_wasmfx.cwasm
$(HYPERFINE) "$(WASMTIMEC_RUN) out/$(BENCHMARK)_bespoke.cwasm" "$(WASMTIMEC_RUN) out/$(BENCHMARK)_asyncify.cwasm" "$(WASMFXTIMEC_RUN) out/$(BENCHMARK)_wasmfx.cwasm"
.PHONY: benchfx
benchfx: out/$(BENCHMARK)_asyncify.cwasm out/$(BENCHMARK)_wasmfx.cwasm
$(HYPERFINE) "$(WASMTIMEC_RUN) out/$(BENCHMARK)_asyncify.cwasm" "$(WASMFXTIMEC_RUN) out/$(BENCHMARK)_wasmfx.cwasm"
.PHONY: bench-mem
bench-mem: out/$(BENCHMARK)_bespoke.cwasm out/$(BENCHMARK)_asyncify.cwasm out/$(BENCHMARK)_wasmfx.cwasm
/usr/bin/time -f ' bespoke: %M' $(WASMTIMEC_RUN) out/$(BENCHMARK)_bespoke.cwasm
/usr/bin/time -f 'asyncify: %M' $(WASMTIMEC_RUN) out/$(BENCHMARK)_asyncify.cwasm
/usr/bin/time -f ' wasmfx: %M' $(WASMFXTIMEC_RUN) out/$(BENCHMARK)_wasmfx.cwasm
.PHONY: benchfx-mem
benchfx-mem: out/$(BENCHMARK)_asyncify.cwasm out/$(BENCHMARK)_wasmfx.cwasm
/usr/bin/time -f 'asyncify: %M' $(WASMTIMEC_RUN) out/$(BENCHMARK)_asyncify.cwasm
/usr/bin/time -f ' wasmfx: %M' $(WASMFXTIMEC_RUN) out/$(BENCHMARK)_wasmfx.cwasm
.PHONY: grant-perf-privileges
grant-perf-privileges:
sudo sysctl -w kernel.perf_event_paranoid=1
.PHONY: revoke-perf-privileges
revoke-perf-privileges:
sudo sysctl -w kernel.perf_event_paranoid=0
.PHONY: perf-wasmfx
perf-wasmfx: out/$(BENCHMARK)_wasmfx.cwasm
sudo perf record -k mono $(WASMFXTIMEC_RUN) --profile=perfmap out/$(BENCHMARK)_wasmfx.cwasm
.PHONY: clean
clean:
test -d out && rm -r out || true