Add benchmarks (#979)

Add scripts to build and run benchmark of coremark, polybench,
sightglass and jetstream2. And add documents.
This commit is contained in:
Wenyong Huang
2022-01-25 10:52:48 +08:00
committed by GitHub
parent d925369a1f
commit 4bc6074273
15 changed files with 595 additions and 0 deletions

View File

@ -0,0 +1,21 @@
# Introduction
[PolyBench](https://github.com/MatthiasJReisinger/PolyBenchC-4.2.1) is a benchmark suite of 30 numerical computations with static control flow, extracted from operations in various application domains (linear algebra computations, image processing, physics simulation, dynamic programming, statistics, etc.).
**Source**: https://github.com/MatthiasJReisinger/PolyBenchC-4.2.1
# Building
Please build iwasm and wamrc, refer to:
- [Build iwasm on Linux](../../../doc/build_wamr.md#linux), or [Build iwasm on MacOS](../../../doc/build_wamr.md#macos)
- [build wamrc AOT compiler](../../../README.md#build-wamrc-aot-compiler)
And install WASI SDK, please download the [wasi-sdk release](https://github.com/CraneStation/wasi-sdk/releases) and extract the archive to default path `/opt/wasi-sdk`.
And then run `./build.sh` to build the source code, the folder `out` will be created and files will be generated under it.
# Running
Run `./run_aot.sh` to test the benchmark, the native mode and iwasm aot mode will be tested for each workload, and the file `report.txt` will be generated.
Run `./run_interp.sh` to test the benchmark, the native mode and iwasm interpreter mode will be tested for each workload, and the file `report.txt` will be generated.

View File

@ -0,0 +1,47 @@
#!/bin/bash
# Copyright (C) 2019 Intel Corporation. All rights reserved.
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
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
echo "Compile ${file_name%.*}.wasm into ${file_name%.*}.aot"
${WAMRC_CMD} -o ${OUT_DIR}/${file_name%.*}.aot \
${OUT_DIR}/${file_name%.*}.wasm
done
done
cd ..
echo "Done"

View File

@ -0,0 +1,55 @@
#!/bin/bash
# Copyright (C) 2019 Intel Corporation. All rights reserved.
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
CUR_DIR=$PWD
OUT_DIR=$CUR_DIR/out
REPORT=$CUR_DIR/report.txt
TIME=/usr/bin/time
PLATFORM=$(uname -s | tr A-Z a-z)
IWASM_CMD=$CUR_DIR/../../../product-mini/platforms/${PLATFORM}/build/iwasm
BENCH_NAME_MAX_LEN=20
POLYBENCH_CASES="2mm 3mm adi atax bicg cholesky correlation covariance \
deriche doitgen durbin fdtd-2d floyd-warshall gemm gemver \
gesummv gramschmidt heat-3d jacobi-1d jacobi-2d ludcmp lu \
mvt nussinov seidel-2d symm syr2k syrk trisolv trmm"
rm -f $REPORT
touch $REPORT
function print_bench_name()
{
name=$1
echo -en "$name" >> $REPORT
name_len=${#name}
if [ $name_len -lt $BENCH_NAME_MAX_LEN ]
then
spaces=$(( $BENCH_NAME_MAX_LEN - $name_len ))
for i in $(eval echo "{1..$spaces}"); do echo -n " " >> $REPORT; done
fi
}
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
for t in $POLYBENCH_CASES
do
print_bench_name $t
echo "run $t with native .."
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 -en "\t" >> $REPORT
$TIME -f "real-%e-time" $IWASM_CMD ${t}.aot 2>&1 | grep "real-.*-time" | awk -F '-' '{ORS=""; print $2}' >> $REPORT
echo -en "\n" >> $REPORT
done

View File

@ -0,0 +1,55 @@
#!/bin/bash
# Copyright (C) 2019 Intel Corporation. All rights reserved.
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
CUR_DIR=$PWD
OUT_DIR=$CUR_DIR/out
REPORT=$CUR_DIR/report.txt
TIME=/usr/bin/time
PLATFORM=$(uname -s | tr A-Z a-z)
IWASM_CMD=$CUR_DIR/../../../product-mini/platforms/${PLATFORM}/build/iwasm
BENCH_NAME_MAX_LEN=20
POLYBENCH_CASES="2mm 3mm adi atax bicg cholesky correlation covariance \
deriche doitgen durbin fdtd-2d floyd-warshall gemm gemver \
gesummv gramschmidt heat-3d jacobi-1d jacobi-2d ludcmp lu \
mvt nussinov seidel-2d symm syr2k syrk trisolv trmm"
rm -f $REPORT
touch $REPORT
function print_bench_name()
{
name=$1
echo -en "$name" >> $REPORT
name_len=${#name}
if [ $name_len -lt $BENCH_NAME_MAX_LEN ]
then
spaces=$(( $BENCH_NAME_MAX_LEN - $name_len ))
for i in $(eval echo "{1..$spaces}"); do echo -n " " >> $REPORT; done
fi
}
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
for t in $POLYBENCH_CASES
do
print_bench_name $t
echo "run $t with native .."
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 interp .."
echo -en "\t" >> $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