Skip to content

Commit 48fc077

Browse files
authored
Merge pull request #480 from vacantron/prebuilt
Automate doom, quake, and scimark2 builds
2 parents c757229 + 2690815 commit 48fc077

33 files changed

+70
-1107
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,5 +25,6 @@ build/sail_cSim/
2525
tests/**/*.elf
2626
tests/arch-test-target/config.ini
2727
tests/arch-test-target/sail_cSim/riscv_sim_RV32
28+
tests/scimark2/
2829
__pycache__/
2930
src/rv32_jit.c

.gitmodules

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,11 @@
2323
path = src/ieeelib
2424
url = https://github.com/sysprog21/ieeelib
2525
shallow = true
26+
[submodule "tests/doom"]
27+
path = tests/doom
28+
url = https://github.com/sysprog21/doom_riscv
29+
shallow = true
30+
[submodule "tests/quake"]
31+
path = tests/quake
32+
url = https://github.com/sysprog21/quake-embedded
33+
shallow = true

Makefile

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -275,15 +275,15 @@ misalign: $(BIN) artifact
275275

276276
# Non-trivial demonstration programs
277277
ifeq ($(call has, SDL), 1)
278-
doom_action := (cd $(OUT); ../$(BIN) doom.elf)
278+
doom_action := (cd $(OUT); ../$(BIN) riscv32/doom)
279279
doom_deps += $(DOOM_DATA) $(BIN)
280-
doom: $(doom_deps)
280+
doom: artifact $(doom_deps)
281281
$(doom_action)
282282

283283
ifeq ($(call has, EXT_F), 1)
284-
quake_action := (cd $(OUT); ../$(BIN) quake.elf)
284+
quake_action := (cd $(OUT); ../$(BIN) riscv32/quake)
285285
quake_deps += $(QUAKE_DATA) $(BIN)
286-
quake: $(quake_deps)
286+
quake: artifact $(quake_deps)
287287
$(quake_action)
288288
endif
289289
endif

build/doom.elf

-670 KB
Binary file not shown.

build/quake.elf

-534 KB
Binary file not shown.

build/scimark2.elf

-95.9 KB
Binary file not shown.

