Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add option to measure last iterration #62

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 38 additions & 3 deletions core_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,10 @@ main(int argc, char *argv[])
ee_s16 known_id = -1, total_errors = 0;
ee_u16 seedcrc = 0;
CORE_TICKS total_time;
#if MEASURE_ONE_ITER
ee_u32 org_iterations;
CORE_TICKS sub_total_time;
#endif
core_results results[MULTITHREAD];
#if (MEM_METHOD == MEM_STACK)
ee_u8 stack_memblock[TOTAL_DATA_SIZE * MULTITHREAD];
Expand Down Expand Up @@ -278,11 +282,32 @@ for (i = 0; i < MULTITHREAD; i++)
{
core_stop_parallel(&results[i]);
}
stop_time();
total_time = get_time();
#elif MEASURE_ONE_ITER
/* Must have more than one iterations */
if (results[0].iterations <= 1) {
ee_printf("Need more than one iteration\n");
return MAIN_RETURN_VAL;
}
/* Run N-1 iterations, measure sub-total time */
org_iterations = results[0].iterations;
results[0].iterations--;
iterate(&results[0]);
stop_time();
sub_total_time = get_time();
/* Run 1 iteration, measure time, calculate total time */
start_time();
results[0].iterations = 1;
iterate(&results[0]);
stop_time();
total_time = sub_total_time + get_time();
results[0].iterations = org_iterations;
#else
iterate(&results[0]);
#endif
stop_time();
total_time = get_time();
#endif
/* get a function of the input to report */
seedcrc = crc16(results[0].seed1, seedcrc);
seedcrc = crc16(results[0].seed2, seedcrc);
Expand Down Expand Up @@ -370,13 +395,23 @@ for (i = 0; i < MULTITHREAD; i++)
default_num_contexts * results[0].iterations
/ time_in_secs(total_time));
#endif
if (time_in_secs(total_time) < 10)
if (time_in_secs(total_time) < CORE_MIN_RUNTIME)
{
ee_printf(
"ERROR! Must execute for at least 10 secs for a valid result!\n");
"ERROR! Must execute for at least %d secs for a valid result!\n",
CORE_MIN_RUNTIME);
total_errors++;
}

#if MEASURE_ONE_ITER
ee_printf("Iteration ticks : %lu\n", total_time - sub_total_time);
#if HAS_FLOAT
ee_printf("Iteration time(s): %f\n", time_in_secs(total_time - sub_total_time));
#else
ee_printf("Iteration time(s): %d\n", time_in_secs(total_time - sub_total_time));
#endif
#endif

ee_printf("Iterations : %lu\n",
(long unsigned)default_num_contexts * results[0].iterations);
ee_printf("Compiler version : %s\n", COMPILER_VERSION);
Expand Down
9 changes: 9 additions & 0 deletions coremark.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@ Original Author: Shay Gal-on
#define ee_printf printf
#endif

#ifndef CORE_MIN_RUNTIME
#define CORE_MIN_RUNTIME 10
#endif

/* Actual benchmark execution in iterate */
void *iterate(void *pres);

Expand Down Expand Up @@ -181,3 +185,8 @@ ee_u32 core_init_matrix(ee_u32 blksize,
ee_s32 seed,
mat_params *p);
ee_u16 core_bench_matrix(mat_params *p, ee_s16 seed, ee_u16 crc);

/* Single iteration time measurement */
#ifndef MEASURE_ONE_ITER
#define MEASURE_ONE_ITER 0
#endif