diff mbox

[API-NEXT] validation: scheduler: use number of workers

Message ID 1437409497-20286-1-git-send-email-maxim.uvarov@linaro.org
State New
Headers show

Commit Message

Maxim Uvarov July 20, 2015, 4:24 p.m. UTC
Use number of workes instead of number of total cpus.

Signed-off-by: Maxim Uvarov <maxim.uvarov@linaro.org>
---
 test/validation/scheduler/scheduler.c | 19 +++++++++----------
 1 file changed, 9 insertions(+), 10 deletions(-)
diff mbox

Patch

diff --git a/test/validation/scheduler/scheduler.c b/test/validation/scheduler/scheduler.c
index f73c23a..57ac528 100644
--- a/test/validation/scheduler/scheduler.c
+++ b/test/validation/scheduler/scheduler.c
@@ -38,7 +38,7 @@ 
 
 /* Test global variables */
 typedef struct {
-	int cpu_count;
+	int num_workers;
 	odp_barrier_t barrier;
 	int buf_count;
 	odp_ticketlock_t lock;
@@ -164,14 +164,12 @@  static void *schedule_common_(void *arg)
 {
 	thread_args_t *args = (thread_args_t *)arg;
 	odp_schedule_sync_t sync;
-	int num_cpus;
 	test_globals_t *globals;
 
 	globals = args->globals;
 	sync = args->sync;
-	num_cpus = args->num_cpus;
 
-	if (num_cpus == globals->cpu_count)
+	if (args->num_cpus > 1)
 		odp_barrier_wait(&globals->barrier);
 
 	while (1) {
@@ -352,14 +350,14 @@  static void parallel_execute(odp_schedule_sync_t sync, int num_queues,
 		args->num_bufs = NUM_BUFS_EXCL;
 	else
 		args->num_bufs = TEST_NUM_BUFS;
-	args->num_cpus = globals->cpu_count;
+	args->num_cpus = globals->num_workers;
 	args->enable_schd_multi = enable_schd_multi;
 	args->enable_excl_atomic = enable_excl_atomic;
 
 	fill_queues(args);
 
 	/* Create and launch worker threads */
-	args->cu_thr.numthrds = globals->cpu_count;
+	args->cu_thr.numthrds = globals->num_workers;
 	odp_cunit_thread_create(schedule_common_, &args->cu_thr);
 
 	/* Wait for worker threads to terminate */
@@ -662,6 +660,7 @@  static int create_queues(void)
 
 static int scheduler_suite_init(void)
 {
+	odp_cpumask_t mask;
 	odp_shm_t shm;
 	odp_pool_t pool;
 	test_globals_t *globals;
@@ -692,9 +691,9 @@  static int scheduler_suite_init(void)
 
 	memset(globals, 0, sizeof(test_globals_t));
 
-	globals->cpu_count = odp_cpu_count();
-	if (globals->cpu_count > MAX_WORKERS)
-		globals->cpu_count = MAX_WORKERS;
+	globals->num_workers = odp_cpumask_def_worker(&mask, 0);
+	if (globals->num_workers > MAX_WORKERS)
+		globals->num_workers = MAX_WORKERS;
 
 	shm = odp_shm_reserve(SHM_THR_ARGS_NAME, sizeof(thread_args_t),
 			      ODP_CACHE_LINE_SIZE, 0);
@@ -708,7 +707,7 @@  static int scheduler_suite_init(void)
 	memset(args, 0, sizeof(thread_args_t));
 
 	/* Barrier to sync test case execution */
-	odp_barrier_init(&globals->barrier, globals->cpu_count);
+	odp_barrier_init(&globals->barrier, globals->num_workers);
 	odp_ticketlock_init(&globals->lock);
 	odp_spinlock_init(&globals->atomic_lock);