Skip to content

Commit

Permalink
linux-gen: timer: add possibility to profile inline timer performance
Browse files Browse the repository at this point in the history
Add the branch to profile inline timer scan performance. Enable inline
timer scan performance test by setting CONFIG_TIMER_PROFILE_INLINE in
odp_config_internal.h.

Signed-off-by: Joyce Kong <joyce.kong@arm.com>
Reviewed-by: Petri Savolainen <petri.savolainen@nokia.com>
  • Loading branch information
JoyceKong-Arm authored and MatiasElo committed Oct 18, 2023
1 parent 1530457 commit 5da59c5
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 2 deletions.
3 changes: 3 additions & 0 deletions platform/linux-generic/include/odp_config_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,9 @@ extern "C" {
*/
#define CONFIG_TIMER_128BIT_ATOMICS 1

/* Enable timer scan performance benchmark. This works with inline enabled. */
#define CONFIG_TIMER_PROFILE_INLINE 0

#ifdef __cplusplus
}
#endif
Expand Down
1 change: 1 addition & 0 deletions platform/linux-generic/odp_system_info.c
Original file line number Diff line number Diff line change
Expand Up @@ -611,5 +611,6 @@ void odp_sys_config_print(void)
_ODP_PRINT("CONFIG_POOL_MAX_NUM: %i\n", CONFIG_POOL_MAX_NUM);
_ODP_PRINT("CONFIG_POOL_CACHE_MAX_SIZE: %i\n", CONFIG_POOL_CACHE_MAX_SIZE);
_ODP_PRINT("CONFIG_TIMER_128BIT_ATOMICS: %i\n", CONFIG_TIMER_128BIT_ATOMICS);
_ODP_PRINT("CONFIG_TIMER_PROFILE_INLINE: %i\n", CONFIG_TIMER_PROFILE_INLINE);
_ODP_PRINT("\n");
}
28 changes: 26 additions & 2 deletions platform/linux-generic/odp_timer.c
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,8 @@ typedef struct timer_local_t {
odp_time_t last_run;
int run_cnt;
uint8_t poll_shared;

uint64_t prof_nsec;
uint64_t prof_rounds;
} timer_local_t;

/* Points to timer global data */
Expand Down Expand Up @@ -872,7 +873,17 @@ void _odp_timer_run_inline(int dec)
}

/* Check the timer pools. */
timer_pool_scan_inline(num, now);
if (CONFIG_TIMER_PROFILE_INLINE) {
odp_time_t t1 = odp_time_local_strict();

timer_pool_scan_inline(num, now);
odp_time_t t2 = odp_time_local_strict();

timer_local.prof_nsec += odp_time_diff_ns(t2, t1);
timer_local.prof_rounds++;
} else {
timer_pool_scan_inline(num, now);
}
}

/******************************************************************************
Expand Down Expand Up @@ -2119,6 +2130,8 @@ int _odp_timer_init_local(void)
timer_local.last_run = odp_time_global_from_ns(0);
timer_local.run_cnt = 1;
timer_local.poll_shared = 0;
timer_local.prof_nsec = 0;
timer_local.prof_rounds = 0;

/* Timer feature disabled */
if (timer_global == NULL)
Expand All @@ -2140,5 +2153,16 @@ int _odp_timer_init_local(void)

int _odp_timer_term_local(void)
{
if (CONFIG_TIMER_PROFILE_INLINE) {
if (timer_local.prof_rounds) {
_ODP_PRINT("\n"
"Inline timer profiling for thread %i:\n"
"scan rounds: %" PRIu64 "\n"
"ave scan nsec: %.1f\n",
odp_thread_id(), timer_local.prof_rounds,
(double)timer_local.prof_nsec / timer_local.prof_rounds);
}
}

return 0;
}

0 comments on commit 5da59c5

Please sign in to comment.