Message ID | 1438986490-12100-3-git-send-email-ivan.khoronzhuk@linaro.org |
---|---|
State | New |
Headers | show |
On Sat, Aug 08, 2015 at 01:28:08AM +0300, Ivan Khoronzhuk wrote: > The word "cycle" is left from old API time names. The "cycle" is > ambiguous word, especially when it can be used for other purposes. > So better to use "tick" word or just "t" symbol. > > Signed-off-by: Ivan Khoronzhuk <ivan.khoronzhuk@linaro.org> > --- > example/ipsec/odp_ipsec.c | 14 +++--- > example/timer/odp_timer_test.c | 22 +++++----- > test/performance/odp_pktio_perf.c | 32 +++++++------- > test/performance/odp_scheduling.c | 80 +++++++++++++++++------------------ > test/validation/scheduler/scheduler.c | 4 +- > test/validation/time/time.c | 38 ++++++++--------- > 6 files changed, 95 insertions(+), 95 deletions(-) > > diff --git a/example/ipsec/odp_ipsec.c b/example/ipsec/odp_ipsec.c > index 3d34210..019a0b6 100644 > --- a/example/ipsec/odp_ipsec.c > +++ b/example/ipsec/odp_ipsec.c > @@ -265,11 +265,11 @@ odp_queue_t polled_odp_queue_create(const char *name, > static > odp_event_t polled_odp_schedule(odp_queue_t *from, uint64_t wait) > { > - uint64_t start_cycle; > - uint64_t cycle; > + uint64_t start_tick; > + uint64_t tick; > uint64_t diff; > > - start_cycle = 0; > + start_tick = 0; > > while (1) { > int idx; > @@ -292,13 +292,13 @@ odp_event_t polled_odp_schedule(odp_queue_t *from, uint64_t wait) > if (ODP_SCHED_NO_WAIT == wait) > break; > > - if (0 == start_cycle) { > - start_cycle = odp_time_tick(); > + if (0 == start_tick) { > + start_tick = odp_time_tick(); > continue; > } > > - cycle = odp_time_tick(); > - diff = odp_time_ticks_diff(start_cycle, cycle); > + tick = odp_time_tick(); > + diff = odp_time_ticks_diff(start_tick, tick); > > if (wait < diff) > break; > diff --git a/example/timer/odp_timer_test.c b/example/timer/odp_timer_test.c > index c6c809d..bbaaf7d 100644 > --- a/example/timer/odp_timer_test.c > +++ b/example/timer/odp_timer_test.c > @@ -313,7 +313,7 @@ int main(int argc, char *argv[]) > odph_linux_pthread_t thread_tbl[MAX_WORKERS]; > int num_workers; > odp_queue_t queue; > - uint64_t cycles, ns; > + uint64_t ticks, ns; > odp_queue_param_t param; > odp_pool_param_t params; > odp_timer_pool_param_t tparams; > @@ -438,21 +438,21 @@ int main(int argc, char *argv[]) > } > > printf("CPU freq %"PRIu64" Hz\n", odp_sys_cpu_hz()); > - printf("Cycles vs nanoseconds:\n"); > + printf("Ticks vs nanoseconds:\n"); > ns = 0; > - cycles = odp_time_ns_to_tick(ns); > + ticks = odp_time_ns_to_tick(ns); > > - printf(" %12"PRIu64" ns -> %12"PRIu64" cycles\n", ns, cycles); > - printf(" %12"PRIu64" cycles -> %12"PRIu64" ns\n", cycles, > - odp_time_tick_to_ns(cycles)); > + printf(" %12"PRIu64" ns -> %12"PRIu64" ticks\n", ns, ticks); This was already present, but checkpatch complains about; CHECK: Concatenated strings should use spaces between elements > + printf(" %12"PRIu64" ticks -> %12"PRIu64" ns\n", ticks, nit: this puts the alignment out, need another space after ticks. > + odp_time_tick_to_ns(ticks)); > > for (ns = 1; ns <= 100*ODP_TIME_SEC; ns *= 10) { > - cycles = odp_time_ns_to_tick(ns); > + ticks = odp_time_ns_to_tick(ns); > > - printf(" %12"PRIu64" ns -> %12"PRIu64" cycles\n", ns, > - cycles); > - printf(" %12"PRIu64" cycles -> %12"PRIu64" ns\n", cycles, > - odp_time_tick_to_ns(cycles)); > + printf(" %12"PRIu64" ns -> %12"PRIu64" ticks\n", ns, > + ticks); > + printf(" %12"PRIu64" ticks -> %12"PRIu64" ns\n", ticks, And here. > + odp_time_tick_to_ns(ticks)); > } > > printf("\n"); > diff --git a/test/performance/odp_pktio_perf.c b/test/performance/odp_pktio_perf.c > index b3f8d2b..a80d19a 100644 > --- a/test/performance/odp_pktio_perf.c > +++ b/test/performance/odp_pktio_perf.c > @@ -106,7 +106,7 @@ struct tx_stats_s { > uint64_t tx_cnt; /* Packets transmitted */ > uint64_t alloc_failures;/* Packet allocation failures */ > uint64_t enq_failures; /* Enqueue failures */ > - uint64_t idle_cycles; /* Idle cycle count in TX loop */ > + uint64_t idle_ticks; /* Idle ticks count in TX loop */ > }; > > typedef union tx_stats_u { > @@ -302,8 +302,8 @@ static void *run_thread_tx(void *arg) > int thr_id; > odp_queue_t outq; > pkt_tx_stats_t *stats; > - uint64_t next_tx_cycles, end_cycles, cur_cycles; > - uint64_t burst_gap_cycles; > + uint64_t next_tx_tick, end_tick, cur_tick; > + uint64_t burst_gap; > uint32_t batch_len; > int unsent_pkts = 0; > odp_event_t tx_event[BATCH_LEN_MAX]; > @@ -325,33 +325,33 @@ 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_tick( > + burst_gap = odp_time_ns_to_tick( > ODP_TIME_SEC / (targs->pps / targs->batch_len)); > > odp_barrier_wait(&globals->tx_barrier); > > - cur_cycles = odp_time_tick(); > - next_tx_cycles = cur_cycles; > - end_cycles = cur_cycles + > + cur_tick = odp_time_tick(); > + next_tx_tick = cur_tick; > + end_tick = cur_tick + > odp_time_ns_to_tick(targs->duration * ODP_TIME_SEC); > > - while (cur_cycles < end_cycles) { > + while (cur_tick < end_tick) { > unsigned alloc_cnt = 0, tx_cnt; > > - if (cur_cycles < next_tx_cycles) { > - cur_cycles = odp_time_tick(); > + if (cur_tick < next_tx_tick) { > + cur_tick = odp_time_tick(); > if (idle_start == 0) > - idle_start = cur_cycles; > + idle_start = cur_tick; > continue; > } > > if (idle_start) { > - stats->s.idle_cycles += odp_time_ticks_diff( > - idle_start, cur_cycles); > + stats->s.idle_ticks += odp_time_ticks_diff(idle_start, > + cur_tick); > idle_start = 0; > } > > - next_tx_cycles += burst_gap_cycles; > + next_tx_tick += burst_gap; > > alloc_cnt = alloc_packets(tx_event, batch_len - unsent_pkts); > if (alloc_cnt != batch_len) > @@ -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_tick(); > + cur_tick = odp_time_tick(); > } > > 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_tick_to_ns(stats->s.idle_cycles) / 1000 / 1000); > + odp_time_tick_to_ns(stats->s.idle_ticks) / 1000 / 1000); > > return NULL; > } > diff --git a/test/performance/odp_scheduling.c b/test/performance/odp_scheduling.c > index e34cea9..8c8a283 100644 > --- a/test/performance/odp_scheduling.c > +++ b/test/performance/odp_scheduling.c > @@ -183,7 +183,7 @@ static int test_alloc_single(int thr, odp_pool_t pool) > { > int i; > odp_buffer_t temp_buf; > - uint64_t t1, t2, cycles, ns; > + uint64_t t1, t2, ticks, ns; > > t1 = odp_time_tick(); > > @@ -199,11 +199,11 @@ static int test_alloc_single(int thr, odp_pool_t pool) > } > > t2 = odp_time_tick(); > - cycles = odp_time_ticks_diff(t1, t2); > - ns = odp_time_tick_to_ns(cycles); > + ticks = odp_time_ticks_diff(t1, t2); > + ns = odp_time_tick_to_ns(ticks); > > - printf(" [%i] alloc_sng alloc+free %"PRIu64" cycles, %"PRIu64" ns\n", > - thr, cycles/ALLOC_ROUNDS, ns/ALLOC_ROUNDS); > + printf(" [%i] alloc_sng alloc+free %"PRIu64" ticks, %"PRIu64" ns\n", > + thr, ticks / ALLOC_ROUNDS, ns / ALLOC_ROUNDS); > > return 0; > } > @@ -220,7 +220,7 @@ static int test_alloc_multi(int thr, odp_pool_t pool) > { > int i, j; > odp_buffer_t temp_buf[MAX_ALLOCS]; > - uint64_t t1, t2, cycles, ns; > + uint64_t t1, t2, ticks, ns; > > t1 = odp_time_tick(); > > @@ -239,11 +239,11 @@ static int test_alloc_multi(int thr, odp_pool_t pool) > } > > t2 = odp_time_tick(); > - cycles = odp_time_ticks_diff(t1, t2); > - ns = odp_time_tick_to_ns(cycles); > + ticks = odp_time_ticks_diff(t1, t2); > + ns = odp_time_tick_to_ns(ticks); > > - printf(" [%i] alloc_multi alloc+free %"PRIu64" cycles, %"PRIu64" ns\n", > - thr, cycles/(ALLOC_ROUNDS*MAX_ALLOCS), > + printf(" [%i] alloc_multi alloc+free %"PRIu64" ticks, %"PRIu64" ns\n", > + thr, ticks / (ALLOC_ROUNDS * MAX_ALLOCS), > ns/(ALLOC_ROUNDS*MAX_ALLOCS)); > > return 0; > @@ -265,7 +265,7 @@ static int test_poll_queue(int thr, odp_pool_t msg_pool) > odp_buffer_t buf; > test_message_t *t_msg; > odp_queue_t queue; > - uint64_t t1, t2, cycles, ns; > + uint64_t t1, t2, ticks, ns; > int i; > > /* Alloc test message */ > @@ -311,11 +311,11 @@ static int test_poll_queue(int thr, odp_pool_t msg_pool) > } > > t2 = odp_time_tick(); > - cycles = odp_time_ticks_diff(t1, t2); > - ns = odp_time_tick_to_ns(cycles); > + ticks = odp_time_ticks_diff(t1, t2); > + ns = odp_time_tick_to_ns(ticks); > > - printf(" [%i] poll_queue enq+deq %"PRIu64" cycles, %"PRIu64" ns\n", > - thr, cycles/QUEUE_ROUNDS, ns/QUEUE_ROUNDS); > + printf(" [%i] poll_queue enq+deq %"PRIu64" ticks, %"PRIu64" ns\n", > + thr, ticks / QUEUE_ROUNDS, ns / QUEUE_ROUNDS); > > odp_buffer_free(buf); > return 0; > @@ -341,7 +341,7 @@ static int test_schedule_single(const char *str, int thr, > { > odp_event_t ev; > odp_queue_t queue; > - uint64_t t1, t2, cycles, ns; > + uint64_t t1, t2, ticks, ns; > uint32_t i; > uint32_t tot = 0; > > @@ -383,17 +383,17 @@ static int test_schedule_single(const char *str, int thr, > odp_schedule_resume(); > > t2 = odp_time_tick(); > - cycles = odp_time_ticks_diff(t1, t2); > - ns = odp_time_tick_to_ns(cycles); > + ticks = odp_time_ticks_diff(t1, t2); > + ns = odp_time_tick_to_ns(ticks); > > odp_barrier_wait(barrier); > clear_sched_queues(); > > - cycles = cycles/tot; > + ticks = ticks / tot; > ns = ns/tot; > > - printf(" [%i] %s enq+deq %"PRIu64" cycles, %"PRIu64" ns\n", > - thr, str, cycles, ns); > + printf(" [%i] %s enq+deq %"PRIu64" ticks, %"PRIu64" ns\n", > + thr, str, ticks, ns); > > return 0; > } > @@ -421,7 +421,7 @@ static int test_schedule_many(const char *str, int thr, > odp_queue_t queue; > uint64_t t1 = 0; > uint64_t t2 = 0; > - uint64_t cycles, ns; > + uint64_t ticks, ns; > uint32_t i; > uint32_t tot = 0; > > @@ -464,17 +464,17 @@ static int test_schedule_many(const char *str, int thr, > odp_schedule_resume(); > > t2 = odp_time_tick(); > - cycles = odp_time_ticks_diff(t1, t2); > - ns = odp_time_tick_to_ns(cycles); > + ticks = odp_time_ticks_diff(t1, t2); > + ns = odp_time_tick_to_ns(ticks); > > odp_barrier_wait(barrier); > clear_sched_queues(); > > - cycles = cycles/tot; > + ticks = ticks / tot; > ns = ns/tot; > > - printf(" [%i] %s enq+deq %"PRIu64" cycles, %"PRIu64" ns\n", > - thr, str, cycles, ns); > + printf(" [%i] %s enq+deq %"PRIu64" ticks, %"PRIu64" ns\n", > + thr, str, ticks, ns); > > return 0; > } > @@ -498,7 +498,7 @@ static int test_schedule_multi(const char *str, int thr, > odp_queue_t queue; > uint64_t t1 = 0; > uint64_t t2 = 0; > - uint64_t cycles, ns; > + uint64_t ticks, ns; > int i, j; > int num; > uint32_t tot = 0; > @@ -585,22 +585,22 @@ static int test_schedule_multi(const char *str, int thr, > > > t2 = odp_time_tick(); > - cycles = odp_time_ticks_diff(t1, t2); > - ns = odp_time_tick_to_ns(cycles); > + ticks = odp_time_ticks_diff(t1, t2); > + ns = odp_time_tick_to_ns(ticks); > > odp_barrier_wait(barrier); > clear_sched_queues(); > > if (tot) { > - cycles = cycles/tot; > + ticks = ticks / tot; > ns = ns/tot; > } else { > - cycles = 0; > + ticks = 0; > ns = 0; > } > > - printf(" [%i] %s enq+deq %"PRIu64" cycles, %"PRIu64" ns\n", > - thr, str, cycles, ns); > + printf(" [%i] %s enq+deq %"PRIu64" ticks, %"PRIu64" ns\n", > + thr, str, ticks, ns); > > return 0; > } > @@ -714,13 +714,13 @@ static void *run_thread(void *arg) > } > > /** > - * @internal Test cycle counter accuracy > + * @internal Test time counter accuracy > */ > static void test_time(void) > { > struct timespec tp1, tp2; > uint64_t t1, t2; > - uint64_t ns1, ns2, cycles; > + uint64_t ns1, ns2, ticks; > double err; > > if (clock_gettime(CLOCK_MONOTONIC, &tp2)) { > @@ -757,13 +757,13 @@ static void test_time(void) > else > ns1 -= tp1.tv_nsec - tp2.tv_nsec; > > - cycles = odp_time_ticks_diff(t1, t2); > - ns2 = odp_time_tick_to_ns(cycles); > + ticks = odp_time_ticks_diff(t1, t2); > + ns2 = odp_time_tick_to_ns(ticks); > > err = ((double)(ns2) - (double)ns1) / (double)ns1; > > printf("clock_gettime %"PRIu64" ns\n", ns1); > - printf("odp_time_tick %"PRIu64" cycles\n", cycles); > + printf("odp_time_tick %"PRIu64" cycles\n", ticks); cycles -> ticks > printf("odp_time_tick_to_ns %"PRIu64" ns\n", ns2); > printf("odp get cycle error %f%%\n", err*100.0); cycle -> tick > > @@ -898,7 +898,7 @@ int main(int argc, char *argv[]) > printf("first CPU: %i\n", odp_cpumask_first(&cpumask)); > printf("cpu mask: %s\n", cpumaskstr); > > - /* Test cycle count accuracy */ > + /* Test time count accuracy */ > test_time(); > > shm = odp_shm_reserve("test_globals", > diff --git a/test/validation/scheduler/scheduler.c b/test/validation/scheduler/scheduler.c > index 5fb711f..bfe1f27 100644 > --- a/test/validation/scheduler/scheduler.c > +++ b/test/validation/scheduler/scheduler.c > @@ -212,10 +212,10 @@ static void *schedule_common_(void *arg) > CU_ASSERT(from != ODP_QUEUE_INVALID); > if (locked) { > int cnt; > - uint64_t cycles = 0; > + uint64_t ticks = 0; > /* Do some work here to keep the thread busy */ > for (cnt = 0; cnt < 1000; cnt++) > - cycles += odp_time_tick(); > + ticks += odp_time_tick(); > > odp_spinlock_unlock(&globals->atomic_lock); > } > diff --git a/test/validation/time/time.c b/test/validation/time/time.c > index a6169aa..89aef00 100644 > --- a/test/validation/time/time.c > +++ b/test/validation/time/time.c > @@ -11,48 +11,48 @@ > #define TOLERANCE 1 > #define BUSY_LOOP_CNT 100 > > -/* check that a cycles difference gives a reasonable result */ > -static void time_test_odp_cycles_diff(void) > +/* check that a counts difference gives a reasonable result */ > +static void time_test_odp_counts_diff(void) counts -> ticks Should be consistent, I assume this is just a leftover from the previous version. > { > /* volatile to stop optimization of busy loop */ > volatile int count = 0; > - uint64_t diff, cycles1, cycles2; > + uint64_t diff, t1, t2; > > - cycles1 = odp_time_tick(); > + t1 = odp_time_tick(); > > while (count < BUSY_LOOP_CNT) { > count++; > }; > > - cycles2 = odp_time_tick(); > - CU_ASSERT(cycles2 > cycles1); > + t2 = odp_time_tick(); > + CU_ASSERT(t2 > t1); > > - diff = odp_time_ticks_diff(cycles1, cycles2); > + diff = odp_time_ticks_diff(t1, t2); > CU_ASSERT(diff > 0); > } > > -/* check that a negative cycles difference gives a reasonable result */ > -static void time_test_odp_cycles_negative_diff(void) > +/* check that a negative counts difference gives a reasonable result */ > +static void time_test_odp_counts_negative_diff(void) counts -> ticks > { > - uint64_t diff, cycles1, cycles2; > + uint64_t diff, t1, t2; > > - cycles1 = 10; > - cycles2 = 5; > - diff = odp_time_ticks_diff(cycles1, cycles2); > + t1 = 10; > + t2 = 5; > + diff = odp_time_ticks_diff(t1, t2); > CU_ASSERT(diff > 0); > } > > /* check that related conversions come back to the same value */ > static void time_test_odp_time_conversion(void) > { > - uint64_t ns1, ns2, cycles; > + uint64_t ns1, ns2, tick; > uint64_t upper_limit, lower_limit; > > ns1 = 100; > - cycles = odp_time_ns_to_tick(ns1); > - CU_ASSERT(cycles > 0); > + tick = odp_time_ns_to_tick(ns1); > + CU_ASSERT(tick > 0); > > - ns2 = odp_time_tick_to_ns(cycles); > + ns2 = odp_time_tick_to_ns(tick); > > /* need to check within arithmetic tolerance that the same > * value in ns is returned after conversions */ > @@ -62,8 +62,8 @@ static void time_test_odp_time_conversion(void) > } > > CU_TestInfo time_suite_time[] = { > - {"cycles diff", time_test_odp_cycles_diff}, > - {"negative diff", time_test_odp_cycles_negative_diff}, > + {"counts diff", time_test_odp_counts_diff}, > + {"negative diff", time_test_odp_counts_negative_diff}, > {"conversion", time_test_odp_time_conversion}, > CU_TEST_INFO_NULL > }; > -- > 1.9.1 >
On 19.08.15 12:49, Stuart Haslam wrote: > On Sat, Aug 08, 2015 at 01:28:08AM +0300, Ivan Khoronzhuk wrote: >> The word "cycle" is left from old API time names. The "cycle" is >> ambiguous word, especially when it can be used for other purposes. >> So better to use "tick" word or just "t" symbol. >> >> Signed-off-by: Ivan Khoronzhuk <ivan.khoronzhuk@linaro.org> >> --- >> example/ipsec/odp_ipsec.c | 14 +++--- >> example/timer/odp_timer_test.c | 22 +++++----- >> test/performance/odp_pktio_perf.c | 32 +++++++------- >> test/performance/odp_scheduling.c | 80 +++++++++++++++++------------------ >> test/validation/scheduler/scheduler.c | 4 +- >> test/validation/time/time.c | 38 ++++++++--------- >> 6 files changed, 95 insertions(+), 95 deletions(-) >> >> diff --git a/example/ipsec/odp_ipsec.c b/example/ipsec/odp_ipsec.c >> index 3d34210..019a0b6 100644 >> --- a/example/ipsec/odp_ipsec.c >> +++ b/example/ipsec/odp_ipsec.c >> @@ -265,11 +265,11 @@ odp_queue_t polled_odp_queue_create(const char *name, >> static >> odp_event_t polled_odp_schedule(odp_queue_t *from, uint64_t wait) >> { >> - uint64_t start_cycle; >> - uint64_t cycle; >> + uint64_t start_tick; >> + uint64_t tick; >> uint64_t diff; >> >> - start_cycle = 0; >> + start_tick = 0; >> >> while (1) { >> int idx; >> @@ -292,13 +292,13 @@ odp_event_t polled_odp_schedule(odp_queue_t *from, uint64_t wait) >> if (ODP_SCHED_NO_WAIT == wait) >> break; >> >> - if (0 == start_cycle) { >> - start_cycle = odp_time_tick(); >> + if (0 == start_tick) { >> + start_tick = odp_time_tick(); >> continue; >> } >> >> - cycle = odp_time_tick(); >> - diff = odp_time_ticks_diff(start_cycle, cycle); >> + tick = odp_time_tick(); >> + diff = odp_time_ticks_diff(start_tick, tick); >> >> if (wait < diff) >> break; >> diff --git a/example/timer/odp_timer_test.c b/example/timer/odp_timer_test.c >> index c6c809d..bbaaf7d 100644 >> --- a/example/timer/odp_timer_test.c >> +++ b/example/timer/odp_timer_test.c >> @@ -313,7 +313,7 @@ int main(int argc, char *argv[]) >> odph_linux_pthread_t thread_tbl[MAX_WORKERS]; >> int num_workers; >> odp_queue_t queue; >> - uint64_t cycles, ns; >> + uint64_t ticks, ns; >> odp_queue_param_t param; >> odp_pool_param_t params; >> odp_timer_pool_param_t tparams; >> @@ -438,21 +438,21 @@ int main(int argc, char *argv[]) >> } >> >> printf("CPU freq %"PRIu64" Hz\n", odp_sys_cpu_hz()); >> - printf("Cycles vs nanoseconds:\n"); >> + printf("Ticks vs nanoseconds:\n"); >> ns = 0; >> - cycles = odp_time_ns_to_tick(ns); >> + ticks = odp_time_ns_to_tick(ns); >> >> - printf(" %12"PRIu64" ns -> %12"PRIu64" cycles\n", ns, cycles); >> - printf(" %12"PRIu64" cycles -> %12"PRIu64" ns\n", cycles, >> - odp_time_tick_to_ns(cycles)); >> + printf(" %12"PRIu64" ns -> %12"PRIu64" ticks\n", ns, ticks); > > This was already present, but checkpatch complains about; > > CHECK: Concatenated strings should use spaces between elements > Ok. I'll correct it. >> + printf(" %12"PRIu64" ticks -> %12"PRIu64" ns\n", ticks, > > nit: this puts the alignment out, need another space after ticks. > Ok. I'll add 1 space after ticks. >> + odp_time_tick_to_ns(ticks)); >> >> for (ns = 1; ns <= 100*ODP_TIME_SEC; ns *= 10) { >> - cycles = odp_time_ns_to_tick(ns); >> + ticks = odp_time_ns_to_tick(ns); >> >> - printf(" %12"PRIu64" ns -> %12"PRIu64" cycles\n", ns, >> - cycles); >> - printf(" %12"PRIu64" cycles -> %12"PRIu64" ns\n", cycles, >> - odp_time_tick_to_ns(cycles)); >> + printf(" %12"PRIu64" ns -> %12"PRIu64" ticks\n", ns, >> + ticks); >> + printf(" %12"PRIu64" ticks -> %12"PRIu64" ns\n", ticks, > > And here. Ok. >> + odp_time_tick_to_ns(ticks)); >> } >> >> printf("\n"); >> diff --git a/test/performance/odp_pktio_perf.c b/test/performance/odp_pktio_perf.c >> index b3f8d2b..a80d19a 100644 >> --- a/test/performance/odp_pktio_perf.c >> +++ b/test/performance/odp_pktio_perf.c >> @@ -106,7 +106,7 @@ struct tx_stats_s { >> uint64_t tx_cnt; /* Packets transmitted */ >> uint64_t alloc_failures;/* Packet allocation failures */ >> uint64_t enq_failures; /* Enqueue failures */ >> - uint64_t idle_cycles; /* Idle cycle count in TX loop */ >> + uint64_t idle_ticks; /* Idle ticks count in TX loop */ >> }; >> >> typedef union tx_stats_u { >> @@ -302,8 +302,8 @@ static void *run_thread_tx(void *arg) >> int thr_id; >> odp_queue_t outq; >> pkt_tx_stats_t *stats; >> - uint64_t next_tx_cycles, end_cycles, cur_cycles; >> - uint64_t burst_gap_cycles; >> + uint64_t next_tx_tick, end_tick, cur_tick; >> + uint64_t burst_gap; >> uint32_t batch_len; >> int unsent_pkts = 0; >> odp_event_t tx_event[BATCH_LEN_MAX]; >> @@ -325,33 +325,33 @@ 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_tick( >> + burst_gap = odp_time_ns_to_tick( >> ODP_TIME_SEC / (targs->pps / targs->batch_len)); >> >> odp_barrier_wait(&globals->tx_barrier); >> >> - cur_cycles = odp_time_tick(); >> - next_tx_cycles = cur_cycles; >> - end_cycles = cur_cycles + >> + cur_tick = odp_time_tick(); >> + next_tx_tick = cur_tick; >> + end_tick = cur_tick + >> odp_time_ns_to_tick(targs->duration * ODP_TIME_SEC); >> >> - while (cur_cycles < end_cycles) { >> + while (cur_tick < end_tick) { >> unsigned alloc_cnt = 0, tx_cnt; >> >> - if (cur_cycles < next_tx_cycles) { >> - cur_cycles = odp_time_tick(); >> + if (cur_tick < next_tx_tick) { >> + cur_tick = odp_time_tick(); >> if (idle_start == 0) >> - idle_start = cur_cycles; >> + idle_start = cur_tick; >> continue; >> } >> >> if (idle_start) { >> - stats->s.idle_cycles += odp_time_ticks_diff( >> - idle_start, cur_cycles); >> + stats->s.idle_ticks += odp_time_ticks_diff(idle_start, >> + cur_tick); >> idle_start = 0; >> } >> >> - next_tx_cycles += burst_gap_cycles; >> + next_tx_tick += burst_gap; >> >> alloc_cnt = alloc_packets(tx_event, batch_len - unsent_pkts); >> if (alloc_cnt != batch_len) >> @@ -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_tick(); >> + cur_tick = odp_time_tick(); >> } >> >> 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_tick_to_ns(stats->s.idle_cycles) / 1000 / 1000); >> + odp_time_tick_to_ns(stats->s.idle_ticks) / 1000 / 1000); >> >> return NULL; >> } >> diff --git a/test/performance/odp_scheduling.c b/test/performance/odp_scheduling.c >> index e34cea9..8c8a283 100644 >> --- a/test/performance/odp_scheduling.c >> +++ b/test/performance/odp_scheduling.c >> @@ -183,7 +183,7 @@ static int test_alloc_single(int thr, odp_pool_t pool) >> { >> int i; >> odp_buffer_t temp_buf; >> - uint64_t t1, t2, cycles, ns; >> + uint64_t t1, t2, ticks, ns; >> >> t1 = odp_time_tick(); >> >> @@ -199,11 +199,11 @@ static int test_alloc_single(int thr, odp_pool_t pool) >> } >> >> t2 = odp_time_tick(); >> - cycles = odp_time_ticks_diff(t1, t2); >> - ns = odp_time_tick_to_ns(cycles); >> + ticks = odp_time_ticks_diff(t1, t2); >> + ns = odp_time_tick_to_ns(ticks); >> >> - printf(" [%i] alloc_sng alloc+free %"PRIu64" cycles, %"PRIu64" ns\n", >> - thr, cycles/ALLOC_ROUNDS, ns/ALLOC_ROUNDS); >> + printf(" [%i] alloc_sng alloc+free %"PRIu64" ticks, %"PRIu64" ns\n", >> + thr, ticks / ALLOC_ROUNDS, ns / ALLOC_ROUNDS); >> >> return 0; >> } >> @@ -220,7 +220,7 @@ static int test_alloc_multi(int thr, odp_pool_t pool) >> { >> int i, j; >> odp_buffer_t temp_buf[MAX_ALLOCS]; >> - uint64_t t1, t2, cycles, ns; >> + uint64_t t1, t2, ticks, ns; >> >> t1 = odp_time_tick(); >> >> @@ -239,11 +239,11 @@ static int test_alloc_multi(int thr, odp_pool_t pool) >> } >> >> t2 = odp_time_tick(); >> - cycles = odp_time_ticks_diff(t1, t2); >> - ns = odp_time_tick_to_ns(cycles); >> + ticks = odp_time_ticks_diff(t1, t2); >> + ns = odp_time_tick_to_ns(ticks); >> >> - printf(" [%i] alloc_multi alloc+free %"PRIu64" cycles, %"PRIu64" ns\n", >> - thr, cycles/(ALLOC_ROUNDS*MAX_ALLOCS), >> + printf(" [%i] alloc_multi alloc+free %"PRIu64" ticks, %"PRIu64" ns\n", >> + thr, ticks / (ALLOC_ROUNDS * MAX_ALLOCS), >> ns/(ALLOC_ROUNDS*MAX_ALLOCS)); >> >> return 0; >> @@ -265,7 +265,7 @@ static int test_poll_queue(int thr, odp_pool_t msg_pool) >> odp_buffer_t buf; >> test_message_t *t_msg; >> odp_queue_t queue; >> - uint64_t t1, t2, cycles, ns; >> + uint64_t t1, t2, ticks, ns; >> int i; >> >> /* Alloc test message */ >> @@ -311,11 +311,11 @@ static int test_poll_queue(int thr, odp_pool_t msg_pool) >> } >> >> t2 = odp_time_tick(); >> - cycles = odp_time_ticks_diff(t1, t2); >> - ns = odp_time_tick_to_ns(cycles); >> + ticks = odp_time_ticks_diff(t1, t2); >> + ns = odp_time_tick_to_ns(ticks); >> >> - printf(" [%i] poll_queue enq+deq %"PRIu64" cycles, %"PRIu64" ns\n", >> - thr, cycles/QUEUE_ROUNDS, ns/QUEUE_ROUNDS); >> + printf(" [%i] poll_queue enq+deq %"PRIu64" ticks, %"PRIu64" ns\n", >> + thr, ticks / QUEUE_ROUNDS, ns / QUEUE_ROUNDS); >> >> odp_buffer_free(buf); >> return 0; >> @@ -341,7 +341,7 @@ static int test_schedule_single(const char *str, int thr, >> { >> odp_event_t ev; >> odp_queue_t queue; >> - uint64_t t1, t2, cycles, ns; >> + uint64_t t1, t2, ticks, ns; >> uint32_t i; >> uint32_t tot = 0; >> >> @@ -383,17 +383,17 @@ static int test_schedule_single(const char *str, int thr, >> odp_schedule_resume(); >> >> t2 = odp_time_tick(); >> - cycles = odp_time_ticks_diff(t1, t2); >> - ns = odp_time_tick_to_ns(cycles); >> + ticks = odp_time_ticks_diff(t1, t2); >> + ns = odp_time_tick_to_ns(ticks); >> >> odp_barrier_wait(barrier); >> clear_sched_queues(); >> >> - cycles = cycles/tot; >> + ticks = ticks / tot; >> ns = ns/tot; >> >> - printf(" [%i] %s enq+deq %"PRIu64" cycles, %"PRIu64" ns\n", >> - thr, str, cycles, ns); >> + printf(" [%i] %s enq+deq %"PRIu64" ticks, %"PRIu64" ns\n", >> + thr, str, ticks, ns); >> >> return 0; >> } >> @@ -421,7 +421,7 @@ static int test_schedule_many(const char *str, int thr, >> odp_queue_t queue; >> uint64_t t1 = 0; >> uint64_t t2 = 0; >> - uint64_t cycles, ns; >> + uint64_t ticks, ns; >> uint32_t i; >> uint32_t tot = 0; >> >> @@ -464,17 +464,17 @@ static int test_schedule_many(const char *str, int thr, >> odp_schedule_resume(); >> >> t2 = odp_time_tick(); >> - cycles = odp_time_ticks_diff(t1, t2); >> - ns = odp_time_tick_to_ns(cycles); >> + ticks = odp_time_ticks_diff(t1, t2); >> + ns = odp_time_tick_to_ns(ticks); >> >> odp_barrier_wait(barrier); >> clear_sched_queues(); >> >> - cycles = cycles/tot; >> + ticks = ticks / tot; >> ns = ns/tot; >> >> - printf(" [%i] %s enq+deq %"PRIu64" cycles, %"PRIu64" ns\n", >> - thr, str, cycles, ns); >> + printf(" [%i] %s enq+deq %"PRIu64" ticks, %"PRIu64" ns\n", >> + thr, str, ticks, ns); >> >> return 0; >> } >> @@ -498,7 +498,7 @@ static int test_schedule_multi(const char *str, int thr, >> odp_queue_t queue; >> uint64_t t1 = 0; >> uint64_t t2 = 0; >> - uint64_t cycles, ns; >> + uint64_t ticks, ns; >> int i, j; >> int num; >> uint32_t tot = 0; >> @@ -585,22 +585,22 @@ static int test_schedule_multi(const char *str, int thr, >> >> >> t2 = odp_time_tick(); >> - cycles = odp_time_ticks_diff(t1, t2); >> - ns = odp_time_tick_to_ns(cycles); >> + ticks = odp_time_ticks_diff(t1, t2); >> + ns = odp_time_tick_to_ns(ticks); >> >> odp_barrier_wait(barrier); >> clear_sched_queues(); >> >> if (tot) { >> - cycles = cycles/tot; >> + ticks = ticks / tot; >> ns = ns/tot; >> } else { >> - cycles = 0; >> + ticks = 0; >> ns = 0; >> } >> >> - printf(" [%i] %s enq+deq %"PRIu64" cycles, %"PRIu64" ns\n", >> - thr, str, cycles, ns); >> + printf(" [%i] %s enq+deq %"PRIu64" ticks, %"PRIu64" ns\n", >> + thr, str, ticks, ns); >> >> return 0; >> } >> @@ -714,13 +714,13 @@ static void *run_thread(void *arg) >> } >> >> /** >> - * @internal Test cycle counter accuracy >> + * @internal Test time counter accuracy >> */ >> static void test_time(void) >> { >> struct timespec tp1, tp2; >> uint64_t t1, t2; >> - uint64_t ns1, ns2, cycles; >> + uint64_t ns1, ns2, ticks; >> double err; >> >> if (clock_gettime(CLOCK_MONOTONIC, &tp2)) { >> @@ -757,13 +757,13 @@ static void test_time(void) >> else >> ns1 -= tp1.tv_nsec - tp2.tv_nsec; >> >> - cycles = odp_time_ticks_diff(t1, t2); >> - ns2 = odp_time_tick_to_ns(cycles); >> + ticks = odp_time_ticks_diff(t1, t2); >> + ns2 = odp_time_tick_to_ns(ticks); >> >> err = ((double)(ns2) - (double)ns1) / (double)ns1; >> >> printf("clock_gettime %"PRIu64" ns\n", ns1); >> - printf("odp_time_tick %"PRIu64" cycles\n", cycles); >> + printf("odp_time_tick %"PRIu64" cycles\n", ticks); > > cycles -> ticks > Ok. >> printf("odp_time_tick_to_ns %"PRIu64" ns\n", ns2); >> printf("odp get cycle error %f%%\n", err*100.0); > > cycle -> tick Ok. > >> >> @@ -898,7 +898,7 @@ int main(int argc, char *argv[]) >> printf("first CPU: %i\n", odp_cpumask_first(&cpumask)); >> printf("cpu mask: %s\n", cpumaskstr); >> >> - /* Test cycle count accuracy */ >> + /* Test time count accuracy */ >> test_time(); >> >> shm = odp_shm_reserve("test_globals", >> diff --git a/test/validation/scheduler/scheduler.c b/test/validation/scheduler/scheduler.c >> index 5fb711f..bfe1f27 100644 >> --- a/test/validation/scheduler/scheduler.c >> +++ b/test/validation/scheduler/scheduler.c >> @@ -212,10 +212,10 @@ static void *schedule_common_(void *arg) >> CU_ASSERT(from != ODP_QUEUE_INVALID); >> if (locked) { >> int cnt; >> - uint64_t cycles = 0; >> + uint64_t ticks = 0; >> /* Do some work here to keep the thread busy */ >> for (cnt = 0; cnt < 1000; cnt++) >> - cycles += odp_time_tick(); >> + ticks += odp_time_tick(); >> >> odp_spinlock_unlock(&globals->atomic_lock); >> } >> diff --git a/test/validation/time/time.c b/test/validation/time/time.c >> index a6169aa..89aef00 100644 >> --- a/test/validation/time/time.c >> +++ b/test/validation/time/time.c >> @@ -11,48 +11,48 @@ >> #define TOLERANCE 1 >> #define BUSY_LOOP_CNT 100 >> >> -/* check that a cycles difference gives a reasonable result */ >> -static void time_test_odp_cycles_diff(void) >> +/* check that a counts difference gives a reasonable result */ >> +static void time_test_odp_counts_diff(void) > > counts -> ticks > > Should be consistent, I assume this is just a leftover from the previous > version. Yep. I'll correct. > >> { >> /* volatile to stop optimization of busy loop */ >> volatile int count = 0; >> - uint64_t diff, cycles1, cycles2; >> + uint64_t diff, t1, t2; >> >> - cycles1 = odp_time_tick(); >> + t1 = odp_time_tick(); >> >> while (count < BUSY_LOOP_CNT) { >> count++; >> }; >> >> - cycles2 = odp_time_tick(); >> - CU_ASSERT(cycles2 > cycles1); >> + t2 = odp_time_tick(); >> + CU_ASSERT(t2 > t1); >> >> - diff = odp_time_ticks_diff(cycles1, cycles2); >> + diff = odp_time_ticks_diff(t1, t2); >> CU_ASSERT(diff > 0); >> } >> >> -/* check that a negative cycles difference gives a reasonable result */ >> -static void time_test_odp_cycles_negative_diff(void) >> +/* check that a negative counts difference gives a reasonable result */ >> +static void time_test_odp_counts_negative_diff(void) > > counts -> ticks Ok. > >> { >> - uint64_t diff, cycles1, cycles2; >> + uint64_t diff, t1, t2; >> >> - cycles1 = 10; >> - cycles2 = 5; >> - diff = odp_time_ticks_diff(cycles1, cycles2); >> + t1 = 10; >> + t2 = 5; >> + diff = odp_time_ticks_diff(t1, t2); >> CU_ASSERT(diff > 0); >> } >> >> /* check that related conversions come back to the same value */ >> static void time_test_odp_time_conversion(void) >> { >> - uint64_t ns1, ns2, cycles; >> + uint64_t ns1, ns2, tick; >> uint64_t upper_limit, lower_limit; >> >> ns1 = 100; >> - cycles = odp_time_ns_to_tick(ns1); >> - CU_ASSERT(cycles > 0); >> + tick = odp_time_ns_to_tick(ns1); >> + CU_ASSERT(tick > 0); >> >> - ns2 = odp_time_tick_to_ns(cycles); >> + ns2 = odp_time_tick_to_ns(tick); >> >> /* need to check within arithmetic tolerance that the same >> * value in ns is returned after conversions */ >> @@ -62,8 +62,8 @@ static void time_test_odp_time_conversion(void) >> } >> >> CU_TestInfo time_suite_time[] = { >> - {"cycles diff", time_test_odp_cycles_diff}, >> - {"negative diff", time_test_odp_cycles_negative_diff}, >> + {"counts diff", time_test_odp_counts_diff}, >> + {"negative diff", time_test_odp_counts_negative_diff}, Ok. >> {"conversion", time_test_odp_time_conversion}, >> CU_TEST_INFO_NULL >> }; >> -- >> 1.9.1 >> > Thanks!
diff --git a/example/ipsec/odp_ipsec.c b/example/ipsec/odp_ipsec.c index 3d34210..019a0b6 100644 --- a/example/ipsec/odp_ipsec.c +++ b/example/ipsec/odp_ipsec.c @@ -265,11 +265,11 @@ odp_queue_t polled_odp_queue_create(const char *name, static odp_event_t polled_odp_schedule(odp_queue_t *from, uint64_t wait) { - uint64_t start_cycle; - uint64_t cycle; + uint64_t start_tick; + uint64_t tick; uint64_t diff; - start_cycle = 0; + start_tick = 0; while (1) { int idx; @@ -292,13 +292,13 @@ odp_event_t polled_odp_schedule(odp_queue_t *from, uint64_t wait) if (ODP_SCHED_NO_WAIT == wait) break; - if (0 == start_cycle) { - start_cycle = odp_time_tick(); + if (0 == start_tick) { + start_tick = odp_time_tick(); continue; } - cycle = odp_time_tick(); - diff = odp_time_ticks_diff(start_cycle, cycle); + tick = odp_time_tick(); + diff = odp_time_ticks_diff(start_tick, tick); if (wait < diff) break; diff --git a/example/timer/odp_timer_test.c b/example/timer/odp_timer_test.c index c6c809d..bbaaf7d 100644 --- a/example/timer/odp_timer_test.c +++ b/example/timer/odp_timer_test.c @@ -313,7 +313,7 @@ int main(int argc, char *argv[]) odph_linux_pthread_t thread_tbl[MAX_WORKERS]; int num_workers; odp_queue_t queue; - uint64_t cycles, ns; + uint64_t ticks, ns; odp_queue_param_t param; odp_pool_param_t params; odp_timer_pool_param_t tparams; @@ -438,21 +438,21 @@ int main(int argc, char *argv[]) } printf("CPU freq %"PRIu64" Hz\n", odp_sys_cpu_hz()); - printf("Cycles vs nanoseconds:\n"); + printf("Ticks vs nanoseconds:\n"); ns = 0; - cycles = odp_time_ns_to_tick(ns); + ticks = odp_time_ns_to_tick(ns); - printf(" %12"PRIu64" ns -> %12"PRIu64" cycles\n", ns, cycles); - printf(" %12"PRIu64" cycles -> %12"PRIu64" ns\n", cycles, - odp_time_tick_to_ns(cycles)); + printf(" %12"PRIu64" ns -> %12"PRIu64" ticks\n", ns, ticks); + printf(" %12"PRIu64" ticks -> %12"PRIu64" ns\n", ticks, + odp_time_tick_to_ns(ticks)); for (ns = 1; ns <= 100*ODP_TIME_SEC; ns *= 10) { - cycles = odp_time_ns_to_tick(ns); + ticks = odp_time_ns_to_tick(ns); - printf(" %12"PRIu64" ns -> %12"PRIu64" cycles\n", ns, - cycles); - printf(" %12"PRIu64" cycles -> %12"PRIu64" ns\n", cycles, - odp_time_tick_to_ns(cycles)); + printf(" %12"PRIu64" ns -> %12"PRIu64" ticks\n", ns, + ticks); + printf(" %12"PRIu64" ticks -> %12"PRIu64" ns\n", ticks, + odp_time_tick_to_ns(ticks)); } printf("\n"); diff --git a/test/performance/odp_pktio_perf.c b/test/performance/odp_pktio_perf.c index b3f8d2b..a80d19a 100644 --- a/test/performance/odp_pktio_perf.c +++ b/test/performance/odp_pktio_perf.c @@ -106,7 +106,7 @@ struct tx_stats_s { uint64_t tx_cnt; /* Packets transmitted */ uint64_t alloc_failures;/* Packet allocation failures */ uint64_t enq_failures; /* Enqueue failures */ - uint64_t idle_cycles; /* Idle cycle count in TX loop */ + uint64_t idle_ticks; /* Idle ticks count in TX loop */ }; typedef union tx_stats_u { @@ -302,8 +302,8 @@ static void *run_thread_tx(void *arg) int thr_id; odp_queue_t outq; pkt_tx_stats_t *stats; - uint64_t next_tx_cycles, end_cycles, cur_cycles; - uint64_t burst_gap_cycles; + uint64_t next_tx_tick, end_tick, cur_tick; + uint64_t burst_gap; uint32_t batch_len; int unsent_pkts = 0; odp_event_t tx_event[BATCH_LEN_MAX]; @@ -325,33 +325,33 @@ 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_tick( + burst_gap = odp_time_ns_to_tick( ODP_TIME_SEC / (targs->pps / targs->batch_len)); odp_barrier_wait(&globals->tx_barrier); - cur_cycles = odp_time_tick(); - next_tx_cycles = cur_cycles; - end_cycles = cur_cycles + + cur_tick = odp_time_tick(); + next_tx_tick = cur_tick; + end_tick = cur_tick + odp_time_ns_to_tick(targs->duration * ODP_TIME_SEC); - while (cur_cycles < end_cycles) { + while (cur_tick < end_tick) { unsigned alloc_cnt = 0, tx_cnt; - if (cur_cycles < next_tx_cycles) { - cur_cycles = odp_time_tick(); + if (cur_tick < next_tx_tick) { + cur_tick = odp_time_tick(); if (idle_start == 0) - idle_start = cur_cycles; + idle_start = cur_tick; continue; } if (idle_start) { - stats->s.idle_cycles += odp_time_ticks_diff( - idle_start, cur_cycles); + stats->s.idle_ticks += odp_time_ticks_diff(idle_start, + cur_tick); idle_start = 0; } - next_tx_cycles += burst_gap_cycles; + next_tx_tick += burst_gap; alloc_cnt = alloc_packets(tx_event, batch_len - unsent_pkts); if (alloc_cnt != batch_len) @@ -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_tick(); + cur_tick = odp_time_tick(); } 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_tick_to_ns(stats->s.idle_cycles) / 1000 / 1000); + odp_time_tick_to_ns(stats->s.idle_ticks) / 1000 / 1000); return NULL; } diff --git a/test/performance/odp_scheduling.c b/test/performance/odp_scheduling.c index e34cea9..8c8a283 100644 --- a/test/performance/odp_scheduling.c +++ b/test/performance/odp_scheduling.c @@ -183,7 +183,7 @@ static int test_alloc_single(int thr, odp_pool_t pool) { int i; odp_buffer_t temp_buf; - uint64_t t1, t2, cycles, ns; + uint64_t t1, t2, ticks, ns; t1 = odp_time_tick(); @@ -199,11 +199,11 @@ static int test_alloc_single(int thr, odp_pool_t pool) } t2 = odp_time_tick(); - cycles = odp_time_ticks_diff(t1, t2); - ns = odp_time_tick_to_ns(cycles); + ticks = odp_time_ticks_diff(t1, t2); + ns = odp_time_tick_to_ns(ticks); - printf(" [%i] alloc_sng alloc+free %"PRIu64" cycles, %"PRIu64" ns\n", - thr, cycles/ALLOC_ROUNDS, ns/ALLOC_ROUNDS); + printf(" [%i] alloc_sng alloc+free %"PRIu64" ticks, %"PRIu64" ns\n", + thr, ticks / ALLOC_ROUNDS, ns / ALLOC_ROUNDS); return 0; } @@ -220,7 +220,7 @@ static int test_alloc_multi(int thr, odp_pool_t pool) { int i, j; odp_buffer_t temp_buf[MAX_ALLOCS]; - uint64_t t1, t2, cycles, ns; + uint64_t t1, t2, ticks, ns; t1 = odp_time_tick(); @@ -239,11 +239,11 @@ static int test_alloc_multi(int thr, odp_pool_t pool) } t2 = odp_time_tick(); - cycles = odp_time_ticks_diff(t1, t2); - ns = odp_time_tick_to_ns(cycles); + ticks = odp_time_ticks_diff(t1, t2); + ns = odp_time_tick_to_ns(ticks); - printf(" [%i] alloc_multi alloc+free %"PRIu64" cycles, %"PRIu64" ns\n", - thr, cycles/(ALLOC_ROUNDS*MAX_ALLOCS), + printf(" [%i] alloc_multi alloc+free %"PRIu64" ticks, %"PRIu64" ns\n", + thr, ticks / (ALLOC_ROUNDS * MAX_ALLOCS), ns/(ALLOC_ROUNDS*MAX_ALLOCS)); return 0; @@ -265,7 +265,7 @@ static int test_poll_queue(int thr, odp_pool_t msg_pool) odp_buffer_t buf; test_message_t *t_msg; odp_queue_t queue; - uint64_t t1, t2, cycles, ns; + uint64_t t1, t2, ticks, ns; int i; /* Alloc test message */ @@ -311,11 +311,11 @@ static int test_poll_queue(int thr, odp_pool_t msg_pool) } t2 = odp_time_tick(); - cycles = odp_time_ticks_diff(t1, t2); - ns = odp_time_tick_to_ns(cycles); + ticks = odp_time_ticks_diff(t1, t2); + ns = odp_time_tick_to_ns(ticks); - printf(" [%i] poll_queue enq+deq %"PRIu64" cycles, %"PRIu64" ns\n", - thr, cycles/QUEUE_ROUNDS, ns/QUEUE_ROUNDS); + printf(" [%i] poll_queue enq+deq %"PRIu64" ticks, %"PRIu64" ns\n", + thr, ticks / QUEUE_ROUNDS, ns / QUEUE_ROUNDS); odp_buffer_free(buf); return 0; @@ -341,7 +341,7 @@ static int test_schedule_single(const char *str, int thr, { odp_event_t ev; odp_queue_t queue; - uint64_t t1, t2, cycles, ns; + uint64_t t1, t2, ticks, ns; uint32_t i; uint32_t tot = 0; @@ -383,17 +383,17 @@ static int test_schedule_single(const char *str, int thr, odp_schedule_resume(); t2 = odp_time_tick(); - cycles = odp_time_ticks_diff(t1, t2); - ns = odp_time_tick_to_ns(cycles); + ticks = odp_time_ticks_diff(t1, t2); + ns = odp_time_tick_to_ns(ticks); odp_barrier_wait(barrier); clear_sched_queues(); - cycles = cycles/tot; + ticks = ticks / tot; ns = ns/tot; - printf(" [%i] %s enq+deq %"PRIu64" cycles, %"PRIu64" ns\n", - thr, str, cycles, ns); + printf(" [%i] %s enq+deq %"PRIu64" ticks, %"PRIu64" ns\n", + thr, str, ticks, ns); return 0; } @@ -421,7 +421,7 @@ static int test_schedule_many(const char *str, int thr, odp_queue_t queue; uint64_t t1 = 0; uint64_t t2 = 0; - uint64_t cycles, ns; + uint64_t ticks, ns; uint32_t i; uint32_t tot = 0; @@ -464,17 +464,17 @@ static int test_schedule_many(const char *str, int thr, odp_schedule_resume(); t2 = odp_time_tick(); - cycles = odp_time_ticks_diff(t1, t2); - ns = odp_time_tick_to_ns(cycles); + ticks = odp_time_ticks_diff(t1, t2); + ns = odp_time_tick_to_ns(ticks); odp_barrier_wait(barrier); clear_sched_queues(); - cycles = cycles/tot; + ticks = ticks / tot; ns = ns/tot; - printf(" [%i] %s enq+deq %"PRIu64" cycles, %"PRIu64" ns\n", - thr, str, cycles, ns); + printf(" [%i] %s enq+deq %"PRIu64" ticks, %"PRIu64" ns\n", + thr, str, ticks, ns); return 0; } @@ -498,7 +498,7 @@ static int test_schedule_multi(const char *str, int thr, odp_queue_t queue; uint64_t t1 = 0; uint64_t t2 = 0; - uint64_t cycles, ns; + uint64_t ticks, ns; int i, j; int num; uint32_t tot = 0; @@ -585,22 +585,22 @@ static int test_schedule_multi(const char *str, int thr, t2 = odp_time_tick(); - cycles = odp_time_ticks_diff(t1, t2); - ns = odp_time_tick_to_ns(cycles); + ticks = odp_time_ticks_diff(t1, t2); + ns = odp_time_tick_to_ns(ticks); odp_barrier_wait(barrier); clear_sched_queues(); if (tot) { - cycles = cycles/tot; + ticks = ticks / tot; ns = ns/tot; } else { - cycles = 0; + ticks = 0; ns = 0; } - printf(" [%i] %s enq+deq %"PRIu64" cycles, %"PRIu64" ns\n", - thr, str, cycles, ns); + printf(" [%i] %s enq+deq %"PRIu64" ticks, %"PRIu64" ns\n", + thr, str, ticks, ns); return 0; } @@ -714,13 +714,13 @@ static void *run_thread(void *arg) } /** - * @internal Test cycle counter accuracy + * @internal Test time counter accuracy */ static void test_time(void) { struct timespec tp1, tp2; uint64_t t1, t2; - uint64_t ns1, ns2, cycles; + uint64_t ns1, ns2, ticks; double err; if (clock_gettime(CLOCK_MONOTONIC, &tp2)) { @@ -757,13 +757,13 @@ static void test_time(void) else ns1 -= tp1.tv_nsec - tp2.tv_nsec; - cycles = odp_time_ticks_diff(t1, t2); - ns2 = odp_time_tick_to_ns(cycles); + ticks = odp_time_ticks_diff(t1, t2); + ns2 = odp_time_tick_to_ns(ticks); err = ((double)(ns2) - (double)ns1) / (double)ns1; printf("clock_gettime %"PRIu64" ns\n", ns1); - printf("odp_time_tick %"PRIu64" cycles\n", cycles); + printf("odp_time_tick %"PRIu64" cycles\n", ticks); printf("odp_time_tick_to_ns %"PRIu64" ns\n", ns2); printf("odp get cycle error %f%%\n", err*100.0); @@ -898,7 +898,7 @@ int main(int argc, char *argv[]) printf("first CPU: %i\n", odp_cpumask_first(&cpumask)); printf("cpu mask: %s\n", cpumaskstr); - /* Test cycle count accuracy */ + /* Test time count accuracy */ test_time(); shm = odp_shm_reserve("test_globals", diff --git a/test/validation/scheduler/scheduler.c b/test/validation/scheduler/scheduler.c index 5fb711f..bfe1f27 100644 --- a/test/validation/scheduler/scheduler.c +++ b/test/validation/scheduler/scheduler.c @@ -212,10 +212,10 @@ static void *schedule_common_(void *arg) CU_ASSERT(from != ODP_QUEUE_INVALID); if (locked) { int cnt; - uint64_t cycles = 0; + uint64_t ticks = 0; /* Do some work here to keep the thread busy */ for (cnt = 0; cnt < 1000; cnt++) - cycles += odp_time_tick(); + ticks += odp_time_tick(); odp_spinlock_unlock(&globals->atomic_lock); } diff --git a/test/validation/time/time.c b/test/validation/time/time.c index a6169aa..89aef00 100644 --- a/test/validation/time/time.c +++ b/test/validation/time/time.c @@ -11,48 +11,48 @@ #define TOLERANCE 1 #define BUSY_LOOP_CNT 100 -/* check that a cycles difference gives a reasonable result */ -static void time_test_odp_cycles_diff(void) +/* check that a counts difference gives a reasonable result */ +static void time_test_odp_counts_diff(void) { /* volatile to stop optimization of busy loop */ volatile int count = 0; - uint64_t diff, cycles1, cycles2; + uint64_t diff, t1, t2; - cycles1 = odp_time_tick(); + t1 = odp_time_tick(); while (count < BUSY_LOOP_CNT) { count++; }; - cycles2 = odp_time_tick(); - CU_ASSERT(cycles2 > cycles1); + t2 = odp_time_tick(); + CU_ASSERT(t2 > t1); - diff = odp_time_ticks_diff(cycles1, cycles2); + diff = odp_time_ticks_diff(t1, t2); CU_ASSERT(diff > 0); } -/* check that a negative cycles difference gives a reasonable result */ -static void time_test_odp_cycles_negative_diff(void) +/* check that a negative counts difference gives a reasonable result */ +static void time_test_odp_counts_negative_diff(void) { - uint64_t diff, cycles1, cycles2; + uint64_t diff, t1, t2; - cycles1 = 10; - cycles2 = 5; - diff = odp_time_ticks_diff(cycles1, cycles2); + t1 = 10; + t2 = 5; + diff = odp_time_ticks_diff(t1, t2); CU_ASSERT(diff > 0); } /* check that related conversions come back to the same value */ static void time_test_odp_time_conversion(void) { - uint64_t ns1, ns2, cycles; + uint64_t ns1, ns2, tick; uint64_t upper_limit, lower_limit; ns1 = 100; - cycles = odp_time_ns_to_tick(ns1); - CU_ASSERT(cycles > 0); + tick = odp_time_ns_to_tick(ns1); + CU_ASSERT(tick > 0); - ns2 = odp_time_tick_to_ns(cycles); + ns2 = odp_time_tick_to_ns(tick); /* need to check within arithmetic tolerance that the same * value in ns is returned after conversions */ @@ -62,8 +62,8 @@ static void time_test_odp_time_conversion(void) } CU_TestInfo time_suite_time[] = { - {"cycles diff", time_test_odp_cycles_diff}, - {"negative diff", time_test_odp_cycles_negative_diff}, + {"counts diff", time_test_odp_counts_diff}, + {"negative diff", time_test_odp_counts_negative_diff}, {"conversion", time_test_odp_time_conversion}, CU_TEST_INFO_NULL };
The word "cycle" is left from old API time names. The "cycle" is ambiguous word, especially when it can be used for other purposes. So better to use "tick" word or just "t" symbol. Signed-off-by: Ivan Khoronzhuk <ivan.khoronzhuk@linaro.org> --- example/ipsec/odp_ipsec.c | 14 +++--- example/timer/odp_timer_test.c | 22 +++++----- test/performance/odp_pktio_perf.c | 32 +++++++------- test/performance/odp_scheduling.c | 80 +++++++++++++++++------------------ test/validation/scheduler/scheduler.c | 4 +- test/validation/time/time.c | 38 ++++++++--------- 6 files changed, 95 insertions(+), 95 deletions(-)