Message ID | 1438808473-26968-2-git-send-email-ivan.khoronzhuk@linaro.org |
---|---|
State | New |
Headers | show |
On 08/06/15 00:01, Ivan Khoronzhuk wrote: > /** > - * Current time in CPU cycles > + * Current time in counts of best hi-resolution timer available > * > - * @return Current time in CPU cycles > + * @return Current time in timer counts > */ > -uint64_t odp_time_cycles(void); > +uint64_t odp_time_counts(void); How about naming it odp_time_tick() ? And it's not clear why we need s in the end. English is not my native language but that call returns value of current time tick, not several ticks. So logically it has to be odp_time_count() or odp_time_tick(). Maxim.
Hi, Maxim On 06.08.15 11:28, Maxim Uvarov wrote: > On 08/06/15 00:01, Ivan Khoronzhuk wrote: >> /** >> - * Current time in CPU cycles >> + * Current time in counts of best hi-resolution timer available >> * >> - * @return Current time in CPU cycles >> + * @return Current time in timer counts >> */ >> -uint64_t odp_time_cycles(void); >> +uint64_t odp_time_counts(void); > > How about naming it odp_time_tick() ? I have no objections. If others are OK with it I can change it. It looks more clear. > > And it's not clear why we need s in the end. English is not my native > language but that call returns value of current time tick, not several > ticks. It's also confused me a little, but here is the same logic as with cycles. But if use tick word instead, maybe better..and more clear, as tick is closer to time then some count...So I will replace counts in flavor of tick, like: odp_time_counts -> odp_time_tick odp_time_ns_to_counts -> odp_time_ns_to_tick odp_time_diff_counts -> odp_time_diff_ticks odp_time_counts_to_ns -> odp_time_tick_to_ns If anyone has some objections, please reply here. > So logically it has to be odp_time_count() or odp_time_tick(). > > Maxim. > _______________________________________________ > lng-odp mailing list > lng-odp@lists.linaro.org > https://lists.linaro.org/mailman/listinfo/lng-odp
On 08/06/15 14:30, Ivan Khoronzhuk wrote: > Hi, Maxim > > On 06.08.15 11:28, Maxim Uvarov wrote: >> On 08/06/15 00:01, Ivan Khoronzhuk wrote: >>> /** >>> - * Current time in CPU cycles >>> + * Current time in counts of best hi-resolution timer available >>> * >>> - * @return Current time in CPU cycles >>> + * @return Current time in timer counts >>> */ >>> -uint64_t odp_time_cycles(void); >>> +uint64_t odp_time_counts(void); >> >> How about naming it odp_time_tick() ? > > I have no objections. If others are OK with it I can change it. > It looks more clear. > >> >> And it's not clear why we need s in the end. English is not my native >> language but that call returns value of current time tick, not several >> ticks. > > It's also confused me a little, but here is the same logic as with > cycles. But if use tick word instead, maybe better..and more clear, > as tick is closer to time then some count...So I will replace > counts in flavor of tick, like: > > odp_time_counts -> odp_time_tick > odp_time_ns_to_counts -> odp_time_ns_to_tick > odp_time_diff_counts -> odp_time_diff_ticks > odp_time_counts_to_ns -> odp_time_tick_to_ns odp_time_ticks_diff() also looks better due to most of functions start with odp_time_tick.. Maxim. > > > If anyone has some objections, please reply here. > >> So logically it has to be odp_time_count() or odp_time_tick(). >> >> Maxim. >> _______________________________________________ >> lng-odp mailing list >> lng-odp@lists.linaro.org >> https://lists.linaro.org/mailman/listinfo/lng-odp >
On 06.08.15 15:08, Maxim Uvarov wrote: > On 08/06/15 14:30, Ivan Khoronzhuk wrote: >> Hi, Maxim >> >> On 06.08.15 11:28, Maxim Uvarov wrote: >>> On 08/06/15 00:01, Ivan Khoronzhuk wrote: >>>> /** >>>> - * Current time in CPU cycles >>>> + * Current time in counts of best hi-resolution timer available >>>> * >>>> - * @return Current time in CPU cycles >>>> + * @return Current time in timer counts >>>> */ >>>> -uint64_t odp_time_cycles(void); >>>> +uint64_t odp_time_counts(void); >>> >>> How about naming it odp_time_tick() ? >> >> I have no objections. If others are OK with it I can change it. >> It looks more clear. >> >>> >>> And it's not clear why we need s in the end. English is not my native >>> language but that call returns value of current time tick, not several >>> ticks. >> >> It's also confused me a little, but here is the same logic as with >> cycles. But if use tick word instead, maybe better..and more clear, >> as tick is closer to time then some count...So I will replace >> counts in flavor of tick, like: >> >> odp_time_counts -> odp_time_tick >> odp_time_ns_to_counts -> odp_time_ns_to_tick >> odp_time_diff_counts -> odp_time_diff_ticks >> odp_time_counts_to_ns -> odp_time_tick_to_ns > > odp_time_ticks_diff() also looks better due to most of functions start > with odp_time_tick.. If it doesn't break naming convention, I agree. Will add it in new series. > > Maxim. > >> >> >> If anyone has some objections, please reply here. >> >>> So logically it has to be odp_time_count() or odp_time_tick(). >>> >>> Maxim. >>> _______________________________________________ >>> lng-odp mailing list >>> lng-odp@lists.linaro.org >>> https://lists.linaro.org/mailman/listinfo/lng-odp >> > > _______________________________________________ > lng-odp mailing list > lng-odp@lists.linaro.org > https://lists.linaro.org/mailman/listinfo/lng-odp
On 08/06/15 15:14, Ivan Khoronzhuk wrote: > > > On 06.08.15 15:08, Maxim Uvarov wrote: >> On 08/06/15 14:30, Ivan Khoronzhuk wrote: >>> Hi, Maxim >>> >>> On 06.08.15 11:28, Maxim Uvarov wrote: >>>> On 08/06/15 00:01, Ivan Khoronzhuk wrote: >>>>> /** >>>>> - * Current time in CPU cycles >>>>> + * Current time in counts of best hi-resolution timer available >>>>> * >>>>> - * @return Current time in CPU cycles >>>>> + * @return Current time in timer counts >>>>> */ >>>>> -uint64_t odp_time_cycles(void); >>>>> +uint64_t odp_time_counts(void); >>>> >>>> How about naming it odp_time_tick() ? >>> >>> I have no objections. If others are OK with it I can change it. >>> It looks more clear. >>> >>>> >>>> And it's not clear why we need s in the end. English is not my native >>>> language but that call returns value of current time tick, not several >>>> ticks. >>> >>> It's also confused me a little, but here is the same logic as with >>> cycles. But if use tick word instead, maybe better..and more clear, >>> as tick is closer to time then some count...So I will replace >>> counts in flavor of tick, like: >>> >>> odp_time_counts -> odp_time_tick >>> odp_time_ns_to_counts -> odp_time_ns_to_tick >>> odp_time_diff_counts -> odp_time_diff_ticks >>> odp_time_counts_to_ns -> odp_time_tick_to_ns >> >> odp_time_ticks_diff() also looks better due to most of functions start >> with odp_time_tick.. > > If it doesn't break naming convention, I agree. > Will add it in new series. Wait until it's discussed or everybody looked to that thread before updating all patches. Maxim. > >> >> Maxim. >> >>> >>> >>> If anyone has some objections, please reply here. >>> >>>> So logically it has to be odp_time_count() or odp_time_tick(). >>>> >>>> Maxim. >>>> _______________________________________________ >>>> lng-odp mailing list >>>> lng-odp@lists.linaro.org >>>> https://lists.linaro.org/mailman/listinfo/lng-odp >>> >> >> _______________________________________________ >> lng-odp mailing list >> lng-odp@lists.linaro.org >> https://lists.linaro.org/mailman/listinfo/lng-odp >
On Thu, Aug 06, 2015 at 02:30:34PM +0300, Ivan Khoronzhuk wrote: > Hi, Maxim > > On 06.08.15 11:28, Maxim Uvarov wrote: > >On 08/06/15 00:01, Ivan Khoronzhuk wrote: > >> /** > >>- * Current time in CPU cycles > >>+ * Current time in counts of best hi-resolution timer available > >> * > >>- * @return Current time in CPU cycles > >>+ * @return Current time in timer counts > >> */ > >>-uint64_t odp_time_cycles(void); > >>+uint64_t odp_time_counts(void); > > > >How about naming it odp_time_tick() ? > > I have no objections. If others are OK with it I can change it. > It looks more clear. > > > > >And it's not clear why we need s in the end. English is not my native > >language but that call returns value of current time tick, not several > >ticks. > > It's also confused me a little, but here is the same logic as with > cycles. But if use tick word instead, maybe better..and more clear, > as tick is closer to time then some count...So I will replace > counts in flavor of tick, like: > > odp_time_counts -> odp_time_tick > odp_time_ns_to_counts -> odp_time_ns_to_tick > odp_time_diff_counts -> odp_time_diff_ticks > odp_time_counts_to_ns -> odp_time_tick_to_ns > This now makes it pretty similar to the timer API, which has; odp_timer_tick_to_ns() odp_timer_ns_to_tick() But it also has; odp_timer_current_tick() So we should be consistent and use odp_time_current_tick() here.
On 08/06/15 15:38, Stuart Haslam wrote: > On Thu, Aug 06, 2015 at 02:30:34PM +0300, Ivan Khoronzhuk wrote: >> Hi, Maxim >> >> On 06.08.15 11:28, Maxim Uvarov wrote: >>> On 08/06/15 00:01, Ivan Khoronzhuk wrote: >>>> /** >>>> - * Current time in CPU cycles >>>> + * Current time in counts of best hi-resolution timer available >>>> * >>>> - * @return Current time in CPU cycles >>>> + * @return Current time in timer counts >>>> */ >>>> -uint64_t odp_time_cycles(void); >>>> +uint64_t odp_time_counts(void); >>> How about naming it odp_time_tick() ? >> I have no objections. If others are OK with it I can change it. >> It looks more clear. >> >>> And it's not clear why we need s in the end. English is not my native >>> language but that call returns value of current time tick, not several >>> ticks. >> It's also confused me a little, but here is the same logic as with >> cycles. But if use tick word instead, maybe better..and more clear, >> as tick is closer to time then some count...So I will replace >> counts in flavor of tick, like: >> >> odp_time_counts -> odp_time_tick >> odp_time_ns_to_counts -> odp_time_ns_to_tick >> odp_time_diff_counts -> odp_time_diff_ticks >> odp_time_counts_to_ns -> odp_time_tick_to_ns >> > This now makes it pretty similar to the timer API, which has; > > odp_timer_tick_to_ns() > odp_timer_ns_to_tick() > > But it also has; > > odp_timer_current_tick() > > So we should be consistent and use odp_time_current_tick() here. > Good finding. But to be shorter I would also rename odp_timer_current_tick() to odp_timer_tick() due to work current does not brings any sense but it usage of it will shift code on 8 chars right. Maxim.
On Thu, Aug 06, 2015 at 03:43:16PM +0300, Maxim Uvarov wrote: > On 08/06/15 15:38, Stuart Haslam wrote: > >On Thu, Aug 06, 2015 at 02:30:34PM +0300, Ivan Khoronzhuk wrote: > >>Hi, Maxim > >> > >>On 06.08.15 11:28, Maxim Uvarov wrote: > >>>On 08/06/15 00:01, Ivan Khoronzhuk wrote: > >>>> /** > >>>>- * Current time in CPU cycles > >>>>+ * Current time in counts of best hi-resolution timer available > >>>> * > >>>>- * @return Current time in CPU cycles > >>>>+ * @return Current time in timer counts > >>>> */ > >>>>-uint64_t odp_time_cycles(void); > >>>>+uint64_t odp_time_counts(void); > >>>How about naming it odp_time_tick() ? > >>I have no objections. If others are OK with it I can change it. > >>It looks more clear. > >> > >>>And it's not clear why we need s in the end. English is not my native > >>>language but that call returns value of current time tick, not several > >>>ticks. > >>It's also confused me a little, but here is the same logic as with > >>cycles. But if use tick word instead, maybe better..and more clear, > >>as tick is closer to time then some count...So I will replace > >>counts in flavor of tick, like: > >> > >>odp_time_counts -> odp_time_tick > >>odp_time_ns_to_counts -> odp_time_ns_to_tick > >>odp_time_diff_counts -> odp_time_diff_ticks > >>odp_time_counts_to_ns -> odp_time_tick_to_ns > >> > >This now makes it pretty similar to the timer API, which has; > > > >odp_timer_tick_to_ns() > >odp_timer_ns_to_tick() > > > >But it also has; > > > >odp_timer_current_tick() > > > >So we should be consistent and use odp_time_current_tick() here. > > > Good finding. But to be shorter I would also rename > odp_timer_current_tick() to odp_timer_tick() due to > work current does not brings any sense but it usage of it will shift > code on 8 chars right. > > Maxim. Fine by me.
diff --git a/example/ipsec/odp_ipsec.c b/example/ipsec/odp_ipsec.c index d392925..8a18322 100644 --- a/example/ipsec/odp_ipsec.c +++ b/example/ipsec/odp_ipsec.c @@ -293,12 +293,12 @@ odp_event_t polled_odp_schedule(odp_queue_t *from, uint64_t wait) break; if (0 == start_cycle) { - start_cycle = odp_time_cycles(); + start_cycle = odp_time_counts(); continue; } - cycle = odp_time_cycles(); - diff = odp_time_diff_cycles(start_cycle, cycle); + cycle = odp_time_counts(); + diff = odp_time_diff_counts(start_cycle, cycle); if (wait < diff) break; diff --git a/example/timer/odp_timer_test.c b/example/timer/odp_timer_test.c index 5d362ec..ace280b 100644 --- a/example/timer/odp_timer_test.c +++ b/example/timer/odp_timer_test.c @@ -440,19 +440,19 @@ int main(int argc, char *argv[]) printf("CPU freq %"PRIu64" Hz\n", odp_sys_cpu_hz()); printf("Cycles vs nanoseconds:\n"); ns = 0; - cycles = odp_time_ns_to_cycles(ns); + cycles = odp_time_ns_to_counts(ns); printf(" %12"PRIu64" ns -> %12"PRIu64" cycles\n", ns, cycles); printf(" %12"PRIu64" cycles -> %12"PRIu64" ns\n", cycles, - odp_time_cycles_to_ns(cycles)); + odp_time_counts_to_ns(cycles)); for (ns = 1; ns <= 100*ODP_TIME_SEC; ns *= 10) { - cycles = odp_time_ns_to_cycles(ns); + cycles = odp_time_ns_to_counts(ns); printf(" %12"PRIu64" ns -> %12"PRIu64" cycles\n", ns, cycles); printf(" %12"PRIu64" cycles -> %12"PRIu64" ns\n", cycles, - odp_time_cycles_to_ns(cycles)); + odp_time_counts_to_ns(cycles)); } printf("\n"); diff --git a/include/odp/api/time.h b/include/odp/api/time.h index b0072fc..6f15dec 100644 --- a/include/odp/api/time.h +++ b/include/odp/api/time.h @@ -30,11 +30,11 @@ extern "C" { /** - * Current time in CPU cycles + * Current time in counts of best hi-resolution timer available * - * @return Current time in CPU cycles + * @return Current time in timer counts */ -uint64_t odp_time_cycles(void); +uint64_t odp_time_counts(void); /** @@ -43,29 +43,29 @@ uint64_t odp_time_cycles(void); * @param t1 First time stamp * @param t2 Second time stamp * - * @return Difference of time stamps in CPU cycles + * @return Difference of time stamps in timer counts */ -uint64_t odp_time_diff_cycles(uint64_t t1, uint64_t t2); +uint64_t odp_time_diff_counts(uint64_t t1, uint64_t t2); /** - * Convert CPU cycles to nanoseconds + * Convert timer counts to nanoseconds * - * @param cycles Time in CPU cycles + * @param counts Time in timer counts * * @return Time in nanoseconds */ -uint64_t odp_time_cycles_to_ns(uint64_t cycles); +uint64_t odp_time_counts_to_ns(uint64_t counts); /** - * Convert nanoseconds to CPU cycles + * Convert nanoseconds to counts of best hi-resolution timer available * * @param ns Time in nanoseconds * - * @return Time in CPU cycles + * @return Time in timer counts */ -uint64_t odp_time_ns_to_cycles(uint64_t ns); +uint64_t odp_time_ns_to_counts(uint64_t ns); /** * @} diff --git a/test/performance/odp_pktio_perf.c b/test/performance/odp_pktio_perf.c index b09055f..0574536 100644 --- a/test/performance/odp_pktio_perf.c +++ b/test/performance/odp_pktio_perf.c @@ -325,28 +325,28 @@ static void *run_thread_tx(void *arg) if (outq == ODP_QUEUE_INVALID) LOG_ABORT("Failed to get output queue for thread %d\n", thr_id); - burst_gap_cycles = odp_time_ns_to_cycles( + burst_gap_cycles = odp_time_ns_to_counts( ODP_TIME_SEC / (targs->pps / targs->batch_len)); odp_barrier_wait(&globals->tx_barrier); - cur_cycles = odp_time_cycles(); + cur_cycles = odp_time_counts(); next_tx_cycles = cur_cycles; end_cycles = cur_cycles + - odp_time_ns_to_cycles(targs->duration * ODP_TIME_SEC); + odp_time_ns_to_counts(targs->duration * ODP_TIME_SEC); while (cur_cycles < end_cycles) { unsigned alloc_cnt = 0, tx_cnt; if (cur_cycles < next_tx_cycles) { - cur_cycles = odp_time_cycles(); + cur_cycles = odp_time_counts(); if (idle_start == 0) idle_start = cur_cycles; continue; } if (idle_start) { - stats->s.idle_cycles += odp_time_diff_cycles( + stats->s.idle_cycles += odp_time_diff_counts( idle_start, cur_cycles); idle_start = 0; } @@ -362,14 +362,14 @@ static void *run_thread_tx(void *arg) stats->s.enq_failures += unsent_pkts; stats->s.tx_cnt += tx_cnt; - cur_cycles = odp_time_cycles(); + cur_cycles = odp_time_counts(); } VPRINT(" %02d: TxPkts %-8"PRIu64" EnqFail %-6"PRIu64 " AllocFail %-6"PRIu64" Idle %"PRIu64"ms\n", thr_id, stats->s.tx_cnt, stats->s.enq_failures, stats->s.alloc_failures, - odp_time_cycles_to_ns(stats->s.idle_cycles)/1000/1000); + odp_time_counts_to_ns(stats->s.idle_cycles) / 1000 / 1000); return NULL; } @@ -587,8 +587,9 @@ static int setup_txrx_masks(odp_cpumask_t *thd_mask_tx, */ static void busy_loop_ns(uint64_t wait_ns) { - uint64_t end = odp_time_cycles() + odp_time_ns_to_cycles(wait_ns); - while (odp_time_cycles() < end) + uint64_t end = odp_time_counts() + odp_time_ns_to_counts(wait_ns); + + while (odp_time_counts() < end) ; } diff --git a/test/performance/odp_scheduling.c b/test/performance/odp_scheduling.c index c425024..3969111 100644 --- a/test/performance/odp_scheduling.c +++ b/test/performance/odp_scheduling.c @@ -185,7 +185,7 @@ static int test_alloc_single(int thr, odp_pool_t pool) odp_buffer_t temp_buf; uint64_t t1, t2, cycles, ns; - t1 = odp_time_cycles(); + t1 = odp_time_counts(); for (i = 0; i < ALLOC_ROUNDS; i++) { temp_buf = odp_buffer_alloc(pool); @@ -198,9 +198,9 @@ static int test_alloc_single(int thr, odp_pool_t pool) odp_buffer_free(temp_buf); } - t2 = odp_time_cycles(); - cycles = odp_time_diff_cycles(t1, t2); - ns = odp_time_cycles_to_ns(cycles); + t2 = odp_time_counts(); + cycles = odp_time_diff_counts(t1, t2); + ns = odp_time_counts_to_ns(cycles); printf(" [%i] alloc_sng alloc+free %"PRIu64" cycles, %"PRIu64" ns\n", thr, cycles/ALLOC_ROUNDS, ns/ALLOC_ROUNDS); @@ -222,7 +222,7 @@ static int test_alloc_multi(int thr, odp_pool_t pool) odp_buffer_t temp_buf[MAX_ALLOCS]; uint64_t t1, t2, cycles, ns; - t1 = odp_time_cycles(); + t1 = odp_time_counts(); for (i = 0; i < ALLOC_ROUNDS; i++) { for (j = 0; j < MAX_ALLOCS; j++) { @@ -238,9 +238,9 @@ static int test_alloc_multi(int thr, odp_pool_t pool) odp_buffer_free(temp_buf[j-1]); } - t2 = odp_time_cycles(); - cycles = odp_time_diff_cycles(t1, t2); - ns = odp_time_cycles_to_ns(cycles); + t2 = odp_time_counts(); + cycles = odp_time_diff_counts(t1, t2); + ns = odp_time_counts_to_ns(cycles); printf(" [%i] alloc_multi alloc+free %"PRIu64" cycles, %"PRIu64" ns\n", thr, cycles/(ALLOC_ROUNDS*MAX_ALLOCS), @@ -289,7 +289,7 @@ static int test_poll_queue(int thr, odp_pool_t msg_pool) return -1; } - t1 = odp_time_cycles(); + t1 = odp_time_counts(); for (i = 0; i < QUEUE_ROUNDS; i++) { ev = odp_buffer_to_event(buf); @@ -310,9 +310,9 @@ static int test_poll_queue(int thr, odp_pool_t msg_pool) } } - t2 = odp_time_cycles(); - cycles = odp_time_diff_cycles(t1, t2); - ns = odp_time_cycles_to_ns(cycles); + t2 = odp_time_counts(); + cycles = odp_time_diff_counts(t1, t2); + ns = odp_time_counts_to_ns(cycles); printf(" [%i] poll_queue enq+deq %"PRIu64" cycles, %"PRIu64" ns\n", thr, cycles/QUEUE_ROUNDS, ns/QUEUE_ROUNDS); @@ -348,7 +348,7 @@ static int test_schedule_single(const char *str, int thr, if (create_queue(thr, msg_pool, prio)) return -1; - t1 = odp_time_cycles(); + t1 = odp_time_counts(); for (i = 0; i < QUEUE_ROUNDS; i++) { ev = odp_schedule(&queue, ODP_SCHED_WAIT); @@ -382,9 +382,9 @@ static int test_schedule_single(const char *str, int thr, odp_schedule_resume(); - t2 = odp_time_cycles(); - cycles = odp_time_diff_cycles(t1, t2); - ns = odp_time_cycles_to_ns(cycles); + t2 = odp_time_counts(); + cycles = odp_time_diff_counts(t1, t2); + ns = odp_time_counts_to_ns(cycles); odp_barrier_wait(barrier); clear_sched_queues(); @@ -429,7 +429,7 @@ static int test_schedule_many(const char *str, int thr, return -1; /* Start sched-enq loop */ - t1 = odp_time_cycles(); + t1 = odp_time_counts(); for (i = 0; i < QUEUE_ROUNDS; i++) { ev = odp_schedule(&queue, ODP_SCHED_WAIT); @@ -463,9 +463,9 @@ static int test_schedule_many(const char *str, int thr, odp_schedule_resume(); - t2 = odp_time_cycles(); - cycles = odp_time_diff_cycles(t1, t2); - ns = odp_time_cycles_to_ns(cycles); + t2 = odp_time_counts(); + cycles = odp_time_diff_counts(t1, t2); + ns = odp_time_counts_to_ns(cycles); odp_barrier_wait(barrier); clear_sched_queues(); @@ -547,7 +547,7 @@ static int test_schedule_multi(const char *str, int thr, } /* Start sched-enq loop */ - t1 = odp_time_cycles(); + t1 = odp_time_counts(); for (i = 0; i < QUEUE_ROUNDS; i++) { num = odp_schedule_multi(&queue, ODP_SCHED_WAIT, ev, @@ -584,9 +584,9 @@ static int test_schedule_multi(const char *str, int thr, odp_schedule_resume(); - t2 = odp_time_cycles(); - cycles = odp_time_diff_cycles(t1, t2); - ns = odp_time_cycles_to_ns(cycles); + t2 = odp_time_counts(); + cycles = odp_time_diff_counts(t1, t2); + ns = odp_time_counts_to_ns(cycles); odp_barrier_wait(barrier); clear_sched_queues(); @@ -738,7 +738,7 @@ static void test_time(void) } while (tp1.tv_sec == tp2.tv_sec); - t1 = odp_time_cycles(); + t1 = odp_time_counts(); do { if (clock_gettime(CLOCK_MONOTONIC, &tp2)) { @@ -748,7 +748,7 @@ static void test_time(void) } while ((tp2.tv_sec - tp1.tv_sec) < TEST_SEC); - t2 = odp_time_cycles(); + t2 = odp_time_counts(); ns1 = (tp2.tv_sec - tp1.tv_sec)*1000000000; @@ -757,14 +757,14 @@ static void test_time(void) else ns1 -= tp1.tv_nsec - tp2.tv_nsec; - cycles = odp_time_diff_cycles(t1, t2); - ns2 = odp_time_cycles_to_ns(cycles); + cycles = odp_time_diff_counts(t1, t2); + ns2 = odp_time_counts_to_ns(cycles); err = ((double)(ns2) - (double)ns1) / (double)ns1; printf("clock_gettime %"PRIu64" ns\n", ns1); - printf("odp_time_cycles %"PRIu64" cycles\n", cycles); - printf("odp_time_cycles_to_ns %"PRIu64" ns\n", ns2); + printf("odp_time_counts %"PRIu64" cycles\n", cycles); + printf("odp_time_counts_to_ns %"PRIu64" ns\n", ns2); printf("odp get cycle error %f%%\n", err*100.0); printf("\n"); diff --git a/test/validation/pktio/pktio.c b/test/validation/pktio/pktio.c index dc8d427..1dc744e 100644 --- a/test/validation/pktio/pktio.c +++ b/test/validation/pktio/pktio.c @@ -305,15 +305,15 @@ static odp_event_t queue_deq_wait_time(odp_queue_t queue, uint64_t ns) uint64_t start, now, diff; odp_event_t ev; - start = odp_time_cycles(); + start = odp_time_counts(); do { ev = odp_queue_deq(queue); if (ev != ODP_EVENT_INVALID) return ev; - now = odp_time_cycles(); - diff = odp_time_diff_cycles(start, now); - } while (odp_time_cycles_to_ns(diff) < ns); + now = odp_time_counts(); + diff = odp_time_diff_counts(start, now); + } while (odp_time_counts_to_ns(diff) < ns); return ODP_EVENT_INVALID; } @@ -325,7 +325,7 @@ static odp_packet_t wait_for_packet(odp_queue_t queue, odp_event_t ev; odp_packet_t pkt = ODP_PACKET_INVALID; - start = odp_time_cycles(); + start = odp_time_counts(); do { if (queue != ODP_QUEUE_INVALID && @@ -345,9 +345,9 @@ static odp_packet_t wait_for_packet(odp_queue_t queue, odp_event_free(ev); } - now = odp_time_cycles(); - diff = odp_time_diff_cycles(start, now); - } while (odp_time_cycles_to_ns(diff) < ns); + now = odp_time_counts(); + diff = odp_time_diff_counts(start, now); + } while (odp_time_counts_to_ns(diff) < ns); CU_FAIL("failed to receive transmitted packet"); diff --git a/test/validation/scheduler/scheduler.c b/test/validation/scheduler/scheduler.c index fe03ab7..22d19a6 100644 --- a/test/validation/scheduler/scheduler.c +++ b/test/validation/scheduler/scheduler.c @@ -215,7 +215,7 @@ static void *schedule_common_(void *arg) uint64_t cycles = 0; /* Do some work here to keep the thread busy */ for (cnt = 0; cnt < 1000; cnt++) - cycles += odp_time_cycles(); + cycles += odp_time_counts(); odp_spinlock_unlock(&globals->atomic_lock); } diff --git a/test/validation/time/time.c b/test/validation/time/time.c index 0aac599..8ef7f2a 100644 --- a/test/validation/time/time.c +++ b/test/validation/time/time.c @@ -18,16 +18,16 @@ static void time_test_odp_cycles_diff(void) volatile int count = 0; uint64_t diff, cycles1, cycles2; - cycles1 = odp_time_cycles(); + cycles1 = odp_time_counts(); while (count < BUSY_LOOP_CNT) { count++; }; - cycles2 = odp_time_cycles(); + cycles2 = odp_time_counts(); CU_ASSERT(cycles2 > cycles1); - diff = odp_time_diff_cycles(cycles1, cycles2); + diff = odp_time_diff_counts(cycles1, cycles2); CU_ASSERT(diff > 0); } @@ -38,7 +38,7 @@ static void time_test_odp_cycles_negative_diff(void) cycles1 = 10; cycles2 = 5; - diff = odp_time_diff_cycles(cycles1, cycles2); + diff = odp_time_diff_counts(cycles1, cycles2); CU_ASSERT(diff > 0); } @@ -49,10 +49,10 @@ static void time_test_odp_time_conversion(void) uint64_t upper_limit, lower_limit; ns1 = 100; - cycles = odp_time_ns_to_cycles(ns1); + cycles = odp_time_ns_to_counts(ns1); CU_ASSERT(cycles > 0); - ns2 = odp_time_cycles_to_ns(cycles); + ns2 = odp_time_counts_to_ns(cycles); /* need to check within arithmetic tolerance that the same * value in ns is returned after conversions */
Current time API supposes that frequency of counter is equal to CPU frequency. But that's not always true, for instance, in case if no access to CPU cycle counter, another hi-resolution timer can be used, and it`s frequency can be different from CPU frequency. There is no big difference in which cycles to measure time, the better hi-resolution timer the better measurements. So, unbind CPU cycle counter from time API by eliminating word "cycle" as it's believed to use with CPU. Signed-off-by: Ivan Khoronzhuk <ivan.khoronzhuk@linaro.org> --- example/ipsec/odp_ipsec.c | 6 ++-- example/timer/odp_timer_test.c | 8 ++--- include/odp/api/time.h | 22 ++++++------- test/performance/odp_pktio_perf.c | 19 +++++------ test/performance/odp_scheduling.c | 60 +++++++++++++++++------------------ test/validation/pktio/pktio.c | 16 +++++----- test/validation/scheduler/scheduler.c | 2 +- test/validation/time/time.c | 12 +++---- 8 files changed, 73 insertions(+), 72 deletions(-)