Skip to content

Commit de3978e

Browse files
committed
Initialize variable before use
When computing number of procs, we need to construct the node list and set the number of slots before using it. Signed-off-by: Ralph Castain <[email protected]>
1 parent 2e6698d commit de3978e

File tree

1 file changed

+16
-16
lines changed

1 file changed

+16
-16
lines changed

src/mca/rmaps/base/rmaps_base_map_job.c

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
* and Technology (RIST). All rights reserved.
1818
* Copyright (c) 2019 UT-Battelle, LLC. All rights reserved.
1919
*
20-
* Copyright (c) 2021-2025 Nanook Consulting All rights reserved.
20+
* Copyright (c) 2021-2026 Nanook Consulting All rights reserved.
2121
* Copyright (c) 2022 IBM Corporation. All rights reserved.
2222
* $COPYRIGHT$
2323
*
@@ -543,21 +543,21 @@ void prte_rmaps_base_map_job(int fd, short args, void *cbdata)
543543
app->num_procs = PMIX_ARGV_COUNT_COMPAT(ck);
544544
PMIX_ARGV_FREE_COMPAT(ck);
545545
} else {
546+
/*
547+
* get the target nodes for this app - the base function
548+
* will take any host or hostfile directive into account
549+
*/
550+
PMIX_CONSTRUCT(&nodes, pmix_list_t);
551+
rc = prte_rmaps_base_get_target_nodes(&nodes, &slots,
552+
jdata, app, jdata->map->mapping,
553+
true, true, false);
554+
if (PRTE_SUCCESS != rc) {
555+
PMIX_LIST_DESTRUCT(&nodes);
556+
jdata->exit_code = rc;
557+
PRTE_ACTIVATE_JOB_STATE(jdata, PRTE_JOB_STATE_MAP_FAILED);
558+
goto cleanup;
559+
}
546560
if (1 < options.cpus_per_rank) {
547-
/*
548-
* get the target nodes for this app - the base function
549-
* will take any host or hostfile directive into account
550-
*/
551-
PMIX_CONSTRUCT(&nodes, pmix_list_t);
552-
rc = prte_rmaps_base_get_target_nodes(&nodes, &slots,
553-
jdata, app, jdata->map->mapping,
554-
true, true, false);
555-
if (PRTE_SUCCESS != rc) {
556-
PMIX_LIST_DESTRUCT(&nodes);
557-
jdata->exit_code = rc;
558-
PRTE_ACTIVATE_JOB_STATE(jdata, PRTE_JOB_STATE_MAP_FAILED);
559-
goto cleanup;
560-
}
561561
// compute the number of cpus on each node
562562
len = 0;
563563
PMIX_LIST_FOREACH (node, &nodes, prte_node_t) {
@@ -569,7 +569,6 @@ void prte_rmaps_base_map_job(int fd, short args, void *cbdata)
569569
HWLOC_OBJ_CORE) / options.cpus_per_rank;
570570
}
571571
}
572-
PMIX_LIST_DESTRUCT(&nodes);
573572
app->num_procs = len;
574573
// ensure we always wind up with at least one proc
575574
if (0 == app->num_procs) {
@@ -580,6 +579,7 @@ void prte_rmaps_base_map_job(int fd, short args, void *cbdata)
580579
} else {
581580
app->num_procs = slots;
582581
}
582+
PMIX_LIST_DESTRUCT(&nodes);
583583
}
584584
options.nprocs += app->num_procs;
585585
}

0 commit comments

Comments
 (0)