[v1,2/3] test: sched_perf: add event forward option

Message ID 1535623206-484-3-git-send-email-odpbot@yandex.ru
State New
Headers show
Series
  • Add options to sched_perf test application
Related show

Commit Message

Github ODP bot Aug. 30, 2018, 10 a.m.
From: Petri Savolainen <petri.savolainen@linaro.org>


Added -f option to enable event forwarding between queues.
By default, an event is sent back to the queue it was
received from. When forwaring is enabled, it's sent to the
next queue.

Signed-off-by: Petri Savolainen <petri.savolainen@linaro.org>

---
/** Email created from pull request 687 (psavol:master-test-sched-perf-options)
 ** https://github.com/Linaro/odp/pull/687
 ** Patch: https://github.com/Linaro/odp/pull/687.patch
 ** Base sha: 97fc51b1e5b3fcea9db99ba63c10bda47f79341a
 ** Merge commit sha: b10a9d3318c78101ad4c590deb3d4be6ad7b3cc1
 **/
 test/performance/odp_sched_perf.c | 36 ++++++++++++++++++++++++++++++-
 1 file changed, 35 insertions(+), 1 deletion(-)

Patch

diff --git a/test/performance/odp_sched_perf.c b/test/performance/odp_sched_perf.c
index d5fceede9..ba16623c9 100644
--- a/test/performance/odp_sched_perf.c
+++ b/test/performance/odp_sched_perf.c
@@ -24,6 +24,7 @@  typedef struct test_options_t {
 	uint32_t num_round;
 	uint32_t max_burst;
 	int      queue_type;
+	int      forward;
 	uint32_t tot_queue;
 	uint32_t tot_event;
 
@@ -66,6 +67,7 @@  static void print_usage(void)
 	       "  -r, --num_round        Number of rounds\n"
 	       "  -b, --burst            Maximum number of events per operation. Default: 100.\n"
 	       "  -t, --type             Queue type. 0: parallel, 1: atomic, 2: ordered. Default: 0.\n"
+	       "  -f, --forward          0: Keep event in the original queue, 1: Forward event to the next queue. Default: 0.\n"
 	       "  -h, --help             This help\n"
 	       "\n");
 }
@@ -84,11 +86,12 @@  static int parse_options(int argc, char *argv[], test_options_t *test_options)
 		{"num_round", required_argument, NULL, 'r'},
 		{"burst",     required_argument, NULL, 'b'},
 		{"type",      required_argument, NULL, 't'},
+		{"forward",   required_argument, NULL, 'f'},
 		{"help",      no_argument,       NULL, 'h'},
 		{NULL, 0, NULL, 0}
 	};
 
-	static const char *shortopts = "+c:q:d:e:r:b:t:h";
+	static const char *shortopts = "+c:q:d:e:r:b:t:f:h";
 
 	test_options->num_cpu    = 1;
 	test_options->num_queue  = 1;
@@ -97,6 +100,7 @@  static int parse_options(int argc, char *argv[], test_options_t *test_options)
 	test_options->num_round  = 100000;
 	test_options->max_burst  = 100;
 	test_options->queue_type = 0;
+	test_options->forward    = 0;
 
 	while (1) {
 		opt = getopt_long(argc, argv, shortopts, longopts, &long_index);
@@ -126,6 +130,9 @@  static int parse_options(int argc, char *argv[], test_options_t *test_options)
 		case 't':
 			test_options->queue_type = atoi(optarg);
 			break;
+		case 'f':
+			test_options->forward = atoi(optarg);
+			break;
 		case 'h':
 			/* fall through */
 		default:
@@ -194,6 +201,7 @@  static int create_pool(test_global_t *global)
 	uint32_t max_burst = test_options->max_burst;
 	uint32_t tot_queue = test_options->tot_queue;
 	uint32_t tot_event = test_options->tot_event;
+	int      forward   = test_options->forward;
 
 	printf("\nScheduler performance test\n");
 	printf("  num cpu          %u\n", num_cpu);
@@ -204,6 +212,7 @@  static int create_pool(test_global_t *global)
 	printf("  max burst size   %u\n", max_burst);
 	printf("  total events     %u\n", tot_event);
 	printf("  num rounds       %u\n", num_round);
+	printf("  forward events   %i\n", forward ? 1 : 0);
 
 	if (odp_pool_capability(&pool_capa)) {
 		printf("Error: Pool capa failed.\n");
@@ -298,6 +307,19 @@  static int create_queues(test_global_t *global)
 	for (i = 0; i < num_queue; i++) {
 		queue = global->queue[i];
 
+		if (test_options->forward) {
+			uint32_t next = i + 1;
+
+			if (next == num_queue)
+				next = 0;
+
+			if (odp_queue_context_set(queue, &global->queue[next],
+						  sizeof(odp_queue_t))) {
+				printf("Error: Context set failed %u\n", i);
+				return -1;
+			}
+		}
+
 		for (j = 0; j < num_event; j++) {
 			buf = odp_buffer_alloc(pool);
 
@@ -349,10 +371,12 @@  static int test_sched(void *arg)
 	uint64_t events, enqueues;
 	odp_time_t t1, t2;
 	odp_queue_t queue;
+	odp_queue_t *next;
 	test_global_t *global = arg;
 	test_options_t *test_options = &global->test_options;
 	uint32_t num_round = test_options->num_round;
 	uint32_t max_burst = test_options->max_burst;
+	int forward = test_options->forward;
 	odp_event_t ev[max_burst];
 
 	thr = odp_thread_id();
@@ -378,6 +402,11 @@  static int test_sched(void *arg)
 			events += num;
 			i = 0;
 
+			if (odp_unlikely(forward)) {
+				next  = odp_queue_context(queue);
+				queue = *next;
+			}
+
 			while (num) {
 				num_enq = odp_queue_enq_multi(queue, &ev[i],
 							      num);
@@ -430,6 +459,11 @@  static int test_sched(void *arg)
 		if (ev[0] == ODP_EVENT_INVALID)
 			break;
 
+		if (odp_unlikely(forward)) {
+			next  = odp_queue_context(queue);
+			queue = *next;
+		}
+
 		odp_queue_enq(queue, ev[0]);
 	}