1
1

Cleanup use of pointer arrays - thanks to Lenny for pointing it out.

This commit was SVN r21529.
Этот коммит содержится в:
Ralph Castain 2009-06-25 14:08:36 +00:00
родитель 26363fcc8b
Коммит 863e57700e
2 изменённых файлов: 19 добавлений и 49 удалений

Просмотреть файл

@ -71,21 +71,13 @@ Please see the orte_hosts man page for further information.
# #
[hostfile:relative-node-not-found] [hostfile:relative-node-not-found]
A relative host was specified, but was not found. The requested host was A relative host was specified, but was not found. The requested host was
specified with as: specified as:
Index: %d Index: %d
Syntax given: %s Syntax given: %s
Please see the orte_hosts man page for further information. This is most likely due to the relative index being out of bounds. You
# could obtain a larger allocation or reduce the relative host index.
[hostfile:relative-node-out-of-bounds]
A relative host was specified, but the index given is beyond the number
of hosts in the current allocation:
Index: %d
#hosts: %d
You could obtain a larger allocation or reduce the relative host index.
Please see the orte_hosts man page for further information. Please see the orte_hosts man page for further information.
# #
[hostfile:invalid-relative-node-syntax] [hostfile:invalid-relative-node-syntax]

Просмотреть файл

@ -482,11 +482,10 @@ int orte_util_filter_hostfile_nodes(opal_list_t *nodes,
{ {
opal_list_t newnodes, exclude; opal_list_t newnodes, exclude;
opal_list_item_t *item1, *item2, *next, *item3; opal_list_item_t *item1, *item2, *next, *item3;
orte_node_t *node_from_list, *node_from_file, *node3; orte_node_t *node_from_list, *node_from_file, *node_from_pool, *node3;
int rc = ORTE_SUCCESS; int rc = ORTE_SUCCESS;
char *cptr; char *cptr;
int num_empty, nodeidx; int num_empty, nodeidx;
orte_node_t **nodepool;
bool want_all_empty = false; bool want_all_empty = false;
opal_list_t keep; opal_list_t keep;
@ -521,9 +520,6 @@ int orte_util_filter_hostfile_nodes(opal_list_t *nodes,
OBJ_RELEASE(item1); OBJ_RELEASE(item1);
} }
/* setup for relative node syntax */
nodepool = (orte_node_t**)orte_node_pool->addr;
/* now check our nodes and keep those that match. We can /* now check our nodes and keep those that match. We can
* destruct our hostfile list as we go since this won't be needed * destruct our hostfile list as we go since this won't be needed
*/ */
@ -592,16 +588,7 @@ int orte_util_filter_hostfile_nodes(opal_list_t *nodes,
* look it up on global pool * look it up on global pool
*/ */
nodeidx = strtol(&node_from_file->name[2], NULL, 10); nodeidx = strtol(&node_from_file->name[2], NULL, 10);
if (nodeidx < 0 || if (NULL == (node_from_pool = (orte_node_t*)opal_pointer_array_get_item(orte_node_pool, nodeidx))) {
nodeidx > (int)orte_node_pool->size) {
/* this is an error */
orte_show_help("help-hostfile.txt", "hostfile:relative-node-out-of-bounds",
true, nodeidx, node_from_file->name);
rc = ORTE_ERR_SILENT;
goto cleanup;
}
/* see if that location is filled */
if (NULL == nodepool[nodeidx]) {
/* this is an error */ /* this is an error */
orte_show_help("help-hostfile.txt", "hostfile:relative-node-not-found", orte_show_help("help-hostfile.txt", "hostfile:relative-node-not-found",
true, nodeidx, node_from_file->name); true, nodeidx, node_from_file->name);
@ -613,7 +600,7 @@ int orte_util_filter_hostfile_nodes(opal_list_t *nodes,
item1 != opal_list_get_end(nodes); item1 != opal_list_get_end(nodes);
item1 = opal_list_get_next(nodes)) { item1 = opal_list_get_next(nodes)) {
node_from_list = (orte_node_t*)item1; node_from_list = (orte_node_t*)item1;
if (0 == strcmp(node_from_list->name, nodepool[nodeidx]->name)) { if (0 == strcmp(node_from_list->name, node_from_pool->name)) {
/* match - remove item from list */ /* match - remove item from list */
opal_list_remove_item(nodes, item1); opal_list_remove_item(nodes, item1);
/* xfer to keep list */ /* xfer to keep list */
@ -702,7 +689,7 @@ int orte_util_get_ordered_host_list(opal_list_t *nodes,
char *cptr; char *cptr;
int num_empty, i, nodeidx, startempty=0; int num_empty, i, nodeidx, startempty=0;
bool want_all_empty=false; bool want_all_empty=false;
orte_node_t **nodepool, *newnode; orte_node_t *node_from_pool, *newnode;
int rc; int rc;
OPAL_OUTPUT_VERBOSE((1, orte_debug_output, OPAL_OUTPUT_VERBOSE((1, orte_debug_output,
@ -716,9 +703,6 @@ int orte_util_get_ordered_host_list(opal_list_t *nodes,
goto cleanup; goto cleanup;
} }
/* setup to parse relative syntax */
nodepool = (orte_node_t**)orte_node_pool->addr;
/* parse the nodes to process any relative node directives */ /* parse the nodes to process any relative node directives */
item2 = opal_list_get_first(nodes); item2 = opal_list_get_first(nodes);
while (item2 != opal_list_get_end(nodes)) { while (item2 != opal_list_get_end(nodes)) {
@ -753,19 +737,22 @@ int orte_util_get_ordered_host_list(opal_list_t *nodes,
if (!orte_hnp_is_allocated && 0 == startempty) { if (!orte_hnp_is_allocated && 0 == startempty) {
startempty = 1; startempty = 1;
} }
for (i=startempty; 0 < num_empty && i < orte_node_pool->size && NULL != nodepool[i]; i++) { for (i=startempty; 0 < num_empty && i < orte_node_pool->size; i++) {
if (0 == nodepool[i]->slots_inuse) { if (NULL == (node_from_pool = (orte_node_t*)opal_pointer_array_get_item(orte_node_pool, i))) {
continue;
}
if (0 == node_from_pool->slots_inuse) {
newnode = OBJ_NEW(orte_node_t); newnode = OBJ_NEW(orte_node_t);
newnode->name = strdup(nodepool[i]->name); newnode->name = strdup(node_from_pool->name);
/* if the slot count here is less than the /* if the slot count here is less than the
* total slots avail on this node, set it * total slots avail on this node, set it
* to the specified count - this allows people * to the specified count - this allows people
* to subdivide an allocation * to subdivide an allocation
*/ */
if (node->slots < nodepool[i]->slots) { if (node->slots < node_from_pool->slots) {
newnode->slots_alloc = node->slots; newnode->slots_alloc = node->slots;
} else { } else {
newnode->slots_alloc = nodepool[i]->slots; newnode->slots_alloc = node_from_pool->slots;
} }
opal_list_insert_pos(nodes, item1, &newnode->super); opal_list_insert_pos(nodes, item1, &newnode->super);
/* track number added */ /* track number added */
@ -792,14 +779,6 @@ int orte_util_get_ordered_host_list(opal_list_t *nodes,
* look it up on global pool * look it up on global pool
*/ */
nodeidx = strtol(&node->name[2], NULL, 10); nodeidx = strtol(&node->name[2], NULL, 10);
if (nodeidx < 0 ||
nodeidx > (int)orte_node_pool->size) {
/* this is an error */
orte_show_help("help-hostfile.txt", "hostfile:relative-node-out-of-bounds",
true, nodeidx, node->name);
rc = ORTE_ERR_SILENT;
goto cleanup;
}
/* if the HNP is not allocated, then we need to /* if the HNP is not allocated, then we need to
* adjust the index as the node pool is offset * adjust the index as the node pool is offset
* by one * by one
@ -808,8 +787,7 @@ int orte_util_get_ordered_host_list(opal_list_t *nodes,
nodeidx++; nodeidx++;
} }
/* see if that location is filled */ /* see if that location is filled */
if (NULL == (node_from_pool = (orte_node_t*)opal_pointer_array_get_item(orte_node_pool, nodeidx))) {
if (NULL == nodepool[nodeidx]) {
/* this is an error */ /* this is an error */
orte_show_help("help-hostfile.txt", "hostfile:relative-node-not-found", orte_show_help("help-hostfile.txt", "hostfile:relative-node-not-found",
true, nodeidx, node->name); true, nodeidx, node->name);
@ -818,16 +796,16 @@ int orte_util_get_ordered_host_list(opal_list_t *nodes,
} }
/* create the node object */ /* create the node object */
newnode = OBJ_NEW(orte_node_t); newnode = OBJ_NEW(orte_node_t);
newnode->name = strdup(nodepool[nodeidx]->name); newnode->name = strdup(node_from_pool->name);
/* if the slot count here is less than the /* if the slot count here is less than the
* total slots avail on this node, set it * total slots avail on this node, set it
* to the specified count - this allows people * to the specified count - this allows people
* to subdivide an allocation * to subdivide an allocation
*/ */
if (node->slots < nodepool[nodeidx]->slots) { if (node->slots < node_from_pool->slots) {
newnode->slots_alloc = node->slots; newnode->slots_alloc = node->slots;
} else { } else {
newnode->slots_alloc = nodepool[nodeidx]->slots; newnode->slots_alloc = node_from_pool->slots;
} }
/* insert it before item1 */ /* insert it before item1 */
opal_list_insert_pos(nodes, item1, &newnode->super); opal_list_insert_pos(nodes, item1, &newnode->super);