Makefile 4.0 KB

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