docs/prebuilt.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ The prebuilt binaries in `rv32emu-prebuilt` are built from the following reposit
3636
- sha512
3737
- `captcha` : See [tests/captcha.c](/tests/captcha.c)
3838
- `donut` : See [tests/donut.c](/tests/donut.c)
39+
- `doom` : See [sysprog21/doom_riscv](https://github.com/sysprog21/doom_riscv)
3940
- `fcalc` : See [tests/fcalc.c](/tests/fcalc.c)
4041
- `hamilton` : See [tests/hamilton.c](/tests/hamilton.c)
4142
- `jit` : See [tests/jit.c](/tests/jit.c)
@@ -53,15 +54,16 @@ The prebuilt binaries in `rv32emu-prebuilt` are built from the following reposit
5354
- `spirograph` : See [tests/spirograph.c](/tests/spirograph.c)
5455
- `uaes` : See [tests/uaes.c](/tests/uaes.c)
5556

57+
To determine performance of the floating point arithmetic, the following RISC-V binaries are built with option `-march=rv32imf`:
58+
- `quake` : See [sysprog21/quake-embedded](https://github.com/sysprog21/quake-embedded)
59+
- `scimark2` : See [Scimark 2.0](https://math.nist.gov/scimark2)
60+
5661
There are still some prebuilt standalone RISC-V binaries under `build/` directory only for testing purpose:
5762

5863
- `hello.elf` : See [tests/asm-hello](/tests/asm-hello)
5964
- `cc.elf` : See [tests/cc](/tests/cc)
6065
- `chacha20.elf` : See [tests/chacha20](/tests/chacha20)
61-
- `doom.elf` : See [sysprog21/doom_riscv](https://github.com/sysprog21/doom_riscv) [RV32M]
6266
- `ieee754.elf` : See [tests/ieee754.c](/tests/ieee754.c) [RV32F]
6367
- `jit-bf.elf` : See [ezaki-k/xkon_beta](https://github.com/ezaki-k/xkon_beta)
64-
- `quake.elf` : See [sysprog21/quake-embedded](https://github.com/sysprog21/quake-embedded) [RV32F]
6568
- `readelf.elf` : See [tests/readelf](/tests/readelf)
66-
- `scimark2.elf` : See [tests/scimark2](/tests/scimark2) [RV32MF]
6769
- `smolnes.elf` : See [tests/smolnes](/tests/smolnes.c) [RV32M]

mk/artifact.mk

Lines changed: 44 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,40 +31,77 @@ TEST_BENCHES += \
3131
spirograph \
3232
uaes
3333

34+
SCIMARK2_URL := https://math.nist.gov/scimark2/scimark2_1c.zip
35+
SCIMARK2_SHA1 := de278c5b8cef84ab6dda41855052c7bfef919e36
36+
3437
SHELL_HACK := $(shell mkdir -p $(BIN_DIR)/linux-x86-softfp $(BIN_DIR)/riscv32)
3538

3639
ifeq ($(call has, PREBUILT), 1)
3740
LATEST_RELEASE := $(shell wget -q https://api.github.com/repos/sysprog21/rv32emu-prebuilt/releases/latest -O- | grep '"tag_name"' | sed -E 's/.*"tag_name": "([^"]+)".*/\1/')
3841
else
3942
# Since rv32emu only supports the dynamic binary translation of integer instruction in tiered compilation currently,
4043
# we disable the hardware floating-point and the related SIMD operation of x86.
41-
CFLAGS := -m32 -mno-sse -mno-sse2 -msoft-float -O2 -L$(BIN_DIR)
44+
CFLAGS := -m32 -mno-sse -mno-sse2 -msoft-float -O2 -Wno-unused-result -L$(BIN_DIR)
4245
LDFLAGS := -lsoft-fp -lm
4346

44-
CFLAGS_CROSS := -march=rv32im -mabi=ilp32 -O2
47+
CFLAGS_CROSS := -march=rv32im -mabi=ilp32 -O2 -Wno-implicit-function-declaration
4548
LDFLAGS_CROSS := -lm -lsemihost
4649
endif
4750

48-
.PHONY: artifact
51+
.PHONY: artifact scimark2 ieeelib
4952

50-
artifact:
53+
artifact: ieeelib scimark2
5154
ifeq ($(call has, PREBUILT), 1)
5255
$(Q)$(PRINTF) "Fetching prebuilt executables from \"rv32emu-prebuilt\" ...\n"
5356
$(Q)wget -q --show-progress https://github.com/sysprog21/rv32emu-prebuilt/releases/download/$(LATEST_RELEASE)/rv32emu-prebuilt.tar.gz -O- | tar -C build --strip-components=1 -xz
5457
else
55-
git submodule update --init ./src/ieeelib $(addprefix ./tests/,$(foreach tb,$(TEST_SUITES),$(tb)))
56-
$(Q)$(MAKE) -C ./src/ieeelib CC=$(CC) CFLAGS="$(CFLAGS)" BINDIR=$(BIN_DIR)
58+
git submodule update --init $(addprefix ./tests/,$(foreach tb,$(TEST_SUITES),$(tb)))
5759
$(Q)for tb in $(TEST_SUITES); do \
5860
CC=$(CC) CFLAGS="$(CFLAGS)" LDFLAGS="$(LDFLAGS)" BINDIR=$(BIN_DIR)/linux-x86-softfp $(MAKE) -C ./tests/$$tb; \
5961
done
6062
$(Q)for tb in $(TEST_SUITES); do \
6163
CC=$(CROSS_COMPILE)gcc CFLAGS="$(CFLAGS_CROSS)" LDFLAGS="$(LDFLAGS_CROSS)" BINDIR=$(BIN_DIR)/riscv32 $(MAKE) -C ./tests/$$tb; \
6264
done
65+
6366
$(Q)$(PRINTF) "Building standalone testbenches ...\n"
6467
$(Q)for tb in $(TEST_BENCHES); do \
65-
$(CC) $(CFLAGS) -Wno-unused-result -o $(BIN_DIR)/linux-x86-softfp/$$tb ./tests/$$tb.c $(LDFLAGS); \
68+
$(CC) $(CFLAGS) -o $(BIN_DIR)/linux-x86-softfp/$$tb ./tests/$$tb.c $(LDFLAGS); \
6669
done
6770
$(Q)for tb in $(TEST_BENCHES); do \
6871
$(CROSS_COMPILE)gcc $(CFLAGS_CROSS) -o $(BIN_DIR)/riscv32/$$tb ./tests/$$tb.c $(LDFLAGS_CROSS); \
6972
done
73+
74+
git submodule update --init ./tests/doom ./tests/quake
75+
$(Q)$(PRINTF) "Building doom ...\n"
76+
$(Q)$(MAKE) -C ./tests/doom/src/riscv CROSS=$(CROSS_COMPILE)
77+
$(Q)cp ./tests/doom/src/riscv/doom-riscv.elf $(BIN_DIR)/riscv32/doom
78+
$(Q)$(PRINTF) "Building quake ...\n"
79+
$(Q)cd ./tests/quake && mkdir -p build && cd build && \
80+
cmake -DCMAKE_TOOLCHAIN_FILE=../port/boards/rv32emu/toolchain.cmake \
81+
-DCROSS_COMPILE=$(CROSS_COMPILE) \
82+
-DCMAKE_BUILD_TYPE=RELEASE -DBOARD_NAME=rv32emu .. && \
83+
make
84+
$(Q)cp ./tests/quake/build/port/boards/rv32emu/quake $(BIN_DIR)/riscv32/quake
85+
endif
86+
87+
scimark2:
88+
ifeq ($(call has, PREBUILT), 0)
89+
$(Q)$(call prologue,"scimark2")
90+
$(Q)$(call download,$(SCIMARK2_URL))
91+
$(Q)$(call verify,$(SCIMARK2_SHA1),$(notdir $(SCIMARK2_URL)))
92+
$(Q)$(call extract,"./tests/scimark2",$(notdir $(SCIMARK2_URL)))
93+
$(Q)$(call epilogue,$(notdir $(SCIMARK2_URL)),$(SHA1_FILE1),$(SHA1_FILE2))
94+
$(Q)$(PRINTF) "Building scimark2 ...\n"
95+
$(Q)$(MAKE) -C ./tests/scimark2 clean && $(RM) ./tests/scimark2/scimark2.o
96+
$(Q)$(MAKE) -C ./tests/scimark2 CC=$(CC) CFLAGS="-m32 -O2"
97+
$(Q)cp ./tests/scimark2/scimark2 $(BIN_DIR)/linux-x86-softfp/scimark2
98+
$(Q)$(MAKE) -C ./tests/scimark2 clean && $(RM) ./tests/scimark2/scimark2.o
99+
$(Q)$(MAKE) -C ./tests/scimark2 CC=$(CROSS_COMPILE)gcc CFLAGS="-march=rv32imf -mabi=ilp32 -O2"
100+
$(Q)cp ./tests/scimark2/scimark2 $(BIN_DIR)/riscv32/scimark2
101+
endif
102+
103+
ieeelib:
104+
ifeq ($(call has, PREBUILT), 0)
105+
git submodule update --init ./src/ieeelib
106+
$(Q)$(MAKE) -C ./src/ieeelib CC=$(CC) CFLAGS="$(CFLAGS)" BINDIR=$(BIN_DIR)
70107
endif

mk/external.mk

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,15 @@ define download
2525
$(eval _ := $(shell wget -q --show-progress --continue "$(strip $(1))"))
2626
endef
2727

28-
# $(1): compressed source(.zip or.gz)
28+
# $(1): destination directory
29+
# $(2): compressed source(.zip or.gz)
2930
define extract
30-
$(eval COMPRESSED_SUFFIX := $(suffix $(1)))
31+
$(eval COMPRESSED_SUFFIX := $(suffix $(2)))
3132
$(eval COMPRESSED_IS_ZIP := $(filter $(COMPRESSED_SUFFIX),.zip))
3233
$(eval _ := \
3334
$(if $(COMPRESSED_IS_ZIP), \
34-
($(eval EXTRACTOR := unzip -d $(OUT) $(1))), \
35-
($(eval EXTRACTOR := tar -xf $(1) -C $(OUT))) \
35+
($(eval EXTRACTOR := unzip -d $(1) $(2))), \
36+
($(eval EXTRACTOR := tar -xf $(2) -C $(1))) \
3637
))
3738
$(eval _ := $(shell $(EXTRACTOR)))
3839
endef
@@ -90,7 +91,7 @@ define download-extract-verify
9091
$($(T)_DATA):
9192
$(Q)$$(call prologue,$$@)
9293
$(Q)$$(call download,$(strip $($(T)_DATA_URL)))
93-
$(Q)$$(call extract,$(notdir $($(T)_DATA_URL)))
94+
$(Q)$$(call extract,$(OUT),$(notdir $($(T)_DATA_URL)))
9495
$(Q)$$(call verify,$($(T)_DATA_SHA1), $($(T)_DATA))
9596
$(Q)$$(call epilogue,$(notdir $($(T)_DATA_URL)),$(SHA1_FILE1),$(SHA1_FILE2))
9697
endef

tests/doom

Submodule doom added at 9b238b8

0 commit comments

Comments
 (0)