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