From 15dc05331b9821cb449e7bf433a24ddfdfa3c295 Mon Sep 17 00:00:00 2001 From: Andrew Waterman Date: Tue, 3 Jan 2017 18:54:30 -0800 Subject: Add CoreMark build skeleton --- software/coremark/.gitignore | 9 +++++++ software/coremark/Makefile | 20 ++++++++++++++ software/coremark/core_portme.c | 52 ++++++++++++++++++++++++++++++++++++ software/coremark/core_portme.h | 58 +++++++++++++++++++++++++++++++++++++++++ 4 files changed, 139 insertions(+) create mode 100644 software/coremark/.gitignore create mode 100644 software/coremark/Makefile create mode 100644 software/coremark/core_portme.c create mode 100644 software/coremark/core_portme.h (limited to 'software') 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 +#include +#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 +#include + +#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 -- cgit v1.2.3