diff mbox

example: hello: ask odp for available core

Message ID 20170119143450.21473-1-maxim.uvarov@linaro.org
State Accepted
Commit a51c171ebe9e9b0aaced13bc0956bdb38c8cfc7b
Headers show

Commit Message

Maxim Uvarov Jan. 19, 2017, 2:34 p.m. UTC
Core 0 might be not available and app should
ask for available core before pinning to it.
https://bugs.linaro.org/show_bug.cgi?id=2806

Signed-off-by: Maxim Uvarov <maxim.uvarov@linaro.org>

---
 example/hello/odp_hello.c | 15 ++++++++++-----
 1 file changed, 10 insertions(+), 5 deletions(-)

-- 
2.11.0.295.gd7dffce

Comments

Maxim Uvarov Jan. 25, 2017, 6:25 p.m. UTC | #1
ping, please review.

Maxim.

On 01/19/17 17:34, Maxim Uvarov wrote:
> Core 0 might be not available and app should

> ask for available core before pinning to it.

> https://bugs.linaro.org/show_bug.cgi?id=2806

> 

> Signed-off-by: Maxim Uvarov <maxim.uvarov@linaro.org>

> ---

>  example/hello/odp_hello.c | 15 ++++++++++-----

>  1 file changed, 10 insertions(+), 5 deletions(-)

> 

> diff --git a/example/hello/odp_hello.c b/example/hello/odp_hello.c

> index 6d114eea..dba34954 100644

> --- a/example/hello/odp_hello.c

> +++ b/example/hello/odp_hello.c

> @@ -61,6 +61,7 @@ int main(int argc, char *argv[])

>  	pid_t pid;

>  	cpu_set_t cpu_set;

>  	int i;

> +	odp_cpumask_t mask;

>  

>  	memset(&opt, 0, sizeof(opt));

>  	opt.cpu = 0;

> @@ -70,6 +71,15 @@ int main(int argc, char *argv[])

>  		return -1;

>  

>  	pid = getpid();

> +

> +	if (odp_init_global(&inst, NULL, NULL)) {

> +		printf("Global init failed.\n");

> +		return -1;

> +	}

> +

> +	odp_cpumask_default_control(&mask, 0);

> +	opt.cpu = odp_cpumask_first(&mask);

> +

>  	CPU_ZERO(&cpu_set);

>  	CPU_SET(opt.cpu, &cpu_set);

>  

> @@ -78,11 +88,6 @@ int main(int argc, char *argv[])

>  		return -1;

>  	}

>  

> -	if (odp_init_global(&inst, NULL, NULL)) {

> -		printf("Global init failed.\n");

> -		return -1;

> -	}

> -

>  	if (odp_init_local(inst, ODP_THREAD_CONTROL)) {

>  		printf("Local init failed.\n");

>  		return -1;

>
Maxim Uvarov Jan. 27, 2017, 1:24 p.m. UTC | #2
ping.

On 01/19/17 17:34, Maxim Uvarov wrote:
> Core 0 might be not available and app should

> ask for available core before pinning to it.

> https://bugs.linaro.org/show_bug.cgi?id=2806

> 

> Signed-off-by: Maxim Uvarov <maxim.uvarov@linaro.org>

> ---

>  example/hello/odp_hello.c | 15 ++++++++++-----

>  1 file changed, 10 insertions(+), 5 deletions(-)

> 

> diff --git a/example/hello/odp_hello.c b/example/hello/odp_hello.c

> index 6d114eea..dba34954 100644

> --- a/example/hello/odp_hello.c

> +++ b/example/hello/odp_hello.c

> @@ -61,6 +61,7 @@ int main(int argc, char *argv[])

>  	pid_t pid;

>  	cpu_set_t cpu_set;

>  	int i;

> +	odp_cpumask_t mask;

>  

>  	memset(&opt, 0, sizeof(opt));

>  	opt.cpu = 0;

> @@ -70,6 +71,15 @@ int main(int argc, char *argv[])

>  		return -1;

>  

>  	pid = getpid();

> +

> +	if (odp_init_global(&inst, NULL, NULL)) {

> +		printf("Global init failed.\n");

> +		return -1;

> +	}

> +

> +	odp_cpumask_default_control(&mask, 0);

> +	opt.cpu = odp_cpumask_first(&mask);

> +

>  	CPU_ZERO(&cpu_set);

>  	CPU_SET(opt.cpu, &cpu_set);

>  

> @@ -78,11 +88,6 @@ int main(int argc, char *argv[])

>  		return -1;

>  	}

>  

> -	if (odp_init_global(&inst, NULL, NULL)) {

> -		printf("Global init failed.\n");

> -		return -1;

> -	}

> -

>  	if (odp_init_local(inst, ODP_THREAD_CONTROL)) {

>  		printf("Local init failed.\n");

>  		return -1;

>
Mike Holmes Jan. 27, 2017, 1:34 p.m. UTC | #3
On 19 January 2017 at 09:34, Maxim Uvarov <maxim.uvarov@linaro.org> wrote:

> Core 0 might be not available and app should

> ask for available core before pinning to it.

> https://bugs.linaro.org/show_bug.cgi?id=2806

>

> Signed-off-by: Maxim Uvarov <maxim.uvarov@linaro.org>

>


Reviewed-by: Mike Holmes <mike.holmes@linaro.org>




> ---

>  example/hello/odp_hello.c | 15 ++++++++++-----

>  1 file changed, 10 insertions(+), 5 deletions(-)

>

> diff --git a/example/hello/odp_hello.c b/example/hello/odp_hello.c

> index 6d114eea..dba34954 100644

> --- a/example/hello/odp_hello.c

> +++ b/example/hello/odp_hello.c

> @@ -61,6 +61,7 @@ int main(int argc, char *argv[])

>         pid_t pid;

>         cpu_set_t cpu_set;

>         int i;

> +       odp_cpumask_t mask;

>

>         memset(&opt, 0, sizeof(opt));

>         opt.cpu = 0;

> @@ -70,6 +71,15 @@ int main(int argc, char *argv[])

>                 return -1;

>

>         pid = getpid();

> +

> +       if (odp_init_global(&inst, NULL, NULL)) {

> +               printf("Global init failed.\n");

> +               return -1;

> +       }

> +

> +       odp_cpumask_default_control(&mask, 0);

> +       opt.cpu = odp_cpumask_first(&mask);

> +

>         CPU_ZERO(&cpu_set);

>         CPU_SET(opt.cpu, &cpu_set);

>

> @@ -78,11 +88,6 @@ int main(int argc, char *argv[])

>                 return -1;

>         }

