src/mca/rmaps/base/rmaps_base_support_fns.c
/*
 * determine the proper starting point for the next mapping operation
 */
determine the proper starting point for the next mapping operation
determine the proper starting point for the next mapping operation
prte_node_t *prte_rmaps_base_get_starting_point(prte_list_t *node_list, prte_job_t *jdata)
{
    prte_list_item_t *item, *cur_node_item;
    prte_node_t *node, *nd1, *ndmin;
    int overload;
    if (NULL != jdata->bookmark) {
        cur_node_item = NULL;
        for (item = prte_list_get_first(node_list); item != prte_list_get_end(node_list);
             item = prte_list_get_next(item)) {
            node = (prte_node_t *) item;
            if (node->index == jdata->bookmark->index) {
                cur_node_item = item;
                break;
            }
        }
        if (NULL == cur_node_item) {
            cur_node_item = prte_list_get_first(node_list);
        }
    } else {
        cur_node_item = prte_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));
    node = (prte_node_t *) cur_node_item;
    ndmin = node;
    overload = ndmin->slots_inuse - ndmin->slots;
    if (node->slots_inuse >= node->slots) {
        if (cur_node_item != prte_list_get_last(node_list)) {
            item = prte_list_get_next(cur_node_item);
        } else {
            item = prte_list_get_first(node_list);
        }
        nd1 = NULL;
        while (item != cur_node_item) {
            nd1 = (prte_node_t *) item;
            if (nd1->slots_inuse < nd1->slots) {
                cur_node_item = item;
                goto process;
            }
            if (overload >= (nd1->slots_inuse - nd1->slots)) {
                ndmin = nd1;
                overload = ndmin->slots_inuse - ndmin->slots;
            }
            if (item == prte_list_get_last(node_list)) {
                item = prte_list_get_first(node_list);
            } else {
                item = prte_list_get_next(item);
            }
        }
        if (NULL != nd1 && (nd1->slots_inuse - nd1->slots) < (node->slots_inuse - node->slots)) {
            cur_node_item = (prte_list_item_t *) ndmin;
        }
    }
process:
    PRTE_OUTPUT_VERBOSE((5, prte_rmaps_base_framework.framework_output, "%s Starting at node %s",
                         PRTE_NAME_PRINT(PRTE_PROC_MY_NAME),
                         ((prte_node_t *) cur_node_item)->name));
    return (prte_node_t *) cur_node_item;
}
prte_node_t * prte_rmaps_base_get_starting_point ( prte_list_t * node_list , prte_job_t * jdata ) { prte_list_item_t * item , * cur_node_item ; prte_node_t * node , * nd1 , * ndmin ; int overload ; if ( NULL != jdata -> bookmark ) { cur_node_item = NULL ; for ( item = prte_list_get_first ( node_list ) ; item != prte_list_get_end ( node_list ) ; item = prte_list_get_next ( item ) ) { node = ( prte_node_t * ) item ; if ( node -> index == jdata -> bookmark -> index ) { cur_node_item = item ; break ; } } if ( NULL == cur_node_item ) { cur_node_item = prte_list_get_first ( node_list ) ; } } else { cur_node_item = prte_list_get_first ( node_list ) ; } PRTE_OUTPUT_VERBOSE ( ( 5 , prte_rmaps_base_framework . framework_output , " " , PRTE_NAME_PRINT ( PRTE_PROC_MY_NAME ) , ( ( prte_node_t * ) cur_node_item ) -> name ) ) ; node = ( prte_node_t * ) cur_node_item ; ndmin = node ; overload = ndmin -> slots_inuse - ndmin -> slots ; if ( node -> slots_inuse >= node -> slots ) { if ( cur_node_item != prte_list_get_last ( node_list ) ) { item = prte_list_get_next ( cur_node_item ) ; } else { item = prte_list_get_first ( node_list ) ; } nd1 = NULL ; while ( item != cur_node_item ) { nd1 = ( prte_node_t * ) item ; if ( nd1 -> slots_inuse < nd1 -> slots ) { cur_node_item = item ; goto process ; } if ( overload >= ( nd1 -> slots_inuse - nd1 -> slots ) ) { ndmin = nd1 ; overload = ndmin -> slots_inuse - ndmin -> slots ; } if ( item == prte_list_get_last ( node_list ) ) { item = prte_list_get_first ( node_list ) ; } else { item = prte_list_get_next ( item ) ; } } if ( NULL != nd1 && ( nd1 -> slots_inuse - nd1 -> slots ) < ( node -> slots_inuse - node -> slots ) ) { cur_node_item = ( prte_list_item_t * ) ndmin ; } } process : PRTE_OUTPUT_VERBOSE ( ( 5 , prte_rmaps_base_framework . framework_output , " " , PRTE_NAME_PRINT ( PRTE_PROC_MY_NAME ) , ( ( prte_node_t * ) cur_node_item ) -> name ) ) ; return ( prte_node_t * ) cur_node_item ; }
determine the proper starting point for the next mapping operation
determine the proper starting point for the next mapping operation
/* if a bookmark exists from some prior mapping, set us to start there */ /* find this node on the list */ /* see if we found it - if not, just start at the beginning */ /* if no bookmark, then just start at the beginning of the list */ /* is this node fully subscribed? If so, then the first
     * proc we assign will oversubscribe it, so let's look
     * for another candidate
     */ /* work down the list - is there another node that
         * would not be oversubscribed?
         */ /* this node is not oversubscribed! use it! */ /* 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 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
         */