1
1

Rollback commit r14335 it get into the trunk too early.

This commit was SVN r14338.

The following SVN revision numbers were found above:
  r14335 --> open-mpi/ompi@10dfd534f6
Этот коммит содержится в:
George Bosilca 2007-04-12 06:21:59 +00:00
родитель fce678c1d1
Коммит 579184cd72

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

@ -2,7 +2,7 @@
* Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana * Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
* University Research and Technology * University Research and Technology
* Corporation. All rights reserved. * Corporation. All rights reserved.
* Copyright (c) 2004-2007 The University of Tennessee and The University * Copyright (c) 2004-2005 The University of Tennessee and The University
* of Tennessee Research Foundation. All rights * of Tennessee Research Foundation. All rights
* reserved. * reserved.
* Copyright (c) 2004-2005 High Performance Computing Center Stuttgart, * Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
@ -27,24 +27,23 @@
#include "orte_config.h" #include "orte_config.h"
#include "opal/hash_string.h" #include "orte/class/orte_pointer_array.h"
#include "opal/util/output.h" #include "opal/util/output.h"
#include "opal/util/trace.h" #include "opal/util/trace.h"
#include "orte/class/orte_pointer_array.h"
#include "orte/mca/errmgr/errmgr.h" #include "orte/mca/errmgr/errmgr.h"
#include "orte/mca/gpr/replica/gpr_replica.h"
#include "orte/mca/gpr/replica/functional_layer/gpr_replica_fn.h" #include "orte/mca/gpr/replica/functional_layer/gpr_replica_fn.h"
#include "orte/mca/gpr/replica/transition_layer/gpr_replica_tl.h" #include "orte/mca/gpr/replica/transition_layer/gpr_replica_tl.h"
int int
orte_gpr_replica_create_itag(orte_gpr_replica_itag_t *itag, orte_gpr_replica_create_itag(orte_gpr_replica_itag_t *itag,
orte_gpr_replica_segment_t *seg, char *name) orte_gpr_replica_segment_t *seg, char *name)
{ {
orte_gpr_replica_dict_entry_t* new_dict; char **ptr, *new_dict;
orte_std_cntr_t index; orte_gpr_replica_itag_t j;
uint32_t len, hash_key; orte_std_cntr_t i, len, len2, index;
int rc;
OPAL_TRACE(3); OPAL_TRACE(3);
@ -57,19 +56,29 @@ orte_gpr_replica_create_itag(orte_gpr_replica_itag_t *itag,
return ORTE_ERR_BAD_PARAM; return ORTE_ERR_BAD_PARAM;
} }
if( ORTE_ERR_NOT_FOUND != (rc = orte_gpr_replica_dict_lookup(itag, seg, name))) { len = (orte_std_cntr_t)strlen(name);
return rc;
/* check seg's dictionary to ensure uniqueness */
ptr = (char**)(seg->dict)->addr;
for (i=0, j=0; j < seg->num_dict_entries &&
i < (seg->dict)->size; i++) {
if (NULL != ptr[i]) {
j++;
len2 = (orte_std_cntr_t)strlen(ptr[i]);
if ((len == len2 && 0 == strncmp(ptr[i], name, len))) {
/* already present */
if (i < ORTE_GPR_REPLICA_ITAG_MAX) {
*itag = (orte_gpr_replica_itag_t)i;
return ORTE_SUCCESS;
}
/* otherwise, the itag violates the max value */
return ORTE_ERR_BAD_PARAM;
}
}
} }
OPAL_HASH_STRLEN( name, hash_key, len );
/* okay, name is unique - create dictionary entry */ /* okay, name is unique - create dictionary entry */
new_dict = (orte_gpr_replica_dict_entry_t*)malloc( sizeof(orte_gpr_replica_dict_entry_t) + len ); new_dict = strdup(name);
new_dict->hash_key = hash_key;
new_dict->length = len;
strncpy( new_dict->string, name, len );
new_dict->string[len] = '\0';
if (0 > orte_pointer_array_add(&index, seg->dict, (void*)new_dict)) { if (0 > orte_pointer_array_add(&index, seg->dict, (void*)new_dict)) {
free(new_dict); free(new_dict);
ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE); ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);
@ -84,8 +93,7 @@ orte_gpr_replica_create_itag(orte_gpr_replica_itag_t *itag,
/* otherwise, the itag violates the max value */ /* otherwise, the itag violates the max value */
free(new_dict); free(new_dict);
/* remove itag from segment dictionary */ ptr[index] = NULL;
orte_pointer_array_set_item(seg->dict, (orte_std_cntr_t)index, NULL);
return ORTE_ERR_OUT_OF_RESOURCE; return ORTE_ERR_OUT_OF_RESOURCE;
} }
@ -93,7 +101,7 @@ orte_gpr_replica_create_itag(orte_gpr_replica_itag_t *itag,
int orte_gpr_replica_delete_itag(orte_gpr_replica_segment_t *seg, char *name) int orte_gpr_replica_delete_itag(orte_gpr_replica_segment_t *seg, char *name)
{ {
orte_gpr_replica_dict_entry_t **ptr; char **ptr;
orte_gpr_replica_itag_t itag; orte_gpr_replica_itag_t itag;
int rc; int rc;
@ -115,19 +123,19 @@ int orte_gpr_replica_delete_itag(orte_gpr_replica_segment_t *seg, char *name)
/* need to search this segment's registry to find all instances /* need to search this segment's registry to find all instances
* that name & delete them * that name & delete them
*/ */
if (ORTE_SUCCESS != (rc = orte_gpr_replica_purge_itag(seg, itag))) { if (ORTE_SUCCESS != (rc = orte_gpr_replica_purge_itag(seg, itag))) {
ORTE_ERROR_LOG(rc); ORTE_ERROR_LOG(rc);
return rc; return rc;
} }
/* free the dictionary element data */ /* free the dictionary element data */
ptr = (orte_gpr_replica_dict_entry_t**)(seg->dict->addr); ptr = (char**)((seg->dict)->addr);
if (NULL == ptr[itag]) { /* dict element no longer valid */ if (NULL == ptr[itag]) { /* dict element no longer valid */
return ORTE_ERR_NOT_FOUND; return ORTE_ERR_NOT_FOUND;
} }
free(ptr[itag]); free(ptr[itag]);
/* remove itag from segment dictionary */ /* remove itag from segment dictionary */
orte_pointer_array_set_item(seg->dict, (orte_std_cntr_t)itag, NULL); orte_pointer_array_set_item(seg->dict, (orte_std_cntr_t)itag, NULL);
/* decrease the dict counter */ /* decrease the dict counter */
@ -141,10 +149,10 @@ int
orte_gpr_replica_dict_lookup(orte_gpr_replica_itag_t *itag, orte_gpr_replica_dict_lookup(orte_gpr_replica_itag_t *itag,
orte_gpr_replica_segment_t *seg, char *name) orte_gpr_replica_segment_t *seg, char *name)
{ {
orte_gpr_replica_dict_entry_t **ptr; char **ptr;
orte_std_cntr_t i; orte_std_cntr_t i;
orte_gpr_replica_itag_t j; orte_gpr_replica_itag_t j;
uint32_t hash_key, len; orte_std_cntr_t len, len2;
OPAL_TRACE(3); OPAL_TRACE(3);
@ -160,26 +168,27 @@ orte_gpr_replica_dict_lookup(orte_gpr_replica_itag_t *itag,
if (NULL == name) { /* just want segment token-itag pair */ if (NULL == name) { /* just want segment token-itag pair */
*itag = seg->itag; *itag = seg->itag;
return ORTE_SUCCESS; return ORTE_SUCCESS;
} }
OPAL_HASH_STRLEN( name, hash_key, len ); len = (orte_std_cntr_t)strlen(name);
ptr = (orte_gpr_replica_dict_entry_t**)(seg->dict)->addr; /* want specified token-itag pair in that segment's dictionary */
ptr = (char**)((seg->dict)->addr);
for (i=0, j=0; j < seg->num_dict_entries && for (i=0, j=0; j < seg->num_dict_entries &&
i < (seg->dict)->size; i++) { i < (seg->dict)->size; i++) {
if (NULL == ptr[i]) continue; if (NULL != ptr[i]) {
j++; j++;
if( (len == ptr[i]->length) && (hash_key == ptr[i]->hash_key) len2 = (orte_std_cntr_t)strlen(ptr[i]);
&& (0 == strncmp(ptr[i]->string, name, len)) ) { if (len == len2 && 0 == strncmp(ptr[i], name, len)) {
/* already present */ if (i < ORTE_GPR_REPLICA_ITAG_MAX) {
if (i < ORTE_GPR_REPLICA_ITAG_MAX) { *itag = (orte_gpr_replica_itag_t)i;
*itag = (orte_gpr_replica_itag_t)i; return ORTE_SUCCESS;
return ORTE_SUCCESS; }
/* otherwise, the itag violates the max value */
return ORTE_ERR_BAD_PARAM;
} }
/* otherwise, the itag violates the max value */
return ORTE_ERR_BAD_PARAM;
} }
} }
return ORTE_ERR_NOT_FOUND; /* couldn't find the specified entry */ return ORTE_ERR_NOT_FOUND; /* couldn't find the specified entry */
} }
@ -188,7 +197,7 @@ orte_gpr_replica_dict_lookup(orte_gpr_replica_itag_t *itag,
int orte_gpr_replica_dict_reverse_lookup(char **name, int orte_gpr_replica_dict_reverse_lookup(char **name,
orte_gpr_replica_segment_t *seg, orte_gpr_replica_itag_t itag) orte_gpr_replica_segment_t *seg, orte_gpr_replica_itag_t itag)
{ {
orte_gpr_replica_dict_entry_t **ptr; char **ptr;
orte_gpr_replica_segment_t **segptr; orte_gpr_replica_segment_t **segptr;
OPAL_TRACE(3); OPAL_TRACE(3);
@ -203,34 +212,34 @@ int orte_gpr_replica_dict_reverse_lookup(char **name,
} }
if (NULL == seg) { if (NULL == seg) {
/* return the segment name /* return the segment name
* note that itag is the index of the segment in that array * note that itag is the index of the segment in that array
*/ */
segptr = (orte_gpr_replica_segment_t**)(orte_gpr_replica.segments->addr); segptr = (orte_gpr_replica_segment_t**)(orte_gpr_replica.segments->addr);
if (NULL == segptr[itag]) { /* this segment is no longer alive */ if (NULL == segptr[itag]) { /* this segment is no longer alive */
return ORTE_ERR_NOT_FOUND; return ORTE_ERR_NOT_FOUND;
} }
*name = strdup(segptr[itag]->name); *name = strdup(segptr[itag]->name);
return ORTE_SUCCESS; return ORTE_SUCCESS;
} }
/* seg is provided - find the matching token for this itag /* seg is provided - find the matching token for this itag
* note again that itag is the index into this segment's * note again that itag is the index into this segment's
* dictionary array * dictionary array
*/ */
ptr = (orte_gpr_replica_dict_entry_t**)((seg->dict)->addr); ptr = (char**)((seg->dict)->addr);
if (NULL == ptr[itag]) { /* this entry is no longer valid! */ if (NULL == ptr[itag]) { /* this entry is no longer valid! */
return ORTE_ERR_NOT_FOUND; return ORTE_ERR_NOT_FOUND;
} }
*name = strdup(ptr[itag]->string); *name = strdup(ptr[itag]);
return ORTE_SUCCESS; return ORTE_SUCCESS;
} }
int int
orte_gpr_replica_get_itag_list( orte_gpr_replica_itag_t **itaglist, orte_gpr_replica_get_itag_list(orte_gpr_replica_itag_t **itaglist,
orte_gpr_replica_segment_t *seg, char **names, orte_gpr_replica_segment_t *seg, char **names,
orte_std_cntr_t *num_names ) orte_std_cntr_t *num_names)
{ {
char **namptr; char **namptr;
int rc; int rc;
@ -248,15 +257,15 @@ orte_gpr_replica_get_itag_list( orte_gpr_replica_itag_t **itaglist,
/* check for wild-card case */ /* check for wild-card case */
if (NULL == names) { if (NULL == names) {
return ORTE_SUCCESS; return ORTE_SUCCESS;
} }
if (0 >= (*num_names)) { /* NULL-terminated list - count them */ if (0 >= (*num_names)) { /* NULL-terminated list - count them */
*num_names = 0; *num_names = 0;
namptr = names; namptr = names;
while (NULL != *namptr) { while (NULL != *namptr) {
*num_names = (*num_names) + 1; *num_names = (*num_names) + 1;
namptr++; namptr++;
} }
} }
@ -268,13 +277,14 @@ orte_gpr_replica_get_itag_list( orte_gpr_replica_itag_t **itaglist,
namptr = names; namptr = names;
for( i = 0; i < (*num_names); i++ ) { /* traverse array of names - ignore any NULL's */ for (i=0; i < (*num_names); i++) { /* traverse array of names - ignore any NULL's */
if (NULL == names[i]) continue; if (NULL != names[i]) {
if (ORTE_SUCCESS != (rc = orte_gpr_replica_create_itag(&((*itaglist)[i]), seg, names[i]))) { if (ORTE_SUCCESS != (rc = orte_gpr_replica_create_itag(&((*itaglist)[i]), seg, names[i]))) {
ORTE_ERROR_LOG(rc); ORTE_ERROR_LOG(rc);
free(*itaglist); free(*itaglist);
*itaglist = NULL; *itaglist = NULL;
return rc; return rc;
}
} }
} }
return ORTE_SUCCESS; return ORTE_SUCCESS;