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>
  • Loading branch information
JoyceKong-Arm committed Sep 7, 2023
1 parent a2085dd commit 3d32846
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 0 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 @@ -189,6 +189,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");
}
31 changes: 31 additions & 0 deletions platform/linux-generic/odp_timer.c
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,10 @@ typedef struct timer_local_t {
odp_time_t last_run;
int run_cnt;
uint8_t poll_shared;
#if CONFIG_TIMER_PROFILE_INLINE
uint64_t prof_nsec;
uint64_t prof_rounds;
#endif

} timer_local_t;

Expand Down Expand Up @@ -872,7 +876,17 @@ void _odp_timer_run_inline(int dec)
}

/* Check the timer pools. */
#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);
#endif
}

/******************************************************************************
Expand Down Expand Up @@ -2119,6 +2133,10 @@ 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;
#if CONFIG_TIMER_PROFILE_INLINE
timer_local.prof_nsec = 0;
timer_local.prof_rounds = 0;
#endif

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

int _odp_timer_term_local(void)
{
#if CONFIG_TIMER_PROFILE_INLINE
if (timer_local.prof_rounds) {
int thr = odp_thread_id();

odp_ticketlock_lock(&timer_global->lock);
_ODP_PRINT("Inline timer profiling for thread %i:\n", thr);
_ODP_PRINT(" scan rounds: %" PRIu64 "\n", timer_local.prof_rounds);
_ODP_PRINT(" ave scan nsec: %.1f\n",
(double)timer_local.prof_nsec / timer_local.prof_rounds);
odp_ticketlock_unlock(&timer_global->lock);
}
#endif

return 0;
}

0 comments on commit 3d32846

Please sign in to comment.