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>
This commit is contained in:
@ -3,6 +3,8 @@
|
||||
# Copyright (C) 2019 Intel Corporation. All rights reserved.
|
||||
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
|
||||
PLATFORM=$(uname -s | tr A-Z a-z)
|
||||
|
||||
OUT_DIR=$PWD/out
|
||||
WAMRC_CMD=$PWD/../../../wamr-compiler/build/wamrc
|
||||
SHOOTOUT_CASES="base64 fib2 gimli heapsort matrix memmove nestedloop \
|
||||
@ -34,9 +36,12 @@ do
|
||||
-Wl,--export=app_main -Wl,--export=_start \
|
||||
${bench}.c main/main_${bench}.c main/my_libc.c
|
||||
|
||||
|
||||
echo "Compile ${bench}.wasm into ${bench}.aot"
|
||||
${WAMRC_CMD} -o ${OUT_DIR}/${bench}.aot ${OUT_DIR}/${bench}.wasm
|
||||
if [[ ${PLATFORM} == "linux" ]]; then
|
||||
echo "Compile ${bench}.wasm into ${bench}_segue.aot"
|
||||
${WAMRC_CMD} --enable-segue -o ${OUT_DIR}/${bench}_segue.aot ${OUT_DIR}/${bench}.wasm
|
||||
fi
|
||||
done
|
||||
|
||||
cd ..
|
||||
|
||||
@ -36,7 +36,11 @@ echo "Start to run cases, the result is written to report.txt"
|
||||
|
||||
#run benchmarks
|
||||
cd $OUT_DIR
|
||||
echo -en "\t\t\t\t\t native\tiwasm-aot\n" >> $REPORT
|
||||
if [[ ${PLATFORM} == "linux" ]]; then
|
||||
echo -en "\t\t\t\t\t native\tiwasm-aot\tiwasm-aot-segue\n" >> $REPORT
|
||||
else
|
||||
echo -en "\t\t\t\t\t native\tiwasm-aot\n" >> $REPORT
|
||||
fi
|
||||
|
||||
for t in $SHOOTOUT_CASES
|
||||
do
|
||||
@ -50,5 +54,11 @@ do
|
||||
echo -en "\t" >> $REPORT
|
||||
$TIME -f "real-%e-time" $IWASM_CMD ${t}.aot 2>&1 | grep "real-.*-time" | awk -F '-' '{ORS=""; print $2}' >> $REPORT
|
||||
|
||||
if [[ ${PLATFORM} == "linux" ]]; then
|
||||
echo "run $t with iwasm aot segue .."
|
||||
echo -en "\t" >> $REPORT
|
||||
$TIME -f "real-%e-time" $IWASM_CMD ${t}_segue.aot 2>&1 | grep "real-.*-time" | awk -F '-' '{ORS=""; print $2}' >> $REPORT
|
||||
fi
|
||||
|
||||
echo -en "\n" >> $REPORT
|
||||
done
|
||||
|
||||
@ -46,9 +46,9 @@ do
|
||||
echo -en "\t" >> $REPORT
|
||||
$TIME -f "real-%e-time" ./${t}_native 2>&1 | grep "real-.*-time" | awk -F '-' '{ORS=""; print $2}' >> $REPORT
|
||||
|
||||
echo "run $t with iwasm aot .."
|
||||
echo "run $t with iwasm interp .."
|
||||
echo -en "\t" >> $REPORT
|
||||
$TIME -f "real-%e-time" $IWASM_CMD ${t}.aot 2>&1 | grep "real-.*-time" | awk -F '-' '{ORS=""; print $2}' >> $REPORT
|
||||
$TIME -f "real-%e-time" $IWASM_CMD ${t}.wasm 2>&1 | grep "real-.*-time" | awk -F '-' '{ORS=""; print $2}' >> $REPORT
|
||||
|
||||
echo -en "\n" >> $REPORT
|
||||
done
|
||||
|
||||
Reference in New Issue
Block a user