Skip to content

Commit

Permalink
performance: add calls to odp_schedule_config()
Browse files Browse the repository at this point in the history
Signed-off-by: Dmitry Eremin-Solenikov <dmitry.ereminsolenikov@linaro.org>
Signed-off-by: Balasubramanian Manoharan <bala.manoharan@linaro.org>
Reviewed-by: Bill Fischofer <bill.fischofer@linaro.org>
Reviewed-by: Petri Savolainen <petri.savolainen@linaro.org>
Signed-off-by: Maxim Uvarov <maxim.uvarov@linaro.org>
  • Loading branch information
Dmitry Eremin-Solenikov authored and muvarov committed Nov 30, 2018
1 parent ea6a715 commit 6860ee8
Show file tree
Hide file tree
Showing 10 changed files with 49 additions and 42 deletions.
22 changes: 10 additions & 12 deletions test/performance/odp_cpu_bench.c
Expand Up @@ -526,7 +526,7 @@ int main(int argc, char *argv[])
odp_cpumask_t cpumask;
odp_pool_capability_t pool_capa;
odp_pool_t pool;
odp_schedule_capability_t schedule_capa;
odp_schedule_config_t schedule_config;
odp_shm_t shm;
odp_shm_t lookup_tbl_shm;
odp_pool_param_t params;
Expand Down Expand Up @@ -614,26 +614,24 @@ int main(int argc, char *argv[])
printf("first CPU: %i\n", odp_cpumask_first(&cpumask));
printf("cpu mask: %s\n", cpumaskstr);

if (odp_schedule_capability(&schedule_capa)) {
printf("Error: Schedule capa failed.\n");
return -1;
}
odp_schedule_config_init(&schedule_config);
odp_schedule_config(&schedule_config);

/* Make sure a single queue can store all the packets in a group */
pkts_per_group = QUEUES_PER_GROUP * PKTS_PER_QUEUE;
if (schedule_capa.max_queue_size &&
schedule_capa.max_queue_size < pkts_per_group)
pkts_per_group = schedule_capa.max_queue_size;
if (schedule_config.queue_size &&
schedule_config.queue_size < pkts_per_group)
pkts_per_group = schedule_config.queue_size;

