Skip to content

Commit 58130c6

Browse files
committed
Fix relative node processing
The empty nodes were not properly being added to the list of names to be used by the mapper. Signed-off-by: Ralph Castain <rhc@pmix.org>
1 parent cb17cce commit 58130c6

File tree

2 files changed

+39
-5
lines changed

2 files changed

+39
-5
lines changed

src/util/dash_host/dash_host.c

Lines changed: 36 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -450,14 +450,19 @@ int prte_util_add_dash_host_nodes(pmix_list_t *nodes, char *hosts, bool allocati
450450
*/
451451
static int parse_dash_host(char ***mapped_nodes, char *hosts)
452452
{
453-
int32_t j, k;
453+
int32_t j, k, start;
454454
int rc = PRTE_SUCCESS;
455455
char **mini_map = NULL, *cptr;
456-
int nodeidx;
456+
int nodeidx, nnodes, p;
457457
prte_node_t *node;
458458
char **host_argv = NULL;
459459

460460
host_argv = PMIX_ARGV_SPLIT_COMPAT(hosts, ',');
461+
if (prte_hnp_is_allocated) {
462+
start = 0;
463+
} else {
464+
start = 1;
465+
}
461466

462467
/* Accumulate all of the host name mappings */
463468
for (j = 0; j < PMIX_ARGV_COUNT_COMPAT(host_argv); ++j) {
@@ -472,8 +477,35 @@ static int parse_dash_host(char ***mapped_nodes, char *hosts)
472477
*/
473478
if (NULL != (cptr = strchr(mini_map[k], ':'))) {
474479
/* the colon indicates a specific # are requested */
475-
*cptr = '*';
476-
PMIX_ARGV_APPEND_NOSIZE_COMPAT(mapped_nodes, cptr);
480+
++cptr;
481+
if (NULL == cptr) {
482+
// missing number of nodes being requested
483+
pmix_show_help("help-dash-host.txt",
484+
"dash-host:invalid-relative-node-syntax", true,
485+
mini_map[k]);
486+
rc = PRTE_ERR_SILENT;
487+
goto cleanup;
488+
}
489+
nnodes = strtol(cptr, NULL, 10);
490+
for (j=start, p=0; j < (int32_t)prte_node_pool->size && p < nnodes; j++) {
491+
node = (prte_node_t *) pmix_pointer_array_get_item(prte_node_pool, j);
492+
if (NULL == node) {
493+
continue;
494+
}
495+
// if the node is empty, capture it
496+
if (0 == node->num_procs) {
497+
PMIX_ARGV_APPEND_NOSIZE_COMPAT(mapped_nodes, node->name);
498+
++p;
499+
}
500+
}
501+
if (p < nnodes) {
502+
// not enough empty nodes
503+
pmix_show_help("help-dash-host.txt",
504+
"dash-host:not-enough-empty", true,
505+
nnodes-p);
506+
rc = PRTE_ERR_SILENT;
507+
goto cleanup;
508+
}
477509
} else {
478510
/* add a marker to the list */
479511
PMIX_ARGV_APPEND_NOSIZE_COMPAT(mapped_nodes, "*");

src/util/dash_host/help-dash-host.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,9 @@ A relative host was improperly specified — the value provided was.
4848
--host: %s
4949

5050
You may have forgotten to preface a node with "N" or "n", or used the
51-
"e" or "E" to indicate empty nodes.
51+
"e" or "E" to indicate empty nodes, or you ended the value with a
52+
colon but forgot to include the number of empty nodes you were
53+
requesting.
5254

5355
Re-run this command with "--help hosts" for further information.
5456
#

0 commit comments

Comments
 (0)