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 #--------------------------------------------------------------------
45 #--------------------------------------------------------------------
47 #--------------------------------------------------------------------
49 HOST_OPTS
= -std
=gnu99
-DPREALLOCATE
=0 -DHOST_DEBUG
=1
50 HOST_COMP
= gcc
$(HOST_OPTS
)
53 RISCV_GCC_OPTS
= -Wa
,-march
=RVIMAFDXhwacha
-std
=gnu99
-O2
-nostdlib
-nostartfiles
-ffast-math
54 RISCV_LINK
= riscv-gcc
-T
$(bmarkdir
)/common
/test.
ld $(incs
)
55 RISCV_LINK_MT
= riscv-gcc
-T
$(bmarkdir
)/common
/test-mt.
ld
57 RISCV_OBJDUMP
= riscv-objdump
--disassemble-all
--disassemble-zeroes
--section
=.text
--section
=.text.startup
--section
=.data
60 VPATH
+= $(addprefix $(bmarkdir
)/, $(bmarks
))
61 VPATH
+= $(bmarkdir
)/common
63 incs
+= -I..
/env
-I
$(bmarkdir
)/common
$(addprefix -I
$(bmarkdir
)/, $(bmarks
))
66 include $(patsubst %, $(bmarkdir
)/%/bmark.mk
, $(bmarks
))
68 #------------------------------------------------------------
69 # Build and run benchmarks on riscv simulator
71 bmarks_riscv_bin
= $(addsuffix .riscv
, $(bmarks
))
72 bmarks_riscv_dump
= $(addsuffix .riscv.dump
, $(bmarks
))
73 bmarks_riscv_hex
= $(addsuffix .riscv.hex
, $(bmarks
))
74 bmarks_riscv_out
= $(addsuffix .riscv.out
, $(bmarks
))
76 bmarks_defs
= -DPREALLOCATE
=1 -DHOST_DEBUG
=0
80 elf2hex
16 32768 $< > $@
82 $(bmarks_riscv_dump
): %.riscv.dump
: %.riscv
83 $(RISCV_OBJDUMP
) $< > $@
85 $(bmarks_riscv_out
): %.riscv.out
: %.riscv
89 $(RISCV_GCC
) $(RISCV_GCC_OPTS
) $(bmarks_defs
) \
93 $(RISCV_GCC
) $(RISCV_GCC_OPTS
) $(bmarks_defs
) \
96 riscv
: $(bmarks_riscv_dump
) $(bmarks_riscv_hex
)
97 run-riscv
: $(bmarks_riscv_out
)
98 echo
; perl
-ne
'print " [$$1] $$ARGV \t$$2\n" if /\*{3}(.{8})\*{3}(.*)/' \
99 $(bmarks_riscv_out
); echo
;
101 junk
+= $(bmarks_riscv_bin
) $(bmarks_riscv_dump
) $(bmarks_riscv_hex
) $(bmarks_riscv_out
)
103 #------------------------------------------------------------
104 # Build and run benchmarks on host machine
106 bmarks_host_bin
= $(addsuffix .host
, $(bmarks_host
))
107 bmarks_host_out
= $(addsuffix .host.out
, $(bmarks_host
))
109 $(bmarks_host_out
): %.host.out
: %.host
112 host
: $(bmarks_host_bin
)
113 run-host
: $(bmarks_host_out
)
114 echo
; perl
-ne
'print " [$$1] $$ARGV \t$$2\n" if /\*{3}(.{8})\*{3}(.*)/' \
115 $(bmarks_host_out
); echo
;
117 junk
+= $(bmarks_host_bin
) $(bmarks_host_out
)
119 #------------------------------------------------------------
124 #------------------------------------------------------------
127 date_suffix
= $(shell date
+%Y-
%m-
%d_
%H-
%M
)
128 install_dir
= $(instbasedir
)/$(instname
)-$(date_suffix
)
129 latest_install
= $(shell ls
-1 -d
$(instbasedir
)/$(instname
)* | tail
-n
1)
133 cp
-r
$(bmarks_riscv_bin
) $(bmarks_riscv_dump
) $(install_dir
)
136 rm -rf
$(instbasedir
)/$(instname
)
137 ln
-s
$(latest_install
) $(instbasedir
)/$(instname
)
139 #------------------------------------------------------------
143 rm -rf
$(objs
) $(junk
)