aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Waterman <andrew@sifive.com>2017-03-21 18:12:45 -0700
committerAndrew Waterman <andrew@sifive.com>2017-03-21 18:12:45 -0700
commita83e3b9243e57a50de283fc07d5b6c81c0443b3d (patch)
treef17c97e08b7e84f55dd02fc8620b382ecec684d9
parent9fbc573597c8087ab0aa8e20d8835cfc2c5097a4 (diff)
downloadriscv-tests-a83e3b9243e57a50de283fc07d5b6c81c0443b3d.zip
riscv-tests-a83e3b9243e57a50de283fc07d5b6c81c0443b3d.tar.gz
riscv-tests-a83e3b9243e57a50de283fc07d5b6c81c0443b3d.tar.bz2
Clean up bmarks build
-rw-r--r--benchmarks/Makefile28
-rw-r--r--benchmarks/common/crt.S2
-rw-r--r--benchmarks/common/test.ld8
-rw-r--r--benchmarks/dhrystone/bmark.mk32
-rw-r--r--benchmarks/median/bmark.mk31
-rw-r--r--benchmarks/mm/bmark.mk31
-rw-r--r--benchmarks/mt-matmul/bmark.mk31
-rw-r--r--benchmarks/mt-vvadd/bmark.mk31
-rw-r--r--benchmarks/multiply/bmark.mk31
-rw-r--r--benchmarks/qsort/bmark.mk30
-rw-r--r--benchmarks/rsort/bmark.mk30
-rw-r--r--benchmarks/spmv/bmark.mk30
-rw-r--r--benchmarks/towers/bmark.mk30
-rw-r--r--benchmarks/vvadd/bmark.mk30
14 files changed, 14 insertions, 361 deletions
diff --git a/benchmarks/Makefile b/benchmarks/Makefile
index 15509d0..28ba2b7 100644
--- a/benchmarks/Makefile
+++ b/benchmarks/Makefile
@@ -36,20 +36,21 @@ bmarks = \
RISCV_PREFIX ?= riscv$(XLEN)-unknown-elf-
RISCV_GCC ?= $(RISCV_PREFIX)gcc
-RISCV_GCC_OPTS ?= -mcmodel=medany -static -std=gnu99 -O2 -ffast-math -fno-common -fno-builtin-printf
+RISCV_GCC_OPTS ?= -DPREALLOCATE=1 -mcmodel=medany -static -std=gnu99 -O2 -ffast-math -fno-common -fno-builtin-printf
RISCV_LINK ?= $(RISCV_GCC) -T $(src_dir)/common/test.ld $(incs)
-RISCV_LINK_MT ?= $(RISCV_GCC) -T $(src_dir)/common/test-mt.ld
-RISCV_LINK_OPTS ?= -static -nostdlib -nostartfiles -lgcc
+RISCV_LINK_OPTS ?= -static -nostdlib -nostartfiles -lgcc -T $(src_dir)/common/test.ld
RISCV_OBJDUMP ?= $(RISCV_PREFIX)objdump --disassemble-all --disassemble-zeroes --section=.text --section=.text.startup --section=.data
RISCV_SIM ?= spike --isa=rv$(XLEN)gc
-VPATH += $(addprefix $(src_dir)/, $(bmarks))
-VPATH += $(src_dir)/common
-
incs += -I$(src_dir)/../env -I$(src_dir)/common $(addprefix -I$(src_dir)/, $(bmarks))
objs :=
-include $(patsubst %, $(src_dir)/%/bmark.mk, $(bmarks))
+define compile_template
+$(1).riscv: $(wildcard $(src_dir)/$(1)/*) $(wildcard $(src_dir)/common/*)
+ $$(RISCV_GCC) $$(incs) $$(RISCV_GCC_OPTS) $$(RISCV_LINK_OPTS) -o $$@ $(wildcard $(src_dir)/$(1)/*.c) $(wildcard $(src_dir)/common/*.c) $(wildcard $(src_dir)/common/*.S)
+endef
+
+$(foreach bmark,$(bmarks),$(eval $(call compile_template,$(bmark))))
#------------------------------------------------------------
# Build and run benchmarks on riscv simulator
@@ -58,25 +59,14 @@ bmarks_riscv_bin = $(addsuffix .riscv, $(bmarks))
bmarks_riscv_dump = $(addsuffix .riscv.dump, $(bmarks))
bmarks_riscv_out = $(addsuffix .riscv.out, $(bmarks))
-bmarks_defs = -DPREALLOCATE=1
-bmarks_cycles = 80000
-
$(bmarks_riscv_dump): %.riscv.dump: %.riscv
$(RISCV_OBJDUMP) $< > $@
$(bmarks_riscv_out): %.riscv.out: %.riscv
$(RISCV_SIM) $< > $@
-%.o: %.c
- $(RISCV_GCC) $(RISCV_GCC_OPTS) $(bmarks_defs) \
- -c $(incs) $< -o $@
-
-%.o: %.S
- $(RISCV_GCC) $(RISCV_GCC_OPTS) $(bmarks_defs) -D__ASSEMBLY__=1 \
- -c $(incs) $< -o $@
-
riscv: $(bmarks_riscv_dump)
-run-riscv: $(bmarks_riscv_out)
+run: $(bmarks_riscv_out)
echo; perl -ne 'print " [$$1] $$ARGV \t$$2\n" if /\*{3}(.{8})\*{3}(.*)/' \
$(bmarks_riscv_out); echo;
diff --git a/benchmarks/common/crt.S b/benchmarks/common/crt.S
index a821769..38b963d 100644
--- a/benchmarks/common/crt.S
+++ b/benchmarks/common/crt.S
@@ -12,7 +12,7 @@
# define REGBYTES 4
#endif
- .text
+ .section ".text.init"
.globl _start
_start:
la t0, trap_entry
diff --git a/benchmarks/common/test.ld b/benchmarks/common/test.ld
index dd32bb1..8141dda 100644
--- a/benchmarks/common/test.ld
+++ b/benchmarks/common/test.ld
@@ -22,7 +22,7 @@ SECTIONS
/* text: test code section */
. = 0x80000000;
- .text.init : { crt.o(.text) }
+ .text.init : { *(.text.init) }
.tohost ALIGN(0x1000) : { *(.tohost) }
@@ -48,14 +48,14 @@ SECTIONS
.tdata :
{
_tls_data = .;
- crt.o(.tdata.begin)
+ *(.tdata.begin)
*(.tdata)
- crt.o(.tdata.end)
+ *(.tdata.end)
}
.tbss :
{
*(.tbss)
- crt.o(.tbss.end)
+ *(.tbss.end)
}
/* End of uninitalized data segement */
diff --git a/benchmarks/dhrystone/bmark.mk b/benchmarks/dhrystone/bmark.mk
deleted file mode 100644
index 06b4ab8..0000000
--- a/benchmarks/dhrystone/bmark.mk
+++ /dev/null
@@ -1,32 +0,0 @@
-#=======================================================================
-# UCB CS250 Makefile fragment for benchmarks
-#-----------------------------------------------------------------------
-#
-# Each benchmark directory should have its own fragment which
-# essentially lists what the source files are and how to link them
-# into an riscv and/or host executable. All variables should include
-# the benchmark name as a prefix so that they are unique.
-#
-
-dhrystone_c_src = \
- dhrystone_main.c \
- dhrystone.c \
- syscalls.c \
-
-dhrystone_riscv_src = \
- crt.S \
-
-dhrystone_c_objs = $(patsubst %.c, %.o, $(dhrystone_c_src))
-dhrystone_riscv_objs = $(patsubst %.S, %.o, $(dhrystone_riscv_src))
-
-dhrystone_host_bin = dhrystone.host
-$(dhrystone_host_bin): $(dhrystone_c_src)
- $(HOST_COMP) $^ -o $(dhrystone_host_bin)
-
-dhrystone_riscv_bin = dhrystone.riscv
-$(dhrystone_riscv_bin): $(dhrystone_c_objs) $(dhrystone_riscv_objs)
- $(RISCV_LINK) $(dhrystone_c_objs) $(dhrystone_riscv_objs) \
- -o $(dhrystone_riscv_bin) $(RISCV_LINK_OPTS)
-
-junk += $(dhrystone_c_objs) $(dhrystone_riscv_objs) \
- $(dhrystone_host_bin) $(dhrystone_riscv_bin)
diff --git a/benchmarks/median/bmark.mk b/benchmarks/median/bmark.mk
deleted file mode 100644
index b489a67..0000000
--- a/benchmarks/median/bmark.mk
+++ /dev/null
@@ -1,31 +0,0 @@
-#=======================================================================
-# UCB CS250 Makefile fragment for benchmarks
-#-----------------------------------------------------------------------
-#
-# Each benchmark directory should have its own fragment which
-# essentially lists what the source files are and how to link them
-# into an riscv and/or host executable. All variables should include
-# the benchmark name as a prefix so that they are unique.
-#
-
-median_c_src = \
- median_main.c \
- median.c \
- syscalls.c \
-
-median_riscv_src = \
- crt.S \
-
-median_c_objs = $(patsubst %.c, %.o, $(median_c_src))
-median_riscv_objs = $(patsubst %.S, %.o, $(median_riscv_src))
-
-median_host_bin = median.host
-$(median_host_bin): $(median_c_src)
- $(HOST_COMP) $^ -o $(median_host_bin)
-
-median_riscv_bin = median.riscv
-$(median_riscv_bin): $(median_c_objs) $(median_riscv_objs)
- $(RISCV_LINK) $(median_c_objs) $(median_riscv_objs) -o $(median_riscv_bin) $(RISCV_LINK_OPTS)
-
-junk += $(median_c_objs) $(median_riscv_objs) \
- $(median_host_bin) $(median_riscv_bin)
diff --git a/benchmarks/mm/bmark.mk b/benchmarks/mm/bmark.mk
deleted file mode 100644
index ec8fd16..0000000
--- a/benchmarks/mm/bmark.mk
+++ /dev/null
@@ -1,31 +0,0 @@
-#=======================================================================
-# UCB CS250 Makefile fragment for benchmarks
-#-----------------------------------------------------------------------
-#
-# Each benchmark directory should have its own fragment which
-# essentially lists what the source files are and how to link them
-# into an riscv and/or host executable. All variables should include
-# the benchmark name as a prefix so that they are unique.
-#
-
-mm_c_src = \
- mm_main.c \
- mm.c \
- syscalls.c \
-
-mm_riscv_src = \
- crt.S \
-
-mm_c_objs = $(patsubst %.c, %.o, $(mm_c_src))
-mm_riscv_objs = $(patsubst %.S, %.o, $(mm_riscv_src))
-
-mm_host_bin = mm.host
-$(mm_host_bin) : $(mm_c_src)
- $(HOST_COMP) $^ -o $(mm_host_bin)
-
-mm_riscv_bin = mm.riscv
-$(mm_riscv_bin) : $(mm_c_objs) $(mm_riscv_objs)
- $(RISCV_LINK) $(mm_c_objs) $(mm_riscv_objs) -o $(mm_riscv_bin) $(RISCV_LINK_OPTS)
-
-junk += $(mm_c_objs) $(mm_riscv_objs) \
- $(mm_host_bin) $(mm_riscv_bin)
diff --git a/benchmarks/mt-matmul/bmark.mk b/benchmarks/mt-matmul/bmark.mk
deleted file mode 100644
index 6a7140f..0000000
--- a/benchmarks/mt-matmul/bmark.mk
+++ /dev/null
@@ -1,31 +0,0 @@
-#=======================================================================
-# UCB CS250 Makefile fragment for benchmarks
-#-----------------------------------------------------------------------
-#
-# Each benchmark directory should have its own fragment which
-# essentially lists what the source files are and how to link them
-# into an riscv and/or host executable. All variables should include
-# the benchmark name as a prefix so that they are unique.
-#
-
-mt_matmul_c_src = \
- mt-matmul.c \
- matmul.c \
- syscalls.c \
-
-mt_matmul_riscv_src = \
- crt.S \
-
-mt_matmul_c_objs = $(patsubst %.c, %.o, $(mt_matmul_c_src))
-mt_matmul_riscv_objs = $(patsubst %.S, %.o, $(mt_matmul_riscv_src))
-
-mt_matmul_host_bin = mt-matmul.host
-$(mt_matmul_host_bin) : $(mt_matmul_c_src)
- $(HOST_COMP) $^ -o $(mt_matmul_host_bin)
-
-mt_matmul_riscv_bin = mt-matmul.riscv
-$(mt_matmul_riscv_bin) : $(mt_matmul_c_objs) $(mt_matmul_riscv_objs)
- $(RISCV_LINK) $(mt_matmul_c_objs) $(mt_matmul_riscv_objs) $(RISCV_LINK_OPTS) -o $(mt_matmul_riscv_bin)
-
-junk += $(mt_matmul_c_objs) $(mt_matmul_riscv_objs) \
- $(mt_matmul_host_bin) $(mt_matmul_riscv_bin)
diff --git a/benchmarks/mt-vvadd/bmark.mk b/benchmarks/mt-vvadd/bmark.mk
deleted file mode 100644
index ff969c1..0000000
--- a/benchmarks/mt-vvadd/bmark.mk
+++ /dev/null
@@ -1,31 +0,0 @@
-#=======================================================================
-# UCB CS250 Makefile fragment for benchmarks
-#-----------------------------------------------------------------------
-#
-# Each benchmark directory should have its own fragment which
-# essentially lists what the source files are and how to link them
-# into an riscv and/or host executable. All variables should include
-# the benchmark name as a prefix so that they are unique.
-#
-
-mt_vvadd_c_src = \
- mt-vvadd.c \
- vvadd.c \
- syscalls.c \
-
-mt_vvadd_riscv_src = \
- crt.S \
-
-mt_vvadd_c_objs = $(patsubst %.c, %.o, $(mt_vvadd_c_src))
-mt_vvadd_riscv_objs = $(patsubst %.S, %.o, $(mt_vvadd_riscv_src))
-
-mt_vvadd_host_bin = mt-vvadd.host
-$(mt_vvadd_host_bin) : $(mt_vvadd_c_src)
- $(HOST_COMP) $^ -o $(mt_vvadd_host_bin)
-
-mt_vvadd_riscv_bin = mt-vvadd.riscv
-$(mt_vvadd_riscv_bin) : $(mt_vvadd_c_objs) $(mt_vvadd_riscv_objs)
- $(RISCV_LINK) $(mt_vvadd_c_objs) $(mt_vvadd_riscv_objs) $(RISCV_LINK_OPTS) -o $(mt_vvadd_riscv_bin)
-
-junk += $(mt_vvadd_c_objs) $(mt_vvadd_riscv_objs) \
- $(mt_vvadd_host_bin) $(mt_vvadd_riscv_bin)
diff --git a/benchmarks/multiply/bmark.mk b/benchmarks/multiply/bmark.mk
deleted file mode 100644
index 93ba67f..0000000
--- a/benchmarks/multiply/bmark.mk
+++ /dev/null
@@ -1,31 +0,0 @@
-#=======================================================================
-# UCB CS250 Makefile fragment for benchmarks
-#-----------------------------------------------------------------------
-#
-# Each benchmark directory should have its own fragment which
-# essentially lists what the source files are and how to link them
-# into an riscv and/or host executable. All variables should include
-# the benchmark name as a prefix so that they are unique.
-#
-
-multiply_c_src = \
- multiply_main.c \
- multiply.c \
- syscalls.c \
-
-multiply_riscv_src = \
- crt.S \
-
-multiply_c_objs = $(patsubst %.c, %.o, $(multiply_c_src))
-multiply_riscv_objs = $(patsubst %.S, %.o, $(multiply_riscv_src))
-
-multiply_host_bin = multiply.host
-$(multiply_host_bin): $(multiply_c_src)
- $(HOST_COMP) $^ -o $(multiply_host_bin)
-
-multiply_riscv_bin = multiply.riscv
-$(multiply_riscv_bin): $(multiply_c_objs) $(multiply_riscv_objs)
- $(RISCV_LINK) $(multiply_c_objs) $(multiply_riscv_objs) -o $(multiply_riscv_bin) $(RISCV_LINK_OPTS)
-
-junk += $(multiply_c_objs) $(multiply_riscv_objs) \
- $(multiply_host_bin) $(multiply_riscv_bin)
diff --git a/benchmarks/qsort/bmark.mk b/benchmarks/qsort/bmark.mk
deleted file mode 100644
index 4b39d96..0000000
--- a/benchmarks/qsort/bmark.mk
+++ /dev/null
@@ -1,30 +0,0 @@
-#=======================================================================
-# UCB CS250 Makefile fragment for benchmarks
-#-----------------------------------------------------------------------
-#
-# Each benchmark directory should have its own fragment which
-# essentially lists what the source files are and how to link them
-# into an riscv and/or host executable. All variables should include
-# the benchmark name as a prefix so that they are unique.
-#
-
-qsort_c_src = \
- qsort_main.c \
- syscalls.c \
-
-qsort_riscv_src = \
- crt.S \
-
-qsort_c_objs = $(patsubst %.c, %.o, $(qsort_c_src))
-qsort_riscv_objs = $(patsubst %.S, %.o, $(qsort_riscv_src))
-
-qsort_host_bin = qsort.host
-$(qsort_host_bin) : $(qsort_c_src)
- $(HOST_COMP) $^ -o $(qsort_host_bin)
-
-qsort_riscv_bin = qsort.riscv
-$(qsort_riscv_bin) : $(qsort_c_objs) $(qsort_riscv_objs)
- $(RISCV_LINK) $(qsort_c_objs) $(qsort_riscv_objs) -o $(qsort_riscv_bin) $(RISCV_LINK_OPTS)
-
-junk += $(qsort_c_objs) $(qsort_riscv_objs) \
- $(qsort_host_bin) $(qsort_riscv_bin)
diff --git a/benchmarks/rsort/bmark.mk b/benchmarks/rsort/bmark.mk
deleted file mode 100644
index 0fa713c..0000000
--- a/benchmarks/rsort/bmark.mk
+++ /dev/null
@@ -1,30 +0,0 @@
-#=======================================================================
-# UCB CS250 Makefile fragment for benchmarks
-#-----------------------------------------------------------------------
-#
-# Each benchmark directory should have its own fragment which
-# essentially lists what the source files are and how to link them
-# into an riscv and/or host executable. All variables should include
-# the benchmark name as a prefix so that they are unique.
-#
-
-rsort_c_src = \
- rsort.c \
- syscalls.c \
-
-rsort_riscv_src = \
- crt.S \
-
-rsort_c_objs = $(patsubst %.c, %.o, $(rsort_c_src))
-rsort_riscv_objs = $(patsubst %.S, %.o, $(rsort_riscv_src))
-
-rsort_host_bin = rsort.host
-$(rsort_host_bin) : $(rsort_c_src)
- $(HOST_COMP) $^ -o $(rsort_host_bin)
-
-rsort_riscv_bin = rsort.riscv
-$(rsort_riscv_bin) : $(rsort_c_objs) $(rsort_riscv_objs)
- $(RISCV_LINK) $(rsort_c_objs) $(rsort_riscv_objs) -o $(rsort_riscv_bin) $(RISCV_LINK_OPTS)
-
-junk += $(rsort_c_objs) $(rsort_riscv_objs) \
- $(rsort_host_bin) $(rsort_riscv_bin)
diff --git a/benchmarks/spmv/bmark.mk b/benchmarks/spmv/bmark.mk
deleted file mode 100644
index dcfdb19..0000000
--- a/benchmarks/spmv/bmark.mk
+++ /dev/null
@@ -1,30 +0,0 @@
-#=======================================================================
-# UCB CS250 Makefile fragment for benchmarks
-#-----------------------------------------------------------------------
-#
-# Each benchmark directory should have its own fragment which
-# essentially lists what the source files are and how to link them
-# into an riscv and/or host executable. All variables should include
-# the benchmark name as a prefix so that they are unique.
-#
-
-spmv_c_src = \
- spmv_main.c \
- syscalls.c \
-
-spmv_riscv_src = \
- crt.S \
-
-spmv_c_objs = $(patsubst %.c, %.o, $(spmv_c_src))
-spmv_riscv_objs = $(patsubst %.S, %.o, $(spmv_riscv_src))
-
-spmv_host_bin = spmv.host
-$(spmv_host_bin) : $(spmv_c_src)
- $(HOST_COMP) $^ -o $(spmv_host_bin)
-
-spmv_riscv_bin = spmv.riscv
-$(spmv_riscv_bin) : $(spmv_c_objs) $(spmv_riscv_objs)
- $(RISCV_LINK) $(spmv_c_objs) $(spmv_riscv_objs) -o $(spmv_riscv_bin) $(RISCV_LINK_OPTS)
-
-junk += $(spmv_c_objs) $(spmv_riscv_objs) \
- $(spmv_host_bin) $(spmv_riscv_bin)
diff --git a/benchmarks/towers/bmark.mk b/benchmarks/towers/bmark.mk
deleted file mode 100644
index b16bf04..0000000
--- a/benchmarks/towers/bmark.mk
+++ /dev/null
@@ -1,30 +0,0 @@
-#=======================================================================
-# UCB CS250 Makefile fragment for benchmarks
-#-----------------------------------------------------------------------
-#
-# Each benchmark directory should have its own fragment which
-# essentially lists what the source files are and how to link them
-# into an riscv and/or host executable. All variables should include
-# the benchmark name as a prefix so that they are unique.
-#
-
-towers_c_src = \
- towers_main.c \
- syscalls.c \
-
-towers_riscv_src = \
- crt.S \
-
-towers_c_objs = $(patsubst %.c, %.o, $(towers_c_src))
-towers_riscv_objs = $(patsubst %.S, %.o, $(towers_riscv_src))
-
-towers_host_bin = towers.host
-$(towers_host_bin) : $(towers_c_src)
- $(HOST_COMP) $^ -o $(towers_host_bin)
-
-towers_riscv_bin = towers.riscv
-$(towers_riscv_bin) : $(towers_c_objs) $(towers_riscv_objs)
- $(RISCV_LINK) $(towers_c_objs) $(towers_riscv_objs) -o $(towers_riscv_bin) $(RISCV_LINK_OPTS)
-
-junk += $(towers_c_objs) $(towers_riscv_objs) \
- $(towers_host_bin) $(towers_riscv_bin)
diff --git a/benchmarks/vvadd/bmark.mk b/benchmarks/vvadd/bmark.mk
deleted file mode 100644
index 5ab99de..0000000
--- a/benchmarks/vvadd/bmark.mk
+++ /dev/null
@@ -1,30 +0,0 @@
-#=======================================================================
-# UCB CS250 Makefile fragment for benchmarks
-#-----------------------------------------------------------------------
-#
-# Each benchmark directory should have its own fragment which
-# essentially lists what the source files are and how to link them
-# into an riscv and/or host executable. All variables should include
-# the benchmark name as a prefix so that they are unique.
-#
-
-vvadd_c_src = \
- vvadd_main.c \
- syscalls.c \
-
-vvadd_riscv_src = \
- crt.S \
-
-vvadd_c_objs = $(patsubst %.c, %.o, $(vvadd_c_src))
-vvadd_riscv_objs = $(patsubst %.S, %.o, $(vvadd_riscv_src))
-
-vvadd_host_bin = vvadd.host
-$(vvadd_host_bin) : $(vvadd_c_src)
- $(HOST_COMP) $^ -o $(vvadd_host_bin)
-
-vvadd_riscv_bin = vvadd.riscv
-$(vvadd_riscv_bin) : $(vvadd_c_objs) $(vvadd_riscv_objs)
- $(RISCV_LINK) $(vvadd_c_objs) $(vvadd_riscv_objs) -o $(vvadd_riscv_bin) $(RISCV_LINK_OPTS)
-
-junk += $(vvadd_c_objs) $(vvadd_riscv_objs) \
- $(vvadd_host_bin) $(vvadd_riscv_bin)