OpenCores
URL https://opencores.org/ocsvn/neorv32/neorv32/trunk

Subversion Repositories neorv32

[/] [neorv32/] [trunk/] [sw/] [example/] [coremark/] [core_portme.c] - Diff between revs 71 and 73

Show entire file | Details | Blame | View Log

Rev 71 Rev 73
Line 79... Line 79...
   cycles to 0.
   cycles to 0.
*/
*/
void
void
start_time(void)
start_time(void)
{
{
    neorv32_cpu_csr_write(CSR_MCOUNTINHIBIT, 0); // start all counters
 
    GETMYTIME(&start_time_val);
    GETMYTIME(&start_time_val);
 
    neorv32_cpu_csr_write(CSR_MCOUNTINHIBIT, 0); // start all counters
}
}
/* Function : stop_time
/* Function : stop_time
        This function will be called right after ending the timed portion of the
        This function will be called right after ending the timed portion of the
   benchmark.
   benchmark.
 
 
Line 101... Line 101...
/* 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.
 
 
        Actual value returned may be cpu cycles, milliseconds or any other
        Actual value returned may be cpu cycles, milliseconds or any other
   value, as long as it can be converted to seconds by <time_in_secs>. This
   value, as long as it can be converted to seconds by <time_in_secs>. This
   methodology is taken to accomodate any hardware or simulated platform. The
   methodology is taken to accommodate any hardware or simulated platform. The
   sample implementation returns millisecs by default, and the resolution is
   sample implementation returns milliseconds by default, and the resolution is
   controlled by <TIMER_RES_DIVIDER>
   controlled by <TIMER_RES_DIVIDER>
*/
*/
CORE_TICKS
CORE_TICKS
get_time(void)
get_time(void)
{
{
Line 231... Line 231...
  exe_time.uint64 = (uint64_t)get_time();
  exe_time.uint64 = (uint64_t)get_time();
  exe_instructions.uint64 = neorv32_cpu_get_instret();
  exe_instructions.uint64 = neorv32_cpu_get_instret();
 
 
  neorv32_uart0_printf("\nNEORV32: All reported numbers only show the integer part.\n\n");
  neorv32_uart0_printf("\nNEORV32: All reported numbers only show the integer part.\n\n");
 
 
  neorv32_uart0_printf("NEORV32: HPM results\n");
  neorv32_uart0_printf("NEORV32: HPM results (low words only)\n");
  if (num_hpm_cnts_global == 0) {neorv32_uart0_printf("no HPMs available\n"); }
  if (num_hpm_cnts_global == 0) {neorv32_uart0_printf("no HPMs available\n"); }
  if (num_hpm_cnts_global > 0)  {neorv32_uart0_printf("# Retired compr. instructions:  %u\n", (uint32_t)neorv32_cpu_csr_read(CSR_MHPMCOUNTER3)); }
  if (num_hpm_cnts_global > 0)  {neorv32_uart0_printf(" > Retired compr. instructions:  %u\n", (uint32_t)neorv32_cpu_csr_read(CSR_MHPMCOUNTER3)); }
  if (num_hpm_cnts_global > 1)  {neorv32_uart0_printf("# I-fetch wait cycles:          %u\n", (uint32_t)neorv32_cpu_csr_read(CSR_MHPMCOUNTER4)); }
  if (num_hpm_cnts_global > 1)  {neorv32_uart0_printf(" > Instr.-fetch wait cycles:     %u\n", (uint32_t)neorv32_cpu_csr_read(CSR_MHPMCOUNTER4)); }
  if (num_hpm_cnts_global > 2)  {neorv32_uart0_printf("# I-issue wait cycles:          %u\n", (uint32_t)neorv32_cpu_csr_read(CSR_MHPMCOUNTER5)); }
  if (num_hpm_cnts_global > 2)  {neorv32_uart0_printf(" > Instr.-issue wait cycles:     %u\n", (uint32_t)neorv32_cpu_csr_read(CSR_MHPMCOUNTER5)); }
  if (num_hpm_cnts_global > 3)  {neorv32_uart0_printf("# Multi-cycle ALU wait cycles:  %u\n", (uint32_t)neorv32_cpu_csr_read(CSR_MHPMCOUNTER6)); }
  if (num_hpm_cnts_global > 3)  {neorv32_uart0_printf(" > Multi-cycle ALU wait cycles:  %u\n", (uint32_t)neorv32_cpu_csr_read(CSR_MHPMCOUNTER6)); }
  if (num_hpm_cnts_global > 4)  {neorv32_uart0_printf("# Load operations:              %u\n", (uint32_t)neorv32_cpu_csr_read(CSR_MHPMCOUNTER7)); }
  if (num_hpm_cnts_global > 4)  {neorv32_uart0_printf(" > Load operations:              %u\n", (uint32_t)neorv32_cpu_csr_read(CSR_MHPMCOUNTER7)); }
  if (num_hpm_cnts_global > 5)  {neorv32_uart0_printf("# Store operations:             %u\n", (uint32_t)neorv32_cpu_csr_read(CSR_MHPMCOUNTER8)); }
  if (num_hpm_cnts_global > 5)  {neorv32_uart0_printf(" > Store operations:             %u\n", (uint32_t)neorv32_cpu_csr_read(CSR_MHPMCOUNTER8)); }
  if (num_hpm_cnts_global > 6)  {neorv32_uart0_printf("# Load/store wait cycles:       %u\n", (uint32_t)neorv32_cpu_csr_read(CSR_MHPMCOUNTER9)); }
  if (num_hpm_cnts_global > 6)  {neorv32_uart0_printf(" > Load/store wait cycles:       %u\n", (uint32_t)neorv32_cpu_csr_read(CSR_MHPMCOUNTER9)); }
  if (num_hpm_cnts_global > 7)  {neorv32_uart0_printf("# Unconditional jumps:          %u\n", (uint32_t)neorv32_cpu_csr_read(CSR_MHPMCOUNTER10)); }
  if (num_hpm_cnts_global > 7)  {neorv32_uart0_printf(" > Unconditional jumps:          %u\n", (uint32_t)neorv32_cpu_csr_read(CSR_MHPMCOUNTER10)); }
  if (num_hpm_cnts_global > 8)  {neorv32_uart0_printf("# Conditional branches (all):   %u\n", (uint32_t)neorv32_cpu_csr_read(CSR_MHPMCOUNTER11)); }
  if (num_hpm_cnts_global > 8)  {neorv32_uart0_printf(" > Conditional branches (all):   %u\n", (uint32_t)neorv32_cpu_csr_read(CSR_MHPMCOUNTER11)); }
  if (num_hpm_cnts_global > 9)  {neorv32_uart0_printf("# Conditional branches (taken): %u\n", (uint32_t)neorv32_cpu_csr_read(CSR_MHPMCOUNTER12)); }
  if (num_hpm_cnts_global > 9)  {neorv32_uart0_printf(" > Conditional branches (taken): %u\n", (uint32_t)neorv32_cpu_csr_read(CSR_MHPMCOUNTER12)); }
  if (num_hpm_cnts_global > 10) {neorv32_uart0_printf("# Entered traps:                %u\n", (uint32_t)neorv32_cpu_csr_read(CSR_MHPMCOUNTER13)); }
  if (num_hpm_cnts_global > 10) {neorv32_uart0_printf(" > Entered traps:                %u\n", (uint32_t)neorv32_cpu_csr_read(CSR_MHPMCOUNTER13)); }
  if (num_hpm_cnts_global > 11) {neorv32_uart0_printf("# Illegal operations:           %u\n", (uint32_t)neorv32_cpu_csr_read(CSR_MHPMCOUNTER14)); }
  if (num_hpm_cnts_global > 11) {neorv32_uart0_printf(" > Illegal operations:           %u\n", (uint32_t)neorv32_cpu_csr_read(CSR_MHPMCOUNTER14)); }
  neorv32_uart0_printf("\n");
  neorv32_uart0_printf("\n");
 
 
  neorv32_uart0_printf("NEORV32: Executed instructions      0x%x_%x\n", (uint32_t)exe_instructions.uint32[1], (uint32_t)exe_instructions.uint32[0]);
  neorv32_uart0_printf("NEORV32: Executed instructions      0x%x%x\n", (uint32_t)exe_instructions.uint32[1], (uint32_t)exe_instructions.uint32[0]);
  neorv32_uart0_printf("NEORV32: CoreMark core clock cycles 0x%x_%x\n", (uint32_t)exe_time.uint32[1], (uint32_t)exe_time.uint32[0]);
  neorv32_uart0_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_int = exe_time.uint64 / exe_instructions.uint64;
  uint64_t average_cpi_int = exe_time.uint64 / exe_instructions.uint64;
  neorv32_uart0_printf("NEORV32: Average CPI (integer part only): %u cycles/instruction\n", (uint32_t)average_cpi_int);
  neorv32_uart0_printf("NEORV32: Average CPI (integer part only): %u cycles/instruction\n", (uint32_t)average_cpi_int);
 
 
}
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.