Skip to content

Commit

Permalink
Try revised patch
Browse files Browse the repository at this point in the history
Signed-off-by: Ralph Castain <rhc@pmix.org>
  • Loading branch information
rhc54 committed Jul 19, 2022
1 parent dd63e2f commit 777ce03
Showing 1 changed file with 12 additions and 74 deletions.
86 changes: 12 additions & 74 deletions src/mca/rmaps/base/rmaps_base_support_fns.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit 777ce03

Please sign in to comment.