Skip to content

Commit aff3a00

Browse files
author
Ralph Castain
committed
Protect default mapping/binding options for cases where no NUMA or
SOCKET objects exist - like VMs Signed-off-by: Ralph Castain <[email protected]>
1 parent 31a8476 commit aff3a00

File tree

1 file changed

+45
-12
lines changed

1 file changed

+45
-12
lines changed

orte/mca/rmaps/base/rmaps_base_map_job.c

Lines changed: 45 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
* Copyright (c) 2011-2012 Cisco Systems, Inc. All rights reserved.
1313
* Copyright (c) 2011-2012 Los Alamos National Security, LLC.
1414
* All rights reserved.
15-
* Copyright (c) 2014-2016 Intel, Inc. All rights reserved.
15+
* Copyright (c) 2014-2017 Intel, Inc. All rights reserved.
1616
* Copyright (c) 2016 Research Organization for Information Science
1717
* and Technology (RIST). All rights reserved.
1818
* $COPYRIGHT$
@@ -149,9 +149,21 @@ void orte_rmaps_base_map_job(int fd, short args, void *cbdata)
149149
ORTE_SET_MAPPING_POLICY(jdata->map->mapping, ORTE_MAPPING_BYCORE);
150150
}
151151
} else {
152-
opal_output_verbose(5, orte_rmaps_base_framework.framework_output,
153-
"mca:rmaps[%d] mapping not set by user - using bysocket", __LINE__);
154-
ORTE_SET_MAPPING_POLICY(jdata->map->mapping, ORTE_MAPPING_BYSOCKET);
152+
/* if NUMA is available, map by that */
153+
if (NULL != hwloc_get_obj_by_type(opal_hwloc_topology, HWLOC_OBJ_NODE, 0)) {
154+
opal_output_verbose(5, orte_rmaps_base_framework.framework_output,
155+
"mca:rmaps[%d] mapping not set by user - using bynuma", __LINE__);
156+
ORTE_SET_MAPPING_POLICY(jdata->map->mapping, ORTE_MAPPING_BYNUMA);
157+
} else if (NULL != hwloc_get_obj_by_type(opal_hwloc_topology, HWLOC_OBJ_SOCKET, 0)) {
158+
opal_output_verbose(5, orte_rmaps_base_framework.framework_output,
159+
"mca:rmaps[%d] mapping not set by user and no NUMA - using bysocket", __LINE__);
160+
ORTE_SET_MAPPING_POLICY(jdata->map->mapping, ORTE_MAPPING_BYSOCKET);
161+
} else {
162+
/* if we have neither, then just do by slot */
163+
opal_output_verbose(5, orte_rmaps_base_framework.framework_output,
164+
"mca:rmaps[%d] mapping not given and no NUMA or sockets - using byslot", __LINE__);
165+
ORTE_SET_MAPPING_POLICY(jdata->map->mapping, ORTE_MAPPING_BYSLOT);
166+
}
155167
}
156168
}
157169
}
@@ -255,10 +267,20 @@ void orte_rmaps_base_map_job(int fd, short args, void *cbdata)
255267
OPAL_SET_DEFAULT_BINDING_POLICY(jdata->map->binding, OPAL_BIND_TO_CORE);
256268
}
257269
} else {
258-
/* for performance, bind to NUMA */
259-
opal_output_verbose(5, orte_rmaps_base_framework.framework_output,
260-
"mca:rmaps[%d] binding not given - using bynuma", __LINE__);
261-
OPAL_SET_DEFAULT_BINDING_POLICY(jdata->map->binding, OPAL_BIND_TO_NUMA);
270+
if (NULL != hwloc_get_obj_by_type(opal_hwloc_topology, HWLOC_OBJ_NODE, 0)) {
271+
opal_output_verbose(5, orte_rmaps_base_framework.framework_output,
272+
"mca:rmaps[%d] binding not given - using bynuma", __LINE__);
273+
OPAL_SET_DEFAULT_BINDING_POLICY(jdata->map->binding, OPAL_BIND_TO_NUMA);
274+
} else if (NULL != hwloc_get_obj_by_type(opal_hwloc_topology, HWLOC_OBJ_SOCKET, 0)) {
275+
opal_output_verbose(5, orte_rmaps_base_framework.framework_output,
276+
"mca:rmaps[%d] binding not given and no NUMA - using bysocket", __LINE__);
277+
OPAL_SET_DEFAULT_BINDING_POLICY(jdata->map->binding, OPAL_BIND_TO_SOCKET);
278+
} else {
279+
/* if we have neither, then just don't bind */
280+
opal_output_verbose(5, orte_rmaps_base_framework.framework_output,
281+
"mca:rmaps[%d] binding not given and no NUMA or sockets - not binding", __LINE__);
282+
OPAL_SET_BINDING_POLICY(jdata->map->binding, OPAL_BIND_TO_NONE);
283+
}
262284
}
263285
}
264286
} else if (nprocs <= 2) {
@@ -274,10 +296,21 @@ void orte_rmaps_base_map_job(int fd, short args, void *cbdata)
274296
OPAL_SET_DEFAULT_BINDING_POLICY(jdata->map->binding, OPAL_BIND_TO_CORE);
275297
}
276298
} else {
277-
/* for performance, bind to NUMA */
278-
opal_output_verbose(5, orte_rmaps_base_framework.framework_output,
279-
"mca:rmaps[%d] binding not given - using bynuma", __LINE__);
280-
OPAL_SET_DEFAULT_BINDING_POLICY(jdata->map->binding, OPAL_BIND_TO_NUMA);
299+
/* for performance, bind to NUMA, if available */
300+
if (NULL != hwloc_get_obj_by_type(opal_hwloc_topology, HWLOC_OBJ_NODE, 0)) {
301+
opal_output_verbose(5, orte_rmaps_base_framework.framework_output,
302+
"mca:rmaps[%d] binding not given - using bynuma", __LINE__);
303+
OPAL_SET_DEFAULT_BINDING_POLICY(jdata->map->binding, OPAL_BIND_TO_NUMA);
304+
} else if (NULL != hwloc_get_obj_by_type(opal_hwloc_topology, HWLOC_OBJ_SOCKET, 0)) {
305+
opal_output_verbose(5, orte_rmaps_base_framework.framework_output,
306+
"mca:rmaps[%d] binding not given and no NUMA - using bysocket", __LINE__);
307+
OPAL_SET_DEFAULT_BINDING_POLICY(jdata->map->binding, OPAL_BIND_TO_SOCKET);
308+
} else {
309+
/* if we have neither, then just don't bind */
310+
opal_output_verbose(5, orte_rmaps_base_framework.framework_output,
311+
"mca:rmaps[%d] binding not given and no NUMA or sockets - not binding", __LINE__);
312+
OPAL_SET_BINDING_POLICY(jdata->map->binding, OPAL_BIND_TO_NONE);
313+
}
281314
}
282315
if (OPAL_BIND_OVERLOAD_ALLOWED(opal_hwloc_binding_policy)) {
283316
jdata->map->binding |= OPAL_BIND_ALLOW_OVERLOAD;

0 commit comments

Comments
 (0)