Prohibit relaxing the initial gp generation
[riscv-tests.git] / benchmarks / Makefile
1 #=======================================================================
2 # UCB VLSI FLOW: Makefile for riscv-bmarks
3 #-----------------------------------------------------------------------
4 # Yunsup Lee (yunsup@cs.berkeley.edu)
5 #
6
7 XLEN ?= 64
8
9 default: all
10
11 src_dir = .
12
13 instname = riscv-bmarks
14 instbasedir = $(UCB_VLSI_HOME)/install
15
16 #--------------------------------------------------------------------
17 # Sources
18 #--------------------------------------------------------------------
19
20 bmarks = \
21 median \
22 qsort \
23 rsort \
24 towers \
25 vvadd \
26 multiply \
27 mm \
28 dhrystone \
29 spmv \
30 mt-vvadd \
31 mt-matmul \
32 pmp \
33
34 #--------------------------------------------------------------------
35 # Build rules
36 #--------------------------------------------------------------------
37
38 RISCV_PREFIX ?= riscv$(XLEN)-unknown-elf-
39 RISCV_GCC ?= $(RISCV_PREFIX)gcc
40 RISCV_GCC_OPTS ?= -DPREALLOCATE=1 -mcmodel=medany -static -std=gnu99 -O2 -ffast-math -fno-common -fno-builtin-printf
41 RISCV_LINK ?= $(RISCV_GCC) -T $(src_dir)/common/test.ld $(incs)
42 RISCV_LINK_OPTS ?= -static -nostdlib -nostartfiles -lgcc -T $(src_dir)/common/test.ld
43 RISCV_OBJDUMP ?= $(RISCV_PREFIX)objdump --disassemble-all --disassemble-zeroes --section=.text --section=.text.startup --section=.data
44 RISCV_SIM ?= spike --isa=rv$(XLEN)gc
45
46 incs += -I$(src_dir)/../env -I$(src_dir)/common $(addprefix -I$(src_dir)/, $(bmarks))
47 objs :=
48
49 define compile_template
50 $(1).riscv: $(wildcard $(src_dir)/$(1)/*) $(wildcard $(src_dir)/common/*)
51 $$(RISCV_GCC) $$(incs) $$(RISCV_GCC_OPTS) $$(RISCV_LINK_OPTS) -o $$@ $(wildcard $(src_dir)/$(1)/*.c) $(wildcard $(src_dir)/common/*.c) $(wildcard $(src_dir)/common/*.S)
52 endef
53
54 $(foreach bmark,$(bmarks),$(eval $(call compile_template,$(bmark))))
55
56 #------------------------------------------------------------
57 # Build and run benchmarks on riscv simulator
58
59 bmarks_riscv_bin = $(addsuffix .riscv, $(bmarks))
60 bmarks_riscv_dump = $(addsuffix .riscv.dump, $(bmarks))
61 bmarks_riscv_out = $(addsuffix .riscv.out, $(bmarks))
62
63 $(bmarks_riscv_dump): %.riscv.dump: %.riscv
64 $(RISCV_OBJDUMP) $< > $@
65
66 $(bmarks_riscv_out): %.riscv.out: %.riscv
67 $(RISCV_SIM) $< > $@
68
69 riscv: $(bmarks_riscv_dump)
70 run: $(bmarks_riscv_out)
71
72 junk += $(bmarks_riscv_bin) $(bmarks_riscv_dump) $(bmarks_riscv_hex) $(bmarks_riscv_out)
73
74 #------------------------------------------------------------
75 # Default
76
77 all: riscv
78
79 #------------------------------------------------------------
80 # Install
81
82 date_suffix = $(shell date +%Y-%m-%d_%H-%M)
83 install_dir = $(instbasedir)/$(instname)-$(date_suffix)
84 latest_install = $(shell ls -1 -d $(instbasedir)/$(instname)* | tail -n 1)
85
86 install:
87 mkdir $(install_dir)
88 cp -r $(bmarks_riscv_bin) $(bmarks_riscv_dump) $(install_dir)
89
90 install-link:
91 rm -rf $(instbasedir)/$(instname)
92 ln -s $(latest_install) $(instbasedir)/$(instname)
93
94 #------------------------------------------------------------
95 # Clean up
96
97 clean:
98 rm -rf $(objs) $(junk)