aboutsummaryrefslogtreecommitdiff
path: root/test/performance/odp_scheduling.c
diff options
context:
space:
mode:
authorRobbie King <robking@cisco.com>2015-01-14 23:48:26 +0100
committerMaxim Uvarov <maxim.uvarov@linaro.org>2015-01-16 17:33:19 +0300
commit38e36ef15500a3517a635a258bba3fea263cc555 (patch)
treee8996aea5d6a527e66d4a58db2ffca05b6e8ecf0 /test/performance/odp_scheduling.c
parent5e47a0cf301367e47a3e1dfefbd6c5b4677916b8 (diff)
helper: linux: use cpumask in linux thread/proc
Move away from specifying a core count and allow the user to specify a mask. Signed-off-by: Robbie King <robking@cisco.com> Signed-off-by: Anders Roxell <anders.roxell@linaro.org> Reviewed-by: Petri Savolainen <petri.savolainen@linaro.org> Signed-off-by: Maxim Uvarov <maxim.uvarov@linaro.org>
Diffstat (limited to 'test/performance/odp_scheduling.c')
-rw-r--r--test/performance/odp_scheduling.c30
1 files changed, 11 insertions, 19 deletions
diff --git a/test/performance/odp_scheduling.c b/test/performance/odp_scheduling.c
index 72656c4be..bb005d7de 100644
--- a/test/performance/odp_scheduling.c
+++ b/test/performance/odp_scheduling.c
@@ -810,14 +810,15 @@ int main(int argc, char *argv[])
odph_linux_pthread_t thread_tbl[MAX_WORKERS];
test_args_t args;
int num_workers;
+ odp_cpumask_t cpumask;
odp_buffer_pool_t pool;
odp_queue_t queue;
int i, j;
int prios;
- int first_cpu;
odp_shm_t shm;
test_globals_t *globals;
odp_buffer_pool_param_t params;
+ char cpumaskstr[64];
printf("\nODP example starts\n\n");
@@ -857,29 +858,21 @@ int main(int argc, char *argv[])
printf("\n");
- /* A worker thread per CPU */
- num_workers = odp_sys_cpu_count();
-
+ /* Default to system CPU count unless user specified */
+ num_workers = MAX_WORKERS;
if (args.cpu_count)
num_workers = args.cpu_count;
- /* force to max CPU count */
- if (num_workers > MAX_WORKERS)
- num_workers = MAX_WORKERS;
-
- printf("num worker threads: %i\n", num_workers);
-
/*
* By default CPU #0 runs Linux kernel background tasks.
* Start mapping thread from CPU #1
*/
- first_cpu = 1;
-
- if (odp_sys_cpu_count() == 1)
- first_cpu = 0;
-
- printf("first CPU: %i\n", first_cpu);
+ num_workers = odph_linux_cpumask_default(&cpumask, num_workers);
+ odp_cpumask_to_str(&cpumask, cpumaskstr, sizeof(cpumaskstr));
+ printf("num worker threads: %i\n", num_workers);
+ printf("first CPU: %i\n", odp_cpumask_first(&cpumask));
+ printf("cpu mask: %s\n", cpumaskstr);
/* Test cycle count accuracy */
test_time();
@@ -968,8 +961,7 @@ int main(int argc, char *argv[])
odph_linux_process_t proc[MAX_WORKERS];
/* Fork worker processes */
- ret = odph_linux_process_fork_n(proc, num_workers,
- first_cpu);
+ ret = odph_linux_process_fork_n(proc, &cpumask);
if (ret < 0) {
LOG_ERR("Fork workers failed %i\n", ret);
@@ -987,7 +979,7 @@ int main(int argc, char *argv[])
} else {
/* Create and launch worker threads */
- odph_linux_pthread_create(thread_tbl, num_workers, first_cpu,
+ odph_linux_pthread_create(thread_tbl, &cpumask,
run_thread, NULL);
/* Wait for worker threads to terminate */