1 #/=======================================================================
2 # UCB VLSI FLOW: Makefile for riscv-bmarks/mt
3 #-----------------------------------------------------------------------
4 # Henry Cook (hcook@cs.berkeley.edu)
10 common
= ..
/benchmarks
/common
12 instname
= riscv-bmarks-mt
13 instbasedir
= $(UCB_VLSI_HOME
)/install
15 #--------------------------------------------------------------------
17 #--------------------------------------------------------------------
72 bmarks
= $(bmarks_vvadd
) $(bmarks_matmul
)
74 #--------------------------------------------------------------------
76 #--------------------------------------------------------------------
78 RISCV_PREFIX
=riscv64-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
86 VPATH
+= $(common
) $(common
)/..
/mt-matmul
$(common
)/..
/mt-vvadd
88 incs
+= -I.
-I
$(bmarkdir
)/..
/env
-I
$(common
) -I
$(common
)/..
/mt-matmul
-I
$(common
)/..
/mt-vvadd
91 #include $(patsubst %, $(bmarkdir)/%/bmark.mk, $(bmarks))
93 #------------------------------------------------------------
94 # Build and run benchmarks on riscv simulator
95 #------------------------------------------------------------
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
)
105 bmarks_defs
= -DPREALLOCATE
=1 -DHOST_DEBUG
=0
106 bmarks_cycles
= 80000
109 elf2hex
16 32768 $< > $@
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
$@
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
$@
117 $(bmarks_riscv_dump
): %.riscv.dump
: %.riscv
118 $(RISCV_OBJDUMP
) $< > $@
120 $(bmarks_riscv_out
): %.riscv.out
: %.riscv
124 $(RISCV_GCC
) $(RISCV_GCC_OPTS
) $(bmarks_defs
) -D__ASSEMBLY__
=1 \
128 $(RISCV_GCC
) $(RISCV_GCC_OPTS
) $(bmarks_defs
) \
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}(.*)/' \
135 junk
+= $(bmarks_riscv_bin
) $(bmarks_riscv_dump
) $(bmarks_riscv_hex
) $(bmarks_riscv_out
) $(bmarks_riscv_obj
)
138 #------------------------------------------------------------
143 #------------------------------------------------------------
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)
152 cp
-r
$(bmarks_riscv_bin
) $(bmarks_riscv_dump
) $(install_dir
)
155 rm -rf
$(instbasedir
)/$(instname
)
156 ln
-s
$(latest_install
) $(instbasedir
)/$(instname
)
158 #------------------------------------------------------------
162 rm -rf
$(objs
) $(junk
) syscall.o crt.o mt-matmul.o mt-vvadd.o