Skip to content

Repair the binding algorithm #6

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/hwloc/hwloc_base_util.c
Original file line number Diff line number Diff line change
Expand Up @@ -1328,7 +1328,7 @@ void prte_hwloc_get_binding_info(hwloc_const_cpuset_t cpuset,

/* if the cpuset is all zero, then something is wrong */
if (hwloc_bitmap_iszero(cpuset)) {
snprintf(cores, sz, "\n%*c<NOT MAPPED/>\n", 20, ' ');
snprintf(cores, sz, "\n%*c<EMPTY CPUSET/>\n", 20, ' ');
}

/* if the cpuset includes all available cpus, and
Expand Down Expand Up @@ -1401,7 +1401,7 @@ char *prte_hwloc_base_cset2str(hwloc_const_cpuset_t cpuset,

/* if the cpuset is all zero, then something is wrong */
if (hwloc_bitmap_iszero(cpuset)) {
return strdup("NOT MAPPED");
return strdup("EMPTY CPUSET");
}

/* if the cpuset includes all available cpus, and
Expand Down
18 changes: 8 additions & 10 deletions src/mca/rmaps/base/rmaps_base_binding.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
* Copyright (c) 2015-2017 Research Organization for Information Science
* and Technology (RIST). All rights reserved.
* Copyright (c) 2018 Inria. All rights reserved.
* Copyright (c) 2021-2023 Nanook Consulting All rights reserved.
* Copyright (c) 2021-2024 Nanook Consulting All rights reserved.
* $COPYRIGHT$
*
* Additional copyrights may follow
Expand Down Expand Up @@ -61,6 +61,7 @@ static int bind_generic(prte_job_t *jdata, prte_proc_t *proc,
hwloc_obj_type_t type;
hwloc_obj_t target;
hwloc_cpuset_t tgtcpus, tmpcpus;
int nobjs, n;

pmix_output_verbose(5, prte_rmaps_base_framework.framework_output,
"mca:rmaps: bind %s with policy %s",
Expand All @@ -82,18 +83,18 @@ static int bind_generic(prte_job_t *jdata, prte_proc_t *proc,
#endif
hwloc_bitmap_and(prte_rmaps_base.baseset, options->target, tgtcpus);

trg_obj = NULL;
/* find the first object of that type in the target that has at least one available CPU */
tmp_obj = hwloc_get_next_obj_inside_cpuset_by_type(node->topology->topo,
prte_rmaps_base.baseset,
options->hwb, NULL);
while (NULL != tmp_obj) {
nobjs = hwloc_get_nbobjs_by_type(node->topology->topo, options->hwb);

for (n=0; n < nobjs; n++) {
tmp_obj = hwloc_get_obj_by_type(node->topology->topo, options->hwb, n);
#if HWLOC_API_VERSION < 0x20000
tmpcpus = tmp_obj->allowed_cpuset;
#else
tmpcpus = tmp_obj->cpuset;
#endif
hwloc_bitmap_and(prte_rmaps_base.available, node->available, tmpcpus);
hwloc_bitmap_and(prte_rmaps_base.available, prte_rmaps_base.available, prte_rmaps_base.baseset);

if (options->use_hwthreads) {
ncpus = hwloc_bitmap_weight(prte_rmaps_base.available);
} else {
Expand All @@ -112,9 +113,6 @@ static int bind_generic(prte_job_t *jdata, prte_proc_t *proc,
trg_obj = tmp_obj;
break;
}
tmp_obj = hwloc_get_next_obj_inside_cpuset_by_type(node->topology->topo,
prte_rmaps_base.baseset,
options->hwb, tmp_obj);
}
if (NULL == trg_obj) {
/* there aren't any appropriate targets under this object */
Expand Down
18 changes: 5 additions & 13 deletions src/mca/rmaps/base/rmaps_base_support_fns.c
Original file line number Diff line number Diff line change
Expand Up @@ -631,27 +631,18 @@ int prte_rmaps_base_get_ncpus(prte_node_t *node,
{
int ncpus;

#if HWLOC_API_VERSION < 0x20000
hwloc_obj_t root;
root = hwloc_get_root_obj(node->topology->topo);
if (NULL == options->job_cpuset) {
hwloc_bitmap_copy(prte_rmaps_base.available, root->allowed_cpuset);
hwloc_bitmap_copy(prte_rmaps_base.available, node->available);
} else {
hwloc_bitmap_and(prte_rmaps_base.available, root->allowed_cpuset, options->job_cpuset);
hwloc_bitmap_and(prte_rmaps_base.available, node->available, options->job_cpuset);
}
if (NULL != obj) {
#if HWLOC_API_VERSION < 0x20000
hwloc_bitmap_and(prte_rmaps_base.available, prte_rmaps_base.available, obj->allowed_cpuset);
}
#else
if (NULL == options->job_cpuset) {
hwloc_bitmap_copy(prte_rmaps_base.available, hwloc_topology_get_allowed_cpuset(node->topology->topo));
} else {
hwloc_bitmap_and(prte_rmaps_base.available, hwloc_topology_get_allowed_cpuset(node->topology->topo), options->job_cpuset);
}
if (NULL != obj) {
hwloc_bitmap_and(prte_rmaps_base.available, prte_rmaps_base.available, obj->cpuset);
}
#endif
}
if (options->use_hwthreads) {
ncpus = hwloc_bitmap_weight(prte_rmaps_base.available);
} else {
Expand All @@ -664,6 +655,7 @@ int prte_rmaps_base_get_ncpus(prte_node_t *node,
*/
ncpus = hwloc_get_nbobjs_inside_cpuset_by_type(node->topology->topo, prte_rmaps_base.available, HWLOC_OBJ_CORE);
}

return ncpus;
}

Expand Down
Loading