@@ -337,6 +337,7 @@ static opal_list_t *check_components(opal_list_t * components,
337
337
ompi_communicator_t * comm )
338
338
{
339
339
int priority , flag ;
340
+ int count_include = 0 ;
340
341
const mca_base_component_t * component ;
341
342
mca_base_component_list_item_t * cli ;
342
343
mca_coll_base_module_2_3_0_t * module ;
@@ -363,7 +364,8 @@ static opal_list_t *check_components(opal_list_t * components,
363
364
if (NULL == coll_argv ) {
364
365
goto proceed_to_select ;
365
366
}
366
- int idx2 , count_include = opal_argv_count (coll_argv );
367
+ int idx2 ;
368
+ count_include = opal_argv_count (coll_argv );
367
369
/* Allocate the coll_include argv */
368
370
coll_include = (char * * )malloc ((count_include + 1 ) * sizeof (char * ));
369
371
coll_include [count_include ] = NULL ; /* NULL terminated array */
@@ -385,15 +387,6 @@ static opal_list_t *check_components(opal_list_t * components,
385
387
}
386
388
coll_include [idx ] = coll_argv [idx ];
387
389
}
388
- /* Reverse the order of the coll_inclide argv to faciliate the ordering of
389
- * the selected components reverse.
390
- */
391
- for ( idx2 = 0 ; idx2 < (count_include - 1 ); idx2 ++ ) {
392
- char * temp = coll_include [idx2 ];
393
- coll_include [idx2 ] = coll_include [count_include - 1 ];
394
- coll_include [count_include - 1 ] = temp ;
395
- count_include -- ;
396
- }
397
390
}
398
391
proceed_to_select :
399
392
/* Make a list of the components that query successfully */
@@ -453,14 +446,17 @@ static opal_list_t *check_components(opal_list_t * components,
453
446
454
447
/* For all valid component reorder them not on their provided priorities but on
455
448
* the order requested in the info key. As at this point the coll_include is
456
- * already ordered backward we can simply prepend the components.
449
+ * already ordered backward we can simply append the components.
450
+ * Note that the last element in selectable will have the highest priorty.
457
451
*/
458
- mca_coll_base_avail_coll_t * item , * item_next ;
459
- OPAL_LIST_FOREACH_SAFE (item , item_next ,
460
- selectable , mca_coll_base_avail_coll_t ) {
461
- if ( component_in_argv (coll_include , item -> ac_component_name ) ) {
462
- opal_list_remove_item (selectable , & item -> super );
463
- opal_list_prepend (selectable , & item -> super );
452
+ for (int idx = count_include - 1 ; idx >= 0 ; -- idx ) {
453
+ mca_coll_base_avail_coll_t * item ;
454
+ OPAL_LIST_FOREACH (item , selectable , mca_coll_base_avail_coll_t ) {
455
+ if (0 == strcmp (item -> ac_component_name , coll_include [idx ])) {
456
+ opal_list_remove_item (selectable , & item -> super );
457
+ opal_list_append (selectable , & item -> super );
458
+ break ;
459
+ }
464
460
}
465
461
}
466
462
0 commit comments