aboutsummaryrefslogtreecommitdiff
path: root/test/performance
diff options
context:
space:
mode:
Diffstat (limited to 'test/performance')
-rw-r--r--test/performance/odp_l2fwd.c8
-rw-r--r--test/performance/odp_pktio_perf.c32
-rw-r--r--test/performance/odp_scheduling.c37
3 files changed, 22 insertions, 55 deletions
diff --git a/test/performance/odp_l2fwd.c b/test/performance/odp_l2fwd.c
index 481fb01d2..a85b8309b 100644
--- a/test/performance/odp_l2fwd.c
+++ b/test/performance/odp_l2fwd.c
@@ -208,8 +208,8 @@ static void *pktio_queue_thread(void *arg)
stats->s.packets += pkts;
}
- /* Make sure that the last stats write is visible to readers */
- odp_sync_stores();
+ /* Make sure that latest stat writes are visible to other threads */
+ odp_mb_full();
return NULL;
}
@@ -326,8 +326,8 @@ static void *pktio_direct_recv_thread(void *arg)
stats->s.packets += pkts;
}
- /* Make sure that the last stats write is visible to readers */
- odp_sync_stores();
+ /* Make sure that latest stat writes are visible to other threads */
+ odp_mb_full();
return NULL;
}
diff --git a/test/performance/odp_pktio_perf.c b/test/performance/odp_pktio_perf.c
index 82dcf19c1..4cc1affc3 100644
--- a/test/performance/odp_pktio_perf.c
+++ b/test/performance/odp_pktio_perf.c
@@ -305,8 +305,8 @@ static void *run_thread_tx(void *arg)
int thr_id;
odp_queue_t outq;
pkt_tx_stats_t *stats;
- odp_time_t start_time, cur_time, send_duration;
- odp_time_t burst_start_time, burst_gap;
+ odp_time_t cur_time, send_time_end, send_duration;
+ odp_time_t burst_gap_end, burst_gap;
uint32_t batch_len;
int unsent_pkts = 0;
odp_event_t tx_event[BATCH_LEN_MAX];
@@ -336,19 +336,19 @@ static void *run_thread_tx(void *arg)
odp_barrier_wait(&globals->tx_barrier);
cur_time = odp_time_local();
- start_time = cur_time;
- burst_start_time = odp_time_diff(cur_time, burst_gap);
- while (odp_time_diff(cur_time, start_time) < send_duration) {
+ send_time_end = odp_time_sum(cur_time, send_duration);
+ burst_gap_end = cur_time;
+ while (odp_time_cmp(send_time_end, cur_time) > 0) {
unsigned alloc_cnt = 0, tx_cnt;
- if (odp_time_diff(cur_time, burst_start_time) < burst_gap) {
+ if (odp_time_cmp(burst_gap_end, cur_time) > 0) {
cur_time = odp_time_local();
if (!odp_time_cmp(idle_start, ODP_TIME_NULL))
idle_start = cur_time;
continue;
}
- if (odp_time_cmp(idle_start, ODP_TIME_NULL)) {
+ if (odp_time_cmp(idle_start, ODP_TIME_NULL) > 0) {
odp_time_t diff = odp_time_diff(cur_time, idle_start);
stats->s.idle_ticks =
@@ -357,7 +357,7 @@ static void *run_thread_tx(void *arg)
idle_start = ODP_TIME_NULL;
}
- burst_start_time += burst_gap;
+ burst_gap_end = odp_time_sum(burst_gap_end, burst_gap);
alloc_cnt = alloc_packets(tx_event, batch_len - unsent_pkts);
if (alloc_cnt != batch_len)
@@ -591,20 +591,6 @@ static int setup_txrx_masks(odp_cpumask_t *thd_mask_tx,
}
/*
- * Busy loop for specified length of time.
- */
-static void busy_loop_ns(uint64_t wait_ns)
-{
- odp_time_t diff;
- odp_time_t start_time = odp_time_local();
- odp_time_t wait = odp_time_local_from_ns(wait_ns);
-
- do {
- diff = odp_time_diff(odp_time_local(), start_time);
- } while (odp_time_cmp(wait, diff) > 0);
-}
-
-/*
* Run a single instance of the throughput test. When attempting to determine
* the maximum packet rate this will be invoked multiple times with the only
* difference between runs being the target PPS rate.
@@ -647,7 +633,7 @@ static int run_test_single(odp_cpumask_t *thd_mask_tx,
num_tx_workers);
/* delay to allow transmitted packets to reach the receivers */
- busy_loop_ns(SHUTDOWN_DELAY_NS);
+ odp_time_wait_ns(SHUTDOWN_DELAY_NS);
/* indicate to the receivers to exit */
odp_atomic_store_u32(&shutdown, 1);
diff --git a/test/performance/odp_scheduling.c b/test/performance/odp_scheduling.c
index 971d19b05..fc6ccdc2a 100644
--- a/test/performance/odp_scheduling.c
+++ b/test/performance/odp_scheduling.c
@@ -702,7 +702,7 @@ static void *run_thread(void *arg)
*/
static void test_cpu_freq(void)
{
- struct timespec tp1, tp2;
+ odp_time_t cur_time, test_time, start_time, end_time;
uint64_t c1, c2, cycles;
uint64_t nsec;
double diff_max_hz, max_cycles;
@@ -710,40 +710,21 @@ static void test_cpu_freq(void)
printf("\nCPU cycle count frequency test (runs about %i sec)\n",
TEST_SEC);
- if (clock_gettime(CLOCK_MONOTONIC, &tp2)) {
- LOG_ERR("clock_gettime failed.\n");
- return;
- }
-
- /* Wait until clock moves to the next second. It enables easy comparison
- * during the measurement. */
- do {
- if (clock_gettime(CLOCK_MONOTONIC, &tp1)) {
- LOG_ERR("clock_gettime failed.\n");
- return;
- }
-
- } while (tp1.tv_sec == tp2.tv_sec);
+ test_time = odp_time_local_from_ns(TEST_SEC * ODP_TIME_SEC_IN_NS);
+ start_time = odp_time_local();
+ end_time = odp_time_sum(start_time, test_time);
/* Start the measurement */
c1 = odp_cpu_cycles();
do {
- if (clock_gettime(CLOCK_MONOTONIC, &tp2)) {
- LOG_ERR("clock_gettime failed.\n");
- return;
- }
-
- } while ((tp2.tv_sec - tp1.tv_sec) < TEST_SEC);
+ cur_time = odp_time_local();
+ } while (odp_time_cmp(end_time, cur_time) > 0);
c2 = odp_cpu_cycles();
- nsec = (tp2.tv_sec - tp1.tv_sec) * 1000000000;
-
- if (tp2.tv_nsec > tp1.tv_nsec)
- nsec += tp2.tv_nsec - tp1.tv_nsec;
- else
- nsec -= tp1.tv_nsec - tp2.tv_nsec;
+ test_time = odp_time_diff(cur_time, start_time);
+ nsec = odp_time_to_ns(test_time);
cycles = odp_cpu_cycles_diff(c2, c1);
max_cycles = (nsec * odp_sys_cpu_hz()) / 1000000000.0;
@@ -751,7 +732,7 @@ static void test_cpu_freq(void)
/* Compare measured CPU cycles to maximum theoretical CPU cycle count */
diff_max_hz = ((double)(cycles) - max_cycles) / max_cycles;
- printf("clock_gettime %" PRIu64 " ns\n", nsec);
+ printf("odp_time %" PRIu64 " ns\n", nsec);
printf("odp_cpu_cycles %" PRIu64 " CPU cycles\n", cycles);
printf("odp_sys_cpu_hz %" PRIu64 " hz\n", odp_sys_cpu_hz());
printf("Diff from max CPU freq %f%%\n", diff_max_hz * 100.0);