Rely on assembler to relax far branches
[riscv-tests.git] / mt / Makefile
1 #/=======================================================================
2 # UCB VLSI FLOW: Makefile for riscv-bmarks/mt
3 #-----------------------------------------------------------------------
4 # Henry Cook (hcook@cs.berkeley.edu)
5 #
6
7 default: all
8
9 bmarkdir = .
10 common = ../benchmarks/common
11
12 instname = riscv-bmarks-mt
13 instbasedir = $(UCB_VLSI_HOME)/install
14
15 #--------------------------------------------------------------------
16 # Sources
17 #--------------------------------------------------------------------
18
19 bmarks_matmul = \
20 ad_matmul\
21 ae_matmul\
22 af_matmul\
23 ag_matmul\
24 ai_matmul\
25 ak_matmul\
26 al_matmul\
27 am_matmul\
28 an_matmul\
29 ap_matmul\
30 aq_matmul\
31 ar_matmul\
32 at_matmul\
33 av_matmul\
34 ay_matmul\
35 az_matmul\
36 bb_matmul\
37 bc_matmul\
38 bf_matmul\
39 bh_matmul\
40 bj_matmul\
41 bk_matmul\
42 bm_matmul\
43 bo_matmul\
44 br_matmul\
45 bs_matmul\
46 ce_matmul\
47 cf_matmul\
48 cg_matmul\
49 ci_matmul\
50 ck_matmul\
51 cl_matmul\
52 cm_matmul\
53 cs_matmul\
54 cv_matmul\
55 cy_matmul\
56 dc_matmul\
57 df_matmul\
58 dm_matmul\
59 do_matmul\
60 dr_matmul\
61 ds_matmul\
62 du_matmul\
63 dv_matmul\
64
65 bmarks_vvadd = \
66 vvadd0\
67 vvadd1\
68 vvadd2\
69 vvadd3\
70 vvadd4\
71
72 bmarks = $(bmarks_vvadd) $(bmarks_matmul)
73
74 #--------------------------------------------------------------------
75 # Build rules
76 #--------------------------------------------------------------------
77
78 RISCV_GCC = riscv-gcc
79 RISCV_GCC_OPTS = -Wa,-march=RVIMAFDXhwacha -std=gnu99 -O2 -ffast-math
80 RISCV_LINK = riscv-gcc -T $(common)/test.ld $(incs)
81 RISCV_LINK_OPTS = -nostdlib -nostartfiles -ffast-math -lc
82 RISCV_OBJDUMP = riscv-objdump --disassemble-all --disassemble-zeroes --section=.text --section=.text.startup --section=.data
83 RISCV_SIM = spike -p2
84
85 VPATH += $(common) $(common)/../mt-matmul $(common)/../mt-vvadd
86
87 incs += -I. -I$(bmarkdir)/../env -I$(common) -I$(common)/../mt-matmul -I$(common)/../mt-vvadd
88 objs :=
89
90 #include $(patsubst %, $(bmarkdir)/%/bmark.mk, $(bmarks))
91
92 #------------------------------------------------------------
93 # Build and run benchmarks on riscv simulator
94 #------------------------------------------------------------
95
96 bmarks_riscv_obj = $(addsuffix .o, $(bmarks))
97 bmarks_riscv_matmul_bin = $(addsuffix .riscv, $(bmarks_matmul))
98 bmarks_riscv_vvadd_bin = $(addsuffix .riscv, $(bmarks_vvadd))
99 bmarks_riscv_dump = $(addsuffix .riscv.dump, $(bmarks))
100 bmarks_riscv_hex = $(addsuffix .riscv.hex, $(bmarks))
101 bmarks_riscv_out = $(addsuffix .riscv.out, $(bmarks))
102 bmarks_riscv_bin = $(bmarks_riscv_matmul_bin) $(bmarks_riscv_vvadd_bin)
103
104 bmarks_defs = -DPREALLOCATE=1 -DHOST_DEBUG=0
105 bmarks_cycles = 80000
106
107 %.hex: %
108 elf2hex 16 32768 $< > $@
109
110 $(bmarks_riscv_vvadd_bin): %.riscv: %.o mt-vvadd.o syscalls.o crt.o
111 $(RISCV_LINK) $< mt-vvadd.o syscalls.o crt.o $(RISCV_LINK_OPTS) -o $@
112
113 $(bmarks_riscv_matmul_bin): %.riscv: %.o mt-matmul.o syscalls.o crt.o
114 $(RISCV_LINK) $< mt-matmul.o syscalls.o crt.o $(RISCV_LINK_OPTS) -o $@
115
116 $(bmarks_riscv_dump): %.riscv.dump: %.riscv
117 $(RISCV_OBJDUMP) $< > $@
118
119 $(bmarks_riscv_out): %.riscv.out: %.riscv
120 $(RISCV_SIM) $< > $@
121
122 %.o: %.c
123 $(RISCV_GCC) $(RISCV_GCC_OPTS) $(bmarks_defs) -D__ASSEMBLY__=1 \
124 -c $(incs) $< -o $@
125
126 %.o: %.S
127 $(RISCV_GCC) $(RISCV_GCC_OPTS) $(bmarks_defs) \
128 -c $(incs) $< -o $@
129
130 riscv: $(bmarks_riscv_dump) $(bmarks_riscv_hex)
131 run-riscv: $(bmarks_riscv_out)
132 echo; perl -ne 'print " [$$1] $$ARGV \t$$2\n" if /\*{3}(.{8})\*{3}(.*)/' \
133
134 junk += $(bmarks_riscv_bin) $(bmarks_riscv_dump) $(bmarks_riscv_hex) $(bmarks_riscv_out) $(bmarks_riscv_obj)
135
136
137 #------------------------------------------------------------
138 # Default
139
140 all: riscv
141
142 #------------------------------------------------------------
143 # Install
144
145 date_suffix = $(shell date +%Y-%m-%d_%H-%M)
146 install_dir = $(instbasedir)/$(instname)-$(date_suffix)
147 latest_install = $(shell ls -1 -d $(instbasedir)/$(instname)* | tail -n 1)
148
149 install:
150 mkdir $(install_dir)
151 cp -r $(bmarks_riscv_bin) $(bmarks_riscv_dump) $(install_dir)
152
153 install-link:
154 rm -rf $(instbasedir)/$(instname)
155 ln -s $(latest_install) $(instbasedir)/$(instname)
156
157 #------------------------------------------------------------
158 # Clean up
159
160 clean:
161 rm -rf $(objs) $(junk) syscall.o crt.o mt-matmul.o mt-vvadd.o