Skip to content

Commit

Permalink
Merge pull request #603 from riscv-software-src/bmark_compile
Browse files Browse the repository at this point in the history
Compile non-vec benchmarks for rv64gc
  • Loading branch information
jerryz123 authored Mar 1, 2025
2 parents 8bd4a74 + 216f4ff commit 7de2a1f
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions benchmarks/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ instbasedir = $(UCB_VLSI_HOME)/install
# Sources
#--------------------------------------------------------------------

bmarks = \
base_bmarks = \
median \
qsort \
rsort \
Expand All @@ -39,32 +39,39 @@ bmarks = \
mt-matmul \
mt-memcpy \
pmp \

vec_bmarks = \
vec-memcpy \
vec-daxpy \
vec-sgemm \
vec-strcmp \

bmarks = $(base_bmarks) $(vec_bmarks)

#--------------------------------------------------------------------
# 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 -Wno-implicit-int -Wno-implicit-function-declaration -march=rv$(XLEN)gcv -mabi=$(ABI)
RISCV_GCC_OPTS ?= -DPREALLOCATE=1 -mcmodel=medany -static -std=gnu99 -O2 -ffast-math -fno-common -fno-builtin-printf -fno-tree-loop-distribute-patterns -Wno-implicit-int -Wno-implicit-function-declaration -mabi=$(ABI)
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
RISCV_MARCH ?= rv$(XLEN)gc
RISCV_VMARCH ?= rv$(XLEN)gcv
RISCV_SIM ?= spike --isa=rv$(XLEN)gcv

incs += -I$(src_dir)/../env -I$(src_dir)/common $(addprefix -I$(src_dir)/, $(bmarks))
objs :=

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)
$$(RISCV_GCC) $$(incs) $$(RISCV_GCC_OPTS) -march=$(2) -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

$(foreach bmark,$(bmarks),$(eval $(call compile_template,$(bmark))))
$(foreach bmark,$(base_bmarks),$(eval $(call compile_template,$(bmark),$(RISCV_MARCH))))
$(foreach bmark,$(vec_bmarks),$(eval $(call compile_template,$(bmark),$(RISCV_VMARCH))))

#------------------------------------------------------------
# Build and run benchmarks on riscv simulator
Expand Down

0 comments on commit 7de2a1f

Please sign in to comment.