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