Cross-compiling Coremark
Coremark is another benchmarking tool. Here coremark will be cross-compiled for riscv64-unknown-linux-gnu
and will be run on qemu-riscv64
. The github source code commit at the time of build is eefc986ebd3452d6adde22eafaff3e5c859f29e4
and branch is main
.
Getting the source code
Execute the following command to get the source code of coremark.
git clone https://github.com/eembc/coremark.git
Tweaking source files for riscv64-unknown-linux-gnu
At the time of this documentation, linux is being used for this test. First of all core_portme.mak
will be changed.
- Navigate to
linux/
directory in source repository. - Open
core_portme.mak
. Here a single line will be used to includecore_portme.mak
fromposix
directory. So, navigate toposix/
directory in source folder - Open
core_portme.mak
inposix/
directory and do the following changes to variables here.- Change
CC?=cc
toCC=riscv64-unknown-linux-gnu-gcc
. - Scroll down and change
EXE=.exe
toEXE=
(it should be blank). - Scroll down and change
LD=gcc
toLD=riscv64-unknown-linux-gnu-ld
. - As we are using
qemu-riscv64
, so changeRUN=
toRUN=qemu-riscv64 -L "$$RISCV_SYSROOT"
- Save changes and exit this file.
- Change
- Now open
core_portme.h
and change#define USE_CLOCK 0
to#define USE_CLOCK 1
and save. - Navigate to source directory of repository and execute following command
make PORT_DIR=linux/
If everything went right, the output result will be stored in run1.log
and run2.log
and will be of the form as shown below.
2K validation run parameters for coremark.
CoreMark Size : 666
Total ticks : 12368459
Total time (secs): 12.368459
Iterations/Sec : 8893.589735
Iterations : 110000
Compiler version : GCC12.2.0
Compiler flags : -O2 -DPERFORMANCE_RUN=1 -lrt
Memory location : Please put data memory location here
(e.g. code in flash, data on heap etc)
seedcrc : 0x18f2
[0]crclist : 0xe3c1
[0]crcmatrix : 0x0747
[0]crcstate : 0x8d84
[0]crcfinal : 0x0956
Correct operation validated. See README.md for run and reporting rules.