1 #=======================================================================
2 # UCB VLSI FLOW: Makefile for riscv-bmarks
3 #-----------------------------------------------------------------------
4 # Yunsup Lee (yunsup@cs.berkeley.edu)
11 instname
= riscv-bmarks
12 instbasedir
= $(UCB_VLSI_HOME
)/install
14 #--------------------------------------------------------------------
16 #--------------------------------------------------------------------
46 #--------------------------------------------------------------------
48 #--------------------------------------------------------------------
50 HOST_OPTS
= -std
=gnu99
-DPREALLOCATE
=0 -DHOST_DEBUG
=1
51 HOST_COMP
= gcc
$(HOST_OPTS
)
54 RISCV_GCC_OPTS
= -static
-Wa
,-march
=RVIMAFDXhwacha
-std
=gnu99
-O2
-ffast-math
55 RISCV_LINK
= riscv-gcc
-T
$(bmarkdir
)/common
/test.
ld $(incs
)
56 RISCV_LINK_MT
= riscv-gcc
-T
$(bmarkdir
)/common
/test-mt.
ld
57 RISCV_LINK_OPTS
= -nostdlib
-nostartfiles
-ffast-math
-lc
58 RISCV_OBJDUMP
= riscv-objdump
--disassemble-all
--disassemble-zeroes
--section
=.text
--section
=.text.startup
--section
=.data
61 VPATH
+= $(addprefix $(bmarkdir
)/, $(bmarks
))
62 VPATH
+= $(bmarkdir
)/common
64 incs
+= -I
$(bmarkdir
)/..
/env
-I
$(bmarkdir
)/common
$(addprefix -I
$(bmarkdir
)/, $(bmarks
))
67 include $(patsubst %, $(bmarkdir
)/%/bmark.mk
, $(bmarks
))
69 #------------------------------------------------------------
70 # Build and run benchmarks on riscv simulator
72 bmarks_riscv_bin
= $(addsuffix .riscv
, $(bmarks
))
73 bmarks_riscv_dump
= $(addsuffix .riscv.dump
, $(bmarks
))
74 bmarks_riscv_hex
= $(addsuffix .riscv.hex
, $(bmarks
))
75 bmarks_riscv_out
= $(addsuffix .riscv.out
, $(bmarks
))
77 bmarks_defs
= -DPREALLOCATE
=1 -DHOST_DEBUG
=0
81 elf2hex
16 32768 $< > $@
83 $(bmarks_riscv_dump
): %.riscv.dump
: %.riscv
84 $(RISCV_OBJDUMP
) $< > $@
86 $(bmarks_riscv_out
): %.riscv.out
: %.riscv
90 $(RISCV_GCC
) $(RISCV_GCC_OPTS
) $(bmarks_defs
) \
94 $(RISCV_GCC
) $(RISCV_GCC_OPTS
) $(bmarks_defs
) -D__ASSEMBLY__
=1 \
97 riscv
: $(bmarks_riscv_dump
) $(bmarks_riscv_hex
)
98 run-riscv
: $(bmarks_riscv_out
)
99 echo
; perl
-ne
'print " [$$1] $$ARGV \t$$2\n" if /\*{3}(.{8})\*{3}(.*)/' \
100 $(bmarks_riscv_out
); echo
;
102 junk
+= $(bmarks_riscv_bin
) $(bmarks_riscv_dump
) $(bmarks_riscv_hex
) $(bmarks_riscv_out
)
104 #------------------------------------------------------------
105 # Build and run benchmarks on host machine
107 bmarks_host_bin
= $(addsuffix .host
, $(bmarks_host
))
108 bmarks_host_out
= $(addsuffix .host.out
, $(bmarks_host
))
110 $(bmarks_host_out
): %.host.out
: %.host
113 host
: $(bmarks_host_bin
)
114 run-host
: $(bmarks_host_out
)
115 echo
; perl
-ne
'print " [$$1] $$ARGV \t$$2\n" if /\*{3}(.{8})\*{3}(.*)/' \
116 $(bmarks_host_out
); echo
;
118 junk
+= $(bmarks_host_bin
) $(bmarks_host_out
)
120 #------------------------------------------------------------
125 #------------------------------------------------------------
128 date_suffix
= $(shell date
+%Y-
%m-
%d_
%H-
%M
)
129 install_dir
= $(instbasedir
)/$(instname
)-$(date_suffix
)
130 latest_install
= $(shell ls
-1 -d
$(instbasedir
)/$(instname
)* | tail
-n
1)
134 cp
-r
$(bmarks_riscv_bin
) $(bmarks_riscv_dump
) $(install_dir
)
137 rm -rf
$(instbasedir
)/$(instname
)
138 ln
-s
$(latest_install
) $(instbasedir
)/$(instname
)
140 #------------------------------------------------------------
144 rm -rf
$(objs
) $(junk
)