Skip to content

Commit

Permalink
Properly compute number of procs when not given
Browse files Browse the repository at this point in the history
When computing the number of procs to launch under the
condition where the number of slots was specified (via
--host or hostfile) and cpus/rank was given, we need to
take into account the number of cpus on each node and
treat the number of slots as a max value.

Signed-off-by: Ralph Castain <[email protected]>
(cherry picked from commit f01b9c4)
  • Loading branch information
rhc54 committed Nov 29, 2024
1 parent 9c901be commit 47fc7be
Showing 1 changed file with 21 additions and 9 deletions.
30 changes: 21 additions & 9 deletions src/mca/rmaps/base/rmaps_base_map_job.c
Original file line number Diff line number Diff line change
Expand Up @@ -494,15 +494,27 @@ void prte_rmaps_base_map_job(int fd, short args, void *cbdata)
app->num_procs = PMIX_ARGV_COUNT_COMPAT(ck);
PMIX_ARGV_FREE_COMPAT(ck);
} else {
/* set the num_procs to equal the number of slots on these
* mapped nodes, taking into account the number of cpus/rank
*/
app->num_procs = slots / options.cpus_per_rank;
/* sometimes, we have only one "slot" assigned, but may
* want more than one cpu/rank - so ensure we always wind
* up with at least one proc */
if (0 == app->num_procs) {
app->num_procs = 1;
if (1 < options.cpus_per_rank) {
// compute the number of cpus on each node
len = 0;
PMIX_LIST_FOREACH (node, &nodes, prte_node_t) {
if (options.use_hwthreads) {
len += prte_hwloc_base_get_nbobjs_by_type(node->topology->topo,
HWLOC_OBJ_PU) / options.cpus_per_rank;
} else {
len += prte_hwloc_base_get_nbobjs_by_type(node->topology->topo,
HWLOC_OBJ_CORE) / options.cpus_per_rank;
}
}
app->num_procs = len;
// ensure we always wind up with at least one proc
if (0 == app->num_procs) {
app->num_procs = 1;
} else if (slots < app->num_procs) {
app->num_procs = slots;
}
} else {
app->num_procs = slots;
}
}
}
Expand Down

0 comments on commit 47fc7be

Please sign in to comment.