From 8fdc7c316d6dca184129b78bdce3e271573e8ed7 Mon Sep 17 00:00:00 2001 From: imi415 Date: Thu, 11 Aug 2022 09:50:36 +0800 Subject: [PATCH] Runnable CoreMark. --- CMakeLists.txt | 17 ++++++---- README.md | 37 +++++++++++++++++++++ include/core_portme.h | 6 ++-- src/core_portme.c | 15 --------- src/syscalls.c | 75 +++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 125 insertions(+), 25 deletions(-) create mode 100644 README.md create mode 100644 src/syscalls.c diff --git a/CMakeLists.txt b/CMakeLists.txt index f3c36de..8383a80 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -16,6 +16,7 @@ set(TARGET_SOURCES "src/core_portme.c" "src/stx7105_exc.c" "src/stx7105_utils.c" + "src/syscalls.c" "startup_stx7105.S" ) @@ -26,19 +27,21 @@ set(TARGET_INCLUDES ) set(TARGET_DEFS - "ITERATIONS=2000UL" - "PERFORMANCE_RUN=1" + "ITERATIONS=20000UL" + "VALIDATION_RUN=1" ) set(TARGET_FLAGS_HARDWARE "-m4-300 -ml") -set(CMAKE_C_FLAGS_DEBUG "-DDEBUG -g -O1") -set(CMAKE_CXX_FLAGS_DEBUG "-DDEBUG -g -O1") +set(TARGET_FLAGS_OPTS "-O3 -fomit-frame-pointer -funroll-all-loops -finline-limit=1000 -ftree-dominator-opts -fno-if-conversion2 -fselective-scheduling -fno-code-hoisting -freorder-blocks-and-partition") + +set(CMAKE_C_FLAGS_DEBUG "-DDEBUG -g -O0") +set(CMAKE_CXX_FLAGS_DEBUG "-DDEBUG -g -O0") set(CMAKE_EXE_LINKER_FLAGS_DEBUG "") -set(CMAKE_C_FLAGS_RELEASE "-DNDEBUG -O2 -flto") -set(CMAKE_CXX_FLAGS_RELEASE "-DNDEBUG -O2 -flto") -set(CMAKE_EXE_LINKER_FLAGS_RELEASE "-flto") +set(CMAKE_C_FLAGS_RELEASE "-DNDEBUG ${TARGET_FLAGS_OPTS}") +set(CMAKE_CXX_FLAGS_RELEASE "-DNDEBUG ${TARGET_FLAGS_OPTS}") +set(CMAKE_EXE_LINKER_FLAGS_RELEASE " ") set(CMAKE_C_FLAGS "${TARGET_FLAGS_HARDWARE} -Wall -ffunction-sections -fdata-sections") set(CMAKE_CXX_FLAGS "${TARGET_FLAGS_HARDWARE} -Wall -ffunction-sections -fdata-sections") diff --git a/README.md b/README.md new file mode 100644 index 0000000..200b6f7 --- /dev/null +++ b/README.md @@ -0,0 +1,37 @@ +# CoreMark benchmark for NextVOD + +## Results + +``` +2K performance run parameters for coremark. +CoreMark Size : 666 +Total ticks : 1457116 +Total time (secs): 14.920868 +Iterations/Sec : 1340.404607 +Iterations : 20000 +Compiler version : GCC12.1.0 +Compiler flags : -O3 -fomit-frame-pointer -funroll-all-loops -finline-limit=1000 -ftree-dominator-opts -fno-if-conversion2 -fselective-scheduling -fno-code-hoisting -freorder-blocks-and-partition +Memory location : DDR2 LMI +seedcrc : 0xe9f5 +[0]crclist : 0xe714 +[0]crcmatrix : 0x1fd7 +[0]crcstate : 0x8e3a +[0]crcfinal : 0x382f +Correct operation validated. See README.md for run and reporting rules. +CoreMark 1.0 : 1340.404607 / GCC12.1.0 -O3 -fomit-frame-pointer -funroll-all-loops -finline-limit=1000 -ftree-dominator-opts -fno-if-conversion2 -fselective-scheduling -fno-code-hoisting -freorder-blocks-and-partition / DDR2 LMI +2K validation run parameters for coremark. +CoreMark Size : 666 +Total ticks : 1463060 +Total time (secs): 14.981734 +Iterations/Sec : 1334.958922 +Iterations : 20000 +Compiler version : GCC12.1.0 +Compiler flags : -O3 -fomit-frame-pointer -funroll-all-loops -finline-limit=1000 -ftree-dominator-opts -fno-if-conversion2 -fselective-scheduling -fno-code-hoisting -freorder-blocks-and-partition +Memory location : DDR2 LMI +seedcrc : 0x18f2 +[0]crclist : 0xe3c1 +[0]crcmatrix : 0x0747 +[0]crcstate : 0x8d84 +[0]crcfinal : 0xd304 +Correct operation validated. See README.md for run and reporting rules. +``` \ No newline at end of file diff --git a/include/core_portme.h b/include/core_portme.h index 1aa1b47..9a941cf 100644 --- a/include/core_portme.h +++ b/include/core_portme.h @@ -16,7 +16,7 @@ limitations under the License. Original Author: Shay Gal-on */ -#include "printf.h" +#include /* Topic : Description This file contains configuration constants required to execute on @@ -51,7 +51,7 @@ Original Author: Shay Gal-on Define to 1 if the platform has stdio.h. */ #ifndef HAS_STDIO -#define HAS_STDIO 0 +#define HAS_STDIO 1 #endif /* Configuration : HAS_PRINTF Define to 1 if the platform has stdio.h and implements the printf @@ -78,7 +78,7 @@ typedef uint32_t CORE_TICKS; #endif #endif #ifndef COMPILER_FLAGS -#define COMPILER_FLAGS "-O0" +#define COMPILER_FLAGS "-O3 -fomit-frame-pointer -funroll-all-loops -finline-limit=1000 -ftree-dominator-opts -fno-if-conversion2 -fselective-scheduling -fno-code-hoisting -freorder-blocks-and-partition" #endif #ifndef MEM_LOCATION #define MEM_LOCATION "DDR2 LMI" diff --git a/src/core_portme.c b/src/core_portme.c index 8c563ad..5366aaf 100644 --- a/src/core_portme.c +++ b/src/core_portme.c @@ -20,7 +20,6 @@ Original Author: Shay Gal-on #include #include "coremark.h" -#include "printf.h" #include "stx7105.h" #define SYSTEM_CONFIG34 (0xFE001188U) /* PIO4 */ @@ -154,17 +153,3 @@ void portable_init(core_portable *p, int *argc, char *argv[]) { void portable_fini(core_portable *p) { p->portable_id = 0; } - -void _putchar(char ch) { - if (ch == '\n') { - while (CONSOLE_ASC->STA & (1 << 9U)) { - /**/ - } - - CONSOLE_ASC->TX_BUF = '\r'; - } - while (CONSOLE_ASC->STA & (1 << 9U)) { - // wait for TX FIFO slot. - } - CONSOLE_ASC->TX_BUF = ch; -} \ No newline at end of file diff --git a/src/syscalls.c b/src/syscalls.c new file mode 100644 index 0000000..eadec10 --- /dev/null +++ b/src/syscalls.c @@ -0,0 +1,75 @@ +#include +#include + +#include "stx7105.h" + +#define CONSOLE_ASC ASC2 + +#define HEAP_SIZE 0x10000 + +extern char _end; +static uint32_t s_heap_size = 0U; + +caddr_t _sbrk(int incr) { + char *heap_base = &_end; + + caddr_t ret = heap_base + s_heap_size; + + if (s_heap_size + incr >= HEAP_SIZE) { + return (void *)(-ENOMEM); + } + + s_heap_size += incr; + + return ret; +} + +int _write(int file, char *ptr, int len) { + for (int i = 0; i < len; i++) { + if (ptr[i] == '\n') { + while (CONSOLE_ASC->STA & 1 << 9U) { + // wait for TX FIFO slot. + } + CONSOLE_ASC->TX_BUF = '\r'; + } + + while (CONSOLE_ASC->STA & 1 << 9U) { + // wait for TX FIFO slot. + } + CONSOLE_ASC->TX_BUF = ptr[i]; + } + return len; +} + +int _open(const char *name, int flags, int mode) { + return -1; +} + +int _read(int file, char *ptr, int len) { + return 0; +} + +int _lseek(int file, int ptr, int dir) { + return 0; +} + +int _close(int file) { + return -1; +} + +int _isatty(int file) { + return -1; +} + +pid_t _getpid(void) { + return -1; +} + +void _kill(int pid, int sig) { + return; +} + +int _fstat(int file, struct stat *st) { + st->st_mode = S_IFCHR; + return 0; +}