forked from Github_Repos/cvw
Merge branch 'main' of https://github.com/davidharrishmc/riscv-wally into main
This commit is contained in:
commit
c93b6abed2
@ -212,25 +212,52 @@ MAIN_RETURN_TYPE main(int argc, char *argv[]) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*int foreverLoop = 1;
|
||||||
|
secs_ret timing = 0;
|
||||||
|
int timingInt;
|
||||||
|
ee_printf("\nENTERING FOREVER WHILE LOOP\n");
|
||||||
|
while(foreverLoop == 1)
|
||||||
|
{
|
||||||
|
start_time();
|
||||||
|
//filler
|
||||||
|
stop_time();
|
||||||
|
timing += time_in_secs(get_time());
|
||||||
|
timingInt = (int)timing;
|
||||||
|
ee_printf("Timing is %d\n", timingInt);
|
||||||
|
}/*
|
||||||
|
|
||||||
/* automatically determine number of iterations if not set */
|
/* automatically determine number of iterations if not set */
|
||||||
if (results[0].iterations==0) {
|
if (results[0].iterations==0) {
|
||||||
secs_ret secs_passed=0;
|
secs_ret secs_passed=0;
|
||||||
ee_u32 divisor;
|
ee_u32 divisor;
|
||||||
results[0].iterations=1;
|
results[0].iterations=1;
|
||||||
|
int iterationInc = 0;
|
||||||
|
ee_printf("\n\nENTERING ITERATION WHILE LOOP\n");
|
||||||
while (secs_passed < (secs_ret)1) {
|
while (secs_passed < (secs_ret)1) {
|
||||||
results[0].iterations*=10;
|
if(iterationInc != 0)
|
||||||
|
{
|
||||||
|
results[0].iterations++;
|
||||||
|
}
|
||||||
|
ee_printf("iterations is %d\n", results[0].iterations);
|
||||||
start_time();
|
start_time();
|
||||||
iterate(&results[0]);
|
iterate(&results[0]);
|
||||||
stop_time();
|
stop_time();
|
||||||
secs_passed=time_in_secs(get_time());
|
secs_passed = time_in_secs(get_time());
|
||||||
|
int secs_passed_int = (int)secs_passed;
|
||||||
|
ee_printf("secs passed is %d\n", secs_passed_int);
|
||||||
|
iterationInc++;
|
||||||
}
|
}
|
||||||
|
ee_printf("LEAVING ITERATION WHILE LOOP!\n\n");
|
||||||
/* now we know it executes for at least 1 sec, set actual run time at about 10 secs */
|
/* now we know it executes for at least 1 sec, set actual run time at about 10 secs */
|
||||||
divisor=(ee_u32)secs_passed;
|
divisor=(ee_u32)secs_passed;
|
||||||
|
ee_printf("divisor is %lu\n", divisor);
|
||||||
if (divisor==0) /* some machines cast float to int as 0 since this conversion is not defined by ANSI, but we know at least one second passed */
|
if (divisor==0) /* some machines cast float to int as 0 since this conversion is not defined by ANSI, but we know at least one second passed */
|
||||||
divisor=1;
|
divisor=1;
|
||||||
results[0].iterations*=1+10/divisor;
|
results[0].iterations*=1+10/divisor;
|
||||||
|
ee_printf("iterations is %d\n", results[0].iterations);
|
||||||
}
|
}
|
||||||
/* perform actual benchmark */
|
/* perform actual benchmark */
|
||||||
|
ee_printf("Starting benchmark\n");
|
||||||
start_time();
|
start_time();
|
||||||
#if (MULTITHREAD>1)
|
#if (MULTITHREAD>1)
|
||||||
if (default_num_contexts>MULTITHREAD) {
|
if (default_num_contexts>MULTITHREAD) {
|
||||||
@ -249,7 +276,8 @@ MAIN_RETURN_TYPE main(int argc, char *argv[]) {
|
|||||||
#endif
|
#endif
|
||||||
stop_time();
|
stop_time();
|
||||||
total_time=get_time();
|
total_time=get_time();
|
||||||
ee_printf("ending benchmark");
|
ee_printf("total time is %u\n", total_time);
|
||||||
|
ee_printf("ending benchmark\n");
|
||||||
/* get a function of the input to report */
|
/* get a function of the input to report */
|
||||||
seedcrc=crc16(results[0].seed1,seedcrc);
|
seedcrc=crc16(results[0].seed1,seedcrc);
|
||||||
seedcrc=crc16(results[0].seed2,seedcrc);
|
seedcrc=crc16(results[0].seed2,seedcrc);
|
||||||
@ -340,12 +368,17 @@ MAIN_RETURN_TYPE main(int argc, char *argv[]) {
|
|||||||
for (i=0 ; i<default_num_contexts; i++)
|
for (i=0 ; i<default_num_contexts; i++)
|
||||||
ee_printf("[%d]crcstate : 0x%04x\n",i,results[i].crcstate);
|
ee_printf("[%d]crcstate : 0x%04x\n",i,results[i].crcstate);
|
||||||
for (i=0 ; i<default_num_contexts; i++)
|
for (i=0 ; i<default_num_contexts; i++)
|
||||||
ee_printf("[%d]crcfinal : 0x%04x\"n",i,results[i].crc);
|
ee_printf("[%d]crcfinal : 0x%04x\n",i,results[i].crc);
|
||||||
if (total_errors==0) {
|
if (total_errors==0) {
|
||||||
ee_printf("Correct operation validated. See README.md for run and reporting rules.\n");
|
ee_printf("Correct operation validated. See README.md for run and reporting rules.\n");
|
||||||
#if HAS_FLOAT
|
#if HAS_FLOAT
|
||||||
if (known_id==3) {
|
if (known_id==3) {
|
||||||
ee_printf("CoreMark 1.0 : %f / %s %s",default_num_contexts*results[0].iterations/time_in_secs(total_time),COMPILER_VERSION,COMPILER_FLAGS);
|
unsigned long long tmp = (unsigned long long) 1000.0*default_num_contexts*results[0].iterations/time_in_secs(total_time);
|
||||||
|
secs_ret totalmsecs = time_in_secs(total_time);
|
||||||
|
int totalmint = (int) totalmsecs;
|
||||||
|
ee_printf("ELAPSED S: %d\n", totalmint);
|
||||||
|
|
||||||
|
ee_printf("CoreMark 1.0 : %d / %s %s\n",tmp,COMPILER_VERSION,COMPILER_FLAGS);
|
||||||
#if defined(MEM_LOCATION) && !defined(MEM_LOCATION_UNSPEC)
|
#if defined(MEM_LOCATION) && !defined(MEM_LOCATION_UNSPEC)
|
||||||
ee_printf(" / %s",MEM_LOCATION);
|
ee_printf(" / %s",MEM_LOCATION);
|
||||||
#else
|
#else
|
||||||
|
@ -114,9 +114,10 @@ void portable_free(void *p) {
|
|||||||
#define read_csr(reg) ({ unsigned long __tmp; \
|
#define read_csr(reg) ({ unsigned long __tmp; \
|
||||||
asm volatile ("csrr %0, " #reg : "=r"(__tmp)); \
|
asm volatile ("csrr %0, " #reg : "=r"(__tmp)); \
|
||||||
__tmp; })
|
__tmp; })
|
||||||
#define GETMYTIME(_t) (*_t=read_csr(cycle))
|
#define GETMYTIME(_t) (_t = *(volatile unsigned long long*)0x0200BFF8)
|
||||||
#define MYTIMEDIFF(fin,ini) ((fin)-(ini))
|
#define MYTIMEDIFF(fin,ini) ((fin)-(ini))
|
||||||
#define TIMER_RES_DIVIDER 1
|
// Changing TIMER_RES_DIVIDER to 1000000 sets EE_TICKS_PER_SEC to 1000 (now counting ticks per ms)
|
||||||
|
#define TIMER_RES_DIVIDER 10000
|
||||||
#define SAMPLE_TIME_IMPLEMENTATION 1
|
#define SAMPLE_TIME_IMPLEMENTATION 1
|
||||||
#endif
|
#endif
|
||||||
#define EE_TICKS_PER_SEC (NSECS_PER_SEC / TIMER_RES_DIVIDER)
|
#define EE_TICKS_PER_SEC (NSECS_PER_SEC / TIMER_RES_DIVIDER)
|
||||||
@ -132,7 +133,9 @@ static CORETIMETYPE start_time_val, stop_time_val;
|
|||||||
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) {
|
||||||
GETMYTIME(&start_time_val );
|
GETMYTIME(start_time_val);
|
||||||
|
ee_printf("Timer started\n");
|
||||||
|
ee_printf(" MTIME: %u\n", start_time_val);
|
||||||
#if CALLGRIND_RUN
|
#if CALLGRIND_RUN
|
||||||
CALLGRIND_START_INSTRUMENTATION
|
CALLGRIND_START_INSTRUMENTATION
|
||||||
#endif
|
#endif
|
||||||
@ -153,7 +156,9 @@ void stop_time(void) {
|
|||||||
#if MICA
|
#if MICA
|
||||||
asm volatile("int3");/*1 */
|
asm volatile("int3");/*1 */
|
||||||
#endif
|
#endif
|
||||||
GETMYTIME(&stop_time_val );
|
GETMYTIME(stop_time_val);
|
||||||
|
ee_printf("Timer stopped\n");
|
||||||
|
ee_printf(" MTIME: %u\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.
|
||||||
@ -166,6 +171,7 @@ void stop_time(void) {
|
|||||||
*/
|
*/
|
||||||
CORE_TICKS get_time(void) {
|
CORE_TICKS get_time(void) {
|
||||||
CORE_TICKS elapsed=(CORE_TICKS)(MYTIMEDIFF(stop_time_val, start_time_val));
|
CORE_TICKS elapsed=(CORE_TICKS)(MYTIMEDIFF(stop_time_val, start_time_val));
|
||||||
|
ee_printf(" Elapsed MTIME: %u\n", elapsed);
|
||||||
return elapsed;
|
return elapsed;
|
||||||
}
|
}
|
||||||
/* Function: time_in_secs
|
/* Function: time_in_secs
|
||||||
@ -176,13 +182,15 @@ CORE_TICKS get_time(void) {
|
|||||||
*/
|
*/
|
||||||
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;
|
||||||
|
int retvalint = (int)retval;
|
||||||
|
ee_printf(" RETURN VALUE FROM TIME IN SECS FUNCTION: %d\n", retvalint);
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
#error "Please implement timing functionality in core_portme.c"
|
#error "Please implement timing functionality in core_portme.c"
|
||||||
#endif /* SAMPLE_TIME_IMPLEMENTATION */
|
#endif /* SAMPLE_TIME_IMPLEMENTATION */
|
||||||
|
|
||||||
ee_u32 default_num_contexts=MULTITHREAD;
|
ee_u32 default_num_contexts = MULTITHREAD;
|
||||||
|
|
||||||
/* Function: portable_init
|
/* Function: portable_init
|
||||||
Target specific initialization code
|
Target specific initialization code
|
||||||
|
Loading…
Reference in New Issue
Block a user