From 005b1a8f84ff743710ebd693b70d208da583098d Mon Sep 17 00:00:00 2001 From: Andrew Waterman Date: Tue, 3 Jan 2017 17:45:33 -0800 Subject: Regularize timing code Provide get_timer_value() and get_timer_freq() and use them. On Arty, they use mcycle and the known-fixed core frequency, whereas on HiFive1 they use mtime and the known-fixed mtime frequency. --- software/dhrystone/dhry_stubs.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) (limited to 'software/dhrystone') diff --git a/software/dhrystone/dhry_stubs.c b/software/dhrystone/dhry_stubs.c index d3bd14c..0616f86 100644 --- a/software/dhrystone/dhry_stubs.c +++ b/software/dhrystone/dhry_stubs.c @@ -3,16 +3,13 @@ /* The functions in this file are only meant to support Dhrystone on an * embedded RV32 system and are obviously incorrect in general. */ -// return the cycle counter as though it were the current time long time(void) { - long t; - asm volatile ("csrr %0, mcycle" : "=r" (t)); - return t / (get_cpu_freq() / 1000); + return get_timer_value() / get_timer_freq(); } // set the number of dhrystone iterations void __wrap_scanf(const char* fmt, int* n) { - *n = 1500000; + *n = 100000000; } -- cgit v1.2.3 From 628d2b3559be5e9e651801d289a075d68df820e8 Mon Sep 17 00:00:00 2001 From: Andrew Waterman Date: Tue, 3 Jan 2017 17:58:18 -0800 Subject: Compile Dhrystone without RVC Branch target misalignment reduces performance by about 10%. --- software/dhrystone/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'software/dhrystone') diff --git a/software/dhrystone/Makefile b/software/dhrystone/Makefile index a55b1ec..78a7b23 100644 --- a/software/dhrystone/Makefile +++ b/software/dhrystone/Makefile @@ -5,7 +5,7 @@ C_SRCS := dhry_stubs.c dhry_printf.c HEADERS := dhry.h DHRY_SRCS := dhry_1.c dhry_2.c -DHRY_CFLAGS := -O2 -DTIME -fno-inline -fno-builtin-printf -Wno-implicit +DHRY_CFLAGS := -O2 -DTIME -fno-inline -fno-builtin-printf -Wno-implicit -march=rv32ima XLEN ?= 32 CFLAGS := -Os -fno-common -- cgit v1.2.3