1
1

More cleanup of pointer array usage

This commit was SVN r20981.
Этот коммит содержится в:
Ralph Castain 2009-04-13 19:06:54 +00:00
родитель cd512599bf
Коммит 9f7c605166
2 изменённых файлов: 10 добавлений и 21 удалений

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

@ -410,26 +410,22 @@ int orte_dt_init(void)
orte_job_t* orte_get_job_data_object(orte_jobid_t job) orte_job_t* orte_get_job_data_object(orte_jobid_t job)
{ {
orte_job_t **jptr; int32_t ljob;
orte_std_cntr_t i;
/* if I am not an HNP, I cannot provide this object */ /* if I am not an HNP, I cannot provide this object */
if (!orte_process_info.hnp) { if (!orte_process_info.hnp) {
return NULL; return NULL;
} }
jptr = (orte_job_t**)orte_job_data->addr; /* the job is indexed by its local jobid, so we can
for (i=0; i < orte_job_data->size; i++) { * just look it up here. it is not an error for this
if (NULL != jptr[i] && job == jptr[i]->jobid) { * to not be found - could just be
return jptr[i];
}
}
/* not an error for this to not be found - could just be
* a race condition whereby the job has already been * a race condition whereby the job has already been
* removed from the array. So just return NULL * removed from the array. The get_item function
* will just return NULL in that case.
*/ */
return NULL; ljob = ORTE_LOCAL_JOBID(job);
return (orte_job_t*)opal_pointer_array_get_item(orte_job_data, ljob);
} }

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

@ -819,28 +819,21 @@ int orte_util_encode_pidmap(opal_byte_object_t *boptr)
opal_buffer_t buf; opal_buffer_t buf;
orte_local_rank_t *lrank; orte_local_rank_t *lrank;
orte_node_rank_t *nrank; orte_node_rank_t *nrank;
orte_job_t **jobs, *jdata; orte_job_t *jdata;
int j; int j;
int rc; int rc;
/* setup the working buffer */ /* setup the working buffer */
OBJ_CONSTRUCT(&buf, opal_buffer_t); OBJ_CONSTRUCT(&buf, opal_buffer_t);
jobs = (orte_job_t**)orte_job_data->addr;
/* unfortunately, job objects cannot be stored
* by index number as the jobid is a constructed
* value. So we have no choice but to cycle through
* the job pointer array and look at each entry
*/
for (j=1; j < orte_job_data->size; j++) { for (j=1; j < orte_job_data->size; j++) {
/* the job array is no longer left-justified and may /* the job array is no longer left-justified and may
* have holes in it as we recover resources at job * have holes in it as we recover resources at job
* completion * completion
*/ */
if (NULL == jobs[j]) { if (NULL == (jdata = (orte_job_t*)opal_pointer_array_get_item(orte_job_data, j))) {
continue; continue;
} }
jdata = jobs[j];
/* pack the jobid */ /* pack the jobid */
if (ORTE_SUCCESS != (rc = opal_dss.pack(&buf, &jdata->jobid, 1, ORTE_JOBID))) { if (ORTE_SUCCESS != (rc = opal_dss.pack(&buf, &jdata->jobid, 1, ORTE_JOBID))) {
ORTE_ERROR_LOG(rc); ORTE_ERROR_LOG(rc);