Skip to content
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
19 changes: 17 additions & 2 deletions platform/linux-generic/arch/common/odp/api/abi/time_cpu_inlines.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ typedef struct _odp_time_global_t {
uint64_t freq_hz;
uint64_t start_time;
uint64_t start_time_ns;
uint64_t mult_to_ns;
uint64_t mult_from_ns;
uint32_t shift_to_ns;
uint32_t shift_from_ns;

} _odp_time_global_t;

Expand All @@ -45,9 +49,14 @@ static inline odp_time_t _odp_time_cur_strict(void)

static inline uint64_t _odp_time_to_ns(odp_time_t time)
{
uint64_t count = time.count;

#ifdef __SIZEOF_INT128__
return (uint64_t)(((__uint128_t)count * _odp_time_glob.mult_to_ns) >>
_odp_time_glob.shift_to_ns);
#else
uint64_t nsec;
uint64_t freq_hz = _odp_time_glob.freq_hz;
uint64_t count = time.count;
uint64_t sec = 0;

if (count >= freq_hz) {
Expand All @@ -58,12 +67,18 @@ static inline uint64_t _odp_time_to_ns(odp_time_t time)
nsec = (_ODP_TIME_GIGA_HZ * count) / freq_hz;

return (sec * _ODP_TIME_GIGA_HZ) + nsec;
#endif
}

static inline odp_time_t _odp_time_from_ns(uint64_t ns)
{
odp_time_t time;
uint64_t count;

#ifdef __SIZEOF_INT128__
count = (uint64_t)(((__uint128_t)ns * _odp_time_glob.mult_from_ns) >>
_odp_time_glob.shift_from_ns);
#else
uint64_t freq_hz = _odp_time_glob.freq_hz;
uint64_t sec = 0;

Expand All @@ -74,7 +89,7 @@ static inline odp_time_t _odp_time_from_ns(uint64_t ns)

count = sec * freq_hz;
count += (ns * freq_hz) / ODP_TIME_SEC_IN_NS;

#endif
time.count = count;

return time;
Expand Down
19 changes: 19 additions & 0 deletions platform/linux-generic/arch/common/odp_time_cpu.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,25 @@ int _odp_time_init_global(void)

_ODP_PRINT("HW time counter freq: %" PRIu64 " hz\n\n", global->freq_hz);

#ifdef __SIZEOF_INT128__
/* Find the maximum shift for which the multiplier fits into 64 bits */
for (global->shift_to_ns = 63; global->shift_to_ns > 0; global->shift_to_ns--) {
if ((((__uint128_t)_ODP_TIME_GIGA_HZ << global->shift_to_ns) /
global->freq_hz) <= UINT64_MAX)
break;
}
global->mult_to_ns = (uint64_t)(((__uint128_t)_ODP_TIME_GIGA_HZ << global->shift_to_ns) /
global->freq_hz);

for (global->shift_from_ns = 63; global->shift_from_ns > 0; global->shift_from_ns--) {
if ((((__uint128_t)global->freq_hz << global->shift_from_ns) /
ODP_TIME_SEC_IN_NS) <= UINT64_MAX)
break;
}
global->mult_from_ns = (uint64_t)(((__uint128_t)global->freq_hz << global->shift_from_ns) /
ODP_TIME_SEC_IN_NS);
#endif

count = _odp_time_cpu_global();
time.count = count;
global->start_time = count;
Expand Down
11 changes: 8 additions & 3 deletions test/performance/odp_ml_perf.c
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,11 @@ static int parse_args(int argc, char *argv[])
exit(EXIT_FAILURE);
}

if (glb->opt.warmup < 0) {
ODPH_ERR("Invalid number of warmup rounds: %d\n", glb->opt.warmup);
exit(EXIT_FAILURE);
}

printf("Options:\n");
printf("--------\n");
printf("model_name: %s\n", glb->opt.model_name);
Expand Down Expand Up @@ -456,7 +461,7 @@ static void dequantize_output(uint8_t *out_d_addr, uint8_t *out_q_addr)

static int test_ml(void *ptr)
{
odp_time_t time;
odp_time_t time = ODP_TIME_NULL;
odp_ml_data_seg_t inp_seg[MAX_IO];
uint8_t *inp_addr;
odp_ml_data_seg_t out_seg[MAX_IO];
Expand Down Expand Up @@ -588,7 +593,7 @@ static int test_ml(void *ptr)

static int test_ml_create(void *ptr)
{
odp_time_t time;
odp_time_t time = ODP_TIME_NULL;
int thread_idx = (int)(uintptr_t)ptr;
odp_ml_model_t mdl;
odp_ml_model_param_t model_param;
Expand Down Expand Up @@ -630,7 +635,7 @@ static int test_ml_create(void *ptr)

static int test_ml_load(void *ptr)
{
odp_time_t time;
odp_time_t time = ODP_TIME_NULL;
int thread_idx = (int)(uintptr_t)ptr;
odp_ml_model_t mdl;
odp_ml_model_param_t model_param;
Expand Down