hello word app should not use any linux specific
things. Pinning thread to core is also optional
and should not be in minimal app. This also fixes
bug with cgroups env where core 0 is not available.

Signed-off-by: Maxim Uvarov <maxim.uva...@linaro.org>
---
 example/hello/odp_hello.c | 29 ++---------------------------
 1 file changed, 2 insertions(+), 27 deletions(-)

diff --git a/example/hello/odp_hello.c b/example/hello/odp_hello.c
index 6d114eea..0b75b58f 100644
--- a/example/hello/odp_hello.c
+++ b/example/hello/odp_hello.c
@@ -10,21 +10,12 @@
  * anything else than the ODP API header file.
  */
 
-/* Linux CPU affinity */
-#define _GNU_SOURCE
-#include <sched.h>
-
-/* Linux PID */
-#include <sys/types.h>
-#include <unistd.h>
-
 #include <stdio.h>
 #include <string.h>
 
 #include <odp_api.h>
 
 typedef struct {
-       int cpu;
        int num;
 } options_t;
 
@@ -36,17 +27,12 @@ static int parse_args(int argc, char *argv[], options_t 
*opt)
        for (i = 1; i < argc; i++) {
                if ((strcmp(argv[i], args[0]) == 0) &&
                    (sscanf(argv[i + 1], "%i", &tmp) == 1)) {
-                       opt->cpu = tmp;
-                       i++;
-               } else if ((strcmp(argv[i], args[1]) == 0) &&
-                          (sscanf(argv[i + 1], "%i", &tmp) == 1)) {
                        opt->num = tmp;
                        i++;
                } else {
                        printf("\nUsage:\n"
-                              "  %s  CPU number\n"
                               "  %s  Number of iterations\n\n",
-                              args[0], args[1]);
+                              args[0]);
                        return -1;
                }
        }
@@ -58,26 +44,14 @@ int main(int argc, char *argv[])
 {
        odp_instance_t inst;
        options_t opt;
-       pid_t pid;
-       cpu_set_t cpu_set;
        int i;
 
        memset(&opt, 0, sizeof(opt));
-       opt.cpu = 0;
        opt.num = 1;
 
        if (parse_args(argc, argv, &opt))
                return -1;
 
-       pid = getpid();
-       CPU_ZERO(&cpu_set);
-       CPU_SET(opt.cpu, &cpu_set);
-
-       if (sched_setaffinity(pid, sizeof(cpu_set_t), &cpu_set)) {
-               printf("Set CPU affinity failed.\n");
-               return -1;
-       }
-
        if (odp_init_global(&inst, NULL, NULL)) {
                printf("Global init failed.\n");
                return -1;
@@ -85,6 +59,7 @@ int main(int argc, char *argv[])
 
        if (odp_init_local(inst, ODP_THREAD_CONTROL)) {
                printf("Local init failed.\n");
+               (void)odp_term_global(inst);
                return -1;
        }
 
-- 
2.11.0.295.gd7dffce

Reply via email to