⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 rmaps_base_support_fns.c

📁 MPI stands for the Message Passing Interface. Written by the MPI Forum (a large committee comprising
💻 C
📖 第 1 页 / 共 2 页
字号:
/* * Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana *                         University Research and Technology *                         Corporation.  All rights reserved. * Copyright (c) 2004-2005 The University of Tennessee and The University *                         of Tennessee Research Foundation.  All rights *                         reserved. * Copyright (c) 2004-2005 High Performance Computing Center Stuttgart, *                         University of Stuttgart.  All rights reserved. * Copyright (c) 2004-2005 The Regents of the University of California. *                         All rights reserved. * $COPYRIGHT$ * * Additional copyrights may follow * * $HEADER$ */#include "orte_config.h"#include "orte/orte_constants.h"#include <string.h>#include "opal/util/output.h"#include "opal/util/argv.h"#include "opal/mca/mca.h"#include "opal/mca/base/base.h"#include "opal/mca/base/mca_base_param.h"#include "opal/util/if.h"#include "opal/util/show_help.h"#include "orte/util/sys_info.h"#include "orte/mca/errmgr/errmgr.h"#include "orte/mca/smr/smr_types.h"#include "orte/mca/ras/ras.h"#include "orte/mca/gpr/gpr.h"#include "orte/mca/ns/ns.h"#include "orte/mca/rmaps/base/rmaps_private.h"#include "orte/mca/rmaps/base/base.h"/* * A sanity check to ensure that all of the requested nodes are actually * allocated to this application. */static bool are_all_mapped_valid(char **mapping,                                 int num_mapped,                                 opal_list_t* nodes){    opal_list_item_t *item;    orte_ras_node_t *node;    int i;    bool matched;        for (i = 0; i < num_mapped; ++i) {        matched = false;                for(item  = opal_list_get_first(nodes);            item != opal_list_get_end(nodes);            item  = opal_list_get_next(item) ) {            node = (orte_ras_node_t*) item;            if( 0 == strcmp(node->node_name, mapping[i]) ) {                matched = true;                break;            }        }                /* If we find one requested resource that is not allocated,             * then return an error */        if(!matched) {            return false;        }    }        return true;}/* * If the node in question is in the current mapping. */static bool is_mapped(opal_list_item_t *item,                       char **mapping,                       int num_mapped) {    int i;        for ( i = 0; i < num_mapped; ++i) {        if ( 0 == strcmp( ((orte_ras_node_t*) item)->node_name, mapping[i])){            return true;        }    }        return false;}/* * Query the registry for all nodes allocated to a specified job */int orte_rmaps_base_get_target_nodes(opal_list_t *allocated_nodes, orte_jobid_t jobid, orte_std_cntr_t *total_num_slots, bool nolocal){    opal_list_item_t *item, *next;    orte_ras_node_t *node;    int rc;    size_t nodelist_size;    orte_std_cntr_t num_slots=0;    /** set default answer */    *total_num_slots = 0;        /* get the allocation for this job */    if(ORTE_SUCCESS != (rc = orte_ras.node_query_alloc(allocated_nodes, jobid))) {        ORTE_ERROR_LOG(rc);        return rc;    }    nodelist_size = opal_list_get_size(allocated_nodes);    /* If the "no local" option was set, then remove the local node        from the list */    if (nolocal) {        for (item  = opal_list_get_first(allocated_nodes);             item != opal_list_get_end(allocated_nodes);             item  = opal_list_get_next(item) ) {            node = (orte_ras_node_t*)item;            if (0 == strcmp(node->node_name, orte_system_info.nodename) ||                opal_ifislocal(node->node_name)) {                opal_list_remove_item(allocated_nodes, item);                break;            }        }    }    /** remove all nodes that are already at max usage */    item  = opal_list_get_first(allocated_nodes);    while (item != opal_list_get_end(allocated_nodes)) {        /** save the next pointer in case we remove this node */        next  = opal_list_get_next(item);        /** check to see if this node is fully used - remove if so */        node = (orte_ras_node_t*)item;        if (0 != node->node_slots_max && node->node_slots_inuse > node->node_slots_max) {            opal_list_remove_item(allocated_nodes, item);        } else { /** otherwise, add the slots for our job to the total */            num_slots += node->node_slots;        }        /** go on to next item */        item = next;    }    /* Sanity check to make sure we have resources available */    if (0 == opal_list_get_size(allocated_nodes)) {        /* so there are 3 reasons we could be erroring here:         * 1. There were no nodes allocated to this job          * 2. The local node was the only one available and nolocal was passed          * 3. All the nodes were full */        if(0 == nodelist_size) {            opal_show_help("help-orte-rmaps-base.txt",                            "orte-rmaps-base:no-available-resources", true);        } else if(nolocal) {            opal_show_help("help-orte-rmaps-base.txt",                            "orte-rmaps-base:nolocal-no-available-resources", true);        } else {            opal_show_help("help-orte-rmaps-base.txt",                            "orte-rmaps-base:all-available-resources-used", true);        }        ORTE_ERROR_LOG(ORTE_ERR_TEMP_OUT_OF_RESOURCE);        return ORTE_ERR_TEMP_OUT_OF_RESOURCE;    }        *total_num_slots = num_slots;        return ORTE_SUCCESS;}/* * Create a sub-list of nodes to be used for user-specified mappings */int orte_rmaps_base_get_mapped_targets(opal_list_t *mapped_node_list,                                       orte_app_context_t *app,                                       opal_list_t *master_node_list,                                       orte_std_cntr_t *total_num_slots){    orte_app_context_map_t** loc_map = app->map_data;    opal_list_item_t *item;    orte_ras_node_t *node, *new_node;    char **mapped_nodes = NULL;    int num_mapped_nodes = 0;    orte_std_cntr_t j, k, num_slots=0;    int rc;        /** set default answer */    *total_num_slots = 0;        /* Accumulate all of the host name mappings */    for(k = 0; k < app->num_map; ++k) {        if ( ORTE_APP_CONTEXT_MAP_HOSTNAME == loc_map[k]->map_type ) {            if(mapped_nodes == NULL) {                mapped_nodes     = opal_argv_split(loc_map[k]->map_data, ',');                num_mapped_nodes = opal_argv_count(mapped_nodes);            }            else { /* Append to the existing mapping */                char ** mini_map    = opal_argv_split(loc_map[k]->map_data, ',');                orte_std_cntr_t mini_num_map = opal_argv_count(mini_map);                for (j = 0; j < mini_num_map; ++j) {                    rc = opal_argv_append(&num_mapped_nodes, &mapped_nodes, mini_map[j]);                    if (OPAL_SUCCESS != rc) {                        ORTE_ERROR_LOG(rc);                        return rc;                    }                }                opal_argv_free(mini_map);            }        }    }    /** check to see that all the nodes in the specified mapping have been allocated     * for our use - if not, then that's an error     */    if( !are_all_mapped_valid(mapped_nodes, num_mapped_nodes, master_node_list) ) {        opal_show_help("help-orte-rmaps-base.txt", "orte-rmaps-base:not-all-mapped-alloc",                       true, app->app, opal_argv_join(mapped_nodes, ','));        ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -