Use cached region for benchmarks, added some optimization opts.

This commit is contained in:
imi415 2022-08-10 01:23:15 +08:00
parent cead82c9fe
commit 1f1f3c5aed
Signed by: imi415
GPG Key ID: 17F01E106F9F5E0A
6 changed files with 29 additions and 25 deletions

View File

@ -26,14 +26,16 @@ set(TARGET_INCLUDES
) )
set(TARGET_DEFS set(TARGET_DEFS
"ITERATIONS=65536" "ITERATIONS=2000UL"
"PERFORMANCE_RUN=1" "PERFORMANCE_RUN=1"
) )
set(TARGET_FLAGS_HARDWARE "-m4-300 -ml") set(TARGET_FLAGS_HARDWARE "-m4-300 -ml")
set(CMAKE_C_FLAGS_DEBUG "-DDEBUG -g -O2") set(TARGET_MANUAL_OPTS "-fauto-inc-dec -fbranch-count-reg -fcombine-stack-adjustments -fcompare-elim -fcprop-registers -fdce -fdefer-pop -fdelayed-branch -fdse -fforward-propagate")
set(CMAKE_CXX_FLAGS_DEBUG "-DDEBUG -g -O2")
set(CMAKE_C_FLAGS_DEBUG "-DDEBUG -g -O0 ${TARGET_MANUAL_OPTS}")
set(CMAKE_CXX_FLAGS_DEBUG "-DDEBUG -g -O0 ${TARGET_MANUAL_OPTS}")
set(CMAKE_EXE_LINKER_FLAGS_DEBUG "") set(CMAKE_EXE_LINKER_FLAGS_DEBUG "")
set(CMAKE_C_FLAGS_RELEASE "-DNDEBUG -O2 -flto") set(CMAKE_C_FLAGS_RELEASE "-DNDEBUG -O2 -flto")
@ -42,7 +44,7 @@ set(CMAKE_EXE_LINKER_FLAGS_RELEASE "-flto")
set(CMAKE_C_FLAGS "${TARGET_FLAGS_HARDWARE} -Wall -ffunction-sections -fdata-sections") set(CMAKE_C_FLAGS "${TARGET_FLAGS_HARDWARE} -Wall -ffunction-sections -fdata-sections")
set(CMAKE_CXX_FLAGS "${TARGET_FLAGS_HARDWARE} -Wall -ffunction-sections -fdata-sections") set(CMAKE_CXX_FLAGS "${TARGET_FLAGS_HARDWARE} -Wall -ffunction-sections -fdata-sections")
set(CMAKE_EXE_LINKER_FLAGS "${TARGET_FLAGS_HARDWARE} -Wall -lc -lm -nostartfiles -Wl,--print-memory-usage -Wl,--gc-sections") set(CMAKE_EXE_LINKER_FLAGS "${TARGET_FLAGS_HARDWARE} -specs=nosys.specs -Wall -lc -lm -nostartfiles -Wl,--print-memory-usage -Wl,--gc-sections")
add_compile_definitions(${TARGET_DEFS}) add_compile_definitions(${TARGET_DEFS})
include_directories(${TARGET_INCLUDES}) include_directories(${TARGET_INCLUDES})

View File

