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
fastcompand 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
builddirectory 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
~/.emscriptenfile and setLLVM_ROOTto the absolute path offastcomp-1.37.22/build/bindirectory. - Clone
emscriptenfrom https://github.com/plasma-umass/browsix-emscripten.git toemscriptenor extractemscripten.tar.xztoemscripten. cd emscriptenand execute./emcc -vto 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
CCandCXXvariables inbrowsix-asmjs.cfgandbrowsix-wasm.cfgto absolute paths ofemccandem++. - Copy
browsix-asmjs.cfgandbrowsix-wasm.cfgto/spec-cpu2006/config. - Compile
401.bzip2benchmark to WebAssembly withrefdataset
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
builddirectory 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.jscontains compiled asm.js and WebAssembly code for 401.bzip2. - A
rundirectory will be created in/spec-cpu2006/benchspec/CPU2006/401.bzip2/run/run_base_ref_browsix-wasm.0000, that contains input files andspeccmds.cmddescribing the commands forspecinvoketo execute.
- Install NodeJS 8.5 (or later). The latest 8.x release can be found here. Notice that
emsdkprovidesnodejs 8.12.0by default. - Install Linux Kernel's
perfutility on Ubuntu using
sudo apt-get install linux-tools-generic linux-tools-`uname -r`
Or on Fedora/RedHat using
sudo dnf install perf
- Clone
browsix-specfrom here tobrowsix-spec2006directory or extractbrowsix-spec2006.tar.xztobrowsix-spec2006directory.
tar -xvf browsix-spec2006.tgz
- Within
browsix-spec2006runnpm ito install all required node modules.
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.0000directory.
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. 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
perfto it.
cd browsix-spec2006
sudo node server.js
- To enable SharedArrayBuffer in Chrome go to
chrome://flagsand enableExperimental enabled SharedArrayBuffer support in JavaScript.and in Firefox go toabout:configand enablejavascript.options.shared_memory. - To execute the benchmark in Firefox, open Firefox in command line using
firefox -contentproc=2and to execute the benchmark in Chrome open Chrome in command line usinggoogle-chrome-stable. - To execute
bzip2withrefdataset, 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.erretc. files. - Data collected by perf is in
browsix-spec2006/perf_data.