Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,6 @@ build/sail_cSim/
tests/**/*.elf
tests/arch-test-target/config.ini
tests/arch-test-target/sail_cSim/riscv_sim_RV32
tests/scimark2/
__pycache__/
src/rv32_jit.c
8 changes: 8 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,11 @@
path = src/ieeelib
url = https://github.com/sysprog21/ieeelib
shallow = true
[submodule "tests/doom"]
path = tests/doom
url = https://github.com/sysprog21/doom_riscv
shallow = true
[submodule "tests/quake"]
path = tests/quake
url = https://github.com/sysprog21/quake-embedded
shallow = true
8 changes: 4 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -275,15 +275,15 @@ misalign: $(BIN) artifact

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

ifeq ($(call has, EXT_F), 1)
quake_action := (cd $(OUT); ../$(BIN) quake.elf)
quake_action := (cd $(OUT); ../$(BIN) riscv32/quake)
quake_deps += $(QUAKE_DATA) $(BIN)
quake: $(quake_deps)
quake: artifact $(quake_deps)
$(quake_action)
endif
endif
Expand Down
Binary file removed build/doom.elf
Binary file not shown.
Binary file removed build/quake.elf
Binary file not shown.
Binary file removed build/scimark2.elf
Binary file not shown.
6 changes: 3 additions & 3 deletions docs/prebuilt.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ The prebuilt binaries in `rv32emu-prebuilt` are built from the following reposit
- sha512
- `captcha` : See [tests/captcha.c](/tests/captcha.c)
- `donut` : See [tests/donut.c](/tests/donut.c)
- `doom` : See [sysprog21/doom_riscv](https://github.com/sysprog21/doom_riscv)
- `fcalc` : See [tests/fcalc.c](/tests/fcalc.c)
- `hamilton` : See [tests/hamilton.c](/tests/hamilton.c)
- `jit` : See [tests/jit.c](/tests/jit.c)
Expand All @@ -48,8 +49,10 @@ The prebuilt binaries in `rv32emu-prebuilt` are built from the following reposit
- `pi` : See [tests/pi.c](/tests/pi.c)
- `puzzle` : See [tests/puzzle.c](/tests/puzzle.c)
- `qrcode` : See [tests/qrcode.c](/tests/qrcode.c)
- `quake` : See [sysprog21/quake-embedded](https://github.com/sysprog21/quake-embedded)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mention RV32F explicitly.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The current prebuilt binaries are built with -march=rv32im option. I'd like to keep quake been built without F extension for the consistency.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SciMark2 should be built in RV32F since it reports a composite score in approximate Mflops (Millions of floating point operations per second).

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SciMark2 should be built in RV32F since it reports a composite score in approximate Mflops (Millions of floating point operations per second).

Got it. Should we also build quake with rv32f? I feel the execution is smooth when building with rv32im.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Got it. Should we also build quake with rv32f? I feel the execution is smooth when building with rv32im.

Quake needs to be compiled with RV32IMF. Otherwise, it is unlikely to function properly.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I found quake is already built with RV32IMF within its Makefile. I'll update the document later.

- `richards` : See [tests/richards.c](/tests/richards.c)
- `rvsim` : See [tests/rvsim.c](/tests/rvsim.c)
- `scimark2` : See [Scimark 2.0](https://math.nist.gov/scimark2)
- `spirograph` : See [tests/spirograph.c](/tests/spirograph.c)
- `uaes` : See [tests/uaes.c](/tests/uaes.c)

Expand All @@ -58,10 +61,7 @@ There are still some prebuilt standalone RISC-V binaries under `build/` director
- `hello.elf` : See [tests/asm-hello](/tests/asm-hello)
- `cc.elf` : See [tests/cc](/tests/cc)
- `chacha20.elf` : See [tests/chacha20](/tests/chacha20)
- `doom.elf` : See [sysprog21/doom_riscv](https://github.com/sysprog21/doom_riscv) [RV32M]
- `ieee754.elf` : See [tests/ieee754.c](/tests/ieee754.c) [RV32F]
- `jit-bf.elf` : See [ezaki-k/xkon_beta](https://github.com/ezaki-k/xkon_beta)
- `quake.elf` : See [sysprog21/quake-embedded](https://github.com/sysprog21/quake-embedded) [RV32F]
- `readelf.elf` : See [tests/readelf](/tests/readelf)
- `scimark2.elf` : See [tests/scimark2](/tests/scimark2) [RV32MF]
- `smolnes.elf` : See [tests/smolnes](/tests/smolnes.c) [RV32M]
50 changes: 43 additions & 7 deletions mk/artifact.mk
Original file line number Diff line number Diff line change
Expand Up @@ -31,40 +31,76 @@ TEST_BENCHES += \
spirograph \
uaes

SCIMARK2_URL := https://math.nist.gov/scimark2/scimark2_1c.zip
SCIMARK2_SHA1 := de278c5b8cef84ab6dda41855052c7bfef919e36

SHELL_HACK := $(shell mkdir -p $(BIN_DIR)/linux-x86-softfp $(BIN_DIR)/riscv32)

ifeq ($(call has, PREBUILT), 1)
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/')
else
# Since rv32emu only supports the dynamic binary translation of integer instruction in tiered compilation currently,
# we disable the hardware floating-point and the related SIMD operation of x86.
CFLAGS := -m32 -mno-sse -mno-sse2 -msoft-float -O2 -L$(BIN_DIR)
CFLAGS := -m32 -mno-sse -mno-sse2 -msoft-float -O2 -Wno-unused-result -L$(BIN_DIR)
LDFLAGS := -lsoft-fp -lm

CFLAGS_CROSS := -march=rv32im -mabi=ilp32 -O2
CFLAGS_CROSS := -march=rv32im -mabi=ilp32 -O2 -Wno-implicit-function-declaration
LDFLAGS_CROSS := -lm -lsemihost
endif

.PHONY: artifact
.PHONY: artifact scimark2 ieeelib

artifact:
artifact: ieeelib scimark2
ifeq ($(call has, PREBUILT), 1)
$(Q)$(PRINTF) "Fetching prebuilt executables from \"rv32emu-prebuilt\" ...\n"
$(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
else
git submodule update --init ./src/ieeelib $(addprefix ./tests/,$(foreach tb,$(TEST_SUITES),$(tb)))
$(Q)$(MAKE) -C ./src/ieeelib CC=$(CC) CFLAGS="$(CFLAGS)" BINDIR=$(BIN_DIR)
git submodule update --init $(addprefix ./tests/,$(foreach tb,$(TEST_SUITES),$(tb)))
$(Q)for tb in $(TEST_SUITES); do \
CC=$(CC) CFLAGS="$(CFLAGS)" LDFLAGS="$(LDFLAGS)" BINDIR=$(BIN_DIR)/linux-x86-softfp $(MAKE) -C ./tests/$$tb; \
done
$(Q)for tb in $(TEST_SUITES); do \
CC=$(CROSS_COMPILE)gcc CFLAGS="$(CFLAGS_CROSS)" LDFLAGS="$(LDFLAGS_CROSS)" BINDIR=$(BIN_DIR)/riscv32 $(MAKE) -C ./tests/$$tb; \
done

$(Q)$(PRINTF) "Building standalone testbenches ...\n"
$(Q)for tb in $(TEST_BENCHES); do \
$(CC) $(CFLAGS) -Wno-unused-result -o $(BIN_DIR)/linux-x86-softfp/$$tb ./tests/$$tb.c $(LDFLAGS); \
$(CC) $(CFLAGS) -o $(BIN_DIR)/linux-x86-softfp/$$tb ./tests/$$tb.c $(LDFLAGS); \
done
$(Q)for tb in $(TEST_BENCHES); do \
$(CROSS_COMPILE)gcc $(CFLAGS_CROSS) -o $(BIN_DIR)/riscv32/$$tb ./tests/$$tb.c $(LDFLAGS_CROSS); \
done

git submodule update --init ./tests/doom ./tests/quake
$(Q)$(PRINTF) "Building doom ...\n"
$(Q)$(MAKE) -C ./tests/doom/src/riscv CROSS=$(CROSS_COMPILE)
$(Q)cp ./tests/doom/src/riscv/doom-riscv.elf $(BIN_DIR)/riscv32/doom
$(Q)$(PRINTF) "Building quake ...\n"
$(Q)cd ./tests/quake && mkdir -p build && cd build && \
cmake -DCMAKE_TOOLCHAIN_FILE=../port/boards/rv32emu/toolchain.cmake \
-DCROSS_COMPILE=$(CROSS_COMPILE) \
-DCMAKE_BUILD_TYPE=RELEASE -DBOARD_NAME=rv32emu .. && \
make
$(Q)cp ./tests/quake/build/port/boards/rv32emu/quake $(BIN_DIR)/riscv32/quake
endif

scimark2: ieeelib
ifeq ($(call has, PREBUILT), 0)
$(Q)$(call prologue,"scimark2")
$(Q)$(call download,$(SCIMARK2_URL))
$(Q)$(call verify,$(SCIMARK2_SHA1),$(notdir $(SCIMARK2_URL)))
$(Q)$(call extract,"./tests/scimark2",$(notdir $(SCIMARK2_URL)))
$(Q)$(call epilogue,$(notdir $(SCIMARK2_URL)),$(SHA1_FILE1),$(SHA1_FILE2))
$(Q)$(PRINTF) "Building scimark2 ...\n"
$(Q)$(MAKE) -C ./tests/scimark2 CC=$(CC) CFLAGS="$(CFLAGS)" LDFLAGS="$(LDFLAGS)"
$(Q)cp ./tests/scimark2/scimark2 $(BIN_DIR)/linux-x86-softfp/scimark2
$(Q)$(MAKE) -C ./tests/scimark2 clean && $(RM) ./tests/scimark2/scimark2.o
$(Q)$(MAKE) -C ./tests/scimark2 CC=$(CROSS_COMPILE)gcc CFLAGS="$(CFLAGS_CROSS)"
$(Q)cp ./tests/scimark2/scimark2 $(BIN_DIR)/riscv32/scimark2
endif

ieeelib:
ifeq ($(call has, PREBUILT), 0)
git submodule update --init ./src/ieeelib
$(Q)$(MAKE) -C ./src/ieeelib CC=$(CC) CFLAGS="$(CFLAGS)" BINDIR=$(BIN_DIR)
endif
11 changes: 6 additions & 5 deletions mk/external.mk
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,15 @@ define download
$(eval _ := $(shell wget -q --show-progress --continue "$(strip $(1))"))
endef

# $(1): compressed source(.zip or.gz)
# $(1): destination directory
# $(2): compressed source(.zip or.gz)
define extract
$(eval COMPRESSED_SUFFIX := $(suffix $(1)))
$(eval COMPRESSED_SUFFIX := $(suffix $(2)))
$(eval COMPRESSED_IS_ZIP := $(filter $(COMPRESSED_SUFFIX),.zip))
$(eval _ := \
$(if $(COMPRESSED_IS_ZIP), \
($(eval EXTRACTOR := unzip -d $(OUT) $(1))), \
($(eval EXTRACTOR := tar -xf $(1) -C $(OUT))) \
($(eval EXTRACTOR := unzip -d $(1) $(2))), \
($(eval EXTRACTOR := tar -xf $(2) -C $(1))) \
))
$(eval _ := $(shell $(EXTRACTOR)))
endef
Expand Down Expand Up @@ -90,7 +91,7 @@ define download-extract-verify
$($(T)_DATA):
$(Q)$$(call prologue,$$@)
$(Q)$$(call download,$(strip $($(T)_DATA_URL)))
$(Q)$$(call extract,$(notdir $($(T)_DATA_URL)))
$(Q)$$(call extract,$(OUT),$(notdir $($(T)_DATA_URL)))
$(Q)$$(call verify,$($(T)_DATA_SHA1), $($(T)_DATA))
$(Q)$$(call epilogue,$(notdir $($(T)_DATA_URL)),$(SHA1_FILE1),$(SHA1_FILE2))
endef
Expand Down
1 change: 1 addition & 0 deletions tests/doom
Submodule doom added at 9b238b
1 change: 1 addition & 0 deletions tests/quake
Submodule quake added at da5c5a
159 changes: 0 additions & 159 deletions tests/scimark2/FFT.c

This file was deleted.

6 changes: 0 additions & 6 deletions tests/scimark2/FFT.h

This file was deleted.

Loading
Loading