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
"ITERATIONS=65536"
"ITERATIONS=2000UL"
"PERFORMANCE_RUN=1"
)
set(TARGET_FLAGS_HARDWARE "-m4-300 -ml")
set(CMAKE_C_FLAGS_DEBUG "-DDEBUG -g -O2")
set(CMAKE_CXX_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_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_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_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})
include_directories(${TARGET_INCLUDES})

View File

@ -78,7 +78,7 @@ typedef uint32_t CORE_TICKS;
#endif
#endif
#ifndef COMPILER_FLAGS
#define COMPILER_FLAGS "-O2"
#define COMPILER_FLAGS "-O0"
#endif
#ifndef MEM_LOCATION
#define MEM_LOCATION "DDR2 LMI"
@ -98,7 +98,7 @@ typedef int32_t ee_s32;
typedef float ee_f32;
typedef uint8_t ee_u8;
typedef uint32_t ee_u32;
typedef ee_u32 ee_ptr_int;
typedef ee_s32 ee_ptr_int;
typedef size_t ee_size_t;
/* align_mem :
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.
*/
#ifndef MAIN_HAS_NOARGC
#define MAIN_HAS_NOARGC 0
#define MAIN_HAS_NOARGC 1
#endif
/* 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.
*/
#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. */
static uint32_t start_time_val, stop_time_val;
@ -86,8 +86,6 @@ void start_time(void) {
void stop_time(void) {
TMU->TSTR &= ~TMU_TSTR_STR0_Msk; /* Stop counter */
stop_time_val = TMU->TCNT0;
printf("Stop time: 0x%09lx\r\n", stop_time_val);
}
/* Function : get_time
Return an abstract "ticks" number that signifies time on the system.
@ -99,9 +97,7 @@ void stop_time(void) {
controlled by <TIMER_RES_DIVIDER>
*/
CORE_TICKS get_time(void) {
CORE_TICKS elapsed = (CORE_TICKS)(start_time_val - stop_time_val);
printf("Get time: 0x%08lx\r\n", elapsed);
return elapsed;
return start_time_val - stop_time_val;
}
/* Function : time_in_secs
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();
ee_printf("Portable initialized\r\n");
if (sizeof(ee_ptr_int) != sizeof(ee_u8 *)) {
ee_printf(
"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) {
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.
}
CONSOLE_ASC->TX_BUF = ch;

View File

@ -63,10 +63,11 @@ _main_entry:
jsr @r0
or r0, r0
mov r0, r4
mov.l _exit_k, r0
jsr @r0
or r0, r0
mov.l _exit_loop_k, r0
_exit_loop:
sleep
jmp @r0
nop
.balign 4
/* libc FPU routine */
@ -88,8 +89,8 @@ _end_k:
/* Function pointers */
_main_k:
.long _main /* Same address as main */
_exit_k:
.long _exit
_exit_loop_k:
.long _exit_loop
_exc_base_k:
.long _exc_base
_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. */
MEMORY {
EMI (rx) : ORIGIN = 0x80000000, LENGTH = 0x01000000 /* LMI virtual address: 0x8000_0000 */
LMI (rwx) : ORIGIN = 0x81000000, LENGTH = 0x0F000000 /* LMI virtual address: 0x8100_0000 */
EMI (rx) : ORIGIN = 0x90000000, LENGTH = 0x01000000 /* LMI virtual address: 0x8000_0000 */
LMI (rwx) : ORIGIN = 0x91000000, LENGTH = 0x0F000000 /* LMI virtual address: 0x8100_0000 */
}
SECTIONS {