>

> -       if (odp_init_global(&inst, NULL, NULL)) {

> -               printf("Global init failed.\n");

> -               return -1;

> -       }

> -

>         if (odp_init_local(inst, ODP_THREAD_CONTROL)) {

>                 printf("Local init failed.\n");

>                 return -1;

> --

> 2.11.0.295.gd7dffce

>

>



-- 
Mike Holmes
Program Manager - Linaro Networking Group
Linaro.org <http://www.linaro.org/> *│ *Open source software for ARM SoCs
"Work should be fun and collaborative, the rest follows"
Maxim Uvarov Jan. 27, 2017, 2:35 p.m. UTC | #4
Merged,
Maxim.

On 01/27/17 16:34, Mike Holmes wrote:
> 

> 

> On 19 January 2017 at 09:34, Maxim Uvarov <maxim.uvarov@linaro.org

> <mailto:maxim.uvarov@linaro.org>> wrote:

> 

>     Core 0 might be not available and app should

>     ask for available core before pinning to it.

>     https://bugs.linaro.org/show_bug.cgi?id=2806

>     <https://bugs.linaro.org/show_bug.cgi?id=2806>

> 

>     Signed-off-by: Maxim Uvarov <maxim.uvarov@linaro.org

>     <mailto:maxim.uvarov@linaro.org>>

> 

> 

> Reviewed-by: Mike Holmes <mike.holmes@linaro.org

> <mailto:mike.holmes@linaro.org>>

> 

>  

> 

>     ---

>      example/hello/odp_hello.c | 15 ++++++++++-----

>      1 file changed, 10 insertions(+), 5 deletions(-)

> 

>     diff --git a/example/hello/odp_hello.c b/example/hello/odp_hello.c

>     index 6d114eea..dba34954 100644

>     --- a/example/hello/odp_hello.c

>     +++ b/example/hello/odp_hello.c

>     @@ -61,6 +61,7 @@ int main(int argc, char *argv[])

>             pid_t pid;

>             cpu_set_t cpu_set;

>             int i;

>     +       odp_cpumask_t mask;

> 

>             memset(&opt, 0, sizeof(opt));

>             opt.cpu = 0;

>     @@ -70,6 +71,15 @@ int main(int argc, char *argv[])

>                     return -1;

> 

>             pid = getpid();

>     +

>     +       if (odp_init_global(&inst, NULL, NULL)) {

>     +               printf("Global init failed.\n");

>     +               return -1;

>     +       }

>     +

>     +       odp_cpumask_default_control(&mask, 0);

>     +       opt.cpu = odp_cpumask_first(&mask);

>     +

>             CPU_ZERO(&cpu_set);

>             CPU_SET(opt.cpu, &cpu_set);

> 

>     @@ -78,11 +88,6 @@ int main(int argc, char *argv[])

>                     return -1;

>             }

> 

>     -       if (odp_init_global(&inst, NULL, NULL)) {

>     -               printf("Global init failed.\n");

>     -               return -1;

>     -       }

>     -

>             if (odp_init_local(inst, ODP_THREAD_CONTROL)) {

>                     printf("Local init failed.\n");

>                     return -1;

>     --

>     2.11.0.295.gd7dffce

> 

> 

> 

> 

> -- 

> Mike Holmes

> Program Manager - Linaro Networking Group

> Linaro.org <http://www.linaro.org/>* **│ *Open source software for ARM SoCs

> "Work should be fun and collaborative, the rest follows"

> 

> __

> 

>
diff mbox

Patch

diff --git a/example/hello/odp_hello.c b/example/hello/odp_hello.c
index 6d114eea..dba34954 100644
--- a/example/hello/odp_hello.c
+++ b/example/hello/odp_hello.c
@@ -61,6 +61,7 @@  int main(int argc, char *argv[])
 	pid_t pid;
 	cpu_set_t cpu_set;
 	int i;
+	odp_cpumask_t mask;
 
 	memset(&opt, 0, sizeof(opt));
 	opt.cpu = 0;
@@ -70,6 +71,15 @@  int main(int argc, char *argv[])
 		return -1;
 
 	pid = getpid();
+
+	if (odp_init_global(&inst, NULL, NULL)) {
+		printf("Global init failed.\n");
+		return -1;
+	}
+
+	odp_cpumask_default_control(&mask, 0);
+	opt.cpu = odp_cpumask_first(&mask);
+
 	CPU_ZERO(&cpu_set);
 	CPU_SET(opt.cpu, &cpu_set);
 
@@ -78,11 +88,6 @@  int main(int argc, char *argv[])
 		return -1;
 	}
 
-	if (odp_init_global(&inst, NULL, NULL)) {
-		printf("Global init failed.\n");
-		return -1;
-	}
-
 	if (odp_init_local(inst, ODP_THREAD_CONTROL)) {
 		printf("Local init failed.\n");
 		return -1;