Skip to content

Commit a047eef

Browse files
committed
Protect against missing HWLOC object types
If we are trying to bind to an HWLOC object type that is not defined on a given node, then (a) if the binding policy was specified by user, then error out; and (b) if we are using a default binding policy, then simply do not bind. Signed-off-by: Ralph Castain <[email protected]> (cherry picked from commit 5d21059)
1 parent 55f6e2e commit a047eef

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

src/mca/rmaps/base/rmaps_base_binding.c

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,18 @@ static int bind_generic(prte_job_t *jdata, prte_proc_t *proc,
8585

8686
nobjs = hwloc_get_nbobjs_by_type(node->topology->topo, options->hwb);
8787

88+
// check for target object existence
89+
if (0 == nobjs) {
90+
// if this is not a default binding policy, then error out
91+
if (PRTE_BINDING_POLICY_IS_SET(jdata->map->binding)) {
92+
pmix_show_help("help-prte-rmaps-base.txt", "rmaps:binding-target-not-found",
93+
true, prte_hwloc_base_print_binding(jdata->map->binding), node->name);
94+
return PRTE_ERR_SILENT;
95+
}
96+
// fallback to not binding
97+
return PRTE_SUCCESS;
98+
}
99+
88100
for (n=0; n < nobjs; n++) {
89101
tmp_obj = hwloc_get_obj_by_type(node->topology->topo, options->hwb, n);
90102
#if HWLOC_API_VERSION < 0x20000
@@ -129,6 +141,9 @@ static int bind_generic(prte_job_t *jdata, prte_proc_t *proc,
129141
#else
130142
tgtcpus = trg_obj->cpuset;
131143
#endif
144+
if (NULL == tgtcpus) {
145+
return PRTE_ERROR;
146+
}
132147
hwloc_bitmap_list_asprintf(&proc->cpuset, tgtcpus); // bind to the entire target object
133148
if (4 < pmix_output_get_verbosity(prte_rmaps_base_framework.framework_output)) {
134149
char *tmp1;

0 commit comments

Comments
 (0)