diff mbox

[odp-lng,v3,2/3] test/example: avoid "cycle" word usage

Message ID 1441228253-21225-3-git-send-email-ivan.khoronzhuk@linaro.org
State New
Headers show

Commit Message

Ivan Khoronzhuk Sept. 2, 2015, 9:10 p.m. UTC
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" or "time" word or just "t" symbol.

Signed-off-by: Ivan Khoronzhuk <ivan.khoronzhuk@linaro.org>
---
 example/generator/odp_generator.c     | 12 ++---
 example/timer/odp_timer_test.c        | 24 +++++-----
 test/performance/odp_pktio_perf.c     | 39 +++++++++--------
 test/performance/odp_scheduling.c     | 82 +++++++++++++++++------------------
 test/validation/scheduler/scheduler.c |  5 +--
 test/validation/time/time.c           | 42 +++++++++---------
 test/validation/time/time.h           |  6 +--
 7 files changed, 105 insertions(+), 105 deletions(-)
diff mbox

Patch

diff --git a/example/generator/odp_generator.c b/example/generator/odp_generator.c
index f7aed76..46ddf11 100644
--- a/example/generator/odp_generator.c
+++ b/example/generator/odp_generator.c
@@ -585,7 +585,7 @@  static void *gen_recv_thread(void *arg)
  */
 static void print_global_stats(int num_workers)
 {
-	uint64_t start, now, diff;
+	odp_time_t start, now, diff;
 	uint64_t pkts, pkts_prev = 0, pps, maximum_pps = 0;
 	int verbose_interval = 20;
 	odp_thrmask_t thrd_mask;
@@ -593,7 +593,7 @@  static void print_global_stats(int num_workers)
 	while (odp_thrmask_worker(&thrd_mask) < num_workers)
 		continue;
 
-	start = odp_time_cycles();
+	start = odp_time();
 
 	while (odp_thrmask_worker(&thrd_mask) == num_workers) {
 		if (args->appl.number != -1 &&
@@ -602,14 +602,14 @@  static void print_global_stats(int num_workers)
 			break;
 		}
 
-		now = odp_time_cycles();
-		diff = odp_time_diff_cycles(start, now);
-		if (odp_time_cycles_to_ns(diff) <
+		now = odp_time();
+		diff = odp_time_diff(start, now);
+		if (odp_time_to_ns(diff) <
 		    verbose_interval * ODP_TIME_SEC) {
 			continue;
 		}
 
-		start = odp_time_cycles();
+		start = odp_time();
 
 		if (args->appl.mode == APPL_MODE_RCV) {
 			pkts = odp_atomic_load_u64(&counters.udp);
diff --git a/example/timer/odp_timer_test.c b/example/timer/odp_timer_test.c
index 23c5a9a..58c215e 100644
--- a/example/timer/odp_timer_test.c
+++ b/example/timer/odp_timer_test.c
@@ -323,7 +323,7 @@  int main(int argc, char *argv[])
 	uint64_t ns;
 	int num_workers;
 	odp_queue_t queue;
-	odp_time_t cycles;
+	odp_time_t ticks;
 	odp_queue_param_t param;
 	odp_pool_param_t params;
 	odp_timer_pool_param_t tparams;
@@ -448,22 +448,22 @@  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_from_ns(ns);
+	ticks = odp_time_from_ns(ns);
 
-	printf("  %12" PRIu64 " ns      ->  %12" PRIu64 " cycles\n", ns,
-	       odp_time_to_u64(cycles));
-	printf("  %12" PRIu64 " cycles  ->  %12" PRIu64 " ns\n",
-	       odp_time_to_u64(cycles), odp_time_to_ns(cycles));
+	printf("  %12" PRIu64 " ns      ->  %12" PRIu64 " ticks\n", ns,
+	       odp_time_to_u64(ticks));
+	printf("  %12" PRIu64 " ticks   ->  %12" PRIu64 " ns\n",
+	       odp_time_to_u64(ticks), odp_time_to_ns(ticks));
 
 	for (ns = 1; ns <= 100*ODP_TIME_SEC; ns *= 10) {
-		cycles = odp_time_from_ns(ns);
+		ticks = odp_time_from_ns(ns);
 
-		printf("  %12" PRIu64 " ns      ->  %12" PRIu64 " cycles\n", ns,
-		       odp_time_to_u64(cycles));
-		printf("  %12" PRIu64 " cycles  ->  %12" PRIu64 " ns\n",
-		       odp_time_to_u64(cycles), odp_time_to_ns(cycles));
+		printf("  %12" PRIu64 " ns      ->  %12" PRIu64 " ticks\n", ns,
+		       odp_time_to_u64(ticks));
+		printf("  %12" PRIu64 " ticks   ->  %12" PRIu64 " ns\n",
+		       odp_time_to_u64(ticks), odp_time_to_ns(ticks));
 	}
 
 	printf("\n");
diff --git a/test/performance/odp_pktio_perf.c b/test/performance/odp_pktio_perf.c
index b27efc8..3ecd042 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 */
-	odp_time_t idle_cycles;	/* Idle cycle count in TX loop */
+	odp_time_t idle_ticks;	/* Idle ticks count in TX loop */
 };
 
 typedef union tx_stats_u {
@@ -303,8 +303,8 @@  static void *run_thread_tx(void *arg)
 	int thr_id;
 	odp_queue_t outq;
 	pkt_tx_stats_t *stats;
-	odp_time_t start_cycles, cur_cycles, send_duration;
-	odp_time_t burst_start_cycles, burst_gap_cycles;
+	odp_time_t start_time, cur_time, send_duration;
+	odp_time_t burst_start_time, burst_gap;
 	uint32_t batch_len;
 	int unsent_pkts = 0;
 	odp_event_t  tx_event[BATCH_LEN_MAX];
@@ -326,36 +326,35 @@  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_from_ns(
+	burst_gap = odp_time_from_ns(
 				ODP_TIME_SEC / (targs->pps / targs->batch_len));
 	send_duration = odp_time_from_ns(targs->duration * ODP_TIME_SEC);
 
 	odp_barrier_wait(&globals->tx_barrier);
 
-	cur_cycles     = odp_time();
-	start_cycles   = cur_cycles;
-	burst_start_cycles = odp_time_diff(cur_cycles, burst_gap_cycles);
-	while (odp_time_diff(start_cycles, cur_cycles) < send_duration) {
+	cur_time     = odp_time();
+	start_time   = cur_time;
+	burst_start_time = odp_time_diff(cur_time, burst_gap);
+	while (odp_time_diff(start_time, cur_time) < send_duration) {
 		unsigned alloc_cnt = 0, tx_cnt;
 
-		if (odp_time_diff(burst_start_cycles, cur_cycles)
-							< burst_gap_cycles) {
-			cur_cycles = odp_time();
+		if (odp_time_diff(burst_start_time, cur_time) < burst_gap) {
+			cur_time = odp_time();
 			if (!odp_time_cmp(ODP_TIME_NULL, idle_start))
-				idle_start = cur_cycles;
+				idle_start = cur_time;
 			continue;
 		}
 
 		if (odp_time_cmp(ODP_TIME_NULL, idle_start)) {
-			odp_time_t diff = odp_time_diff(idle_start, cur_cycles);
+			odp_time_t diff = odp_time_diff(idle_start, cur_time);
 
-			stats->s.idle_cycles =
-				odp_time_sum(diff, stats->s.idle_cycles);
+			stats->s.idle_ticks =
+				odp_time_sum(diff, stats->s.idle_ticks);
 
 			idle_start = ODP_TIME_NULL;
 		}
 
-		burst_start_cycles += burst_gap_cycles;
+		burst_start_time += burst_gap;
 
 		alloc_cnt = alloc_packets(tx_event, batch_len - unsent_pkts);
 		if (alloc_cnt != batch_len)
@@ -366,14 +365,14 @@  static void *run_thread_tx(void *arg)
 		stats->s.enq_failures += unsent_pkts;
 		stats->s.tx_cnt += tx_cnt;
 
-		cur_cycles = odp_time();
+		cur_time = odp_time();
 	}
 
 	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_to_ns(stats->s.idle_cycles) / (uint64_t)ODP_TIME_MSEC);
+	       odp_time_to_ns(stats->s.idle_ticks) / (uint64_t)ODP_TIME_MSEC);
 
 	return NULL;
 }
@@ -591,11 +590,13 @@  static int setup_txrx_masks(odp_cpumask_t *thd_mask_tx,
  */
 static void busy_loop_ns(uint64_t wait_ns)
 {
+	odp_time_t diff;
 	odp_time_t start_time = odp_time();
 	odp_time_t wait = odp_time_from_ns(wait_ns);
 
-	while (odp_time_cmp(diff, wait) > 0)
+	do {
 		diff = odp_time_diff(start_time, odp_time());
+	} while (odp_time_cmp(diff, wait) > 0);
 }
 
 /*
diff --git a/test/performance/odp_scheduling.c b/test/performance/odp_scheduling.c
index 5859460..c100cb1 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;
-	odp_time_t t1, t2, cycles;
+	odp_time_t t1, t2, ticks;
 	uint64_t ns;
 
 	t1 = odp_time();
@@ -200,11 +200,11 @@  static int test_alloc_single(int thr, odp_pool_t pool)
 	}
 
 	t2     = odp_time();
-	cycles = odp_time_diff(t1, t2);
-	ns     = odp_time_to_ns(cycles);
+	ticks = odp_time_diff(t1, t2);
+	ns     = odp_time_to_ns(ticks);
 
-	printf("  [%i] alloc_sng alloc+free   %"PRIu64" cycles, %"PRIu64" ns\n",
-	       thr, odp_time_to_u64(cycles) / ALLOC_ROUNDS, ns / ALLOC_ROUNDS);
+	printf("  [%i] alloc_sng alloc+free   %" PRIu64 " ticks, %" PRIu64 " ns\n",
+	       thr, odp_time_to_u64(ticks) / ALLOC_ROUNDS, ns / ALLOC_ROUNDS);
 
 	return 0;
 }
@@ -221,7 +221,7 @@  static int test_alloc_multi(int thr, odp_pool_t pool)
 {
 	int i, j;
 	odp_buffer_t temp_buf[MAX_ALLOCS];
-	odp_time_t t1, t2, cycles;
+	odp_time_t t1, t2, ticks;
 	uint64_t ns;
 
 	t1 = odp_time();
@@ -241,11 +241,11 @@  static int test_alloc_multi(int thr, odp_pool_t pool)
 	}
 
 	t2     = odp_time();
-	cycles = odp_time_diff(t1, t2);
-	ns     = odp_time_to_ns(cycles);
+	ticks = odp_time_diff(t1, t2);
+	ns     = odp_time_to_ns(ticks);
 
-	printf("  [%i] alloc_multi alloc+free %"PRIu64" cycles, %"PRIu64" ns\n",
-	       thr, odp_time_to_u64(cycles) / (ALLOC_ROUNDS * MAX_ALLOCS),
+	printf("  [%i] alloc_multi alloc+free %" PRIu64 " ticks, %" PRIu64 " ns\n",
+	       thr, odp_time_to_u64(ticks) / (ALLOC_ROUNDS * MAX_ALLOCS),
 	       ns/(ALLOC_ROUNDS*MAX_ALLOCS));
 
 	return 0;
@@ -267,7 +267,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;
-	odp_time_t t1, t2, cycles;
+	odp_time_t t1, t2, ticks;
 	uint64_t ns;
 	int i;
 
@@ -314,11 +314,11 @@  static int test_poll_queue(int thr, odp_pool_t msg_pool)
 	}
 
 	t2     = odp_time();
-	cycles = odp_time_diff(t1, t2);
-	ns     = odp_time_to_ns(cycles);
+	ticks = odp_time_diff(t1, t2);
+	ns     = odp_time_to_ns(ticks);
 
-	printf("  [%i] poll_queue enq+deq     %"PRIu64" cycles, %"PRIu64" ns\n",
-	       thr, odp_time_to_u64(cycles) / QUEUE_ROUNDS, ns / QUEUE_ROUNDS);
+	printf("  [%i] poll_queue enq+deq     %" PRIu64 " ticks, %" PRIu64 " ns\n",
+	       thr, odp_time_to_u64(ticks) / QUEUE_ROUNDS, ns / QUEUE_ROUNDS);
 
 	odp_buffer_free(buf);
 	return 0;
@@ -344,7 +344,7 @@  static int test_schedule_single(const char *str, int thr,
 {
 	odp_event_t ev;
 	odp_queue_t queue;
-	odp_time_t t1, t2, cycles;
+	odp_time_t t1, t2, ticks;
 	uint64_t ns;
 	uint32_t i;
 	uint32_t tot;
@@ -387,14 +387,14 @@  static int test_schedule_single(const char *str, int thr,
 	odp_schedule_resume();
 
 	t2     = odp_time();
-	cycles = odp_time_diff(t1, t2);
-	ns     = odp_time_to_ns(cycles);
+	ticks = odp_time_diff(t1, t2);
+	ns     = odp_time_to_ns(ticks);
 
 	odp_barrier_wait(barrier);
 	clear_sched_queues();
 
-	printf("  [%i] %s enq+deq %"PRIu64" cycles, %"PRIu64" ns\n",
-	       thr, str, odp_time_to_u64(cycles) / tot, ns / tot);
+	printf("  [%i] %s enq+deq %" PRIu64 " ticks, %" PRIu64 " ns\n",
+	       thr, str, odp_time_to_u64(ticks) / tot, ns / tot);
 
 	return 0;
 }
@@ -420,7 +420,7 @@  static int test_schedule_many(const char *str, int thr,
 {
 	odp_event_t ev;
 	odp_queue_t queue;
-	odp_time_t t1, t2, cycles;
+	odp_time_t t1, t2, ticks;
 	uint64_t ns;
 	uint32_t i;
 	uint32_t tot;
@@ -464,14 +464,14 @@  static int test_schedule_many(const char *str, int thr,
 	odp_schedule_resume();
 
 	t2     = odp_time();
-	cycles = odp_time_diff(t1, t2);
-	ns     = odp_time_to_ns(cycles);
+	ticks = odp_time_diff(t1, t2);
+	ns     = odp_time_to_ns(ticks);
 
 	odp_barrier_wait(barrier);
 	clear_sched_queues();
 
-	printf("  [%i] %s enq+deq %"PRIu64" cycles, %"PRIu64" ns\n",
-	       thr, str, odp_time_to_u64(cycles) / tot, ns / tot);
+	printf("  [%i] %s enq+deq %" PRIu64 " ticks, %" PRIu64 " ns\n",
+	       thr, str, odp_time_to_u64(ticks) / tot, ns / tot);
 
 	return 0;
 }
@@ -493,8 +493,8 @@  static int test_schedule_multi(const char *str, int thr,
 {
 	odp_event_t ev[MULTI_BUFS_MAX];
 	odp_queue_t queue;
-	odp_time_t t1, t2, cycles;
-	uint64_t ns, cycles_pr;
+	odp_time_t t1, t2, ticks;
+	uint64_t ns, ticks_pr;
 	int i, j;
 	int num;
 	uint32_t tot = 0;
@@ -581,22 +581,22 @@  static int test_schedule_multi(const char *str, int thr,
 
 
 	t2     = odp_time();
-	cycles = odp_time_diff(t1, t2);
-	ns     = odp_time_to_ns(cycles);
+	ticks = odp_time_diff(t1, t2);
+	ns     = odp_time_to_ns(ticks);
 
 	odp_barrier_wait(barrier);
 	clear_sched_queues();
 
 	if (tot) {
-		cycles_pr = odp_time_to_u64(cycles) / tot;
+		ticks_pr = odp_time_to_u64(ticks) / tot;
 		ns     = ns/tot;
 	} else {
-		cycles_pr = 0;
+		ticks_pr = 0;
 		ns     = 0;
 	}
 
-	printf("  [%i] %s enq+deq %"PRIu64" cycles, %"PRIu64" ns\n",
-	       thr, str, cycles_pr, ns);
+	printf("  [%i] %s enq+deq %" PRIu64 " ticks, %" PRIu64 " ns\n",
+	       thr, str, ticks_pr, ns);
 
 	return 0;
 }
@@ -710,12 +710,12 @@  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;
-	odp_time_t t1, t2, cycles;
+	odp_time_t t1, t2, ticks;
 	uint64_t ns1, ns2;
 	double err;
 
@@ -753,16 +753,16 @@  static void test_time(void)
 	else
 		ns1 -= tp1.tv_nsec - tp2.tv_nsec;
 
-	cycles = odp_time_diff(t1, t2);
-	ns2    = odp_time_to_ns(cycles);
+	ticks  = odp_time_diff(t1, t2);
+	ns2    = odp_time_to_ns(ticks);
 
 	err = ((double)(ns2) - (double)ns1) / (double)ns1;
 
 	printf("clock_gettime         %"PRIu64" ns\n",    ns1);
-	printf("odp_time              %" PRIu64 " cycles\n",
-	       odp_time_to_u64(cycles));
+	printf("odp_time              %" PRIu64 " ticks\n",
+	       odp_time_to_u64(ticks));
 	printf("odp_time_to_ns        %" PRIu64 " ns\n",    ns2);
-	printf("odp get cycle error   %f%%\n", err*100.0);
+	printf("odp get tick error   %f%%\n", err * 100.0);
 
 	printf("\n");
 }
@@ -895,7 +895,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 f94f0d0..12dff64 100644
--- a/test/validation/scheduler/scheduler.c
+++ b/test/validation/scheduler/scheduler.c
@@ -212,11 +212,10 @@  static void *schedule_common_(void *arg)
 			CU_ASSERT(from != ODP_QUEUE_INVALID);
 			if (locked) {
 				int cnt;
-				odp_time_t cycles = ODP_TIME_NULL;
+				odp_time_t ticks = ODP_TIME_NULL;
 				/* Do some work here to keep the thread busy */
 				for (cnt = 0; cnt < 1000; cnt++)
-					cycles = odp_time_sum(cycles,
-							      odp_time());
+					ticks = odp_time_sum(ticks, odp_time());
 
 				odp_spinlock_unlock(&globals->atomic_lock);
 			}
diff --git a/test/validation/time/time.c b/test/validation/time/time.c
index f8dba8e..4cca319 100644
--- a/test/validation/time/time.c
+++ b/test/validation/time/time.c
@@ -11,49 +11,49 @@ 
 #define TOLERANCE 1
 #define BUSY_LOOP_CNT 100
 
-/* check that a cycles difference gives a reasonable result */
-void time_test_odp_cycles_diff(void)
+/* check that a time difference gives a reasonable result */
+void time_test_odp_diff(void)
 {
 	/* volatile to stop optimization of busy loop */
 	volatile int count = 0;
-	odp_time_t diff, cycles1, cycles2;
+	odp_time_t diff, t1, t2;
 
-	cycles1 = odp_time();
+	t1 = odp_time();
 
 	while (count < BUSY_LOOP_CNT) {
 		count++;
 	};
 
-	cycles2 = odp_time();
-	CU_ASSERT((odp_time_cmp(cycles1, cycles2) > 0);
+	t2 = odp_time();
+	CU_ASSERT(odp_time_cmp(t1, t2) > 0);
 
-	diff = odp_time_diff(cycles1, cycles2);
+	diff = odp_time_diff(t1, t2);
 	CU_ASSERT(odp_time_cmp(ODP_TIME_NULL, diff) > 0);
 }
 
-/* check that a negative cycles difference gives a reasonable result */
-void time_test_odp_cycles_negative_diff(void)
+/* check that a negative time difference gives a reasonable result */
+void time_test_odp_negative_diff(void)
 {
-	odp_time_t diff, cycles1, cycles2;
+	odp_time_t diff, t1, t2;
 
-	cycles1 = 10;
-	cycles2 = 5;
-	diff = odp_time_diff(cycles1, cycles2);
+	t1 = 10;
+	t2 = 5;
+	diff = odp_time_diff(t1, t2);
 	CU_ASSERT(odp_time_cmp(ODP_TIME_NULL, diff) > 0);
 }
 
 /* check that related conversions come back to the same value */
-void time_test_odp_time_conversion(void)
+void time_test_odp_conversion(void)
 {
 	uint64_t ns1, ns2;
-	odp_time_t cycles;
+	odp_time_t time;
 	uint64_t upper_limit, lower_limit;
 
 	ns1 = 100;
-	cycles = odp_time_from_ns(ns1);
-	CU_ASSERT(odp_time_cmp(ODP_TIME_NULL, cycles) > 0);
+	time = odp_time_from_ns(ns1);
+	CU_ASSERT(odp_time_cmp(ODP_TIME_NULL, time) > 0);
 
-	ns2 = odp_time_to_ns(cycles);
+	ns2 = odp_time_to_ns(time);
 
 	/* need to check within arithmetic tolerance that the same
 	 * value in ns is returned after conversions */
@@ -63,9 +63,9 @@  void time_test_odp_time_conversion(void)
 }
 
 CU_TestInfo time_suite_time[] = {
-	_CU_TEST_INFO(time_test_odp_cycles_diff),
-	_CU_TEST_INFO(time_test_odp_cycles_negative_diff),
-	_CU_TEST_INFO(time_test_odp_time_conversion),
+	_CU_TEST_INFO(time_test_odp_diff),
+	_CU_TEST_INFO(time_test_odp_negative_diff),
+	_CU_TEST_INFO(time_test_odp_conversion),
 	 CU_TEST_INFO_NULL
 };
 
diff --git a/test/validation/time/time.h b/test/validation/time/time.h
index 1f69826..19a35df 100644
--- a/test/validation/time/time.h
+++ b/test/validation/time/time.h
@@ -10,9 +10,9 @@ 
 #include <CUnit/Basic.h>
 
 /* test functions: */
-void time_test_odp_cycles_diff(void);
-void time_test_odp_cycles_negative_diff(void);
-void time_test_odp_time_conversion(void);
+void time_test_odp_diff(void);
+void time_test_odp_conversion(void);
+void time_test_odp_negative_diff(void);
 
 /* test arrays: */
 extern CU_TestInfo time_suite_time[];