blob: b6faca53dc66a4753c61e8ea8a670858c3e8d2a1 [file] [log] [blame]
# Run tbm on the riscv-tests.
# First, build the elf files `m springbok_riscv_tests`
# This must be the first thing in the file:
THIS_MAKEFILE := $(lastword $(MAKEFILE_LIST))
.DELETE_ON_ERROR:
include tbm.mk
.PHONY: riscv_tests clean_riscv_tests
clean: clean_riscv_tests
RISCV_TESTS_DIR = $(OUT)/springbok/riscv-tests
###############################################################################
## Run tbm on the ELF files from $(RISCV_TESTS_DIR)/isa
# Defines RISCV_TESTS_ISA
include riscv_tests_isa.mk
# TODO(sflur): is there a better way to list only the elf files?
riscv_tests_isa.mk: $(wildcard $(RISCV_TESTS_DIR)/isa/*)
{ echo "## AUTO GENERATED FILE, DO NOT EDIT!";\
echo "$$(cd $(RISCV_TESTS_DIR)/isa && file * |\
sed -n 's/\([^:]\+\):[[:space:]]*ELF.*/RISCV_TESTS_ISA += \1/p')";\
} > $@
# We only support user-level:
RISCV_TESTS_ISA := $(filter rv32u%,$(RISCV_TESTS_ISA))
# We don't support the A-ext:
RISCV_TESTS_ISA := $(filter-out rv32ua-%,$(RISCV_TESTS_ISA))
# We don't support the C-ext:
RISCV_TESTS_ISA := $(filter-out rv32uc-%,$(RISCV_TESTS_ISA))
# We don't support the D-ext:
RISCV_TESTS_ISA := $(filter-out rv32ud-%,$(RISCV_TESTS_ISA))
define isa_rules
$$(OUT_TRACES)/riscv-tests/isa/$1.spike: $$(RISCV_TESTS_DIR)/isa/$1 | $$(OUT_TRACES)/riscv-tests/isa
# The tests don't terminate nicely, so we have to use CYCLES
$$(OUT_TRACES)/riscv-tests/isa/$1.spike: CYCLES = 10000
$$(OUT_TRACES)/riscv-tests/isa/$1.tbm_log: $$(UARCH)
riscv_tests_isa: $$(OUT_TRACES)/riscv-tests/isa/$1.tbm_log
endef
$(foreach t,$(RISCV_TESTS_ISA),$(eval $(call isa_rules,$(t))))
$(OUT_TRACES)/riscv-tests/isa:
mkdir -p $@
.PHONY: riscv_tests_isa
riscv_tests: riscv_tests_isa
clean_riscv_tests_isa:
$(RM) riscv_tests_isa.mk
$(RM) -r $(OUT_TRACES)/riscv-tests/isa
.PHONY: clean_riscv_tests_isa
clean_riscv_tests: clean_riscv_tests_isa
###############################################################################
## Run tbm on the ELF files from $(RISCV_TESTS_DIR)/benchmarks
RISCV_TESTS_BENCHMARKS := $(wildcard $(RISCV_TESTS_DIR)/benchmarks/*.riscv)
define benchmarks_rules
$$(OUT_TRACES)/riscv-tests/benchmarks/$1.spike: $$(RISCV_TESTS_DIR)/benchmarks/$1 | $$(OUT_TRACES)/riscv-tests/benchmarks
$$(OUT_TRACES)/riscv-tests/benchmarks/$1.spike: SPIKE_MEM := 0x80000000:0x100000
$$(OUT_TRACES)/riscv-tests/benchmarks/$1.spike: SPIKE_ENTRY := 0x80000000
$$(OUT_TRACES)/riscv-tests/benchmarks/$1.tbm_log: $$(UARCH)
riscv_tests_benchmarks: $$(OUT_TRACES)/riscv-tests/benchmarks/$1.tbm_log
RISCV_TESTS_BENCHMARKS_LOGS += $$(OUT_TRACES)/riscv-tests/benchmarks/$1.tbm_log
endef
$(foreach t,$(RISCV_TESTS_BENCHMARKS),$(eval $(call benchmarks_rules,$(notdir $(t)))))
$(OUT_TRACES)/riscv-tests/benchmarks:
mkdir -p $@
.PHONY: riscv_tests_benchmarks
riscv_tests: riscv_tests_benchmarks
# We use -B to make sure everything is up to date
benchmarks:
TBM_OPTS=--report-dont-include-cfg $(MAKE) -f $(THIS_MAKEFILE) -B $(OUT_TRACES)/riscv-tests/benchmarks/benchmarks.md
.PHONY: benchmarks
$(OUT_TRACES)/riscv-tests/benchmarks/benchmarks.md: $(RISCV_TESTS_BENCHMARKS_LOGS)
@{ echo "# Benchmark Results #";\
echo;\
echo "Date: $$(date --iso-8601=seconds --utc)";\
echo "uArch config ($(UARCH)):";\
echo '```';\
cat "$(UARCH)";\
echo '```';\
$(foreach test,$(RISCV_TESTS_BENCHMARKS),\
echo;\
echo "### Test: $(notdir $(test)) ###";\
echo;\
echo "ELF file: $(test:$(ROOTDIR)/%=%)";\
echo;\
echo '```';\
cat "$(test:$(RISCV_TESTS_DIR)/%=$(OUT)/%.tbm_log)";\
echo '```';\
)\
} > $@
clean_riscv_tests_benchmarks:
$(RM) -r $(OUT_TRACES)/riscv-tests/benchmarks
.PHONY: clean_riscv_tests_benchmarks
clean_riscv_tests: clean_riscv_tests_benchmarks