Skip to content

Commit 0f1ad98

Browse files
committed
Add benchmark scripts
1 parent 8cc9bbf commit 0f1ad98

File tree

3 files changed

+62
-1
lines changed

3 files changed

+62
-1
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ build/softfloat
1616
build/cache/
1717
build/map/
1818
build/path/
19+
build/bin/
1920
*.o
2021
*.o.d
2122
tests/**/*.elf

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ $(OUT)/emulate.o: CFLAGS += -foptimize-sibling-calls -fomit-frame-pointer -fno-s
182182
.DEFAULT_GOAL := all
183183

184184
include mk/external.mk
185-
185+
include mk/benchmark.mk
186186
include mk/wasm.mk
187187

188188
all: config $(BIN)

mk/benchmark.mk

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
USE_PREBUILT ?= 1
2+
3+
CC ?= gcc
4+
CROSS_CC ?= riscv-none-elf-gcc
5+
6+
BINDIR := $(abspath $(OUT))/bin
7+
8+
TEST_SUITES += \
9+
ansibench \
10+
rv8-bench
11+
12+
# "ieee754" needs F extension
13+
# "smolnes", "ticks" have inline assembly and only work in riscv
14+
TESTBENCHES += \
15+
captcha \
16+
donut \
17+
fcalc \
18+
hamilton \
19+
$(ieee754) \
20+
jit \
21+
lena \
22+
line \
23+
maj2random \
24+
mandelbrot \
25+
nqueens \
26+
nyancat \
27+
pi \
28+
puzzle \
29+
qrcode \
30+
richards \
31+
rvsim \
32+
$(smolnes) \
33+
spirograph \
34+
$(ticks)
35+
36+
ifeq ($(USE_PREBUILT),1)
37+
LATEST_RELEASE := $(shell curl -s https://api.github.com/repos/sysprog21/rv32emu-prebuilt/releases/latest | grep -Po '(?<="tag_name": ").+(?=",)')
38+
endif
39+
40+
.PHONY: build-testbenches benchmark
41+
42+
# TODO: generate results automatically
43+
benchmark: build-testbenches
44+
45+
build-testbenches:
46+
ifeq ($(USE_PREBUILT),1)
47+
@echo "Fetching prebuilt executables in \"rv32emu-prebuilt\"..."
48+
@curl --progress-bar -L https://github.com/sysprog21/rv32emu-prebuilt/releases/download/$(LATEST_RELEASE)/rv32emu-prebuilt.tar.gz | tar zx -C build
49+
else
50+
@$(foreach tb,$(TEST_SUITES), \
51+
git submodule update --init ./tests/$(tb) &&) true
52+
@$(foreach tb,$(TEST_SUITES), \
53+
CC=$(CC) CROSS_CC=$(CROSS_CC) BINDIR=$(BINDIR) \
54+
$(MAKE) -C ./tests/$(tb) all &&) true
55+
@$(foreach tb,$(TESTBENCHES), \
56+
$(CC) -m32 -O2 -Wno-unused-result -o $(BINDIR)/x86_64/$(tb) tests/$(tb).c -lm &&) true
57+
@$(foreach tb,$(TESTBENCHES), \
58+
$(CROSS_CC) -march=rv32im -mabi=ilp32 -O2 -Wno-unused-result -Wno-implicit-function-declaration \
59+
-o $(BINDIR)/riscv32/$(tb) tests/$(tb).c -lm -lsemihost &&) true
60+
endif

0 commit comments

Comments
 (0)