From 1e62a62441690929b109ef61b4df7df2102449a9 Mon Sep 17 00:00:00 2001 From: Maciej Kurc Date: Mon, 12 Feb 2024 16:14:20 +0100 Subject: [PATCH 1/2] Parametrize minimum required runtime in seconds Internal-tag: [#55140] Signed-off-by: Maciej Kurc --- core_main.c | 5 +++-- coremark.h | 4 ++++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/core_main.c b/core_main.c index a4beeb6..6c0f641 100644 --- a/core_main.c +++ b/core_main.c @@ -370,10 +370,11 @@ 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++; } diff --git a/coremark.h b/coremark.h index 9c5e406..2c4420d 100644 --- a/coremark.h +++ b/coremark.h @@ -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); From 88caed1178857bc0ffaa4d0cad1275fa0dca894b Mon Sep 17 00:00:00 2001 From: Maciej Kurc Date: Tue, 13 Feb 2024 13:21:05 +0100 Subject: [PATCH 2/2] Add an option to allow measuring cycles of the last iteration Internal-Tag: [#55140] Signed-off-by: Maciej Kurc --- core_main.c | 36 +++++++++++++++++++++++++++++++++++- coremark.h | 5 +++++ 2 files changed, 40 insertions(+), 1 deletion(-) diff --git a/core_main.c b/core_main.c index 6c0f641..9bd1d69 100644 --- a/core_main.c +++ b/core_main.c @@ -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]; @@ -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); @@ -378,6 +403,15 @@ for (i = 0; i < MULTITHREAD; i++) 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); diff --git a/coremark.h b/coremark.h index 2c4420d..18314f0 100644 --- a/coremark.h +++ b/coremark.h @@ -185,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