diff mbox

[API-NEXT,PATCHv7,4/5] api: init: add control/worker cpumasks to init data

Message ID 1459429694-6832-5-git-send-email-bill.fischofer@linaro.org
State New
Headers show

Commit Message

Bill Fischofer March 31, 2016, 1:08 p.m. UTC
From: "Gary S. Robertson" <gary.robertson@linaro.org>

Adds pointers to externally supplied cpumasks for
control and worker CPUs to the ODP global init data
which is passed as an argument to odp_init_global.
The intent is to allow an external entity to pass in
lists of the CPU resources available to the current
ODP application.

It is assumed that these pointers would be NULL
unless explicitly populated prior to calling
odp_init_global.

odp_init_global would respond to NULL pointers
here by ensuring that odp_cpumask_default_control and
odp_cpumask_default_worker would return the
platform-specific default CPU configurations.

If these pointers were not NULL when odp_init_global was called,
then the above functions would return cpumasks reflecting the
(possibly amended) contents of the referenced cpumasks
instead of the platform defaults.

Signed-off-by: Gary S. Robertson <gary.robertson@linaro.org>
Signed-off-by: Bill Fischofer <bill.fischofer@linaro.org>
---
 include/odp/api/spec/init.h | 27 +++++++++++++++++++++++++++
 1 file changed, 27 insertions(+)

Comments

Maxim Uvarov March 31, 2016, 1:28 p.m. UTC | #1
Petri, please review this patch.

Maxim.

On 03/31/16 16:08, Bill Fischofer wrote:
> From: "Gary S. Robertson" <gary.robertson@linaro.org>
>
> Adds pointers to externally supplied cpumasks for
> control and worker CPUs to the ODP global init data
> which is passed as an argument to odp_init_global.
> The intent is to allow an external entity to pass in
> lists of the CPU resources available to the current
> ODP application.
>
> It is assumed that these pointers would be NULL
> unless explicitly populated prior to calling
> odp_init_global.
>
> odp_init_global would respond to NULL pointers
> here by ensuring that odp_cpumask_default_control and
> odp_cpumask_default_worker would return the
> platform-specific default CPU configurations.
>
> If these pointers were not NULL when odp_init_global was called,
> then the above functions would return cpumasks reflecting the
> (possibly amended) contents of the referenced cpumasks
> instead of the platform defaults.
>
> Signed-off-by: Gary S. Robertson <gary.robertson@linaro.org>
> Signed-off-by: Bill Fischofer <bill.fischofer@linaro.org>
> ---
>   include/odp/api/spec/init.h | 27 +++++++++++++++++++++++++++
>   1 file changed, 27 insertions(+)
>
> diff --git a/include/odp/api/spec/init.h b/include/odp/api/spec/init.h
> index 47ebd54..8560663 100644
> --- a/include/odp/api/spec/init.h
> +++ b/include/odp/api/spec/init.h
> @@ -31,6 +31,7 @@ extern "C" {
>   #include <odp/api/std_types.h>
>   #include <odp/api/hints.h>
>   #include <odp/api/thread.h>
> +#include <odp/api/cpumask.h>
>   
>   /** @defgroup odp_initialization ODP INITIALIZATION
>    *  Initialisation operations.
> @@ -123,6 +124,32 @@ typedef struct odp_init_t {
>   	    Valid range is from 0 to platform specific maximum. Set both
>   	    num_worker and num_control to zero for default number of threads. */
>   	int num_control;
> +	/** Pointer to bit mask mapping CPUs available to this ODP instance
> +	    for running worker threads.
> +	    Initialize to a NULL pointer to use default CPU mapping.
> +	    When the mask is defined, odp_cpumask_default_worker()
> +	    uses it instead of returning a default mask.
> +	    Applications code should not access this cpumask directly.
> +	    Valid range of CPUs and optimal CPU selection
> +	    are platform specific, but generally it is recommended that:
> +		* worker CPUs are dedicated to run only ODP worker threads
> +		  (one thread per CPU)
> +		* worker and control masks do not overlap
> +		* different ODP instances do not specify overlapping
> +		  worker masks
> +	 */
> +	const odp_cpumask_t *worker_cpus;
> +	/** Pointer to bit mask mapping CPUs available to this ODP instance
> +	    for running control threads.
> +	    Initialize to a NULL pointer to use default CPU mapping.
> +	    When the mask is defined, odp_cpumask_default_control()
> +	    uses it instead of returning a default mask.
> +	    Applications code should not access this cpumask directly.
> +	    Valid range of CPUs and optimal CPU selection
> +	    are platform specific, but generally it is recommended that
> +	    worker and control masks do not overlap.
> +	 */
> +	const odp_cpumask_t *control_cpus;
>   	/** Replacement for the default log fn */
>   	odp_log_func_t log_fn;
>   	/** Replacement for the default abort fn */
diff mbox

Patch

diff --git a/include/odp/api/spec/init.h b/include/odp/api/spec/init.h
index 47ebd54..8560663 100644
--- a/include/odp/api/spec/init.h
+++ b/include/odp/api/spec/init.h
@@ -31,6 +31,7 @@  extern "C" {
 #include <odp/api/std_types.h>
 #include <odp/api/hints.h>
 #include <odp/api/thread.h>
+#include <odp/api/cpumask.h>
 
 /** @defgroup odp_initialization ODP INITIALIZATION
  *  Initialisation operations.
@@ -123,6 +124,32 @@  typedef struct odp_init_t {
 	    Valid range is from 0 to platform specific maximum. Set both
 	    num_worker and num_control to zero for default number of threads. */
 	int num_control;
+	/** Pointer to bit mask mapping CPUs available to this ODP instance
+	    for running worker threads.
+	    Initialize to a NULL pointer to use default CPU mapping.
+	    When the mask is defined, odp_cpumask_default_worker()
+	    uses it instead of returning a default mask.
+	    Applications code should not access this cpumask directly.
+	    Valid range of CPUs and optimal CPU selection
+	    are platform specific, but generally it is recommended that:
+		* worker CPUs are dedicated to run only ODP worker threads
+		  (one thread per CPU)
+		* worker and control masks do not overlap
+		* different ODP instances do not specify overlapping
+		  worker masks
+	 */
+	const odp_cpumask_t *worker_cpus;
+	/** Pointer to bit mask mapping CPUs available to this ODP instance
+	    for running control threads.
+	    Initialize to a NULL pointer to use default CPU mapping.
+	    When the mask is defined, odp_cpumask_default_control()
+	    uses it instead of returning a default mask.
+	    Applications code should not access this cpumask directly.
+	    Valid range of CPUs and optimal CPU selection
+	    are platform specific, but generally it is recommended that
+	    worker and control masks do not overlap.
+	 */
+	const odp_cpumask_t *control_cpus;
 	/** Replacement for the default log fn */
 	odp_log_func_t log_fn;
 	/** Replacement for the default abort fn */