2022-01-25 02:52:48 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
# Copyright (C) 2019 Intel Corporation. All rights reserved.
|
|
|
|
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
|
|
|
|
Implement the segue optimization for LLVM AOT/JIT (#2230)
Segue is an optimization technology which uses x86 segment register to store
the WebAssembly linear memory base address, so as to remove most of the cost
of SFI (Software-based Fault Isolation) base addition and free up a general
purpose register, by this way it may:
- Improve the performance of JIT/AOT
- Reduce the footprint of JIT/AOT, the JIT/AOT code generated is smaller
- Reduce the compilation time of JIT/AOT
This PR uses the x86-64 GS segment register to apply the optimization, currently
it supports linux and linux-sgx platforms on x86-64 target. By default it is disabled,
developer can use the option below to enable it for wamrc and iwasm(with LLVM
JIT enabled):
```bash
wamrc --enable-segue=[<flags>] -o output_file wasm_file
iwasm --enable-segue=[<flags>] wasm_file [args...]
```
`flags` can be:
i32.load, i64.load, f32.load, f64.load, v128.load,
i32.store, i64.store, f32.store, f64.store, v128.store
Use comma to separate them, e.g. `--enable-segue=i32.load,i64.store`,
and `--enable-segue` means all flags are added.
Acknowledgement:
Many thanks to Intel Labs, UC San Diego and UT Austin teams for introducing this
technology and the great support and guidance!
Signed-off-by: Wenyong Huang <wenyong.huang@intel.com>
Co-authored-by: Vahldiek-oberwagner, Anjo Lucas <anjo.lucas.vahldiek-oberwagner@intel.com>
2023-05-26 02:13:33 +00:00
|
|
|
PLATFORM=$(uname -s | tr A-Z a-z)
|
|
|
|
|
2022-01-25 02:52:48 +00:00
|
|
|
WAMRC="../../../wamr-compiler/build/wamrc"
|
|
|
|
|
|
|
|
if [ ! -d coremark ]; then
|
|
|
|
git clone https://github.com/eembc/coremark.git
|
|
|
|
fi
|
|
|
|
|
|
|
|
cd coremark
|
|
|
|
|
|
|
|
echo "Build coremark with gcc .."
|
|
|
|
gcc -O3 -Iposix -I. -DFLAGS_STR=\""-O3 -DPERFORMANCE_RUN=1 -lrt"\" \
|
2023-03-15 00:24:08 +00:00
|
|
|
-DITERATIONS=400000 -DSEED_METHOD=SEED_VOLATILE -DPERFORMANCE_RUN=1 \
|
2022-01-25 02:52:48 +00:00
|
|
|
core_list_join.c core_main.c core_matrix.c core_state.c \
|
|
|
|
core_util.c posix/core_portme.c \
|
|
|
|
-o ../coremark.exe -lrt
|
|
|
|
|
|
|
|
echo "Build coremark with wasi-sdk .."
|
|
|
|
/opt/wasi-sdk/bin/clang -O3 -Iposix -I. -DFLAGS_STR=\""-O3 -DPERFORMANCE_RUN=1"\" \
|
|
|
|
-Wl,--export=main \
|
2023-03-15 00:24:08 +00:00
|
|
|
-DITERATIONS=400000 -DSEED_METHOD=SEED_VOLATILE -DPERFORMANCE_RUN=1 \
|
2022-01-25 02:52:48 +00:00
|
|
|
-Wl,--allow-undefined \
|
|
|
|
core_list_join.c core_main.c core_matrix.c core_state.c \
|
|
|
|
core_util.c posix/core_portme.c \
|
|
|
|
-o ../coremark.wasm
|
|
|
|
|
|
|
|
cd ..
|
|
|
|
|
|
|
|
echo "Compile coremark.wasm to coremark.aot .."
|
|
|
|
${WAMRC} -o coremark.aot coremark.wasm
|
|
|
|
|
Implement the segue optimization for LLVM AOT/JIT (#2230)
Segue is an optimization technology which uses x86 segment register to store
the WebAssembly linear memory base address, so as to remove most of the cost
of SFI (Software-based Fault Isolation) base addition and free up a general
purpose register, by this way it may:
- Improve the performance of JIT/AOT
- Reduce the footprint of JIT/AOT, the JIT/AOT code generated is smaller
- Reduce the compilation time of JIT/AOT
This PR uses the x86-64 GS segment register to apply the optimization, currently
it supports linux and linux-sgx platforms on x86-64 target. By default it is disabled,
developer can use the option below to enable it for wamrc and iwasm(with LLVM
JIT enabled):
```bash
wamrc --enable-segue=[<flags>] -o output_file wasm_file
iwasm --enable-segue=[<flags>] wasm_file [args...]
```
`flags` can be:
i32.load, i64.load, f32.load, f64.load, v128.load,
i32.store, i64.store, f32.store, f64.store, v128.store
Use comma to separate them, e.g. `--enable-segue=i32.load,i64.store`,
and `--enable-segue` means all flags are added.
Acknowledgement:
Many thanks to Intel Labs, UC San Diego and UT Austin teams for introducing this
technology and the great support and guidance!
Signed-off-by: Wenyong Huang <wenyong.huang@intel.com>
Co-authored-by: Vahldiek-oberwagner, Anjo Lucas <anjo.lucas.vahldiek-oberwagner@intel.com>
2023-05-26 02:13:33 +00:00
|
|
|
if [[ ${PLATFORM} == "linux" ]]; then
|
|
|
|
echo "Compile coremark.wasm to coremark_segue.aot .."
|
|
|
|
${WAMRC} --enable-segue -o coremark_segue.aot coremark.wasm
|
|
|
|
fi
|
|
|
|
|
2022-01-25 02:52:48 +00:00
|
|
|
echo "Done"
|