Cross-compiling dhrystone

Dhrystone is a benchmarking tool. Here dhrystone will be compiled from source and run on qemu-riscv64.
Dhrystone is comparable to VAX 11/780 in a way that VAX 11/780 achieves 1757 dhrystones per second which is also referred to as 1 MIPS of VAX11/780. So number of dhrystones per seconds are obtained and then divided by 1757 to get MIPS. See this link for more details.

Cross-compiling for riscv64-unknown-linux-gnu

  • Get the source code of dhrystone using the command below
git clone https://github.com/sifive/benchmark-dhrystone.git
  • Navigate to root directory of repository and compile program with riscv64-unknown-linux-gnu-gcc instead of native gcc
cd benchmark-dhrystone
make CC=riscv64-unknown-linux-gnu-gcc
  • Execute following command to execute dhrystone binary
qemu-riscv64 -L $RISCV_SYSROOT ./dhrystone

Note: You may want to tweak Makefile and dhry_1.c a little bit to get the correct results.