Skip to content

Commit 7762c21

Browse files
Merge pull request #3006 from rhc54/topic/lid
Support -host launch_id
2 parents 95bfc7b + bf0f274 commit 7762c21

File tree

1 file changed

+30
-10
lines changed

1 file changed

+30
-10
lines changed

orte/util/dash_host/dash_host.c

Lines changed: 30 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ int orte_util_add_dash_host_nodes(opal_list_t *nodes,
5858
bool found;
5959
int slots=0;
6060
bool slots_given;
61-
char *cptr;
61+
char *cptr, *ptr;
6262

6363
OPAL_OUTPUT_VERBOSE((1, orte_ras_base_framework.framework_output,
6464
"%s dashhost: parsing args %s",
@@ -213,12 +213,14 @@ int orte_util_add_dash_host_nodes(opal_list_t *nodes,
213213

214214
// Strip off the FQDN if present, ignore IP addresses
215215
if( !orte_keep_fqdn_hostnames && !opal_net_isaddr(ndname) ) {
216-
char *ptr;
217216
if (NULL != (ptr = strchr(ndname, '.'))) {
218217
*ptr = '\0';
219218
}
220219
}
221-
220+
/* remove any modifier */
221+
if (NULL != (ptr = strchr(ndname, ':'))) {
222+
*ptr = '\0';
223+
}
222224
/* see if the node is already on the list */
223225
found = false;
224226
OPAL_LIST_FOREACH(node, &adds, orte_node_t) {
@@ -422,13 +424,14 @@ int orte_util_filter_dash_host_nodes(opal_list_t *nodes,
422424
opal_list_item_t* item;
423425
opal_list_item_t *next;
424426
orte_std_cntr_t i, j, len_mapped_node=0;
425-
int rc;
427+
int rc, test;
426428
char **mapped_nodes = NULL;
427429
orte_node_t *node;
428430
int num_empty=0;
429431
opal_list_t keep;
430432
bool want_all_empty=false;
431433
char *cptr;
434+
size_t lst, lmn;
432435

433436
/* if the incoming node list is empty, then there
434437
* is nothing to filter!
@@ -505,19 +508,36 @@ int orte_util_filter_dash_host_nodes(opal_list_t *nodes,
505508
item = next;
506509
}
507510
} else {
511+
/* remove any modifier */
512+
if (NULL != (cptr = strchr(mapped_nodes[i], ':'))) {
513+
*cptr = '\0';
514+
}
508515
/* we are looking for a specific node on the list. The
509516
* parser will have substituted our local name for any
510-
* alias, so we only have to do a strcmp here */
517+
* alias, so we only have to do a strcmp here. */
518+
lmn = strtol(mapped_nodes[i], &cptr, 10);
519+
if (orte_managed_allocation && NULL != cptr) {
520+
/* if we are only given a number, then we only test the
521+
* number of matching characters starting from the rear
522+
* of the mapped_nodes entry. This allows support for
523+
* launch_id-based environments. For example, a hostname
524+
* of "nid0015" can be referenced by "--host 15" */
525+
lmn = strlen(mapped_nodes[i]);
526+
} else {
527+
lmn = 0;
528+
}
511529
item = opal_list_get_first(nodes);
512530
while (item != opal_list_get_end(nodes)) {
513531
next = opal_list_get_next(item); /* save this position */
514532
node = (orte_node_t*)item;
515-
/* remove any modifier */
516-
if (NULL != (cptr = strchr(mapped_nodes[i], ':'))) {
517-
*cptr = '\0';
518-
}
519533
/* search -host list to see if this one is found */
520-
if (0 == strcmp(node->name, mapped_nodes[i])) {
534+
if (0 < lmn) {
535+
lst = strlen(node->name);
536+
test = strncmp(node->name + lst - lmn, mapped_nodes[i], lmn);
537+
} else {
538+
test = strcmp(node->name, mapped_nodes[i]);
539+
}
540+
if (0 == test) {
521541
if (remove) {
522542
/* remove item from list */
523543
opal_list_remove_item(nodes, item);

0 commit comments

Comments
 (0)