2008-06-24 05:27:22 +04:00
|
|
|
/*
|
|
|
|
* 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"
|
2008-06-26 07:48:22 +04:00
|
|
|
#include "orte/constants.h"
|
|
|
|
#include "orte/types.h"
|
|
|
|
|
2008-06-24 05:27:22 +04:00
|
|
|
#include <unistd.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <sys/bproc.h>
|
|
|
|
|
2008-06-26 07:48:22 +04:00
|
|
|
#include "opal/class/opal_list.h"
|
2008-06-24 05:27:22 +04:00
|
|
|
#include "opal/util/output.h"
|
|
|
|
|
|
|
|
#include "orte/mca/ras/base/ras_private.h"
|
|
|
|
#include "ras_bjs.h"
|
|
|
|
|
2008-06-26 07:48:22 +04:00
|
|
|
/* API functions */
|
|
|
|
static int allocate(opal_list_t *nodes);
|
|
|
|
static int finalize(void);
|
|
|
|
|
|
|
|
orte_ras_base_module_t orte_ras_bjs_module = {
|
|
|
|
allocate,
|
|
|
|
finalize
|
|
|
|
};
|
|
|
|
|
2008-06-24 05:27:22 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Query the bproc node status
|
|
|
|
*/
|
|
|
|
|
2008-06-26 07:48:22 +04:00
|
|
|
static int bjs_node_state(int node)
|
2008-06-24 05:27:22 +04:00
|
|
|
{
|
|
|
|
#if defined BPROC_API_VERSION && BPROC_API_VERSION >= 4
|
|
|
|
char nodestatus[BPROC_STATE_LEN + 1];
|
|
|
|
|
|
|
|
bproc_nodestatus(node, nodestatus, sizeof(nodestatus));
|
|
|
|
if (strcmp(nodestatus, "up") == 0)
|
|
|
|
return ORTE_NODE_STATE_UP;
|
|
|
|
if (strcmp(nodestatus, "down") == 0)
|
|
|
|
return ORTE_NODE_STATE_DOWN;
|
|
|
|
if (strcmp(nodestatus, "boot") == 0)
|
|
|
|
return ORTE_NODE_STATE_REBOOT;
|
|
|
|
return ORTE_NODE_STATE_UNKNOWN;
|
|
|
|
#else
|
|
|
|
switch(bproc_nodestatus(node)) {
|
|
|
|
case bproc_node_up:
|
|
|
|
return ORTE_NODE_STATE_UP;
|
|
|
|
case bproc_node_down:
|
|
|
|
return ORTE_NODE_STATE_DOWN;
|
|
|
|
case bproc_node_boot:
|
|
|
|
return ORTE_NODE_STATE_REBOOT;
|
|
|
|
default:
|
|
|
|
return ORTE_NODE_STATE_UNKNOWN;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-06-26 07:48:22 +04:00
|
|
|
static int allocate(opal_list_t *nodes)
|
2008-06-24 05:27:22 +04:00
|
|
|
{
|
2008-06-26 07:48:22 +04:00
|
|
|
char* nodelist;
|
2008-06-24 05:27:22 +04:00
|
|
|
char* ptr;
|
|
|
|
opal_list_item_t* item;
|
2008-06-26 07:48:22 +04:00
|
|
|
orte_node_t *node;
|
2008-06-24 05:27:22 +04:00
|
|
|
int rc;
|
|
|
|
|
|
|
|
/* parse the node list and check node status/access */
|
2008-06-26 07:48:22 +04:00
|
|
|
nodelist = getenv("NODES");
|
|
|
|
if (NULL == nodelist) {
|
2008-06-24 05:27:22 +04:00
|
|
|
return ORTE_ERR_NOT_AVAILABLE;
|
|
|
|
}
|
|
|
|
|
2008-06-26 07:48:22 +04:00
|
|
|
while(NULL != (ptr = strsep(&nodelist,","))) {
|
2008-06-24 05:27:22 +04:00
|
|
|
orte_node_state_t node_state;
|
|
|
|
int node_num;
|
|
|
|
|
|
|
|
/* is this node already in the list */
|
2008-06-26 07:48:22 +04:00
|
|
|
for(item = opal_list_get_first(nodes);
|
|
|
|
item != opal_list_get_end(nodes);
|
2008-06-24 05:27:22 +04:00
|
|
|
item = opal_list_get_next(item)) {
|
2008-06-26 07:48:22 +04:00
|
|
|
node = (orte_node_t*)item;
|
|
|
|
if(strcmp(node->name, ptr) == 0)
|
2008-06-24 05:27:22 +04:00
|
|
|
break;
|
|
|
|
}
|
2008-06-26 07:48:22 +04:00
|
|
|
/* it if is in the list, then just increment the slot count */
|
|
|
|
if(item != opal_list_get_end(nodes)) {
|
|
|
|
node->slots++;
|
2008-06-24 05:27:22 +04:00
|
|
|
continue;
|
2008-06-26 07:48:22 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/* convert to an int node number */
|
2008-06-24 05:27:22 +04:00
|
|
|
if(sscanf(ptr, "%d", &node_num) != 1) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2008-06-26 07:48:22 +04:00
|
|
|
if(ORTE_NODE_STATE_UP != (node_state = bjs_node_state(node_num))) {
|
2008-06-24 05:27:22 +04:00
|
|
|
opal_output(0, "error: a specified node (%d) is not up.\n", node_num);
|
|
|
|
rc = ORTE_ERROR;
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
if(bproc_access(node_num, BPROC_X_OK) != 0) {
|
|
|
|
opal_output(0, "error: a specified node (%d) is not accessible.\n", node_num);
|
|
|
|
rc = ORTE_ERROR;
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* create a new node entry */
|
2008-06-26 07:48:22 +04:00
|
|
|
node = OBJ_NEW(orte_node_t);
|
|
|
|
node->name = strdup(ptr);
|
|
|
|
node->state = node_state;
|
|
|
|
node->slots = 1;
|
|
|
|
opal_list_append(nodes, &node->super);
|
2008-06-24 05:27:22 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
cleanup:
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-06-26 07:48:22 +04:00
|
|
|
static int finalize(void)
|
2008-06-24 05:27:22 +04:00
|
|
|
{
|
|
|
|
return ORTE_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
|