2005-03-14 20:57:21 +00:00
|
|
|
/*
|
2005-11-05 19:57:48 +00:00
|
|
|
* Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
|
|
|
|
* University Research and Technology
|
|
|
|
* Corporation. All rights reserved.
|
2008-02-28 05:32:23 +00:00
|
|
|
* Copyright (c) 2004-2008 The University of Tennessee and The University
|
2005-11-05 19:57:48 +00:00
|
|
|
* of Tennessee Research Foundation. All rights
|
|
|
|
* reserved.
|
2006-02-07 03:32:36 +00:00
|
|
|
* Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
|
2005-03-14 20:57:21 +00:00
|
|
|
* University of Stuttgart. All rights reserved.
|
2005-03-24 12:43:37 +00:00
|
|
|
* Copyright (c) 2004-2005 The Regents of the University of California.
|
|
|
|
* All rights reserved.
|
2012-12-14 17:00:44 +00:00
|
|
|
* Copyright (c) 2011-2012 Los Alamos National Security, LLC. All rights
|
2012-04-06 14:23:13 +00:00
|
|
|
* reserved.
|
2005-03-14 20:57:21 +00:00
|
|
|
* $COPYRIGHT$
|
2006-02-07 03:32:36 +00:00
|
|
|
*
|
2005-03-14 20:57:21 +00:00
|
|
|
* Additional copyrights may follow
|
2006-02-07 03:32:36 +00:00
|
|
|
*
|
2005-03-14 20:57:21 +00:00
|
|
|
* $HEADER$
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "orte_config.h"
|
2008-02-28 01:57:57 +00:00
|
|
|
#include "orte/constants.h"
|
2005-03-14 20:57:21 +00:00
|
|
|
|
2005-03-29 13:50:15 +00:00
|
|
|
#include <string.h>
|
|
|
|
|
2005-09-20 13:32:08 +00:00
|
|
|
#include "opal/util/argv.h"
|
2008-04-23 14:52:09 +00:00
|
|
|
#include "opal/util/if.h"
|
2005-05-25 16:23:13 +00:00
|
|
|
|
2006-02-12 01:33:29 +00:00
|
|
|
#include "orte/mca/errmgr/errmgr.h"
|
2008-02-28 01:57:57 +00:00
|
|
|
#include "orte/util/name_fns.h"
|
|
|
|
#include "orte/runtime/orte_globals.h"
|
2007-07-02 16:45:40 +00:00
|
|
|
|
2006-09-14 21:29:51 +00:00
|
|
|
#include "orte/mca/ras/base/ras_private.h"
|
2005-03-14 20:57:21 +00:00
|
|
|
|
2007-07-14 15:14:07 +00:00
|
|
|
static void orte_ras_base_proc_construct(orte_ras_proc_t* proc)
|
|
|
|
{
|
|
|
|
proc->node_name = NULL;
|
|
|
|
proc->cpu_list = NULL;
|
|
|
|
proc->rank = ORTE_VPID_MAX;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void orte_ras_base_proc_destruct(orte_ras_proc_t* proc)
|
|
|
|
{
|
|
|
|
if (NULL != proc->node_name) {
|
|
|
|
free(proc->node_name);
|
|
|
|
}
|
|
|
|
if (NULL != proc->cpu_list) {
|
|
|
|
free(proc->cpu_list);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
OBJ_CLASS_INSTANCE(
|
|
|
|
orte_ras_proc_t,
|
|
|
|
opal_list_item_t,
|
|
|
|
orte_ras_base_proc_construct,
|
|
|
|
orte_ras_base_proc_destruct);
|
|
|
|
|
2005-03-14 20:57:21 +00:00
|
|
|
|
2008-02-28 01:57:57 +00:00
|
|
|
/*
|
|
|
|
* Add the specified node definitions to the global data store
|
|
|
|
* NOTE: this removes all items from the list!
|
|
|
|
*/
|
|
|
|
int orte_ras_base_node_insert(opal_list_t* nodes, orte_job_t *jdata)
|
|
|
|
{
|
|
|
|
opal_list_item_t* item;
|
|
|
|
orte_std_cntr_t num_nodes;
|
2009-01-15 18:11:50 +00:00
|
|
|
int rc, i;
|
2008-02-28 01:57:57 +00:00
|
|
|
orte_node_t *node, *hnp_node;
|
2011-12-01 14:24:43 +00:00
|
|
|
char *ptr;
|
2012-08-31 21:28:49 +00:00
|
|
|
bool hnp_alone = true;
|
2008-02-28 01:57:57 +00:00
|
|
|
|
|
|
|
/* get the number of nodes */
|
|
|
|
num_nodes = (orte_std_cntr_t)opal_list_get_size(nodes);
|
|
|
|
if (0 == num_nodes) {
|
|
|
|
return ORTE_SUCCESS; /* nothing to do */
|
|
|
|
}
|
|
|
|
|
2013-03-27 21:14:43 +00:00
|
|
|
OPAL_OUTPUT_VERBOSE((5, orte_ras_base_framework.framework_output,
|
2008-02-28 01:57:57 +00:00
|
|
|
"%s ras:base:node_insert inserting %ld nodes",
|
2009-03-05 21:50:47 +00:00
|
|
|
ORTE_NAME_PRINT(ORTE_PROC_MY_NAME),
|
2008-02-28 01:57:57 +00:00
|
|
|
(long)num_nodes));
|
|
|
|
|
|
|
|
/* set the size of the global array - this helps minimize time
|
|
|
|
* spent doing realloc's
|
|
|
|
*/
|
2008-02-28 05:32:23 +00:00
|
|
|
if (ORTE_SUCCESS != (rc = opal_pointer_array_set_size(orte_node_pool, num_nodes))) {
|
2008-02-28 01:57:57 +00:00
|
|
|
ORTE_ERROR_LOG(rc);
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* get the hnp node's info */
|
2010-07-19 18:30:04 +00:00
|
|
|
hnp_node = (orte_node_t*)opal_pointer_array_get_item(orte_node_pool, 0);
|
2012-12-14 17:00:44 +00:00
|
|
|
|
2008-02-28 01:57:57 +00:00
|
|
|
/* cycle through the list */
|
|
|
|
while (NULL != (item = opal_list_remove_first(nodes))) {
|
|
|
|
node = (orte_node_t*)item;
|
|
|
|
|
|
|
|
/* the HNP had to already enter its node on the array - that entry is in the
|
|
|
|
* first position since it is the first one entered. We need to check to see
|
|
|
|
* if this node is the same as the HNP's node so we don't double-enter it
|
|
|
|
*/
|
2010-07-19 18:30:04 +00:00
|
|
|
if (NULL != hnp_node &&
|
2012-08-31 21:28:49 +00:00
|
|
|
(0 == strcmp(node->name, hnp_node->name) ||
|
|
|
|
0 == strcmp(node->name, "localhost") ||
|
|
|
|
opal_ifislocal(node->name))) {
|
2013-03-27 21:14:43 +00:00
|
|
|
OPAL_OUTPUT_VERBOSE((5, orte_ras_base_framework.framework_output,
|
2012-08-31 21:28:49 +00:00
|
|
|
"%s ras:base:node_insert updating HNP [%s] info to %ld slots",
|
2009-03-05 21:50:47 +00:00
|
|
|
ORTE_NAME_PRINT(ORTE_PROC_MY_NAME),
|
2012-08-31 21:28:49 +00:00
|
|
|
node->name,
|
2008-02-28 01:57:57 +00:00
|
|
|
(long)node->slots));
|
2012-12-14 17:00:44 +00:00
|
|
|
|
2008-07-25 17:13:22 +00:00
|
|
|
/* flag that hnp has been allocated */
|
|
|
|
orte_hnp_is_allocated = true;
|
2012-12-14 17:00:44 +00:00
|
|
|
/* update the total slots in the job */
|
|
|
|
orte_ras_base.total_slots_alloc += node->slots;
|
2008-02-28 01:57:57 +00:00
|
|
|
/* copy the allocation data to that node's info */
|
2012-12-14 17:00:44 +00:00
|
|
|
hnp_node->slots += node->slots;
|
2008-02-28 01:57:57 +00:00
|
|
|
hnp_node->slots_max = node->slots_max;
|
|
|
|
hnp_node->launch_id = node->launch_id;
|
2012-09-07 04:08:17 +00:00
|
|
|
if (orte_managed_allocation) {
|
|
|
|
/* the slots are always treated as sacred
|
|
|
|
* in managed allocations
|
|
|
|
*/
|
|
|
|
hnp_node->slots_given = true;
|
|
|
|
} else {
|
|
|
|
/* in unmanaged allocations, take whatever
|
|
|
|
* was determined by the hostfile or dash-host
|
|
|
|
* parsers
|
|
|
|
*/
|
|
|
|
hnp_node->slots_given = node->slots_given;
|
|
|
|
}
|
2008-04-23 17:00:35 +00:00
|
|
|
/* use the local name for our node - don't trust what
|
2009-01-15 18:11:50 +00:00
|
|
|
* we got from an RM. If requested, store the resolved
|
2008-11-24 19:57:08 +00:00
|
|
|
* nodename info
|
2008-04-23 17:00:35 +00:00
|
|
|
*/
|
2009-01-15 18:11:50 +00:00
|
|
|
if (orte_show_resolved_nodenames) {
|
|
|
|
/* if the node name is different, store it as an alias */
|
|
|
|
if (0 != strcmp(node->name, hnp_node->name)) {
|
|
|
|
/* add to list of aliases for this node - only add if unique */
|
2009-04-14 14:15:49 +00:00
|
|
|
opal_argv_append_unique_nosize(&hnp_node->alias, node->name, false);
|
2009-01-15 18:11:50 +00:00
|
|
|
}
|
|
|
|
if (NULL != node->alias) {
|
|
|
|
/* now copy over any aliases that are unique */
|
|
|
|
for (i=0; NULL != node->alias[i]; i++) {
|
2009-04-14 14:15:49 +00:00
|
|
|
opal_argv_append_unique_nosize(&hnp_node->alias, node->alias[i], false);
|
2009-01-15 18:11:50 +00:00
|
|
|
}
|
2008-11-24 19:57:08 +00:00
|
|
|
}
|
|
|
|
}
|
2008-02-28 01:57:57 +00:00
|
|
|
/* don't keep duplicate copy */
|
|
|
|
OBJ_RELEASE(node);
|
|
|
|
} else {
|
|
|
|
/* insert the object onto the orte_nodes global array */
|
2013-03-27 21:14:43 +00:00
|
|
|
OPAL_OUTPUT_VERBOSE((5, orte_ras_base_framework.framework_output,
|
2014-01-02 16:07:16 +00:00
|
|
|
"%s ras:base:node_insert node %s slots %d",
|
2009-03-05 21:50:47 +00:00
|
|
|
ORTE_NAME_PRINT(ORTE_PROC_MY_NAME),
|
2014-01-02 16:07:16 +00:00
|
|
|
(NULL == node->name) ? "NULL" : node->name,
|
|
|
|
node->slots));
|
2012-09-07 04:08:17 +00:00
|
|
|
if (orte_managed_allocation) {
|
|
|
|
/* the slots are always treated as sacred
|
|
|
|
* in managed allocations
|
|
|
|
*/
|
|
|
|
node->slots_given = true;
|
|
|
|
}
|
2008-07-25 13:35:12 +00:00
|
|
|
/* insert it into the array */
|
2008-02-28 05:32:23 +00:00
|
|
|
node->index = opal_pointer_array_add(orte_node_pool, (void*)node);
|
|
|
|
if (ORTE_SUCCESS > (rc = node->index)) {
|
2008-02-28 01:57:57 +00:00
|
|
|
ORTE_ERROR_LOG(rc);
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
/* update the total slots in the job */
|
2012-09-20 02:50:14 +00:00
|
|
|
orte_ras_base.total_slots_alloc += node->slots;
|
2011-12-01 14:24:43 +00:00
|
|
|
/* check if we have fqdn names in the allocation */
|
|
|
|
if (NULL != strchr(node->name, '.')) {
|
|
|
|
orte_have_fqdn_allocation = true;
|
|
|
|
}
|
2012-08-31 21:28:49 +00:00
|
|
|
/* indicate the HNP is not alone */
|
|
|
|
hnp_alone = false;
|
2011-12-01 14:24:43 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* if we didn't find any fqdn names in the allocation, then
|
|
|
|
* ensure we don't have any domain info in the node record
|
|
|
|
* for the hnp
|
|
|
|
*/
|
2012-08-31 21:28:49 +00:00
|
|
|
if (!orte_have_fqdn_allocation && !hnp_alone) {
|
2011-12-01 14:24:43 +00:00
|
|
|
if (NULL != (ptr = strchr(hnp_node->name, '.'))) {
|
|
|
|
*ptr = '\0';
|
2008-02-28 01:57:57 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return ORTE_SUCCESS;
|
|
|
|
}
|