2be1455c7da961c4cc51348028e233f648bbbf34
[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
11 instname = riscv-bmarks-mt
12 instbasedir = $(UCB_VLSI_HOME)/install
13
14 #--------------------------------------------------------------------
15 # Sources
16 #--------------------------------------------------------------------
17
18 bmarks = \
19 ab_matmul\
20 ab_vvadd\
21 ad_matmul\
22 ad_vvadd\
23 ae_matmul\
24 ae_vvadd\
25 af_matmul\
26 af_vvadd\
27 ag_matmul\
28 ag_vvadd\
29 ai_matmul\
30 ai_vvadd\
31 aj_vvadd\
32 ak_matmul\
33 ak_vvadd\
34 al_matmul\
35 al_vvadd\
36 am_matmul\
37 am_vvadd\
38 an_matmul\
39 ap_matmul\
40 ap_vvadd\
41 aq_matmul\
42 aq_vvadd\
43 ar_matmul\
44 ar_vvadd\
45 as_matmul\
46 as_vvadd\
47 at_matmul\
48 at_vvadd\
49 av_matmul\
50 av_vvadd\
51 ay_matmul\
52 ay_vvadd\
53 az_matmul\
54 az_vvadd\
55 ba_matmul\
56 ba_vvadd\
57 bb_matmul\
58 bb_vvadd\
59 bc_matmul\
60 bc_vvadd\
61 be_matmul\
62 be_vvadd\
63 bf_matmul\
64 bf_vvadd\
65 bh_matmul\
66 bh_vvadd\
67 bj_matmul\
68 bj_vvadd\
69 bk_matmul\
70 bk_vvadd\
71 bm_matmul\
72 bm_vvadd\
73 bn_matmul\
74 bn_vvadd\
75 bo_matmul\
76 bo_vvadd\
77 bp_matmul\
78 bp_vvadd\
79 br_matmul\
80 br_vvadd\
81 bs_matmul\
82 bs_vvadd\
83 bt_matmul\
84 bt_vvadd\
85
86 #--------------------------------------------------------------------
87 # Build rules
88 #--------------------------------------------------------------------
89
90 RISCV_GCC = riscv-gcc
91 RISCV_GCC_OPTS = -std=gnu99 -T common/test.ld -O3 -nostdlib -nostartfiles -funroll-all-loops
92 RISCV_LINK = riscv-gcc -T $(bmarkdir)/common/test.ld
93 RISCV_LINK_MT = riscv-gcc -T $(bmarkdir)/common/test-mt.ld
94 RISCV_LINK_OPTS = -lc
95 RISCV_LINK_SYSCALL = $(bmarkdir)/common/syscalls.c -lc
96 RISCV_OBJDUMP = riscv-objdump --disassemble-all --disassemble-zeroes --section=.text --section=.text.startup --section=.data
97 RISCV_SIM = spike -p2
98
99 VPATH += $(addprefix $(bmarkdir)/, $(bmarks))
100 VPATH += $(bmarkdir)/common
101
102 incs += -I. -I./common $(addprefix -I$(bmarkdir)/, $(bmarks))
103 objs :=
104
105 #include $(patsubst %, $(bmarkdir)/%/bmark.mk, $(bmarks))
106
107 #------------------------------------------------------------
108 # Build and run benchmarks on riscv simulator
109 #------------------------------------------------------------
110
111 bmarks_riscv_obj = $(addsuffix .o, $(bmarks))
112 bmarks_riscv_bin = $(addsuffix .riscv, $(bmarks))
113 bmarks_riscv_dump = $(addsuffix .riscv.dump, $(bmarks))
114 bmarks_riscv_hex = $(addsuffix .riscv.hex, $(bmarks))
115 bmarks_riscv_out = $(addsuffix .riscv.out, $(bmarks))
116
117 bmarks_defs = -DPREALLOCATE=1 -DHOST_DEBUG=0
118 bmarks_cycles = 80000
119
120 %.hex: %
121 elf2hex 16 32768 $< > $@
122
123 $(bmarks_riscv_bin): %.riscv: %.o crt-mt.o
124 $(RISCV_LINK_MT) crt-mt.o $< $(RISCV_LINK_SYSCALL) -o $@
125
126 $(bmarks_riscv_dump): %.riscv.dump: %.riscv
127 $(RISCV_OBJDUMP) $< > $@
128
129 $(bmarks_riscv_out): %.riscv.out: %.riscv
130 $(RISCV_SIM) $< > $@
131
132 %.o: %.c
133 $(RISCV_GCC) $(RISCV_GCC_OPTS) $(bmarks_defs) \
134 -c $(incs) $< -o $@
135
136 %.o: %.S
137 $(RISCV_GCC) $(RISCV_GCC_OPTS) $(bmarks_defs) \
138 -c $(incs) $< -o $@
139
140 riscv: $(bmarks_riscv_dump) $(bmarks_riscv_hex)
141 run-riscv: $(bmarks_riscv_out)
142 echo; perl -ne 'print " [$$1] $$ARGV \t$$2\n" if /\*{3}(.{8})\*{3}(.*)/' \
143
144 junk += $(bmarks_riscv_bin) $(bmarks_riscv_dump) $(bmarks_riscv_hex) $(bmarks_riscv_out)
145
146
147 #------------------------------------------------------------
148 # Default
149
150 all: riscv
151
152 #------------------------------------------------------------
153 # Install
154
155 date_suffix = $(shell date +%Y-%m-%d_%H-%M)
156 install_dir = $(instbasedir)/$(instname)-$(date_suffix)
157 latest_install = $(shell ls -1 -d $(instbasedir)/$(instname)* | tail -n 1)
158
159 install:
160 mkdir $(install_dir)
161 cp -r $(bmarks_riscv_bin) $(bmarks_riscv_dump) $(install_dir)
162
163 install-link:
164 rm -rf $(instbasedir)/$(instname)
165 ln -s $(latest_install) $(instbasedir)/$(instname)
166
167 #------------------------------------------------------------
168 # Clean up
169
170 clean:
171 rm -rf $(objs) $(junk)