Line 69... |
Line 69... |
|
|
Implementation may be capturing a system timer (as implemented in the example code)
|
Implementation may be capturing a system timer (as implemented in the example code)
|
or zeroing some system parameters - e.g. setting the cpu clocks cycles to 0.
|
or zeroing some system parameters - e.g. setting the cpu clocks cycles to 0.
|
*/
|
*/
|
void start_time(void) {
|
void start_time(void) {
|
elapsed_cycles = neorv32_mtime_get_time();
|
elapsed_cycles = 0; // this is time zero
|
|
neorv32_cpu_set_mcycle(0);
|
|
neorv32_cpu_set_minstret(0);
|
//GETMYTIME(&start_time_val );
|
//GETMYTIME(&start_time_val );
|
}
|
}
|
/* Function : stop_time
|
/* Function : stop_time
|
This function will be called right after ending the timed portion of the benchmark.
|
This function will be called right after ending the timed portion of the benchmark.
|
|
|
Line 91... |
Line 93... |
This methodology is taken to accomodate any hardware or simulated platform.
|
This methodology is taken to accomodate any hardware or simulated platform.
|
The sample implementation returns millisecs by default,
|
The sample implementation returns millisecs by default,
|
and the resolution is controlled by <TIMER_RES_DIVIDER>
|
and the resolution is controlled by <TIMER_RES_DIVIDER>
|
*/
|
*/
|
CORE_TICKS get_time(void) {
|
CORE_TICKS get_time(void) {
|
CORE_TICKS elapsed = ((CORE_TICKS)neorv32_mtime_get_time()) - elapsed_cycles;
|
CORE_TICKS elapsed = ((CORE_TICKS)neorv32_cpu_get_cycle()) - elapsed_cycles;
|
elapsed_cycles = elapsed;
|
elapsed_cycles = elapsed;
|
//CORE_TICKS elapsed=(CORE_TICKS)(MYTIMEDIFF(stop_time_val, start_time_val));
|
//CORE_TICKS elapsed=(CORE_TICKS)(MYTIMEDIFF(stop_time_val, start_time_val));
|
return elapsed;
|
return elapsed;
|
}
|
}
|
/* Function : time_in_secs
|
/* Function : time_in_secs
|
Line 104... |
Line 106... |
The <secs_ret> type is used to accomodate systems with no support for floating point.
|
The <secs_ret> type is used to accomodate systems with no support for floating point.
|
Default implementation implemented by the EE_TICKS_PER_SEC macro above.
|
Default implementation implemented by the EE_TICKS_PER_SEC macro above.
|
*/
|
*/
|
secs_ret time_in_secs(CORE_TICKS ticks) {
|
secs_ret time_in_secs(CORE_TICKS ticks) {
|
//secs_ret retval=((secs_ret)ticks) / (secs_ret)EE_TICKS_PER_SEC;
|
//secs_ret retval=((secs_ret)ticks) / (secs_ret)EE_TICKS_PER_SEC;
|
secs_ret retval=(secs_ret)(ticks / neorv32_cpu_csr_read(CSR_MCLOCK));
|
secs_ret retval=(secs_ret)(ticks / SYSINFO_CLK);
|
return retval;
|
return retval;
|
}
|
}
|
|
|
ee_u32 default_num_contexts=1;
|
ee_u32 default_num_contexts=1;
|
|
|
Line 125... |
Line 127... |
neorv32_rte_enable_debug_mode();
|
neorv32_rte_enable_debug_mode();
|
|
|
// setup neorv32 UART
|
// setup neorv32 UART
|
neorv32_uart_setup(BAUD_RATE, 0, 0);
|
neorv32_uart_setup(BAUD_RATE, 0, 0);
|
|
|
// check if MTIME unit was synthesized
|
neorv32_uart_printf("NEORV32: Processor running at %u Hz\n", (uint32_t)SYSINFO_CLK);
|
if (!neorv32_mtime_available()) {
|
|
neorv32_uart_printf("NEORV32: Error! No MTIME unit synthesized!");
|
|
while(1);
|
|
}
|
|
|
|
neorv32_uart_printf("NEORV32: Processor running at %u Hz\n", (uint32_t)neorv32_cpu_csr_read(CSR_MCLOCK));
|
|
neorv32_uart_printf("NEORV32: Executing coremark (%u iterations). This may take some time...\n\n", (uint32_t)ITERATIONS);
|
neorv32_uart_printf("NEORV32: Executing coremark (%u iterations). This may take some time...\n\n", (uint32_t)ITERATIONS);
|
|
|
if (sizeof(ee_ptr_int) != sizeof(ee_u8 *)) {
|
if (sizeof(ee_ptr_int) != sizeof(ee_u8 *)) {
|
ee_printf("ERROR! Please define ee_ptr_int to a type that holds a pointer!\n");
|
ee_printf("ERROR! Please define ee_ptr_int to a type that holds a pointer!\n");
|
}
|
}
|
Line 153... |
Line 149... |
|
|
// show executed instructions, required cycles and resulting average CPI
|
// show executed instructions, required cycles and resulting average CPI
|
union {
|
union {
|
uint64_t uint64;
|
uint64_t uint64;
|
uint32_t uint32[sizeof(uint64_t)/2];
|
uint32_t uint32[sizeof(uint64_t)/2];
|
} exe_cycles;
|
|
|
|
union {
|
|
uint64_t uint64;
|
|
uint32_t uint32[sizeof(uint64_t)/2];
|
|
} exe_instructions, exe_time;
|
} exe_instructions, exe_time;
|
|
|
exe_time.uint64 = (uint64_t)elapsed_cycles;
|
exe_time.uint64 = (uint64_t)elapsed_cycles;
|
exe_cycles.uint32[0] = neorv32_cpu_csr_read(CSR_TIME);
|
exe_instructions.uint64 = neorv32_cpu_get_instret();
|
exe_cycles.uint32[1] = neorv32_cpu_csr_read(CSR_TIMEH);
|
|
exe_instructions.uint32[0] = neorv32_cpu_csr_read(CSR_INSTRET);
|
|
exe_instructions.uint32[1] = neorv32_cpu_csr_read(CSR_INSTRETH);
|
|
|
|
neorv32_uart_printf("\nNEORV32: Executed instructions 0x%x_%x\n", (uint32_t)exe_instructions.uint32[1], (uint32_t)exe_instructions.uint32[0]);
|
neorv32_uart_printf("\nNEORV32: Executed instructions 0x%x_%x\n", (uint32_t)exe_instructions.uint32[1], (uint32_t)exe_instructions.uint32[0]);
|
neorv32_uart_printf("NEORV32: Total required clock cycles 0x%x_%x\n", (uint32_t)exe_cycles.uint32[1], (uint32_t)exe_cycles.uint32[0]);
|
|
neorv32_uart_printf("NEORV32: CoreMark core clock cycles 0x%x_%x\n", (uint32_t)exe_time.uint32[1], (uint32_t)exe_time.uint32[0]);
|
neorv32_uart_printf("NEORV32: CoreMark core clock cycles 0x%x_%x\n", (uint32_t)exe_time.uint32[1], (uint32_t)exe_time.uint32[0]);
|
|
|
uint64_t average_cpi = exe_cycles.uint64 / exe_instructions.uint64;
|
uint64_t average_cpi = exe_time.uint64 / exe_instructions.uint64;
|
neorv32_uart_printf("NEORV32: Average CPI (integer part only): %u cycles/instruction\n", (uint32_t)average_cpi);
|
neorv32_uart_printf("NEORV32: Average CPI (integer part only): %u cycles/instruction\n", (uint32_t)average_cpi);
|
}
|
}
|
|
|
No newline at end of file
|
No newline at end of file
|