@ -78,7 +78,7 @@ typedef uint32_t CORE_TICKS;
#endif #endif
#endif #endif
#ifndef COMPILER_FLAGS #ifndef COMPILER_FLAGS
#define COMPILER_FLAGS "-O2" #define COMPILER_FLAGS "-O0"
#endif #endif
#ifndef MEM_LOCATION #ifndef MEM_LOCATION
#define MEM_LOCATION "DDR2 LMI" #define MEM_LOCATION "DDR2 LMI"
@ -98,7 +98,7 @@ typedef int32_t ee_s32;
typedef float ee_f32; typedef float ee_f32;
typedef uint8_t ee_u8; typedef uint8_t ee_u8;
typedef uint32_t ee_u32; typedef uint32_t ee_u32;
typedef ee_u32 ee_ptr_int; typedef ee_s32 ee_ptr_int;
typedef size_t ee_size_t; typedef size_t ee_size_t;
/* align_mem : /* align_mem :
This macro is used to align an offset to point to a 32b value. It is This macro is used to align an offset to point to a 32b value. It is
@ -167,7 +167,7 @@ typedef size_t ee_size_t;
greater then 1. greater then 1.
*/ */
#ifndef MAIN_HAS_NOARGC #ifndef MAIN_HAS_NOARGC
#define MAIN_HAS_NOARGC 0 #define MAIN_HAS_NOARGC 1
#endif #endif
/* Configuration : MAIN_HAS_NORETURN /* Configuration : MAIN_HAS_NORETURN

@ -1 +1 @@
Subproject commit cfa9ab377835911f23d9b0831c7be302ed1f58de Subproject commit eefc986ebd3452d6adde22eafaff3e5c859f29e4

View File

@ -51,7 +51,7 @@ volatile ee_s32 seed5_volatile = 0;
time.h and windows.h definitions included. time.h and windows.h definitions included.
*/ */
#define EE_TICKS_PER_SEC 97656 #define EE_TICKS_PER_SEC (100000000.0 / 1024.0)
/** Define Host specific (POSIX), or target specific global time variables. */ /** Define Host specific (POSIX), or target specific global time variables. */
static uint32_t start_time_val, stop_time_val; static uint32_t start_time_val, stop_time_val;
@ -86,8 +86,6 @@ void start_time(void) {
void stop_time(void) { void stop_time(void) {
TMU->TSTR &= ~TMU_TSTR_STR0_Msk; /* Stop counter */ TMU->TSTR &= ~TMU_TSTR_STR0_Msk; /* Stop counter */
stop_time_val = TMU->TCNT0; stop_time_val = TMU->TCNT0;
printf("Stop time: 0x%09lx\r\n", stop_time_val);
} }
/* Function : get_time /* Function : get_time
Return an abstract "ticks" number that signifies time on the system. Return an abstract "ticks" number that signifies time on the system.
@ -99,9 +97,7 @@ void stop_time(void) {
controlled by <TIMER_RES_DIVIDER> controlled by <TIMER_RES_DIVIDER>
*/ */
CORE_TICKS get_time(void) { CORE_TICKS get_time(void) {
CORE_TICKS elapsed = (CORE_TICKS)(start_time_val - stop_time_val); return start_time_val - stop_time_val;
printf("Get time: 0x%08lx\r\n", elapsed);
return elapsed;
} }
/* Function : time_in_secs /* Function : time_in_secs
Convert the value returned by get_time to seconds. Convert the value returned by get_time to seconds.
@ -142,8 +138,6 @@ void portable_init(core_portable *p, int *argc, char *argv[]) {
uart_init(); uart_init();
ee_printf("Portable initialized\r\n");
if (sizeof(ee_ptr_int) != sizeof(ee_u8 *)) { if (sizeof(ee_ptr_int) != sizeof(ee_u8 *)) {
ee_printf( ee_printf(
"ERROR! Please define ee_ptr_int to a type that holds a " "ERROR! Please define ee_ptr_int to a type that holds a "
@ -162,7 +156,14 @@ void portable_fini(core_portable *p) {
} }
void _putchar(char ch) { void _putchar(char ch) {
while (CONSOLE_ASC->STA & 1 << 9U) { 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. // wait for TX FIFO slot.
} }
CONSOLE_ASC->TX_BUF = ch; CONSOLE_ASC->TX_BUF = ch;

View File

@ -63,10 +63,11 @@ _main_entry:
jsr @r0 jsr @r0
or r0, r0 or r0, r0
mov r0, r4 mov.l _exit_loop_k, r0
mov.l _exit_k, r0 _exit_loop:
jsr @r0 sleep
or r0, r0 jmp @r0
nop
.balign 4 .balign 4
/* libc FPU routine */ /* libc FPU routine */
@ -88,8 +89,8 @@ _end_k:
/* Function pointers */ /* Function pointers */
_main_k: _main_k:
.long _main /* Same address as main */ .long _main /* Same address as main */
_exit_k: _exit_loop_k:
.long _exit .long _exit_loop
_exc_base_k: _exc_base_k:
.long _exc_base .long _exc_base
_exc_imask_k: _exc_imask_k:

View File

@ -7,8 +7,8 @@ ENTRY(_start)
/* We don't use 29-bit mode since PMB and LMI initialization has to be done anyway. */ /* We don't use 29-bit mode since PMB and LMI initialization has to be done anyway. */
MEMORY { MEMORY {
EMI (rx) : ORIGIN = 0x80000000, LENGTH = 0x01000000 /* LMI virtual address: 0x8000_0000 */ EMI (rx) : ORIGIN = 0x90000000, LENGTH = 0x01000000 /* LMI virtual address: 0x8000_0000 */
LMI (rwx) : ORIGIN = 0x81000000, LENGTH = 0x0F000000 /* LMI virtual address: 0x8100_0000 */ LMI (rwx) : ORIGIN = 0x91000000, LENGTH = 0x0F000000 /* LMI virtual address: 0x8100_0000 */
} }
SECTIONS { SECTIONS {