Increase TEST_ROUNDS for all schedulers except SP for more deterministic
test results. SP is too slow to handle the increased running time.

Use an explicit scheduling group to inform the scheduler of the threads
that will join the group.

Add a timeout to the schedule call for draining queues.

Signed-off-by: Brian Brooks <brian.bro...@arm.com>
Signed-off-by: Ola Liljedahl <ola.liljed...@arm.com>
---
 test/common_plat/performance/odp_sched_latency.c | 68 +++++++++++++++++++++++-
 1 file changed, 67 insertions(+), 1 deletion(-)

diff --git a/test/common_plat/performance/odp_sched_latency.c 
b/test/common_plat/performance/odp_sched_latency.c
index 2b28cd7b..4a933f5b 100644
--- a/test/common_plat/performance/odp_sched_latency.c
+++ b/test/common_plat/performance/odp_sched_latency.c
@@ -28,7 +28,13 @@
 #define MAX_WORKERS      64            /**< Maximum number of worker threads */
 #define MAX_QUEUES       4096          /**< Maximum number of queues */
 #define EVENT_POOL_SIZE          (1024 * 1024) /**< Event pool size */
+
+#ifdef ODP_SCHEDULE_SP
 #define TEST_ROUNDS (4 * 1024 * 1024)  /**< Test rounds for each thread */
+#else
+#define TEST_ROUNDS (32 * 1024 * 1024) /**< Test rounds for each thread */
+#endif
+
 #define MAIN_THREAD       1 /**< Thread ID performing maintenance tasks */
 
 /* Default values for command line arguments */
@@ -104,6 +110,9 @@ typedef union {
 typedef struct {
        core_stat_t      core_stat[MAX_WORKERS]; /**< Core specific stats */
        odp_barrier_t    barrier; /**< Barrier for thread synchronization */
+#ifdef ODP_SCHEDULE_SCALABLE
+       odp_schedule_group_t schedule_group;
+#endif
        odp_pool_t       pool;    /**< Pool for allocating test events */
        test_args_t      args;    /**< Parsed command line arguments */
        odp_queue_t      queue[NUM_PRIOS][MAX_QUEUES]; /**< Scheduled queues */
@@ -119,7 +128,11 @@ static void clear_sched_queues(void)
        odp_event_t ev;
 
        while (1) {
-               ev = odp_schedule(NULL, ODP_SCHED_NO_WAIT);
+               /* Need a non-zero timeout to ensure we can observe
+                * any non-empty queue made eligible for scheduling
+                * by some other thread.
+                */
+               ev = odp_schedule(NULL, 1000);
 
                if (ev == ODP_EVENT_INVALID)
                        break;
@@ -428,6 +441,20 @@ static int run_thread(void *arg ODP_UNUSED)
                return -1;
        }
 
+#ifdef ODP_SCHEDULE_SCALABLE
+       int err;
+       odp_thrmask_t thrmask;
+
+       odp_thrmask_zero(&thrmask);
+       odp_thrmask_set(&thrmask, thr);
+
+       err = odp_schedule_group_join(globals->schedule_group, &thrmask);
+       if (err != 0) {
+               LOG_ERR("odp_schedule_group_join failed\n");
+               return -1;
+       }
+#endif
+
        if (thr == MAIN_THREAD) {
                args = &globals->args;
 
@@ -452,6 +479,13 @@ static int run_thread(void *arg ODP_UNUSED)
        if (test_schedule(thr, globals))
                return -1;
 
+#ifdef ODP_SCHEDULE_SCALABLE
+       err = odp_schedule_group_leave(globals->schedule_group, &thrmask);
+       if (err != 0) {
+               LOG_ERR("odp_schedule_group_leave failed\n");
+               return -1;
+       }
+#endif
        return 0;
 }
 
@@ -692,6 +726,31 @@ int main(int argc, char *argv[])
        }
        globals->pool = pool;
 
+#ifdef ODP_SCHEDULE_SCALABLE
+       /*
+        * Create scheduler group
+        */
+       odp_thrmask_t expected_thrmask;
+       int cpu;
+       int thr;
+
+       odp_thrmask_zero(&expected_thrmask);
+       /* This is a odp_thrmask_from_cpumask() */
+       cpu = odp_cpumask_first(&cpumask);
+       thr = 1;
+       while (0 <= cpu) {
+               odp_thrmask_set(&expected_thrmask, thr++);
+               cpu = odp_cpumask_next(&cpumask, cpu);
+       }
+
+       globals->schedule_group =
+               odp_schedule_group_create("sg0", &expected_thrmask);
+       if (globals->schedule_group == ODP_SCHED_GROUP_INVALID) {
+               LOG_ERR("odp_schedule_group_create failed\n");
+               return -1;
+       }
+#endif
+
        /*
         * Create queues for schedule test
         */
@@ -713,7 +772,11 @@ int main(int argc, char *argv[])
                param.type        = ODP_QUEUE_TYPE_SCHED;
                param.sched.prio  = prio;
                param.sched.sync  = args.sync_type;
+#ifdef ODP_SCHEDULE_SCALABLE
+               param.sched.group = globals->schedule_group;
+#else
                param.sched.group = ODP_SCHED_GROUP_ALL;
+#endif
 
                for (j = 0; j < args.prio[i].queues; j++) {
                        name[9]  = '0' + j / 10;
@@ -758,6 +821,9 @@ int main(int argc, char *argv[])
                }
        }
 
+#ifdef ODP_SCHEDULE_SCALABLE
+       ret += odp_schedule_group_destroy(globals->schedule_group);
+#endif
        ret += odp_shm_free(shm);
        ret += odp_pool_destroy(pool);
        ret += odp_term_local();
-- 
2.12.2

Reply via email to