diff options
author | Andrew Waterman <aswaterman@gmail.com> | 2017-01-05 15:14:28 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-01-05 15:14:28 -0500 |
commit | d69f4cb8653f4974374f98debf9ce2cc820a2b57 (patch) | |
tree | cc6889cdc8877bcf4b1a8e8760c773e9ec0ef76f /software/coremark | |
parent | e641c398daa91d896ce37fbb73015c054a4e0b21 (diff) | |
parent | b8057b191231dea4b973f1d5066f59afa3881dba (diff) |
Merge pull request #38 from sifive/benchmarking
Benchmarking
Diffstat (limited to 'software/coremark')
-rw-r--r-- | software/coremark/.gitignore | 9 | ||||
-rw-r--r-- | software/coremark/Makefile | 20 | ||||
-rw-r--r-- | software/coremark/core_portme.c | 52 | ||||
-rw-r--r-- | software/coremark/core_portme.h | 58 |
4 files changed, 139 insertions, 0 deletions
diff --git a/software/coremark/.gitignore b/software/coremark/.gitignore new file mode 100644 index 0000000..6bd8438 --- /dev/null +++ b/software/coremark/.gitignore @@ -0,0 +1,9 @@ +/*.o +/coremark +/core_list_join.c +/core_main.c +/coremark.h +/core_matrix.c +/core_state.c +/core_util.c +/trans.c diff --git a/software/coremark/Makefile b/software/coremark/Makefile new file mode 100644 index 0000000..b57151e --- /dev/null +++ b/software/coremark/Makefile @@ -0,0 +1,20 @@ +TARGET := coremark + +C_SRCS := \ + core_list_join.c \ + core_main.c \ + core_matrix.c \ + core_state.c \ + core_util.c \ + core_portme.c \ + +HEADERS := \ + coremark.h \ + core_portme.h \ + +CFLAGS := -O2 -fno-common -funroll-loops -finline-functions --param max-inline-insns-auto=20 -falign-functions=4 -falign-jumps=4 -falign-loops=4 +CFLAGS += -DFLAGS_STR=\""$(CFLAGS)"\" +CFLAGS += -DITERATIONS=10000 -DPERFORMANCE_RUN=1 + +BSP_BASE = ../../bsp +include $(BSP_BASE)/env/common.mk diff --git a/software/coremark/core_portme.c b/software/coremark/core_portme.c new file mode 100644 index 0000000..cbf1396 --- /dev/null +++ b/software/coremark/core_portme.c @@ -0,0 +1,52 @@ +#include <stdio.h> +#include <stdlib.h> +#include "coremark.h" +#include "platform.h" +#include "encoding.h" + +#if VALIDATION_RUN + volatile ee_s32 seed1_volatile=0x3415; + volatile ee_s32 seed2_volatile=0x3415; + volatile ee_s32 seed3_volatile=0x66; +#endif + +#if PERFORMANCE_RUN + volatile ee_s32 seed1_volatile=0x0; + volatile ee_s32 seed2_volatile=0x0; + volatile ee_s32 seed3_volatile=0x66; +#endif + +#if PROFILE_RUN + volatile ee_s32 seed1_volatile=0x8; + volatile ee_s32 seed2_volatile=0x8; + volatile ee_s32 seed3_volatile=0x8; +#endif + +volatile ee_s32 seed4_volatile=ITERATIONS; +volatile ee_s32 seed5_volatile=0; + +static CORE_TICKS t0, t1; + +void start_time(void) +{ + t0 = get_timer_value(); +} + +void stop_time(void) +{ + t1 = get_timer_value(); +} + +CORE_TICKS get_time(void) +{ + return t1 - t0; +} + +secs_ret time_in_secs(CORE_TICKS ticks) +{ + // scale timer down to avoid uint64_t -> double conversion in RV32 + int scale = 256; + uint32_t delta = ticks / scale; + uint32_t freq = get_timer_freq() / scale; + return delta / (double)freq; +} diff --git a/software/coremark/core_portme.h b/software/coremark/core_portme.h new file mode 100644 index 0000000..82298d6 --- /dev/null +++ b/software/coremark/core_portme.h @@ -0,0 +1,58 @@ +#ifndef FESDK_CORE_PORTME_H +#define FESDK_CORE_PORTME_H + +#include <stdint.h> +#include <stddef.h> + +#define HAS_FLOAT 1 +#define HAS_TIME_H 1 +#define USE_CLOCK 1 +#define HAS_STDIO 1 +#define HAS_PRINTF 1 +#define SEED_METHOD SEED_VOLATILE +#define CORE_TICKS uint64_t +#define ee_u8 uint8_t +#define ee_u16 uint16_t +#define ee_u32 uint32_t +#define ee_s16 int16_t +#define ee_s32 int32_t +#define ee_ptr_int uintptr_t +#define ee_size_t size_t +#define COMPILER_FLAGS FLAGS_STR + +#define align_mem(x) (void *)(((ee_ptr_int)(x) + sizeof(ee_u32) - 1) & -sizeof(ee_u32)) + +#ifdef __GNUC__ +# define COMPILER_VERSION "GCC"__VERSION__ +#else +# error +#endif + +#define MEM_METHOD MEM_STACK +#define MEM_LOCATION "STACK" + +#define MAIN_HAS_NOARGC 0 +#define MAIN_HAS_NORETURN 0 + +#define MULTITHREAD 1 +#define USE_PTHREAD 0 +#define USE_FORK 0 +#define USE_SOCKET 0 + +#define default_num_contexts MULTITHREAD + +typedef int core_portable; +static void portable_init(core_portable *p, int *argc, char *argv[]) {} +static void portable_fini(core_portable *p) {} + +#if !defined(PROFILE_RUN) && !defined(PERFORMANCE_RUN) && !defined(VALIDATION_RUN) +#if (TOTAL_DATA_SIZE==1200) +#define PROFILE_RUN 1 +#elif (TOTAL_DATA_SIZE==2000) +#define PERFORMANCE_RUN 1 +#else +#define VALIDATION_RUN 1 +#endif +#endif + +#endif |