Skip to content

Commit

Permalink
resources: Merge develop into stable for v23.1 release (#21)
Browse files Browse the repository at this point in the history
  • Loading branch information
BobbyRBruce authored Jan 10, 2024
2 parents b8d0806 + f4ba200 commit 2f6cd72
Show file tree
Hide file tree
Showing 539 changed files with 9,537 additions and 19,349 deletions.
18 changes: 14 additions & 4 deletions src/asmtest/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,21 @@ XLEN ?= 64
src_dir := ./isa
bin_dir := ./bin
dump_dir := ./dump
bench_dir := ./benchmarks

include $(src_dir)/rv64ui/Makefrag
include $(src_dir)/rv64uc/Makefrag
include $(src_dir)/rv64um/Makefrag
include $(src_dir)/rv64ua/Makefrag
include $(src_dir)/rv64uf/Makefrag
include $(src_dir)/rv64ud/Makefrag
include $(src_dir)/rv64uzfh/Makefrag
include $(src_dir)/rv64si/Makefrag
include $(src_dir)/rv64ssvnapot/Makefrag
include $(src_dir)/rv64mi/Makefrag
include $(src_dir)/rv64mzicbo/Makefrag
include $(src_dir)/rv64uamt/Makefrag
include $(src_dir)/rv64samt/Makefrag
include $(src_dir)/rv64uzfh/Makefrag
include $(src_dir)/rv64ub/Makefrag
include $(src_dir)/rv32ui/Makefrag
include $(src_dir)/rv32uc/Makefrag
Expand All @@ -33,6 +36,8 @@ include $(src_dir)/rv32uamt/Makefrag
include $(src_dir)/rv32samt/Makefrag
include $(src_dir)/rv32ub/Makefrag

include $(bench_dir)/Makefile

default: all

#--------------------------------------------------------------------
Expand All @@ -43,7 +48,7 @@ RISCV_PREFIX ?= riscv$(XLEN)-unknown-elf-
RISCV_GCC ?= $(RISCV_PREFIX)gcc
RISCV_GCC_OPTS ?= -static -mcmodel=medany -fvisibility=hidden -nostdlib -nostartfiles
RISCV_OBJDUMP ?= $(RISCV_PREFIX)objdump --disassemble-all --disassemble-zeroes --section=.text --section=.text.startup --section=.text.init --section=.data
RISCV_SIM ?= spike
RISCV_SIM ?= spike --isa=rv$(XLEN)gcv

vpath %.S $(src_dir)

Expand All @@ -55,7 +60,10 @@ vpath %.S $(src_dir)
$(RISCV_OBJDUMP) $(bin_dir)/$< > $(dump_dir)/$@

%.out: %
$(RISCV_SIM) --isa=rv64gc $< 2> $@
$(RISCV_SIM) --isa=rv64gc_zfh_zicboz_svnapot_zicntr --misaligned $< 2> $@

%.out32: %
$(RISCV_SIM) --isa=rv32gc_zfh_zicboz_svnapot_zicntr --misaligned $< 2> $@

define compile_template

Expand Down Expand Up @@ -104,11 +112,13 @@ $(eval $(call compile_template,rv64um,-march=rv64g -mabi=lp64))
$(eval $(call compile_template,rv64ua,-march=rv64g -mabi=lp64))
$(eval $(call compile_template,rv64uf,-march=rv64g -mabi=lp64))
$(eval $(call compile_template,rv64ud,-march=rv64g -mabi=lp64))
$(eval $(call compile_template,rv64uzfh,-march=rv64g_zfh -mabi=lp64))
$(eval $(call compile_template,rv64mzicbo,-march=rv64g_zicboz -mabi=lp64))
$(eval $(call compile_template,rv64si,-march=rv64g -mabi=lp64))
$(eval $(call compile_template,rv64ssvnapot,-march=rv64g -mabi=lp64))
$(eval $(call compile_template,rv64mi,-march=rv64g -mabi=lp64))
$(eval $(call compile_template,rv64uamt,-march=rv64g -mabi=lp64))
$(eval $(call compile_template,rv64samt,-march=rv64g -mabi=lp64))
$(eval $(call compile_template,rv64uzfh,-march=rv64g_zfh -mabi=lp64))
$(eval $(call compile_template,rv64ub,-march=rv64g_zba_zbb_zbc_zbs -mabi=lp64))

p_env_tests_dump = $(addsuffix .dump, $(p_env_tests))
Expand Down
32 changes: 29 additions & 3 deletions src/asmtest/README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
title: gem5 Specifc RISC-V tests
title: gem5 Specific RISC-V tests
tags:
- testing
- riscv
Expand Down Expand Up @@ -73,12 +73,38 @@ thread wait/wakeup behaviors. This set reuses some of the tests in
threads wait and wake up in certain cases. This test set also checks functional
behaviors of threads after a wait/wakeup operation.

5. Bit-manipulation ISA tests (`isa/rv32ub`, `isa/rv64ub`)

This is a instructions test sets of Zba, Zbb, Zbc and Zbs extensions. They are
bit-manipulations of registers.

6. Makefile for `benchmarks` directory

The `compile_template` in the Makefile has been changed to not use
the default `gcc` options and the `riscv-tests` linkers.
Instead, the new compile template only uses the `common` directory in `benchmarks` and the `-static` and `-O2` flags.
To facilitate gem5 compatible ROIs, the `Makefile` links with the `libm5.a` present in the `gem5/include` directory
(NOTE: the `gem5` directory must be in the `common` directory for compiling the benchmarks).
As part of this change, all the source code of the benchmarks use `m5_work_begin` and `m5_work_end` to mark the beginning and end of the ROI.

7. `mm` benchmark source code

A minor change was made to the `mm` benchmark source code to make it
compatible with the `Makefile` changes mentioned above.
Since `mm_main.c` used `thread_entry` as the `main` function,
the compiler was not able to find the `main` function.
This was fixed by renaming `thread_entry` to `main`.

How to compile this test suite
------------------------------

1. Install RISC-V GNU toolchain. Source code and instruction on how to install
it can be found here: <https://github.com/riscv/riscv-gnu-toolchain>.

2. Run `make`
2. Put gem5 with compiled m5ops in the `common` directory. Documentation on how to compile m5ops can be found here: <http://www.gem5.org/documentation/general_docs/m5ops>.

3. Navigate to `gem5/include/gem5/m5ops.h` and change the `#include <gem5/asm/generic/m5ops.h>` statement to `#include <gem5/include/gem5/asm/generic/m5ops.h>`.

4. Run `make`.

3. Test binaries are in `bin`
5. Test binaries are in `bin`.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ XLEN ?= 64

default: all

src_dir = .
src_dir = ./benchmarks

instname = riscv-bmarks
instbasedir = $(UCB_VLSI_HOME)/install
Expand All @@ -23,21 +23,27 @@ bmarks = \
rsort \
towers \
vvadd \
memcpy \
multiply \
mm \
dhrystone \
spmv \
mt-vvadd \
mt-matmul \
pmp \
# vec-memcpy \
# vec-daxpy \
# vec-sgemm \
# vec-strcmp \
# mt-vvadd \
# mt-matmul \
# mt-memcpy \
#--------------------------------------------------------------------
# Build rules
#--------------------------------------------------------------------

RISCV_PREFIX ?= riscv$(XLEN)-unknown-elf-
RISCV_GCC ?= $(RISCV_PREFIX)gcc
RISCV_GCC_OPTS ?= -DPREALLOCATE=1 -mcmodel=medany -static -std=gnu99 -O2 -ffast-math -fno-common -fno-builtin-printf -fno-tree-loop-distribute-patterns
RISCV_GCC_OPTS ?= -DPREALLOCATE=1 -mcmodel=medany -static -std=gnu99 -O2 -ffast-math -fno-common -fno-builtin-printf -fno-tree-loop-distribute-patterns -march=rv$(XLEN)gcv -mabi=lp64d
RISCV_LINK ?= $(RISCV_GCC) -T $(src_dir)/common/test.ld $(incs)
RISCV_LINK_OPTS ?= -static -nostdlib -nostartfiles -lm -lgcc -T $(src_dir)/common/test.ld
RISCV_OBJDUMP ?= $(RISCV_PREFIX)objdump --disassemble-all --disassemble-zeroes --section=.text --section=.text.startup --section=.text.init --section=.data
Expand All @@ -46,9 +52,22 @@ RISCV_SIM ?= spike --isa=rv$(XLEN)gc
incs += -I$(src_dir)/../env -I$(src_dir)/common $(addprefix -I$(src_dir)/, $(bmarks))
objs :=

# old compile template
# define compile_template
# $(1).riscv: $(wildcard $(src_dir)/$(1)/*) $(wildcard $(src_dir)/common/*)
# $$(RISCV_GCC) $$(incs) $$(RISCV_GCC_OPTS) -o $$@ $(wildcard $(src_dir)/$(1)/*.c) $(wildcard $(src_dir)/$(1)/*.S) $(wildcard $(src_dir)/common/*.c) $(wildcard $(src_dir)/common/*.S) $$(RISCV_LINK_OPTS)
# endef

# old compile template
# define compile_template
# $(1).riscv: $(wildcard $(src_dir)/$(1)/*) $(wildcard $(src_dir)/common/*)
# $$(RISCV_GCC) $$(incs) $$(RISCV_GCC_OPTS) -o $$@ $(wildcard $(src_dir)/$(1)/*.c) $(wildcard $(src_dir)/$(1)/*.S) $(wildcard $(src_dir)/common/*.c) $(wildcard $(src_dir)/common/*.S) $$(RISCV_LINK_OPTS)
# endef

define compile_template
$(1).riscv: $(wildcard $(src_dir)/$(1)/*) $(wildcard $(src_dir)/common/*)
$$(RISCV_GCC) $$(incs) $$(RISCV_GCC_OPTS) -o $$@ $(wildcard $(src_dir)/$(1)/*.c) $(wildcard $(src_dir)/common/*.c) $(wildcard $(src_dir)/common/*.S) $$(RISCV_LINK_OPTS)
$$(RISCV_GCC) -I$(src_dir)/common -static -O2 -o $$@ $(wildcard $(src_dir)/$(1)/*.c) $(wildcard $(src_dir)/$(1)/*.S) $(src_dir)/common/gem5/util/m5/build/riscv/out/libm5.a
$$(RISCV_GCC) -I$(src_dir)/common -static -O2 -o $$@ $(wildcard $(src_dir)/$(1)/*.c) $(wildcard $(src_dir)/$(1)/*.S) $(src_dir)/common/gem5/util/m5/build/riscv/out/libm5.a
endef

$(foreach bmark,$(bmarks),$(eval $(call compile_template,$(bmark))))
Expand All @@ -71,10 +90,44 @@ run: $(bmarks_riscv_out)

junk += $(bmarks_riscv_bin) $(bmarks_riscv_dump) $(bmarks_riscv_hex) $(bmarks_riscv_out)

bins_dir = bin

move_riscv_files:
mkdir -p $(bins_dir)
mv $(bmarks_riscv_bin) $(bins_dir)

.PHONY: move_riscv_files

dumps_dir = dump

move_riscv_dumps:
mkdir -p $(dumps_dir)
mv $(bmarks_riscv_dump) $(dumps_dir)

.PHONY: move_riscv_dumps


bins_dir = bin

move_riscv_files:
mkdir -p $(bins_dir)
mv $(bmarks_riscv_bin) $(bins_dir)

.PHONY: move_riscv_files

dumps_dir = dump

move_riscv_dumps:
mkdir -p $(dumps_dir)
mv $(bmarks_riscv_dump) $(dumps_dir)

.PHONY: move_riscv_dumps


#------------------------------------------------------------
# Default

all: riscv
all: riscv move_riscv_files move_riscv_dumps

#------------------------------------------------------------
# Install
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ _start:
li x30,0
li x31,0

# enable FPU and accelerator if present
li t0, MSTATUS_FS | MSTATUS_XS
# enable FPU, vector, and accelerator if present
li t0, MSTATUS_FS | MSTATUS_XS | MSTATUS_VS
csrs mstatus, t0

# make sure XLEN agrees with compilation choice
Expand Down
Loading

0 comments on commit 2f6cd72

Please sign in to comment.