diff options
author | Jere Leppänen <jere.leppanen@nokia.com> | 2021-08-13 13:17:51 +0300 |
---|---|---|
committer | Petri Savolainen <petri.savolainen@nokia.com> | 2021-09-30 11:10:11 +0300 |
commit | 4afbff3323cf1d2f88e51eb6133cbc9c335bc0d7 (patch) | |
tree | 0911a73efd0a5812329181a8160e2d8e457e7b54 /test/performance | |
parent | 654273013d21c3d4fb9ba7070f2195833aa23e94 (diff) |
use odph_thread_create() instead of odph_odpthreads_create()
Use the newer odph_thread_create() and odph_thread_join() functions in
examples and tests instead of the deprecated odph_odpthreads_create()
and odph_odpthreads_join().
Signed-off-by: Jere Leppänen <jere.leppanen@nokia.com>
Reviewed-by: Matias Elo <matias.elo@nokia.com>
Diffstat (limited to 'test/performance')
-rw-r--r-- | test/performance/odp_bench_packet.c | 29 | ||||
-rw-r--r-- | test/performance/odp_cpu_bench.c | 36 | ||||
-rw-r--r-- | test/performance/odp_crypto.c | 28 | ||||
-rw-r--r-- | test/performance/odp_ipsec.c | 28 | ||||
-rw-r--r-- | test/performance/odp_pktio_ordered.c | 33 | ||||
-rw-r--r-- | test/performance/odp_pktio_perf.c | 50 | ||||
-rw-r--r-- | test/performance/odp_pool_perf.c | 27 | ||||
-rw-r--r-- | test/performance/odp_queue_perf.c | 27 | ||||
-rw-r--r-- | test/performance/odp_sched_latency.c | 26 | ||||
-rw-r--r-- | test/performance/odp_sched_pktio.c | 51 |
10 files changed, 187 insertions, 148 deletions
diff --git a/test/performance/odp_bench_packet.c b/test/performance/odp_bench_packet.c index e80e823f6..0354ef9b8 100644 --- a/test/performance/odp_bench_packet.c +++ b/test/performance/odp_bench_packet.c @@ -1739,7 +1739,9 @@ bench_info_t test_suite[] = { int main(int argc, char *argv[]) { odph_helper_options_t helper_options; - odph_odpthread_t worker_thread; + odph_thread_t worker_thread; + odph_thread_common_param_t thr_common; + odph_thread_param_t thr_param; int cpu; odp_shm_t shm; odp_cpumask_t cpumask; @@ -1864,7 +1866,7 @@ int main(int argc, char *argv[]) odp_pool_print(gbl_args->pool); - memset(&worker_thread, 0, sizeof(odph_odpthread_t)); + memset(&worker_thread, 0, sizeof(odph_thread_t)); signal(SIGINT, sig_handler); @@ -1872,20 +1874,23 @@ int main(int argc, char *argv[]) cpu = odp_cpumask_first(&cpumask); odp_cpumask_t thd_mask; - odph_odpthread_params_t thr_params; - - memset(&thr_params, 0, sizeof(thr_params)); - thr_params.start = run_benchmarks; - thr_params.arg = gbl_args; - thr_params.thr_type = ODP_THREAD_WORKER; - thr_params.instance = instance; odp_cpumask_zero(&thd_mask); odp_cpumask_set(&thd_mask, cpu); - odph_odpthreads_create(&worker_thread, &thd_mask, - &thr_params); - odph_odpthreads_join(&worker_thread); + odph_thread_common_param_init(&thr_common); + thr_common.instance = instance; + thr_common.cpumask = &thd_mask; + thr_common.share_param = 1; + + odph_thread_param_init(&thr_param); + thr_param.start = run_benchmarks; + thr_param.arg = gbl_args; + thr_param.thr_type = ODP_THREAD_WORKER; + + odph_thread_create(&worker_thread, &thr_common, &thr_param, 1); + + odph_thread_join(&worker_thread, 1); ret = gbl_args->bench_failed; diff --git a/test/performance/odp_cpu_bench.c b/test/performance/odp_cpu_bench.c index a4999ae27..e0ac82846 100644 --- a/test/performance/odp_cpu_bench.c +++ b/test/performance/odp_cpu_bench.c @@ -521,7 +521,9 @@ int main(int argc, char *argv[]) { stats_t *stats[MAX_WORKERS]; odph_helper_options_t helper_options; - odph_odpthread_t thread_tbl[MAX_WORKERS]; + odph_thread_t thread_tbl[MAX_WORKERS]; + odph_thread_common_param_t thr_common; + odph_thread_param_t thr_param[MAX_WORKERS]; odp_cpumask_t cpumask; odp_pool_capability_t pool_capa; odp_pool_t pool; @@ -540,7 +542,6 @@ int main(int argc, char *argv[]) uint32_t init_val; unsigned int num_workers; unsigned int i, j; - int cpu; int ret = 0; /* Let helper collect its own arguments (e.g. --odph_proc) */ @@ -743,7 +744,6 @@ int main(int argc, char *argv[]) } } - memset(thread_tbl, 0, sizeof(thread_tbl)); odp_barrier_init(&gbl_args->init_barrier, num_workers + 1); odp_barrier_init(&gbl_args->term_barrier, num_workers + 1); @@ -762,34 +762,28 @@ int main(int argc, char *argv[]) } /* Create worker threads */ - cpu = odp_cpumask_first(&cpumask); - for (i = 0; i < num_workers; i++) { - odp_cpumask_t thd_mask; - odph_odpthread_params_t thr_params; + odph_thread_common_param_init(&thr_common); + thr_common.instance = instance; + thr_common.cpumask = &cpumask; + for (i = 0; i < num_workers; i++) { gbl_args->thread[i].idx = i; - - memset(&thr_params, 0, sizeof(thr_params)); - thr_params.start = run_thread; - thr_params.arg = &gbl_args->thread[i]; - thr_params.thr_type = ODP_THREAD_WORKER; - thr_params.instance = instance; - stats[i] = &gbl_args->thread[i].stats; - odp_cpumask_zero(&thd_mask); - odp_cpumask_set(&thd_mask, cpu); - odph_odpthreads_create(&thread_tbl[i], &thd_mask, - &thr_params); - cpu = odp_cpumask_next(&cpumask, cpu); + odph_thread_param_init(&thr_param[i]); + thr_param[i].start = run_thread; + thr_param[i].arg = &gbl_args->thread[i]; + thr_param[i].thr_type = ODP_THREAD_WORKER; } + memset(thread_tbl, 0, sizeof(thread_tbl)); + odph_thread_create(thread_tbl, &thr_common, thr_param, num_workers); + ret = print_stats(num_workers, stats, gbl_args->appl.time, gbl_args->appl.accuracy); /* Master thread waits for other threads to exit */ - for (i = 0; i < num_workers; ++i) - odph_odpthreads_join(&thread_tbl[i]); + odph_thread_join(thread_tbl, num_workers); for (i = 0; i < num_groups; i++) { for (j = 0; j < QUEUES_PER_GROUP; j++) { diff --git a/test/performance/odp_crypto.c b/test/performance/odp_crypto.c index 36324622a..4f81dab17 100644 --- a/test/performance/odp_crypto.c +++ b/test/performance/odp_crypto.c @@ -1032,7 +1032,9 @@ int main(int argc, char *argv[]) char cpumaskstr[ODP_CPUMASK_STR_SIZE]; int num_workers = 1; odph_helper_options_t helper_options; - odph_odpthread_t thr[num_workers]; + odph_thread_t thread_tbl[num_workers]; + odph_thread_common_param_t thr_common; + odph_thread_param_t thr_param; odp_instance_t instance; odp_init_t init_param; odp_pool_capability_t pool_capa; @@ -1146,24 +1148,26 @@ int main(int argc, char *argv[]) printf("Run in sync mode\n"); } - memset(thr, 0, sizeof(thr)); - test_run_arg.crypto_args = cargs; test_run_arg.crypto_alg_config = cargs.alg_config; test_run_arg.crypto_capa = crypto_capa; if (cargs.alg_config) { - odph_odpthread_params_t thr_params; - - memset(&thr_params, 0, sizeof(thr_params)); - thr_params.start = run_thr_func; - thr_params.arg = &test_run_arg; - thr_params.thr_type = ODP_THREAD_WORKER; - thr_params.instance = instance; + odph_thread_common_param_init(&thr_common); + thr_common.instance = instance; + thr_common.cpumask = &cpumask; + thr_common.share_param = 1; if (cargs.schedule) { - odph_odpthreads_create(&thr[0], &cpumask, &thr_params); - odph_odpthreads_join(&thr[0]); + odph_thread_param_init(&thr_param); + thr_param.start = run_thr_func; + thr_param.arg = &test_run_arg; + thr_param.thr_type = ODP_THREAD_WORKER; + + memset(thread_tbl, 0, sizeof(thread_tbl)); + odph_thread_create(thread_tbl, &thr_common, &thr_param, num_workers); + + odph_thread_join(thread_tbl, num_workers); } else { run_measure_one_config(&test_run_arg); } diff --git a/test/performance/odp_ipsec.c b/test/performance/odp_ipsec.c index 40591092a..04788995e 100644 --- a/test/performance/odp_ipsec.c +++ b/test/performance/odp_ipsec.c @@ -1027,7 +1027,9 @@ int main(int argc, char *argv[]) char cpumaskstr[ODP_CPUMASK_STR_SIZE]; int num_workers = 1; odph_helper_options_t helper_options; - odph_odpthread_t thr[num_workers]; + odph_thread_t thread_tbl[num_workers]; + odph_thread_common_param_t thr_common; + odph_thread_param_t thr_param; odp_instance_t instance; odp_init_t init_param; odp_ipsec_capability_t ipsec_capa; @@ -1164,20 +1166,22 @@ int main(int argc, char *argv[]) printf("Run in sync mode\n"); } - memset(thr, 0, sizeof(thr)); - if (cargs.alg_config) { - odph_odpthread_params_t thr_param; - - memset(&thr_param, 0, sizeof(thr_param)); - thr_param.start = run_thr_func; - thr_param.arg = &thr_arg; - thr_param.thr_type = ODP_THREAD_WORKER; - thr_param.instance = instance; + odph_thread_common_param_init(&thr_common); + thr_common.instance = instance; + thr_common.cpumask = &cpumask; + thr_common.share_param = 1; if (cargs.schedule) { - odph_odpthreads_create(&thr[0], &cpumask, &thr_param); - odph_odpthreads_join(&thr[0]); + odph_thread_param_init(&thr_param); + thr_param.start = run_thr_func; + thr_param.arg = &thr_arg; + thr_param.thr_type = ODP_THREAD_WORKER; + + memset(thread_tbl, 0, sizeof(thread_tbl)); + odph_thread_create(thread_tbl, &thr_common, &thr_param, num_workers); + + odph_thread_join(thread_tbl, num_workers); } else { run_measure_one_config(&cargs, cargs.alg_config); } diff --git a/test/performance/odp_pktio_ordered.c b/test/performance/odp_pktio_ordered.c index d5ffcc8ab..e35386d52 100644 --- a/test/performance/odp_pktio_ordered.c +++ b/test/performance/odp_pktio_ordered.c @@ -1060,10 +1060,11 @@ int main(int argc, char *argv[]) odp_pool_capability_t pool_capa; odph_ethaddr_t new_addr; odph_helper_options_t helper_options; - odph_odpthread_t thread_tbl[MAX_WORKERS]; + odph_thread_t thread_tbl[MAX_WORKERS]; + odph_thread_common_param_t thr_common; + odph_thread_param_t thr_param[MAX_WORKERS]; stats_t *stats; char cpumaskstr[ODP_CPUMASK_STR_SIZE]; - int cpu; int i, j; int if_count; int ret; @@ -1281,26 +1282,21 @@ int main(int argc, char *argv[]) odp_barrier_init(&gbl_args->barrier, num_workers + 1); /* Create worker threads */ - cpu = odp_cpumask_first(&cpumask); - for (i = 0; i < num_workers; ++i) { - odp_cpumask_t thd_mask; - odph_odpthread_params_t thr_params; - - memset(&thr_params, 0, sizeof(thr_params)); - thr_params.start = run_worker; - thr_params.arg = &gbl_args->thread[i]; - thr_params.thr_type = ODP_THREAD_WORKER; - thr_params.instance = instance; + odph_thread_common_param_init(&thr_common); + thr_common.instance = instance; + thr_common.cpumask = &cpumask; + for (i = 0; i < num_workers; ++i) { gbl_args->thread[i].stats = &stats[i]; - odp_cpumask_zero(&thd_mask); - odp_cpumask_set(&thd_mask, cpu); - odph_odpthreads_create(&thread_tbl[i], &thd_mask, - &thr_params); - cpu = odp_cpumask_next(&cpumask, cpu); + odph_thread_param_init(&thr_param[i]); + thr_param[i].start = run_worker; + thr_param[i].arg = &gbl_args->thread[i]; + thr_param[i].thr_type = ODP_THREAD_WORKER; } + odph_thread_create(thread_tbl, &thr_common, thr_param, num_workers); + /* Start packet receive and transmit */ for (i = 0; i < if_count; ++i) { odp_pktio_t pktio; @@ -1324,8 +1320,7 @@ int main(int argc, char *argv[]) odp_atomic_store_u32(&gbl_args->exit_threads, 1); /* Master thread waits for other threads to exit */ - for (i = 0; i < num_workers; ++i) - odph_odpthreads_join(&thread_tbl[i]); + odph_thread_join(thread_tbl, num_workers); for (i = 0; i < if_count; i++) { odp_pktio_close(gbl_args->pktios[i].pktio); diff --git a/test/performance/odp_pktio_perf.c b/test/performance/odp_pktio_perf.c index 3d70d7d2b..593465f4f 100644 --- a/test/performance/odp_pktio_perf.c +++ b/test/performance/odp_pktio_perf.c @@ -603,45 +603,61 @@ static int run_test_single(odp_cpumask_t *thd_mask_tx, odp_cpumask_t *thd_mask_rx, test_status_t *status) { - odph_odpthread_t thd_tbl[MAX_WORKERS]; + odph_thread_t thread_tbl[MAX_WORKERS]; + odph_thread_common_param_t thr_common; + odph_thread_param_t thr_param; thread_args_t args_tx, args_rx; uint64_t expected_tx_cnt; int num_tx_workers, num_rx_workers; - odph_odpthread_params_t thr_params; - - memset(&thr_params, 0, sizeof(thr_params)); - thr_params.thr_type = ODP_THREAD_WORKER; - thr_params.instance = gbl_args->instance; odp_atomic_store_u32(&gbl_args->shutdown, 0); - memset(thd_tbl, 0, sizeof(thd_tbl)); + memset(thread_tbl, 0, sizeof(thread_tbl)); memset(gbl_args->rx_stats, 0, gbl_args->rx_stats_size); memset(gbl_args->tx_stats, 0, gbl_args->tx_stats_size); expected_tx_cnt = status->pps_curr * gbl_args->args.duration; /* start receiver threads first */ - thr_params.start = run_thread_rx; - thr_params.arg = &args_rx; + + num_rx_workers = odp_cpumask_count(thd_mask_rx); args_rx.batch_len = gbl_args->args.rx_batch_len; - odph_odpthreads_create(&thd_tbl[0], thd_mask_rx, &thr_params); + + odph_thread_common_param_init(&thr_common); + thr_common.instance = gbl_args->instance; + thr_common.cpumask = thd_mask_rx; + thr_common.share_param = 1; + + odph_thread_param_init(&thr_param); + thr_param.start = run_thread_rx; + thr_param.arg = &args_rx; + thr_param.thr_type = ODP_THREAD_WORKER; + + odph_thread_create(thread_tbl, &thr_common, &thr_param, num_rx_workers); odp_barrier_wait(&gbl_args->rx_barrier); - num_rx_workers = odp_cpumask_count(thd_mask_rx); /* then start transmitters */ - thr_params.start = run_thread_tx; - thr_params.arg = &args_tx; + num_tx_workers = odp_cpumask_count(thd_mask_tx); args_tx.pps = status->pps_curr / num_tx_workers; args_tx.duration = gbl_args->args.duration; args_tx.batch_len = gbl_args->args.tx_batch_len; - odph_odpthreads_create(&thd_tbl[num_rx_workers], thd_mask_tx, - &thr_params); + + odph_thread_common_param_init(&thr_common); + thr_common.instance = gbl_args->instance; + thr_common.cpumask = thd_mask_tx; + thr_common.share_param = 1; + + odph_thread_param_init(&thr_param); + thr_param.start = run_thread_tx; + thr_param.arg = &args_tx; + thr_param.thr_type = ODP_THREAD_WORKER; + + odph_thread_create(&thread_tbl[num_rx_workers], &thr_common, &thr_param, num_tx_workers); odp_barrier_wait(&gbl_args->tx_barrier); /* wait for transmitter threads to terminate */ - odph_odpthreads_join(&thd_tbl[num_rx_workers]); + odph_thread_join(&thread_tbl[num_rx_workers], num_tx_workers); /* delay to allow transmitted packets to reach the receivers */ odp_time_wait_ns(SHUTDOWN_DELAY_NS); @@ -650,7 +666,7 @@ static int run_test_single(odp_cpumask_t *thd_mask_tx, odp_atomic_store_u32(&gbl_args->shutdown, 1); /* wait for receivers */ - odph_odpthreads_join(&thd_tbl[0]); + odph_thread_join(thread_tbl, num_rx_workers); if (!status->warmup) return process_results(expected_tx_cnt, status); diff --git a/test/performance/odp_pool_perf.c b/test/performance/odp_pool_perf.c index ee97af519..957b1de00 100644 --- a/test/performance/odp_pool_perf.c +++ b/test/performance/odp_pool_perf.c @@ -43,7 +43,7 @@ typedef struct test_global_t { odp_barrier_t barrier; odp_pool_t pool; odp_cpumask_t cpumask; - odph_odpthread_t thread_tbl[ODP_THREAD_COUNT_MAX]; + odph_thread_t thread_tbl[ODP_THREAD_COUNT_MAX]; test_stat_t stat[ODP_THREAD_COUNT_MAX]; } test_global_t; @@ -445,23 +445,28 @@ static int test_packet_pool(void *arg) static int start_workers(test_global_t *global, odp_instance_t instance) { - odph_odpthread_params_t thr_params; + odph_thread_common_param_t thr_common; + odph_thread_param_t thr_param; test_options_t *test_options = &global->test_options; int num_cpu = test_options->num_cpu; int packet_pool = test_options->pool_type; - memset(&thr_params, 0, sizeof(thr_params)); - thr_params.thr_type = ODP_THREAD_WORKER; - thr_params.instance = instance; - thr_params.arg = global; + odph_thread_common_param_init(&thr_common); + thr_common.instance = instance; + thr_common.cpumask = &global->cpumask; + thr_common.share_param = 1; + + odph_thread_param_init(&thr_param); + thr_param.arg = global; + thr_param.thr_type = ODP_THREAD_WORKER; if (packet_pool) - thr_params.start = test_packet_pool; + thr_param.start = test_packet_pool; else - thr_params.start = test_buffer_pool; + thr_param.start = test_buffer_pool; - if (odph_odpthreads_create(global->thread_tbl, &global->cpumask, - &thr_params) != num_cpu) + if (odph_thread_create(global->thread_tbl, &thr_common, &thr_param, + num_cpu) != num_cpu) return -1; return 0; @@ -608,7 +613,7 @@ int main(int argc, char **argv) start_workers(global, instance); /* Wait workers to exit */ - odph_odpthreads_join(global->thread_tbl); + odph_thread_join(global->thread_tbl, global->test_options.num_cpu); print_stat(global); diff --git a/test/performance/odp_queue_perf.c b/test/performance/odp_queue_perf.c index 33284d312..320f2f35a 100644 --- a/test/performance/odp_queue_perf.c +++ b/test/performance/odp_queue_perf.c @@ -44,7 +44,7 @@ typedef struct test_global_t { odp_shm_t shm; odp_pool_t pool; odp_queue_t queue[MAX_QUEUES]; - odph_odpthread_t thread_tbl[ODP_THREAD_COUNT_MAX]; + odph_thread_t thread_tbl[ODP_THREAD_COUNT_MAX]; test_stat_t stat[ODP_THREAD_COUNT_MAX]; } test_global_t; @@ -423,18 +423,13 @@ error: static int start_workers(test_global_t *global) { - odph_odpthread_params_t thr_params; + odph_thread_common_param_t thr_common; + odph_thread_param_t thr_param; odp_cpumask_t cpumask; int ret; test_options_t *test_options = &global->options; int num_cpu = test_options->num_cpu; - memset(&thr_params, 0, sizeof(thr_params)); - thr_params.thr_type = ODP_THREAD_WORKER; - thr_params.instance = global->instance; - thr_params.start = run_test; - thr_params.arg = global; - ret = odp_cpumask_default_worker(&cpumask, num_cpu); if (num_cpu && ret != num_cpu) { @@ -452,8 +447,18 @@ static int start_workers(test_global_t *global) odp_barrier_init(&global->barrier, num_cpu); - if (odph_odpthreads_create(global->thread_tbl, &cpumask, &thr_params) - != num_cpu) + odph_thread_common_param_init(&thr_common); + thr_common.instance = global->instance; + thr_common.cpumask = &cpumask; + thr_common.share_param = 1; + + odph_thread_param_init(&thr_param); + thr_param.start = run_test; + thr_param.arg = global; + thr_param.thr_type = ODP_THREAD_WORKER; + + if (odph_thread_create(global->thread_tbl, &thr_common, &thr_param, + num_cpu) != num_cpu) return -1; return 0; @@ -596,7 +601,7 @@ int main(int argc, char **argv) } /* Wait workers to exit */ - odph_odpthreads_join(global->thread_tbl); + odph_thread_join(global->thread_tbl, global->options.num_cpu); print_stat(global); diff --git a/test/performance/odp_sched_latency.c b/test/performance/odp_sched_latency.c index c6b659aac..2910dcdbc 100644 --- a/test/performance/odp_sched_latency.c +++ b/test/performance/odp_sched_latency.c @@ -705,8 +705,9 @@ int main(int argc, char *argv[]) odp_instance_t instance; odp_init_t init_param; odph_helper_options_t helper_options; - odph_odpthread_t *thread_tbl; - odph_odpthread_params_t thr_params; + odph_thread_t *thread_tbl; + odph_thread_common_param_t thr_common; + odph_thread_param_t thr_param; odp_cpumask_t cpumask; odp_pool_t pool; odp_pool_capability_t pool_capa; @@ -766,7 +767,7 @@ int main(int argc, char *argv[]) printf(" First CPU: %i\n", odp_cpumask_first(&cpumask)); printf(" CPU mask: %s\n", cpumaskstr); - thread_tbl = calloc(sizeof(odph_odpthread_t), num_workers); + thread_tbl = calloc(sizeof(odph_thread_t), num_workers); if (!thread_tbl) { ODPH_ERR("no memory for thread_tbl\n"); return -1; @@ -858,15 +859,20 @@ int main(int argc, char *argv[]) odp_barrier_init(&globals->barrier, num_workers); /* Create and launch worker threads */ - memset(&thr_params, 0, sizeof(thr_params)); - thr_params.thr_type = ODP_THREAD_WORKER; - thr_params.instance = instance; - thr_params.start = run_thread; - thr_params.arg = NULL; - odph_odpthreads_create(thread_tbl, &cpumask, &thr_params); + odph_thread_common_param_init(&thr_common); + thr_common.instance = instance; + thr_common.cpumask = &cpumask; + thr_common.share_param = 1; + + odph_thread_param_init(&thr_param); + thr_param.start = run_thread; + thr_param.arg = NULL; + thr_param.thr_type = ODP_THREAD_WORKER; + + odph_thread_create(thread_tbl, &thr_common, &thr_param, num_workers); /* Wait for worker threads to terminate */ - odph_odpthreads_join(thread_tbl); + odph_thread_join(thread_tbl, num_workers); free(thread_tbl); printf("ODP scheduling latency test complete\n\n"); diff --git a/test/performance/odp_sched_pktio.c b/test/performance/odp_sched_pktio.c index cbdbdf4aa..589b58d97 100644 --- a/test/performance/odp_sched_pktio.c +++ b/test/performance/odp_sched_pktio.c @@ -1396,45 +1396,50 @@ static void destroy_timers(test_global_t *test_global) odp_timer_pool_destroy(timer_pool); } -static void start_workers(odph_odpthread_t thread[], +static void start_workers(odph_thread_t thread[], test_global_t *test_global) { int i; odp_cpumask_t cpumask; - odph_odpthread_params_t param; + odph_thread_common_param_t thr_common; + odph_thread_param_t thr_param[MAX_WORKERS]; int num = test_global->opt.num_worker; - memset(¶m, 0, sizeof(odph_odpthread_params_t)); + odp_cpumask_zero(&cpumask); - if (test_global->opt.timeout_us) - param.start = worker_thread_timers; - else if (test_global->opt.pipe_stages) - param.start = worker_thread_pipeline; - else - param.start = worker_thread_direct; - - param.thr_type = ODP_THREAD_WORKER; - param.instance = test_global->instance; - - memset(thread, 0, num * sizeof(odph_odpthread_t)); + odph_thread_common_param_init(&thr_common); + thr_common.instance = test_global->instance; + thr_common.cpumask = &cpumask; for (i = 0; i < num; i++) { - odp_cpumask_zero(&cpumask); odp_cpumask_set(&cpumask, test_global->worker_cpu[i]); test_global->worker_arg[i].worker_id = i; test_global->worker_arg[i].test_global_ptr = test_global; - param.arg = &test_global->worker_arg[i]; - odph_odpthreads_create(&thread[i], &cpumask, ¶m); + odph_thread_param_init(&thr_param[i]); + + if (!i) { + if (test_global->opt.timeout_us) + thr_param[0].start = worker_thread_timers; + else if (test_global->opt.pipe_stages) + thr_param[0].start = worker_thread_pipeline; + else + thr_param[0].start = worker_thread_direct; + } else { + thr_param[i].start = thr_param[0].start; + } + + thr_param[i].arg = &test_global->worker_arg[i]; + thr_param[i].thr_type = ODP_THREAD_WORKER; } + + memset(thread, 0, num * sizeof(odph_thread_t)); + odph_thread_create(thread, &thr_common, thr_param, num); } -static void wait_workers(odph_odpthread_t thread[], test_global_t *test_global) +static void wait_workers(odph_thread_t thread[], test_global_t *test_global) { - int i; - - for (i = 0; i < test_global->opt.num_worker; ++i) - odph_odpthreads_join(&thread[i]); + odph_thread_join(thread, test_global->opt.num_worker); } int main(int argc, char *argv[]) @@ -1444,7 +1449,7 @@ int main(int argc, char *argv[]) odp_shm_t shm; odp_time_t t1 = ODP_TIME_NULL, t2 = ODP_TIME_NULL; odph_helper_options_t helper_options; - odph_odpthread_t thread[MAX_WORKERS]; + odph_thread_t thread[MAX_WORKERS]; test_options_t test_options; int ret = 0; |