This repository contains files necessary for testing a simple image decoding operation using libpng with SIMD instructions when compiled to WebAssembly. Note that this build uses wasi-sdk version 14.0, WASM-Micro-Runtime (WAMR), and WebAssmebly Binary Toolkit (WABT). Additionally, note that libz must be installed for libpng to build.
The build.sh script provides a method for building the libpng library with and without SIMD instructions and with a native or WASM target. For the WebAssembly target, zlib must be built to WASM before building the libpng library. This is dones by using:
export PATH=${WASI_SDK_PATH}/bin:$PATH
export PATH=${WASI_SDK_PATH}/bin/ranlib:$PATH
cd ${ZLIB_PATH}
CC=${WASI_SDK_PATH}/bin/clang ./configure --prefix=${WASI_SDK_PATH}/share/wasi-sysroot
make && make installThe wamr_decode.sh script compiles a decode.c file to WebAssembly. Then, using WAMR's AOT compiler, an .aot module is generated to be executed with WAMR's iwasm VM Core (This script should only be used when working with the WASM target). The 'full_test.sh' script performs a test of execution speed for the built libpng library.
decode.c -> decode.wasm -> decode.aot
The wasm2c_decode.sh script compiles a decode.c file to WebAssembly and then utilizes the wasm2c compiler provided by the wasm2c_sandbox_compiler. This generates C code which can be compiled to native code with gcc and the main.c file. This step is currently non-functional.
decode.c -> decode.wasm -> decode.c -> native code
To setup the benchmarking environment, we first disable CPU frequency scaling and set the system to performance mode (using cpufrequtils):
echo GOVERNOR="performance" >> /etc/default/cpufrequtils
sudo systemctl disable ondemandTo set CPU isolation and shielding, we run
sudo nano /etc/default/gruband add isolcpus=1 to GRUB_CMDLINE_LINUX_DEFAULT. Then, to set CPU shielding,
sudo cset shield -c 1 -k onThere are four tests that can be run, depending on whether SIMD instructions are enabled or disabled and whether we are building to a native or WASM target. Each test can be run as follows:
bash build.sh -s
taskset -c 1 bash full_test.sh -sbash build.sh
taskset -c 1 bash full_test.shbash build.sh -s -w
bash wamr_decode.sh -s
taskset -c 1 bash full_test.sh -s -wbash build.sh -w
bash wamr_decode.sh
taskset -c 1 bash full_test.sh -wIndividual statistical analysis is run for each case in the full_test.sh script. A comparative analysis among all cases can be run proceeding all individual tests using
python3 comp_analysis.py