From 8a79d37ac28a1e0b8071b71ffe62aa96d8f7fedf Mon Sep 17 00:00:00 2001 From: Ralph Castain Date: Mon, 25 Mar 2013 17:51:45 +0000 Subject: [PATCH] Fix a few bugs in the hwloc integration code. The "set binding policy" macro should flag that the policy was indeed set. Some systems don't report sockets, so the print functions need to check for that condition. cmr:v1.7 This commit was SVN r28209. --- opal/mca/hwloc/base/hwloc_base_open.c | 8 +------- opal/mca/hwloc/base/hwloc_base_util.c | 7 ++++++- opal/mca/hwloc/hwloc.h | 2 +- 3 files changed, 8 insertions(+), 9 deletions(-) diff --git a/opal/mca/hwloc/base/hwloc_base_open.c b/opal/mca/hwloc/base/hwloc_base_open.c index 39b9d167e0..c8450d0c1b 100644 --- a/opal/mca/hwloc/base/hwloc_base_open.c +++ b/opal/mca/hwloc/base/hwloc_base_open.c @@ -157,10 +157,8 @@ int opal_hwloc_base_open(void) /* mark that no binding policy was specified */ opal_hwloc_binding_policy &= ~OPAL_BIND_GIVEN; } else if (0 == strncasecmp(str_value, "none", strlen("none"))) { - opal_hwloc_binding_policy = OPAL_BIND_TO_NONE; - opal_hwloc_binding_policy |= OPAL_BIND_GIVEN; + OPAL_SET_BINDING_POLICY(opal_hwloc_binding_policy, OPAL_BIND_TO_NONE); } else { - opal_hwloc_binding_policy |= OPAL_BIND_GIVEN; tmpvals = opal_argv_split(str_value, ':'); if (1 < opal_argv_count(tmpvals)) { quals = opal_argv_split(tmpvals[1], ','); @@ -217,7 +215,6 @@ int opal_hwloc_base_open(void) return OPAL_ERR_BAD_PARAM; } OPAL_SET_BINDING_POLICY(opal_hwloc_binding_policy, OPAL_BIND_TO_CORE); - opal_hwloc_binding_policy |= OPAL_BIND_GIVEN; } mca_base_param_reg_int_name("hwloc", "base_bind_to_socket", @@ -233,7 +230,6 @@ int opal_hwloc_base_open(void) return OPAL_ERR_SILENT; } OPAL_SET_BINDING_POLICY(opal_hwloc_binding_policy, OPAL_BIND_TO_SOCKET); - opal_hwloc_binding_policy |= OPAL_BIND_GIVEN; } mca_base_param_reg_int_name("hwloc", "base_report_bindings", @@ -253,7 +249,6 @@ int opal_hwloc_base_open(void) return OPAL_ERR_SILENT; } OPAL_SET_BINDING_POLICY(opal_hwloc_binding_policy, OPAL_BIND_TO_CPUSET); - opal_hwloc_binding_policy |= OPAL_BIND_GIVEN; } /* cpu allocation specification */ @@ -267,7 +262,6 @@ int opal_hwloc_base_open(void) * ignored if someone didn't also specify a binding policy */ OPAL_SET_BINDING_POLICY(opal_hwloc_binding_policy, OPAL_BIND_TO_CPUSET); - opal_hwloc_binding_policy |= OPAL_BIND_GIVEN; } } diff --git a/opal/mca/hwloc/base/hwloc_base_util.c b/opal/mca/hwloc/base/hwloc_base_util.c index 9d4a35ea6a..faeff3b121 100644 --- a/opal/mca/hwloc/base/hwloc_base_util.c +++ b/opal/mca/hwloc/base/hwloc_base_util.c @@ -1697,7 +1697,12 @@ static int build_map(int *num_sockets_arg, int *num_cores_arg, to look this up every time) */ if (num_sockets < 0) { num_sockets = hwloc_get_nbobjs_by_type(opal_hwloc_topology, HWLOC_OBJ_SOCKET); - + /* some systems (like the iMac) only have one + * socket and so don't report a socket + */ + if (0 == num_sockets) { + num_sockets = 1; + } /* Lazy: take the total number of cores that we have in the topology; that'll be more than the max number of cores under any given socket */ diff --git a/opal/mca/hwloc/hwloc.h b/opal/mca/hwloc/hwloc.h index 81be583c07..5eadaa7199 100644 --- a/opal/mca/hwloc/hwloc.h +++ b/opal/mca/hwloc/hwloc.h @@ -204,7 +204,7 @@ typedef uint16_t opal_binding_policy_t; #define OPAL_GET_BINDING_POLICY(pol) \ ((pol) & 0x0fff) #define OPAL_SET_BINDING_POLICY(target, pol) \ - (target) = (pol) | ((target) & 0xf000) + (target) = (pol) | (((target) & 0xf000) | OPAL_BIND_GIVEN) /* check if policy is set */ #define OPAL_BINDING_POLICY_IS_SET(pol) \ ((pol) & 0x4000)