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