Remove smips/host-debugging cruft
[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
33 #--------------------------------------------------------------------
34 # Build rules
35 #--------------------------------------------------------------------
36
37 RISCV_PREFIX ?= riscv$(XLEN)-unknown-elf-
38 RISCV_GCC ?= $(RISCV_PREFIX)gcc
39 RISCV_GCC_OPTS ?= -mcmodel=medany -static -std=gnu99 -O2 -ffast-math -fno-common -fno-builtin-printf
40 RISCV_LINK ?= $(RISCV_GCC) -T $(src_dir)/common/test.ld $(incs)
41 RISCV_LINK_MT ?= $(RISCV_GCC) -T $(src_dir)/common/test-mt.ld
42 RISCV_LINK_OPTS ?= -static -nostdlib -nostartfiles -lgcc
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 VPATH += $(addprefix $(src_dir)/, $(bmarks))
47 VPATH += $(src_dir)/common
48
49 incs += -I$(src_dir)/../env -I$(src_dir)/common $(addprefix -I$(src_dir)/, $(bmarks))
50 objs :=
51
52 include $(patsubst %, $(src_dir)/%/bmark.mk, $(bmarks))
53
54 #------------------------------------------------------------
55 # Build and run benchmarks on riscv simulator
56
57 bmarks_riscv_bin = $(addsuffix .riscv, $(bmarks))
58 bmarks_riscv_dump = $(addsuffix .riscv.dump, $(bmarks))
59 bmarks_riscv_out = $(addsuffix .riscv.out, $(bmarks))
60
61 bmarks_defs = -DPREALLOCATE=1
62 bmarks_cycles = 80000
63
64 $(bmarks_riscv_dump): %.riscv.dump: %.riscv
65 $(RISCV_OBJDUMP) $< > $@
66
67 $(bmarks_riscv_out): %.riscv.out: %.riscv
68 $(RISCV_SIM) $< > $@
69
70 %.o: %.c
71 $(RISCV_GCC) $(RISCV_GCC_OPTS) $(bmarks_defs) \
72 -c $(incs) $< -o $@
73
74 %.o: %.S
75 $(RISCV_GCC) $(RISCV_GCC_OPTS) $(bmarks_defs) -D__ASSEMBLY__=1 \
76 -c $(incs) $< -o $@
77
78 riscv: $(bmarks_riscv_dump)
79 run-riscv: $(bmarks_riscv_out)
80 echo; perl -ne 'print " [$$1] $$ARGV \t$$2\n" if /\*{3}(.{8})\*{3}(.*)/' \
81 $(bmarks_riscv_out); echo;
82
83 junk += $(bmarks_riscv_bin) $(bmarks_riscv_dump) $(bmarks_riscv_hex) $(bmarks_riscv_out)
84
85 #------------------------------------------------------------
86 # Default
87
88 all: riscv
89
90 #------------------------------------------------------------
91 # Install
92
93 date_suffix = $(shell date +%Y-%m-%d_%H-%M)
94 install_dir = $(instbasedir)/$(instname)-$(date_suffix)
95 latest_install = $(shell ls -1 -d $(instbasedir)/$(instname)* | tail -n 1)
96
97 install:
98 mkdir $(install_dir)
99 cp -r $(bmarks_riscv_bin) $(bmarks_riscv_dump) $(install_dir)
100
101 install-link:
102 rm -rf $(instbasedir)/$(instname)
103 ln -s $(latest_install) $(instbasedir)/$(instname)
104
105 #------------------------------------------------------------
106 # Clean up
107
108 clean:
109 rm -rf $(objs) $(junk)