Skip to content

Commit dd54af9

Browse files
committed
coll/base: Fix collective module selection preference treatment
The selectable list is sorted with lowest to highest priority so the user-defined preferences should be appended to the list. The preference treatment should also maintain the order provided by the user (first item has highest priority) so switch the loop order. Signed-off-by: Joseph Schuchart <[email protected]>
1 parent 282be20 commit dd54af9

File tree

1 file changed

+13
-17
lines changed

1 file changed

+13
-17
lines changed

ompi/mca/coll/base/coll_base_comm_select.c

Lines changed: 13 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -337,6 +337,7 @@ static opal_list_t *check_components(opal_list_t * components,
337337
ompi_communicator_t * comm)
338338
{
339339
int priority, flag;
340+
int count_include = 0;
340341
const mca_base_component_t *component;
341342
mca_base_component_list_item_t *cli;
342343
mca_coll_base_module_2_3_0_t *module;
@@ -363,7 +364,8 @@ static opal_list_t *check_components(opal_list_t * components,
363364
if(NULL == coll_argv) {
364365
goto proceed_to_select;
365366
}
366-
int idx2, count_include = opal_argv_count(coll_argv);
367+
int idx2;
368+
count_include = opal_argv_count(coll_argv);
367369
/* Allocate the coll_include argv */
368370
coll_include = (char**)malloc((count_include + 1) * sizeof(char*));
369371
coll_include[count_include] = NULL; /* NULL terminated array */
@@ -385,15 +387,6 @@ static opal_list_t *check_components(opal_list_t * components,
385387
}
386388
coll_include[idx] = coll_argv[idx];
387389
}
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-
}
397390
}
398391
proceed_to_select:
399392
/* Make a list of the components that query successfully */
@@ -453,14 +446,17 @@ static opal_list_t *check_components(opal_list_t * components,
453446

454447
/* For all valid component reorder them not on their provided priorities but on
455448
* 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.
457451
*/
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+
}
464460
}
465461
}
466462

0 commit comments

Comments
 (0)