@@ -58,7 +58,7 @@ int orte_util_add_dash_host_nodes(opal_list_t *nodes,
58
58
bool found ;
59
59
int slots = 0 ;
60
60
bool slots_given ;
61
- char * cptr ;
61
+ char * cptr , * ptr ;
62
62
63
63
OPAL_OUTPUT_VERBOSE ((1 , orte_ras_base_framework .framework_output ,
64
64
"%s dashhost: parsing args %s" ,
@@ -213,12 +213,14 @@ int orte_util_add_dash_host_nodes(opal_list_t *nodes,
213
213
214
214
// Strip off the FQDN if present, ignore IP addresses
215
215
if ( !orte_keep_fqdn_hostnames && !opal_net_isaddr (ndname ) ) {
216
- char * ptr ;
217
216
if (NULL != (ptr = strchr (ndname , '.' ))) {
218
217
* ptr = '\0' ;
219
218
}
220
219
}
221
-
220
+ /* remove any modifier */
221
+ if (NULL != (ptr = strchr (ndname , ':' ))) {
222
+ * ptr = '\0' ;
223
+ }
222
224
/* see if the node is already on the list */
223
225
found = false;
224
226
OPAL_LIST_FOREACH (node , & adds , orte_node_t ) {
@@ -422,13 +424,14 @@ int orte_util_filter_dash_host_nodes(opal_list_t *nodes,
422
424
opal_list_item_t * item ;
423
425
opal_list_item_t * next ;
424
426
orte_std_cntr_t i , j , len_mapped_node = 0 ;
425
- int rc ;
427
+ int rc , test ;
426
428
char * * mapped_nodes = NULL ;
427
429
orte_node_t * node ;
428
430
int num_empty = 0 ;
429
431
opal_list_t keep ;
430
432
bool want_all_empty = false;
431
433
char * cptr ;
434
+ size_t lst , lmn ;
432
435
433
436
/* if the incoming node list is empty, then there
434
437
* is nothing to filter!
@@ -505,19 +508,36 @@ int orte_util_filter_dash_host_nodes(opal_list_t *nodes,
505
508
item = next ;
506
509
}
507
510
} else {
511
+ /* remove any modifier */
512
+ if (NULL != (cptr = strchr (mapped_nodes [i ], ':' ))) {
513
+ * cptr = '\0' ;
514
+ }
508
515
/* we are looking for a specific node on the list. The
509
516
* 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
+ }
511
529
item = opal_list_get_first (nodes );
512
530
while (item != opal_list_get_end (nodes )) {
513
531
next = opal_list_get_next (item ); /* save this position */
514
532
node = (orte_node_t * )item ;
515
- /* remove any modifier */
516
- if (NULL != (cptr = strchr (mapped_nodes [i ], ':' ))) {
517
- * cptr = '\0' ;
518
- }
519
533
/* 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 ) {
521
541
if (remove ) {
522
542
/* remove item from list */
523
543
opal_list_remove_item (nodes , item );
0 commit comments