From dd30902bdeebc6330f637a4dd36926586790e505 Mon Sep 17 00:00:00 2001 From: Jeff Squyres Date: Thu, 10 Feb 2005 04:15:16 +0000 Subject: [PATCH] Fix a few minor bugs in the coll selection logic -- at least one of which Torsten ran across last week and I was just now able to duplicate: - priority == 0 is still a valid priority - ensure to not compare against an empty list; if the list is empty, just put the selectable item on it without any comparisons - had wrong argument for ompi_list_get_next() (yay macros with no type checking :-( ) that caused badness in some cases This commit was SVN r4372. --- src/mca/coll/base/coll_base_comm_select.c | 40 +++++++++++++---------- 1 file changed, 23 insertions(+), 17 deletions(-) diff --git a/src/mca/coll/base/coll_base_comm_select.c b/src/mca/coll/base/coll_base_comm_select.c index a8a28a9e03..e206302fe9 100644 --- a/src/mca/coll/base/coll_base_comm_select.c +++ b/src/mca/coll/base/coll_base_comm_select.c @@ -354,7 +354,7 @@ static ompi_list_t *check_components(ompi_list_t *components, if (want_to_check) { priority = check_one_component(comm, component, &module, &data); - if (priority > 0) { + if (priority >= 0) { /* We have a component that indicated that it wants to run by giving us a module */ @@ -368,26 +368,32 @@ static ompi_list_t *check_components(ompi_list_t *components, /* Put this item on the list in priority order (highest priority first). Should it go first? */ - item2 = ompi_list_get_first(selectable); - avail2 = (avail_coll_t *) item2; - if (avail->ac_priority > avail2->ac_priority) { - ompi_list_prepend(selectable, (ompi_list_item_t *) avail); + if (ompi_list_is_empty(selectable)) { + ompi_list_prepend(selectable, (ompi_list_item_t *) avail); } else { - for (i = 1; item2 != ompi_list_get_end(selectable); - item2 = ompi_list_get_next(selectable), ++i) { + item2 = ompi_list_get_first(selectable); avail2 = (avail_coll_t *) item2; if (avail->ac_priority > avail2->ac_priority) { - ompi_list_insert(selectable, (ompi_list_item_t *) avail, i); - break; - } - } + ompi_list_prepend(selectable, (ompi_list_item_t *) avail); + } else { + for (i = 1; item2 != ompi_list_get_end(selectable); + item2 = ompi_list_get_next(item2), ++i) { + avail2 = (avail_coll_t *) item2; + if (avail->ac_priority > avail2->ac_priority) { + ompi_list_insert(selectable, + (ompi_list_item_t *) avail, i); + break; + } + } + + /* If we didn't find a place to put it in the list, then + append it (because it has the lowest priority found so + far) */ - /* If we didn't find a place to put it in the list, then - append it (because it has the lowest priority found so - far) */ - if (ompi_list_get_end(selectable) == item2) { - ompi_list_append(selectable, (ompi_list_item_t *) avail); - } + if (ompi_list_get_end(selectable) == item2) { + ompi_list_append(selectable, (ompi_list_item_t *) avail); + } + } } } }