Separate page faults from physical memory access exceptions
[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_PREFIX=riscv$(XLEN)-unknown-elf-
79 RISCV_GCC = $(RISCV_PREFIX)gcc
80 RISCV_GCC_OPTS = -std=gnu99 -O2 -ffast-math
81 RISCV_LINK = $(RISCV_GCC) -T $(common)/test.ld $(incs)
82 RISCV_LINK_OPTS = -nostdlib -nostartfiles -ffast-math -lc
83 RISCV_OBJDUMP = $(RISCV_PREFIX)objdump --disassemble-all --disassemble-zeroes --section=.text --section=.text.startup --section=.data
84 RISCV_SIM = spike -p2
85
86 VPATH += $(common) $(common)/../mt-matmul $(common)/../mt-vvadd
87
88 incs += -I. -I$(bmarkdir)/../env -I$(common) -I$(common)/../mt-matmul -I$(common)/../mt-vvadd
89 objs :=
90
91 #include $(patsubst %, $(bmarkdir)/%/bmark.mk, $(bmarks))
92
93 #------------------------------------------------------------
94 # Build and run benchmarks on riscv simulator
95 #------------------------------------------------------------
96
97 bmarks_riscv_obj = $(addsuffix .o, $(bmarks))
98 bmarks_riscv_matmul_bin = $(addsuffix .riscv, $(bmarks_matmul))
99 bmarks_riscv_vvadd_bin = $(addsuffix .riscv, $(bmarks_vvadd))
100 bmarks_riscv_dump = $(addsuffix .riscv.dump, $(bmarks))
101 bmarks_riscv_hex = $(addsuffix .riscv.hex, $(bmarks))
102 bmarks_riscv_out = $(addsuffix .riscv.out, $(bmarks))
103 bmarks_riscv_bin = $(bmarks_riscv_matmul_bin) $(bmarks_riscv_vvadd_bin)
104
105 bmarks_defs = -DPREALLOCATE=1 -DHOST_DEBUG=0
106 bmarks_cycles = 80000
107
108 %.hex: %
109 elf2hex 16 32768 $< > $@
110
111 $(bmarks_riscv_vvadd_bin): %.riscv: %.o mt-vvadd.o syscalls.o crt.o
112 $(RISCV_LINK) $< mt-vvadd.o syscalls.o crt.o $(RISCV_LINK_OPTS) -o $@
113
114 $(bmarks_riscv_matmul_bin): %.riscv: %.o mt-matmul.o syscalls.o crt.o
115 $(RISCV_LINK) $< mt-matmul.o syscalls.o crt.o $(RISCV_LINK_OPTS) -o $@
116
117 $(bmarks_riscv_dump): %.riscv.dump: %.riscv
118 $(RISCV_OBJDUMP) $< > $@
119
120 $(bmarks_riscv_out): %.riscv.out: %.riscv
121 $(RISCV_SIM) $< > $@
122
123 %.o: %.c
124 $(RISCV_GCC) $(RISCV_GCC_OPTS) $(bmarks_defs) -D__ASSEMBLY__=1 \
125 -c $(incs) $< -o $@
126
127 %.o: %.S
128 $(RISCV_GCC) $(RISCV_GCC_OPTS) $(bmarks_defs) \
129 -c $(incs) $< -o $@
130
131 riscv: $(bmarks_riscv_dump) $(bmarks_riscv_hex)
132 run-riscv: $(bmarks_riscv_out)
133 echo; perl -ne 'print " [$$1] $$ARGV \t$$2\n" if /\*{3}(.{8})\*{3}(.*)/' \
134
135 junk += $(bmarks_riscv_bin) $(bmarks_riscv_dump) $(bmarks_riscv_hex) $(bmarks_riscv_out) $(bmarks_riscv_obj)
136
137
138 #------------------------------------------------------------
139 # Default
140
141 all: riscv
142
143 #------------------------------------------------------------
144 # Install
145
146 date_suffix = $(shell date +%Y-%m-%d_%H-%M)
147 install_dir = $(instbasedir)/$(instname)-$(date_suffix)
148 latest_install = $(shell ls -1 -d $(instbasedir)/$(instname)* | tail -n 1)
149
150 install:
151 mkdir $(install_dir)
152 cp -r $(bmarks_riscv_bin) $(bmarks_riscv_dump) $(install_dir)
153
154 install-link:
155 rm -rf $(instbasedir)/$(instname)
156 ln -s $(latest_install) $(instbasedir)/$(instname)
157
158 #------------------------------------------------------------
159 # Clean up
160
161 clean:
162 rm -rf $(objs) $(junk) syscall.o crt.o mt-matmul.o mt-vvadd.o