/* Divide queues evenly into groups */
if (schedule_capa.max_queues < QUEUES_PER_GROUP) {
if (schedule_config.num_queues < QUEUES_PER_GROUP) {
LOG_ERR("Error: min %d queues required\n", QUEUES_PER_GROUP);
return -1;
}
num_queues = num_workers > schedule_capa.max_queues ?
schedule_capa.max_queues : num_workers;
num_queues = num_workers > schedule_config.num_queues ?
schedule_config.num_queues : num_workers;
num_groups = (num_queues + QUEUES_PER_GROUP - 1) / QUEUES_PER_GROUP;
if (num_groups * QUEUES_PER_GROUP > schedule_capa.max_queues)
if (num_groups * QUEUES_PER_GROUP > schedule_config.num_queues)
num_groups--;
num_queues = num_groups * QUEUES_PER_GROUP;

Expand Down
1 change: 1 addition & 0 deletions test/performance/odp_crypto.c
Expand Up @@ -1101,6 +1101,7 @@ int main(int argc, char *argv[])

odp_queue_param_init(&qparam);
if (cargs.schedule) {
odp_schedule_config(NULL);
qparam.type = ODP_QUEUE_TYPE_SCHED;
qparam.sched.prio = ODP_SCHED_PRIO_DEFAULT;
qparam.sched.sync = ODP_SCHED_SYNC_PARALLEL;
Expand Down
1 change: 1 addition & 0 deletions test/performance/odp_ipsec.c
Expand Up @@ -1088,6 +1088,7 @@ int main(int argc, char *argv[])

odp_queue_param_init(&qparam);
if (cargs.schedule) {
odp_schedule_config(NULL);
qparam.type = ODP_QUEUE_TYPE_SCHED;
qparam.sched.prio = ODP_SCHED_PRIO_DEFAULT;
qparam.sched.sync = ODP_SCHED_SYNC_PARALLEL;
Expand Down
2 changes: 2 additions & 0 deletions test/performance/odp_l2fwd.c
Expand Up @@ -1568,6 +1568,8 @@ int main(int argc, char *argv[])

bind_workers();

odp_schedule_config(NULL);

/* Default */
if (num_groups == 0) {
group[0] = ODP_SCHED_GROUP_ALL;
Expand Down
9 changes: 6 additions & 3 deletions test/performance/odp_pktio_ordered.c
Expand Up @@ -1062,6 +1062,7 @@ int main(int argc, char *argv[])
odp_pool_param_t params;
odp_shm_t shm;
odp_schedule_capability_t schedule_capa;
odp_schedule_config_t schedule_config;
odp_pool_capability_t pool_capa;
odph_ethaddr_t new_addr;
odph_helper_options_t helper_options;
Expand Down Expand Up @@ -1129,6 +1130,8 @@ int main(int argc, char *argv[])
/* Parse and store the application arguments */
parse_args(argc, argv, &gbl_args->appl);

odp_schedule_config(NULL);

if (gbl_args->appl.in_mode == SCHED_ORDERED) {
/* At least one ordered lock required */
if (schedule_capa.max_ordered_locks < 1) {
Expand Down Expand Up @@ -1158,9 +1161,9 @@ int main(int argc, char *argv[])
pool_size = pool_capa.pkt.max_num;

queue_size = MAX_NUM_PKT;
if (schedule_capa.max_queue_size &&
schedule_capa.max_queue_size < MAX_NUM_PKT)
queue_size = schedule_capa.max_queue_size;
if (schedule_config.queue_size &&
schedule_config.queue_size < MAX_NUM_PKT)
queue_size = schedule_config.queue_size;

/* Pool should not be larger than queue, otherwise queue enqueues at
* packet input may fail. */
Expand Down
3 changes: 3 additions & 0 deletions test/performance/odp_pktio_perf.c
Expand Up @@ -759,6 +759,9 @@ static int test_init(void)
iface = gbl_args->args.ifaces[0];
schedule = gbl_args->args.schedule;

if (schedule)
odp_schedule_config(NULL);

/* create pktios and associate input/output queues */
gbl_args->pktio_tx = create_pktio(iface, schedule);
if (gbl_args->args.num_ifaces > 1) {
Expand Down
2 changes: 2 additions & 0 deletions test/performance/odp_sched_latency.c
Expand Up @@ -714,6 +714,8 @@ int main(int argc, char *argv[])
memset(globals, 0, sizeof(test_globals_t));
memcpy(&globals->args, &args, sizeof(test_args_t));

odp_schedule_config(NULL);

/*
* Create event pool
*/
Expand Down
21 changes: 10 additions & 11 deletions test/performance/odp_sched_perf.c
Expand Up @@ -43,6 +43,7 @@ typedef struct test_stat_t {
typedef struct test_global_t {
test_options_t test_options;

odp_schedule_config_t schedule_config;
odp_barrier_t barrier;
odp_pool_t pool;
odp_cpumask_t cpumask;
Expand Down Expand Up @@ -251,7 +252,6 @@ static int create_pool(test_global_t *global)

static int create_queues(test_global_t *global)
{
odp_schedule_capability_t schedule_capa;
odp_queue_param_t queue_param;
odp_queue_t queue;
odp_buffer_t buf;
Expand Down Expand Up @@ -279,20 +279,16 @@ static int create_queues(test_global_t *global)

printf(" queue type %s\n\n", type_str);

if (odp_schedule_capability(&schedule_capa)) {
printf("Error: Schedule capa failed.\n");
return -1;
}

if (tot_queue > schedule_capa.max_queues) {
if (tot_queue > global->schedule_config.num_queues) {
printf("Max queues supported %u\n",
schedule_capa.max_queues);
global->schedule_config.num_queues);
return -1;
}

if (schedule_capa.max_queue_size &&
queue_size > schedule_capa.max_queue_size) {
printf("Max queue size %u\n", schedule_capa.max_queue_size);
if (global->schedule_config.queue_size &&
queue_size > global->schedule_config.queue_size) {
printf("Max queue size %u\n",
global->schedule_config.queue_size);
return -1;
}

Expand Down Expand Up @@ -603,6 +599,9 @@ int main(int argc, char **argv)
return -1;
}

odp_schedule_config_init(&global->schedule_config);
odp_schedule_config(&global->schedule_config);

if (set_num_cpu(global))
return -1;

Expand Down
17 changes: 8 additions & 9 deletions test/performance/odp_sched_pktio.c
Expand Up @@ -127,6 +127,8 @@ typedef struct {
uint64_t rx_pkt_sum;
uint64_t tx_pkt_sum;

odp_schedule_config_t schedule_config;

} test_global_t;

static test_global_t *test_global;
Expand Down Expand Up @@ -723,6 +725,9 @@ static int config_setup(test_global_t *test_global)
cpu = odp_cpumask_next(cpumask, cpu);
}

odp_schedule_config_init(&test_global->schedule_config);
odp_schedule_config(&test_global->schedule_config);

if (odp_pool_capability(&pool_capa)) {
printf("Error: Pool capability failed.\n");
return -1;
Expand Down Expand Up @@ -1109,15 +1114,9 @@ static int create_pipeline_queues(test_global_t *test_global)
int i, j, k, num_pktio, stages, queues, ctx_size;
pipe_queue_context_t *ctx;
odp_queue_param_t queue_param;
odp_schedule_capability_t schedule_capa;
odp_schedule_sync_t sched_sync;
int ret = 0;

if (odp_schedule_capability(&schedule_capa)) {
printf("Error: Schedule capa failed.\n");
return -1;
}

num_pktio = test_global->opt.num_pktio;
stages = test_global->opt.pipe_stages;
queues = test_global->opt.pipe_queues;
Expand All @@ -1130,10 +1129,10 @@ static int create_pipeline_queues(test_global_t *test_global)
queue_param.sched.group = ODP_SCHED_GROUP_ALL;

queue_param.size = test_global->opt.pipe_queue_size;
if (schedule_capa.max_queue_size &&
queue_param.size > schedule_capa.max_queue_size) {
if (test_global->schedule_config.queue_size &&
queue_param.size > test_global->schedule_config.queue_size) {
printf("Error: Pipeline queue max size is %u\n",
schedule_capa.max_queue_size);
test_global->schedule_config.queue_size);
return -1;
}

Expand Down
13 changes: 6 additions & 7 deletions test/performance/odp_scheduling.c
Expand Up @@ -813,7 +813,7 @@ int main(int argc, char *argv[])
odph_odpthread_params_t thr_params;
odp_queue_capability_t capa;
odp_pool_capability_t pool_capa;
odp_schedule_capability_t schedule_capa;
odp_schedule_config_t schedule_config;
uint32_t num_queues, num_buf;

printf("\nODP example starts\n\n");
Expand Down Expand Up @@ -909,15 +909,14 @@ int main(int argc, char *argv[])
return -1;
}

if (odp_schedule_capability(&schedule_capa)) {
printf("Error: Schedule capa failed.\n");
return -1;
}
odp_schedule_config_init(&schedule_config);
odp_schedule_config(&schedule_config);

globals->queues_per_prio = QUEUES_PER_PRIO;
num_queues = globals->queues_per_prio * NUM_PRIOS;
if (num_queues > schedule_capa.max_queues)
globals->queues_per_prio = schedule_capa.max_queues /
if (schedule_config.num_queues &&
num_queues > schedule_config.num_queues)
globals->queues_per_prio = schedule_config.num_queues /
NUM_PRIOS;

/* One plain queue is also used */
Expand Down

0 comments on commit 6860ee8

Please sign in to comment.