aboutsummaryrefslogtreecommitdiff
path: root/test/performance/odp_timer_perf.c
diff options
context:
space:
mode:
authorMatias Elo <matias.elo@nokia.com>2021-04-19 12:47:45 +0300
committerPetri Savolainen <petri.savolainen@nokia.com>2021-04-23 09:18:12 +0300
commitb64fb45634d5620f5f170f3dc7bff3796ebab38a (patch)
tree0d3ca130527617e2b87e67f86daca528c9ff9b1c /test/performance/odp_timer_perf.c
parent4c38177e454804725abe2e65d83092c065a80b97 (diff)
test: timer_perf: add process mode support
Allocate global memory using SHM and add odph_parse_options() call to enable running the application in process mode (--odph_proc or ODPH_PROC_MODE set). The application memory model is set accordingly. Signed-off-by: Matias Elo <matias.elo@nokia.com> Reviewed-by: Petri Savolainen <petri.savolainen@nokia.com>
Diffstat (limited to 'test/performance/odp_timer_perf.c')
-rw-r--r--test/performance/odp_timer_perf.c68
1 files changed, 49 insertions, 19 deletions
diff --git a/test/performance/odp_timer_perf.c b/test/performance/odp_timer_perf.c
index be0fc363a..4b8318557 100644
--- a/test/performance/odp_timer_perf.c
+++ b/test/performance/odp_timer_perf.c
@@ -1,4 +1,4 @@
-/* Copyright (c) 2019-2020, Nokia
+/* Copyright (c) 2019-2021, Nokia
* All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
@@ -110,7 +110,7 @@ typedef struct test_global_t {
} test_global_t;
-test_global_t test_global;
+test_global_t *test_global;
static void print_usage(void)
{
@@ -946,35 +946,29 @@ static void sig_handler(int signo)
{
(void)signo;
- odp_atomic_add_u32(&test_global.exit_test, MAX_TIMER_POOLS);
+ if (test_global == NULL)
+ return;
+ odp_atomic_add_u32(&test_global->exit_test, MAX_TIMER_POOLS);
}
int main(int argc, char **argv)
{
+ odph_helper_options_t helper_options;
odp_instance_t instance;
odp_init_t init;
+ odp_shm_t shm;
test_global_t *global;
test_options_t *test_options;
int i, shared, mode;
- global = &test_global;
- memset(global, 0, sizeof(test_global_t));
- odp_atomic_init_u32(&global->exit_test, 0);
- odp_atomic_init_u32(&global->timers_started, 0);
-
- for (i = 0; i < ODP_THREAD_COUNT_MAX; i++) {
- global->thread_arg[i].global = global;
- global->thread_arg[i].worker_idx = i;
- }
-
signal(SIGINT, sig_handler);
- if (parse_options(argc, argv, &global->test_options))
- return -1;
-
- test_options = &global->test_options;
- shared = test_options->shared;
- mode = test_options->mode;
+ /* Let helper collect its own arguments (e.g. --odph_proc) */
+ argc = odph_parse_options(argc, argv);
+ if (odph_options(&helper_options)) {
+ ODPH_ERR("Reading ODP helper options failed.\n");
+ exit(EXIT_FAILURE);
+ }
/* List features not to be used */
odp_init_param_init(&init);
@@ -984,6 +978,8 @@ int main(int argc, char **argv)
init.not_used.feat.ipsec = 1;
init.not_used.feat.tm = 1;
+ init.mem_model = helper_options.mem_model;
+
/* Init ODP before calling anything else */
if (odp_init_global(&instance, &init, NULL)) {
ODPH_ERR("Global init failed.\n");
@@ -996,6 +992,35 @@ int main(int argc, char **argv)
return -1;
}
+ shm = odp_shm_reserve("timer_perf_global", sizeof(test_global_t), ODP_CACHE_LINE_SIZE, 0);
+ if (shm == ODP_SHM_INVALID) {
+ ODPH_ERR("Shared mem reserve failed.\n");
+ exit(EXIT_FAILURE);
+ }
+
+ global = odp_shm_addr(shm);
+ if (global == NULL) {
+ ODPH_ERR("Shared mem alloc failed\n");
+ exit(EXIT_FAILURE);
+ }
+ test_global = global;
+
+ memset(global, 0, sizeof(test_global_t));
+ odp_atomic_init_u32(&global->exit_test, 0);
+ odp_atomic_init_u32(&global->timers_started, 0);
+
+ for (i = 0; i < ODP_THREAD_COUNT_MAX; i++) {
+ global->thread_arg[i].global = global;
+ global->thread_arg[i].worker_idx = i;
+ }
+
+ if (parse_options(argc, argv, &global->test_options))
+ return -1;
+
+ test_options = &global->test_options;
+ shared = test_options->shared;
+ mode = test_options->mode;
+
odp_sys_info_print();
odp_schedule_config(NULL);
@@ -1052,6 +1077,11 @@ int main(int argc, char **argv)
destroy_timer_pool(global);
+ if (odp_shm_free(shm)) {
+ ODPH_ERR("Shared mem free failed.\n");
+ exit(EXIT_FAILURE);
+ }
+
if (odp_term_local()) {
ODPH_ERR("Term local failed.\n");
return -1;