mirror of
https://github.com/bytecodealliance/wasm-micro-runtime.git
synced 2024-11-26 15:32:05 +00:00
76be848ec3
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>
57 lines
1.7 KiB
Bash
Executable File
57 lines
1.7 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
# 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
|
|
POLYBENCH_CASES="datamining linear-algebra medley stencils"
|
|
|
|
if [ ! -d PolyBenchC-4.2.1 ]; then
|
|
git clone https://github.com/MatthiasJReisinger/PolyBenchC-4.2.1.git
|
|
fi
|
|
|
|
mkdir -p ${OUT_DIR}
|
|
|
|
cd PolyBenchC-4.2.1
|
|
|
|
for case in $POLYBENCH_CASES
|
|
do
|
|
files=`find ${case} -name "*.c"`
|
|
for file in ${files}
|
|
do
|
|
file_name=${file##*/}
|
|
if [[ ${file_name} == "Nussinov.orig.c" ]]; then
|
|
continue
|
|
fi
|
|
|
|
echo "Build ${file_name%.*}_native"
|
|
gcc -O3 -I utilities -I ${file%/*} utilities/polybench.c ${file} \
|
|
-DPOLYBENCH_TIME -lm -o ${OUT_DIR}/${file_name%.*}_native
|
|
|
|
echo "Build ${file_name%.*}.wasm"
|
|
/opt/wasi-sdk/bin/clang -O3 -I utilities -I ${file%/*} \
|
|
utilities/polybench.c ${file} \
|
|
-Wl,--export=__heap_base -Wl,--export=__data_end \
|
|
-Wl,--export=malloc -Wl,--export=free \
|
|
-DPOLYBENCH_TIME -o ${OUT_DIR}/${file_name%.*}.wasm \
|
|
-D_WASI_EMULATED_PROCESS_CLOCKS
|
|
|
|
echo "Compile ${file_name%.*}.wasm into ${file_name%.*}.aot"
|
|
${WAMRC_CMD} -o ${OUT_DIR}/${file_name%.*}.aot \
|
|
${OUT_DIR}/${file_name%.*}.wasm
|
|
|
|
if [[ ${PLATFORM} == "linux" ]]; then
|
|
echo "Compile ${file_name%.*}.wasm into ${file_name%.*}_segue.aot"
|
|
${WAMRC_CMD} --enable-segue -o ${OUT_DIR}/${file_name%.*}_segue.aot \
|
|
${OUT_DIR}/${file_name%.*}.wasm
|
|
fi
|
|
done
|
|
done
|
|
|
|
cd ..
|
|
|
|
echo "Done"
|