We need Browsix-WASM's emscripten
and Browsix-SPEC to execute SPEC CPU 2006 and 2017 Benchmarks. Browsix-WASM emscripten
is available in browsix-wasm
branch of Browsix-Emscripten.
In below steps we will compile bzip2
benchmark to WebAssembly and execute it with ref
size of data set. To compile and execute other benchmarks with ref
or test
size of dataset, repeat the below procedure.
To use Emscripten 1.37.22, we need binaryen tools and fastcomp
1.37.22. The process to build fastcomp
1.37.22 is similar to the instructions mentioned on here.
- Follow instructions on here to install the latest
emsdk
. - Clone
fastcomp
and clang and change the directory tofastcomp-1.37.22
.
git clone https://github.com/emscripten-core/emscripten-fastcomp
cd emsripten-fastcomp
git clone https://github.com/emscripten-core/emscripten-fastcomp-clang tools/clang
cd ..
mv emscripten-fastcomp fastcomp-1.37.22
- Checkout version 1.37.22.
cd fastcomp-1.37.22
git checkout 1.37.22
cd tools/clang
git checkout 1.37.22
cd ../..
- Create a
build
directory and cd into it.
mkdir build
cd build
- Configure and make
cmake .. -DCMAKE_BUILD_TYPE=Release -DLLVM_TARGETS_TO_BUILD="host;JSBackend" -DLLVM_INCLUDE_EXAMPLES=OFF -DLLVM_INCLUDE_TESTS=OFF -DCLANG_INCLUDE_TESTS=OFF
make -j4
- Open
~/.emscripten
file and setLLVM_ROOT
to the absolute path offastcomp-1.37.22/build/bin
directory. - Clone
emscripten
from https://github.com/plasma-umass/browsix-emscripten.git toemscripten
or extractemscripten.tar.xz
toemscripten
. cd emscripten
and execute./emcc -v
to run sanity checks. If there any errors (which are usually in red color), then double check the process.
Now we can use emscripten's C compiler emcc
and C++ compiler em++
to compile C and C++ to WebAssembly or asm.js using Browsix-WASM.
- Install SPEC CPU2006 Benchmarks. All instructions require that SPEC CPU2006 suite has been installed in
/spec-cpu2006/
. - Set the values of
CC
andCXX
variables inbrowsix-asmjs.cfg
andbrowsix-wasm.cfg
to absolute paths ofemcc
andem++
. - Copy
browsix-asmjs.cfg
andbrowsix-wasm.cfg
to/spec-cpu2006/config
. - Compile
401.bzip2
benchmark to WebAssembly withref
dataset
cd /spec
. ./shrc
runspec --size=ref --tune=base --config=browsix-wasm.cfg --noreportable --iterations=1 401.bzip2
- We can ignore the errors spec scripts throws when it executes the benchmarks compiled binaries. However, there should be no compilation error.
- Similarly, to compile to asm.js execute above command but with
--config=browsix-asmjs.cfg
. - A
build
directory will be created in/spec-cpu2006/benchspec/CPU2006/401.bzip2/build/build_base_browsix-wasm.xxxx/
and similarly for asm.js. In both cases,bzip2.js
contains compiled asm.js and WebAssembly code for 401.bzip2. - A
run
directory will be created in/spec-cpu2006/benchspec/CPU2006/401.bzip2/run/run_base_ref_browsix-wasm.0000
, that contains input files andspeccmds.cmd
describing the commands forspecinvoke
to execute.
- Install NodeJS 8.5 (or later). The latest 8.x release can be found here. Notice that
emsdk
providesnodejs 8.12.0
by default. - Install Linux Kernel's
perf
utility on Ubuntu using
sudo apt-get install linux-tools-generic linux-tools-`uname -r`
Or on Fedora/RedHat using
sudo dnf install perf
-
Clone this repo to
browsix-spec2006
directory. -
Build Browsix by
make serve
- Build Browsix-SPEC by
make browsix-spec
Now we copy compiled binaries of SPEC benchmarks and run
directory to the corresponding Browsix-SPEC directory in browsix-spec2006
.
- Following commands to copy all run files (assuming your current directory is
browsix-spec2006
). Unfortunately, currently both WebAssembly and asm.js files has to reside inrun_base_<data_size>_browsix-asmjs.0000
directory.
mkdir -p fs/spec/cpu2006_asmjs/benchspec/CPU2006/401.bzip2/run/run_base_ref_browsix-asmjs.0000
cp /spec-cpu2006/benchspec/CPU2006/401.bzip2/run/run_base_ref_browsix-wasm.0000/* fs/spec/cpu2006_asmjs/benchspec/CPU2006/401.bzip2/run/run_base_ref_browsix-asmjs.0000/
To copy files for asm.js, replace run_base_ref_browsix-wasm.0000
with run_base_ref_browsix-asmjs.0000
.
3. Change file paths to correct file paths in Browsix-SPEC's filesystem in speccmds.cmd
.
cd fs/spec/cpu2006_asmjs/benchspec/CPU2006/401.bzip2/run/run_base_ref_browsix-asmjs.0000/
sed 's/\/spec-cpu2006\/benchspec/\/spec\/cpu2006_asmjs\/benchspec/g' speccmds.cmd > speccmds.cmd-2
sed 's/\/run_base_ref_browsix-wasm.0000/\/run_base_ref_browsix-asmjs.0000/g' speccmds.cmd-2 > speccmds.cmd
cd ../../../../../../../../
- Copy executable file(s), i.e.
bzip2.js
.
cp /spec-cpu2006/benchspec/CPU2006/401.bzip2/build/build_base_browsix-wasm.0000/bzip2.js fs/spec/cpu2006_asmjs/benchspec/CPU2006/401.bzip2/run/run_base_ref_browsix-asmjs.0000/bzip2_base.browsix-wasm
To copy bzip2.js
for asm.js, replace run_base_ref_browsix-wasm.0000
with run_base_ref_browsix-asmjs.0000
.
5. Build specinvoke
binary provided by SPEC CPU2006 Benchmarks using Emscripten and copy that binary to browsix-spec2006/fs/usr/bin
.
6. Update Browsix-WASM's filesystem index.
./xhrfs-index fs > fs/index.json
- Execute Browsix-SPEC's server that finds the process executing the benchmark in the browser and attach
perf
to it.
cd browsix-spec2006
sudo node spec_server.js
- To enable SharedArrayBuffer in Chrome go to
chrome://flags
and enableExperimental enabled SharedArrayBuffer support in JavaScript.
and in Firefox go toabout:config
and enablejavascript.options.shared_memory
. - To execute the benchmark in Firefox, open Firefox in command line using
firefox -contentproc=2
and to execute the benchmark in Chrome open Chrome in command line usinggoogle-chrome-stable
. - To execute
bzip2
withref
dataset, navigate tohttp://localhost:9000/?size=ref&benchmark=bzip2
. - We can use Web Console/Browser Console in Firefox and Developer Tools -> Console in Chrome to see the progress of each benchmark.
- When the benchmark is finished, download the resulting tar file that contains the output of the benchmark,
speccmds.out
,speccmds.err
etc. files. - Data collected by perf is in
browsix-spec2006/perf_data
.