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