Remove vestigial j instruction test; improve jal test
[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 default: all
8
9 src_dir = .
10
11 instname = riscv-bmarks
12 instbasedir = $(UCB_VLSI_HOME)/install
13
14 #--------------------------------------------------------------------
15 # Sources
16 #--------------------------------------------------------------------
17
18 bmarks = \
19 median \
20 qsort \
21 rsort \
22 towers \
23 vvadd \
24 multiply \
25 mm \
26 dhrystone \
27 spmv \
28 mt-vvadd \
29 mt-matmul \
30
31 bmarks_host = \
32 median \
33 qsort \
34 towers \
35 vvadd \
36 multiply \
37 spmv \
38 vec-vvadd \
39 vec-cmplxmult \
40 vec-matmul \
41
42 #--------------------------------------------------------------------
43 # Build rules
44 #--------------------------------------------------------------------
45
46 HOST_OPTS = -std=gnu99 -DPREALLOCATE=0 -DHOST_DEBUG=1
47 HOST_COMP = gcc $(HOST_OPTS)
48
49 RISCV_PREFIX ?= riscv64-unknown-elf-
50 RISCV_GCC ?= $(RISCV_PREFIX)gcc
51 RISCV_GCC_OPTS ?= -mcmodel=medany -static -std=gnu99 -O2 -ffast-math -fno-common -fno-builtin-printf
52 RISCV_LINK ?= $(RISCV_GCC) -T $(src_dir)/common/test.ld $(incs)
53 RISCV_LINK_MT ?= $(RISCV_GCC) -T $(src_dir)/common/test-mt.ld
54 RISCV_LINK_OPTS ?= -nostdlib -nostartfiles -ffast-math -lgcc
55 RISCV_OBJDUMP ?= $(RISCV_PREFIX)objdump --disassemble-all --disassemble-zeroes --section=.text --section=.text.startup --section=.data
56 RISCV_SIM ?= spike
57
58 VPATH += $(addprefix $(src_dir)/, $(bmarks))
59 VPATH += $(src_dir)/common
60
61 incs += -I$(src_dir)/../env -I$(src_dir)/common $(addprefix -I$(src_dir)/, $(bmarks))
62 objs :=
63
64 include $(patsubst %, $(src_dir)/%/bmark.mk, $(bmarks))
65
66 #------------------------------------------------------------
67 # Build and run benchmarks on riscv simulator
68
69 bmarks_riscv_bin = $(addsuffix .riscv, $(bmarks))
70 bmarks_riscv_dump = $(addsuffix .riscv.dump, $(bmarks))
71 bmarks_riscv_out = $(addsuffix .riscv.out, $(bmarks))
72
73 bmarks_defs = -DPREALLOCATE=1 -DHOST_DEBUG=0
74 bmarks_cycles = 80000
75
76 $(bmarks_riscv_dump): %.riscv.dump: %.riscv
77 $(RISCV_OBJDUMP) $< > $@
78
79 $(bmarks_riscv_out): %.riscv.out: %.riscv
80 $(RISCV_SIM) $< > $@
81
82 %.o: %.c
83 $(RISCV_GCC) $(RISCV_GCC_OPTS) $(bmarks_defs) \
84 -c $(incs) $< -o $@
85
86 %.o: %.S
87 $(RISCV_GCC) $(RISCV_GCC_OPTS) $(bmarks_defs) -D__ASSEMBLY__=1 \
88 -c $(incs) $< -o $@
89
90 riscv: $(bmarks_riscv_dump)
91 run-riscv: $(bmarks_riscv_out)
92 echo; perl -ne 'print " [$$1] $$ARGV \t$$2\n" if /\*{3}(.{8})\*{3}(.*)/' \
93 $(bmarks_riscv_out); echo;
94
95 junk += $(bmarks_riscv_bin) $(bmarks_riscv_dump) $(bmarks_riscv_hex) $(bmarks_riscv_out)
96
97 #------------------------------------------------------------
98 # Build and run benchmarks on host machine
99
100 bmarks_host_bin = $(addsuffix .host, $(bmarks_host))
101 bmarks_host_out = $(addsuffix .host.out, $(bmarks_host))
102
103 $(bmarks_host_out): %.host.out: %.host
104 ./$< > $@
105
106 host: $(bmarks_host_bin)
107 run-host: $(bmarks_host_out)
108 echo; perl -ne 'print " [$$1] $$ARGV \t$$2\n" if /\*{3}(.{8})\*{3}(.*)/' \
109 $(bmarks_host_out); echo;
110
111 junk += $(bmarks_host_bin) $(bmarks_host_out)
112
113 #------------------------------------------------------------
114 # Default
115
116 all: riscv
117
118 #------------------------------------------------------------
119 # Install
120
121 date_suffix = $(shell date +%Y-%m-%d_%H-%M)
122 install_dir = $(instbasedir)/$(instname)-$(date_suffix)
123 latest_install = $(shell ls -1 -d $(instbasedir)/$(instname)* | tail -n 1)
124
125 install:
126 mkdir $(install_dir)
127 cp -r $(bmarks_riscv_bin) $(bmarks_riscv_dump) $(install_dir)
128
129 install-link:
130 rm -rf $(instbasedir)/$(instname)
131 ln -s $(latest_install) $(instbasedir)/$(instname)
132
133 #------------------------------------------------------------
134 # Clean up
135
136 clean:
137 rm -rf $(objs) $(junk)