From 777ce03aaefd6d74d661cb8e5dba857bc4c82aa0 Mon Sep 17 00:00:00 2001 From: Ralph Castain Date: Tue, 19 Jul 2022 01:32:22 -0700 Subject: [PATCH] Try revised patch Signed-off-by: Ralph Castain --- src/mca/rmaps/base/rmaps_base_support_fns.c | 86 +++------------------ 1 file changed, 12 insertions(+), 74 deletions(-) diff --git a/src/mca/rmaps/base/rmaps_base_support_fns.c b/src/mca/rmaps/base/rmaps_base_support_fns.c index f93e59242d..a083f81dae 100644 --- a/src/mca/rmaps/base/rmaps_base_support_fns.c +++ b/src/mca/rmaps/base/rmaps_base_support_fns.c @@ -620,96 +620,34 @@ prte_proc_t *prte_rmaps_base_setup_proc(prte_job_t *jdata, */ void prte_rmaps_base_get_starting_point(pmix_list_t *node_list, prte_job_t *jdata) { - pmix_list_item_t *item, *cur_node_item; prte_node_t *node, *nd1, *ndmin; int overload; + bool first = true; /* if a bookmark exists from some prior mapping, set us to start there */ + node = NULL; if (NULL != jdata->bookmark) { - cur_node_item = NULL; /* find this node on the list */ - for (item = pmix_list_get_first(node_list); item != pmix_list_get_end(node_list); - item = pmix_list_get_next(item)) { - node = (prte_node_t *) item; - - if (node->index == jdata->bookmark->index) { - cur_node_item = item; + PMIX_LIST_FOREACH(nd1, node_list, prte_node_t) { + if (nd1->index == jdata->bookmark->index) { + node = nd1; break; } + first = false; } - /* see if we found it - if not, just start at the beginning */ - if (NULL == cur_node_item) { - cur_node_item = pmix_list_get_first(node_list); - } - } else { - /* if no bookmark, then just start at the beginning of the list */ - cur_node_item = pmix_list_get_first(node_list); } - - PRTE_OUTPUT_VERBOSE((5, prte_rmaps_base_framework.framework_output, - "%s Starting bookmark at node %s", PRTE_NAME_PRINT(PRTE_PROC_MY_NAME), - ((prte_node_t *) cur_node_item)->name)); - - /* is this node fully subscribed? If so, then the first - * proc we assign will oversubscribe it, so let's look - * for another candidate - */ - node = (prte_node_t *) cur_node_item; - ndmin = node; - overload = ndmin->slots_inuse - ndmin->slots; - if (node->slots_inuse >= node->slots) { - /* work down the list - is there another node that - * would not be oversubscribed? - */ - if (cur_node_item != pmix_list_get_last(node_list)) { - item = pmix_list_get_next(cur_node_item); - } else { - item = pmix_list_get_first(node_list); - } - nd1 = NULL; - while (item != cur_node_item) { - nd1 = (prte_node_t *) item; - if (nd1->slots_inuse < nd1->slots) { - /* this node is not oversubscribed! use it! */ - cur_node_item = item; - goto process; - } - /* this one was also oversubscribed, keep track of the - * node that has the least usage - if we can't - * find anyone who isn't fully utilized, we will - * start with the least used node - */ - if (overload >= (nd1->slots_inuse - nd1->slots)) { - ndmin = nd1; - overload = ndmin->slots_inuse - ndmin->slots; - } - if (item == pmix_list_get_last(node_list)) { - item = pmix_list_get_first(node_list); - } else { - item = pmix_list_get_next(item); - } - } - /* if we get here, then we cycled all the way around the - * list without finding a better answer - just use the node - * that is minimally overloaded if it is better than - * what we already have - */ - if (NULL != nd1 && (nd1->slots_inuse - nd1->slots) < (node->slots_inuse - node->slots)) { - cur_node_item = (pmix_list_item_t *) ndmin; - } + if (NULL == node || first) { + return; } -process: PRTE_OUTPUT_VERBOSE((5, prte_rmaps_base_framework.framework_output, - "%s Starting at node %s", + "%s Starting bookmark at node %s", PRTE_NAME_PRINT(PRTE_PROC_MY_NAME), - ((prte_node_t *) cur_node_item)->name)); + node->name)); /* put this node at the front of the list */ - if (pmix_list_get_first(node_list) != cur_node_item) { - pmix_list_remove_item(node_list, cur_node_item); - pmix_list_prepend(node_list, cur_node_item); - } + pmix_list_remove_item(node_list, &node->super); + pmix_list_prepend(node_list, &node->super); return; }