Skip to content

Commit b499d4b

Browse files
author
rhc54
committed
Merge pull request #1391 from rhc54/topic/dvm
Convert the orte_job_data pointer array to a hash table so it doesn't…
2 parents 309e23a + d653cf2 commit b499d4b

File tree

15 files changed

+93
-152
lines changed

15 files changed

+93
-152
lines changed

opal/mca/pmix/pmix112/Makefile.am

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#
2-
# Copyright (c) 2014-2015 Intel, Inc. All rights reserved.
2+
# Copyright (c) 2014-2016 Intel, Inc. All rights reserved.
33
# Copyright (c) 2015 Cisco Systems, Inc. All rights reserved.
44
# Copyright (c) 2015 Research Organization for Information Science
55
# and Technology (RIST). All rights reserved.

orte/mca/errmgr/default_orted/errmgr_default_orted.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
* reserved.
99
* Copyright (c) 2011-2013 Los Alamos National Security, LLC.
1010
* All rights reserved.
11-
* Copyright (c) 2014 Intel, Inc. All rights reserved.
11+
* Copyright (c) 2014-2016 Intel, Inc. All rights reserved.
1212
* $COPYRIGHT$
1313
*
1414
* Additional copyrights may follow
@@ -584,7 +584,6 @@ static void proc_errors(int fd, short args, void *cbdata)
584584
orte_session_dir_cleanup(jdata->jobid);
585585

586586
/* remove this job from our local job data since it is complete */
587-
opal_pointer_array_set_item(orte_job_data, ORTE_LOCAL_JOBID(jdata->jobid), NULL);
588587
OBJ_RELEASE(jdata);
589588

590589
/* send it */

orte/mca/ess/base/ess_base_std_orted.c

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
* Copyright (c) 2011 Cisco Systems, Inc. All rights reserved.
1515
* Copyright (c) 2011-2013 Los Alamos National Security, LLC. All rights
1616
* reserved.
17-
* Copyright (c) 2013-2015 Intel, Inc. All rights reserved.
17+
* Copyright (c) 2013-2016 Intel, Inc. All rights reserved.
1818
* $COPYRIGHT$
1919
*
2020
* Additional copyrights may follow
@@ -301,11 +301,8 @@ int orte_ess_base_orted_setup(char **hosts)
301301
}
302302
}
303303
/* setup the global job and node arrays */
304-
orte_job_data = OBJ_NEW(opal_pointer_array_t);
305-
if (ORTE_SUCCESS != (ret = opal_pointer_array_init(orte_job_data,
306-
1,
307-
ORTE_GLOBAL_ARRAY_MAX_SIZE,
308-
1))) {
304+
orte_job_data = OBJ_NEW(opal_hash_table_t);
305+
if (ORTE_SUCCESS != (ret = opal_hash_table_init(orte_job_data, 128))) {
309306
ORTE_ERROR_LOG(ret);
310307
error = "setup job array";
311308
goto error;
@@ -332,7 +329,7 @@ int orte_ess_base_orted_setup(char **hosts)
332329
/* create and store the job data object */
333330
jdata = OBJ_NEW(orte_job_t);
334331
jdata->jobid = ORTE_PROC_MY_NAME->jobid;
335-
opal_pointer_array_set_item(orte_job_data, 0, jdata);
332+
opal_hash_table_set_value_uint32(orte_job_data, jdata->jobid, jdata);
336333
/* every job requires at least one app */
337334
app = OBJ_NEW(orte_app_context_t);
338335
opal_pointer_array_set_item(jdata->apps, 0, app);

orte/mca/ess/hnp/ess_hnp_module.c

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
* Copyright (c) 2011-2014 Cisco Systems, Inc. All rights reserved.
1414
* Copyright (c) 2011-2013 Los Alamos National Security, LLC. All rights
1515
* reserved.
16-
* Copyright (c) 2013-2015 Intel, Inc. All rights reserved.
16+
* Copyright (c) 2013-2016 Intel, Inc. All rights reserved.
1717
* $COPYRIGHT$
1818
*
1919
* Additional copyrights may follow
@@ -357,11 +357,8 @@ static int rte_init(void)
357357
goto error;
358358
}
359359
/* setup the global job and node arrays */
360-
orte_job_data = OBJ_NEW(opal_pointer_array_t);
361-
if (ORTE_SUCCESS != (ret = opal_pointer_array_init(orte_job_data,
362-
1,
363-
ORTE_GLOBAL_ARRAY_MAX_SIZE,
364-
1))) {
360+
orte_job_data = OBJ_NEW(opal_hash_table_t);
361+
if (ORTE_SUCCESS != (ret = opal_hash_table_init(orte_job_data, 128))) {
365362
ORTE_ERROR_LOG(ret);
366363
error = "setup job array";
367364
goto error;
@@ -388,7 +385,7 @@ static int rte_init(void)
388385
/* create and store the job data object */
389386
jdata = OBJ_NEW(orte_job_t);
390387
jdata->jobid = ORTE_PROC_MY_NAME->jobid;
391-
opal_pointer_array_set_item(orte_job_data, 0, jdata);
388+
opal_hash_table_set_value_uint32(orte_job_data, jdata->jobid, jdata);
392389
/* mark that the daemons have reported as we are the
393390
* only ones in the system right now, and we definitely
394391
* are running!

orte/mca/odls/base/odls_base_default_fns.c

Lines changed: 22 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@
101101
int orte_odls_base_default_get_add_procs_data(opal_buffer_t *data,
102102
orte_jobid_t job)
103103
{
104-
int rc, i;
104+
int rc;
105105
orte_job_t *jdata=NULL, *jptr;
106106
orte_job_map_t *map=NULL;
107107
opal_buffer_t *wireup, jobdata;
@@ -191,33 +191,29 @@ int orte_odls_base_default_get_add_procs_data(opal_buffer_t *data,
191191
* properly work should a proc from one of the other jobs
192192
* interact with this one */
193193
if (orte_get_attribute(&jdata->attributes, ORTE_JOB_LAUNCHED_DAEMONS, NULL, OPAL_BOOL)) {
194+
void *nptr;
195+
uint32_t key;
194196
OBJ_CONSTRUCT(&jobdata, opal_buffer_t);
195197
numjobs = 0;
196-
for (i=0; i < orte_job_data->size; i++) {
197-
if (NULL == (jptr = (orte_job_t*)opal_pointer_array_get_item(orte_job_data, i))) {
198-
continue;
199-
}
200-
if (ORTE_JOB_STATE_UNTERMINATED < jptr->state) {
201-
/* job already terminated - ignore it */
202-
continue;
203-
}
204-
if (jptr == jdata) {
205-
/* ignore the job we are looking at - we'll get it separately */
206-
continue;
207-
}
208-
/* pack the job struct */
209-
if (ORTE_SUCCESS != (rc = opal_dss.pack(&jobdata, &jptr, 1, ORTE_JOB))) {
210-
ORTE_ERROR_LOG(rc);
211-
return rc;
198+
rc = opal_hash_table_get_first_key_uint32(orte_job_data, &key, (void **)&jptr, &nptr);
199+
while (OPAL_SUCCESS == rc) {
200+
if (NULL != jptr && jptr != jdata &&
201+
ORTE_PROC_MY_NAME->jobid != jptr->jobid) {
202+
/* pack the job struct */
203+
if (ORTE_SUCCESS != (rc = opal_dss.pack(&jobdata, &jptr, 1, ORTE_JOB))) {
204+
ORTE_ERROR_LOG(rc);
205+
return rc;
206+
}
207+
++numjobs;
212208
}
213-
++numjobs;
209+
rc = opal_hash_table_get_next_key_uint32(orte_job_data, &key, (void **)&jptr, nptr, &nptr);
210+
}
211+
/* pack the number of jobs */
212+
if (ORTE_SUCCESS != (rc = opal_dss.pack(data, &numjobs, 1, OPAL_INT32))) {
213+
ORTE_ERROR_LOG(rc);
214+
return rc;
214215
}
215216
if (0 < numjobs) {
216-
/* pack the number of jobs */
217-
if (ORTE_SUCCESS != (rc = opal_dss.pack(data, &numjobs, 1, OPAL_INT32))) {
218-
ORTE_ERROR_LOG(rc);
219-
return rc;
220-
}
221217
/* pack the jobdata buffer */
222218
wireup = &jobdata;
223219
if (ORTE_SUCCESS != (rc = opal_dss.pack(data, &wireup, 1, OPAL_BUFFER))) {
@@ -302,7 +298,7 @@ int orte_odls_base_default_construct_child_list(opal_buffer_t *data,
302298
/* check to see if we already have this one */
303299
if (NULL == orte_get_job_data_object(jdata->jobid)) {
304300
/* nope - add it */
305-
opal_pointer_array_set_item(orte_job_data, ORTE_LOCAL_JOBID(jdata->jobid), jdata);
301+
opal_hash_table_set_value_uint32(orte_job_data, jdata->jobid, jdata);
306302
/* connect each proc to its node object */
307303
for (j=0; j < jdata->procs->size; j++) {
308304
if (NULL == (pptr = (orte_proc_t*)opal_pointer_array_get_item(jdata->procs, j))) {
@@ -401,16 +397,10 @@ int orte_odls_base_default_construct_child_list(opal_buffer_t *data,
401397
}
402398
}
403399
goto COMPLETE;
400+
} else {
401+
opal_hash_table_set_value_uint32(orte_job_data, jdata->jobid, jdata);
404402
}
405403

406-
if (NULL != orte_get_job_data_object(*job)) {
407-
opal_output(0, "ERROR - JOB ALREADY EXISTS");
408-
/* setup job object for this job */
409-
rc = ORTE_ERR_FATAL;
410-
goto REPORT_ERROR;
411-
}
412-
opal_pointer_array_set_item(orte_job_data, ORTE_LOCAL_JOBID(jdata->jobid), jdata);
413-
414404
/* ensure the map object is present */
415405
if (NULL == jdata->map) {
416406
jdata->map = OBJ_NEW(orte_job_map_t);

orte/mca/plm/base/plm_base_jobid.c

Lines changed: 1 addition & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
* University of Stuttgart. All rights reserved.
1010
* Copyright (c) 2004-2005 The Regents of the University of California.
1111
* All rights reserved.
12+
* Copyright (c) 2016 Intel, Inc. All rights reserved.
1213
* $COPYRIGHT$
1314
*
1415
* Additional copyrights may follow
@@ -76,27 +77,6 @@ int orte_plm_base_set_hnp_name(void)
7677
*/
7778
int orte_plm_base_create_jobid(orte_job_t *jdata)
7879
{
79-
#if 0
80-
int32_t j;
81-
82-
/* RHC: WHILE ORTE CAN NOW HANDLE RECYCLING OF JOBID'S,
83-
* THE MPI LAYER CANNOT SINCE THERE IS NO WAY TO
84-
* UPDATE THE OMPI_PROC_T LIST AND/OR THE BTL'S
85-
*/
86-
87-
/* see if there is a prior
88-
* jobid that has completed and can be re-used. It can
89-
* never be 0 as that belongs to the HNP and its daemons
90-
*/
91-
for (j=1; j < orte_job_data->size; j++) {
92-
if (NULL == opal_pointer_array_get_item(orte_job_data, j)) {
93-
/* this local jobid is available - reuse it */
94-
jdata->jobid = ORTE_CONSTRUCT_LOCAL_JOBID(ORTE_PROC_MY_NAME->jobid, j);
95-
return ORTE_SUCCESS;
96-
}
97-
}
98-
#endif
99-
10080
if (ORTE_FLAG_TEST(jdata, ORTE_JOB_FLAG_RESTART)) {
10181
/* this job is being restarted - do not assign it
10282
* a new jobid

orte/mca/plm/base/plm_base_launch_support.c

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,7 @@ void orte_plm_base_setup_job(int fd, short args, void *cbdata)
289289
* the orte_rmaps_base_setup_virtual_machine routine to
290290
* search all apps for any hosts to be used by the vm
291291
*/
292-
opal_pointer_array_set_item(orte_job_data, ORTE_LOCAL_JOBID(caddy->jdata->jobid), caddy->jdata);
292+
opal_hash_table_set_value_uint32(orte_job_data, caddy->jdata->jobid, caddy->jdata);
293293
}
294294

295295
/* if job recovery is not enabled, set it to default */
@@ -1098,18 +1098,19 @@ void orte_plm_base_daemon_callback(int status, orte_process_name_t* sender,
10981098
jdatorted->num_reported, jdatorted->num_procs));
10991099
if (jdatorted->num_procs == jdatorted->num_reported) {
11001100
bool dvm = true;
1101+
uint32_t key;
1102+
void *nptr;
11011103
jdatorted->state = ORTE_JOB_STATE_DAEMONS_REPORTED;
11021104
/* activate the daemons_reported state for all jobs
11031105
* whose daemons were launched
11041106
*/
1105-
for (idx=1; idx < orte_job_data->size; idx++) {
1106-
if (NULL == (jdata = (orte_job_t*)opal_pointer_array_get_item(orte_job_data, idx))) {
1107-
continue;
1108-
}
1107+
rc = opal_hash_table_get_first_key_uint32(orte_job_data, &key, (void **)&jdata, &nptr);
1108+
while (OPAL_SUCCESS == rc) {
11091109
dvm = false;
11101110
if (ORTE_JOB_STATE_DAEMONS_LAUNCHED == jdata->state) {
11111111
ORTE_ACTIVATE_JOB_STATE(jdata, ORTE_JOB_STATE_DAEMONS_REPORTED);
11121112
}
1113+
rc = opal_hash_table_get_next_key_uint32(orte_job_data, &key, (void **)&jdata, nptr, &nptr);
11131114
}
11141115
if (dvm) {
11151116
/* must be launching a DVM - activate the state */

orte/mca/state/base/state_base_fns.c

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
* Copyright (c) 2011-2012 Los Alamos National Security, LLC.
3-
* Copyright (c) 2014-2015 Intel, Inc. All rights reserved.
3+
* Copyright (c) 2014-2016 Intel, Inc. All rights reserved.
44
* $COPYRIGHT$
55
*
66
* Additional copyrights may follow
@@ -522,13 +522,13 @@ void orte_state_base_track_procs(int fd, short argc, void *cbdata)
522522
/* update the proc state */
523523
ORTE_FLAG_UNSET(pdata, ORTE_PROC_FLAG_ALIVE);
524524
pdata->state = state;
525-
if (ORTE_FLAG_TEST(pdata, ORTE_PROC_FLAG_LOCAL)) {
525+
if (ORTE_FLAG_TEST(pdata, ORTE_PROC_FLAG_LOCAL)) {
526526
/* Clean up the session directory as if we were the process
527527
* itself. This covers the case where the process died abnormally
528528
* and didn't cleanup its own session directory.
529529
*/
530530
orte_session_dir_finalize(proc);
531-
}
531+
}
532532
/* if we are trying to terminate and our routes are
533533
* gone, then terminate ourselves IF no local procs
534534
* remain (might be some from another job)
@@ -551,11 +551,11 @@ void orte_state_base_track_procs(int fd, short argc, void *cbdata)
551551
}
552552
/* return the allocated slot for reuse */
553553
cleanup_node(pdata);
554-
/* track job status */
555-
jdata->num_terminated++;
556-
if (jdata->num_terminated == jdata->num_procs) {
554+
/* track job status */
555+
jdata->num_terminated++;
556+
if (jdata->num_terminated == jdata->num_procs) {
557557
ORTE_ACTIVATE_JOB_STATE(jdata, ORTE_JOB_STATE_TERMINATED);
558-
}
558+
}
559559
}
560560

561561
cleanup:
@@ -577,6 +577,8 @@ void orte_state_base_check_all_complete(int fd, short args, void *cbdata)
577577
bool one_still_alive;
578578
orte_vpid_t lowest=0;
579579
int32_t i32, *i32ptr;
580+
uint32_t u32;
581+
void *nptr;
580582

581583
opal_output_verbose(2, orte_state_base_framework.framework_output,
582584
"%s state:base:check_job_complete on job %s",
@@ -722,13 +724,11 @@ void orte_state_base_check_all_complete(int fd, short args, void *cbdata)
722724
* object when we find it
723725
*/
724726
one_still_alive = false;
725-
for (j=1; j < orte_job_data->size; j++) {
726-
if (NULL == (job = (orte_job_t*)opal_pointer_array_get_item(orte_job_data, j))) {
727-
/* since we are releasing jdata objects as we
728-
* go, we can no longer assume that the job_data
729-
* array is left justified
730-
*/
731-
continue;
727+
j = opal_hash_table_get_first_key_uint32(orte_job_data, &u32, (void **)&job, &nptr);
728+
while (OPAL_SUCCESS == j) {
729+
/* skip the daemon job */
730+
if (job->jobid == ORTE_PROC_MY_NAME->jobid) {
731+
goto next;
732732
}
733733
/* if this is the job we are checking AND it normally terminated,
734734
* then activate the "notify_completed" state - this will release
@@ -762,20 +762,19 @@ void orte_state_base_check_all_complete(int fd, short args, void *cbdata)
762762
/* this was a debugger daemon. notify that a debugger has detached */
763763
ORTE_ACTIVATE_JOB_STATE(jdata, ORTE_JOB_STATE_DEBUGGER_DETACH);
764764
}
765-
opal_pointer_array_set_item(orte_job_data, j, NULL); /* ensure the array has a NULL */
766765
OBJ_RELEASE(jdata);
767766
}
768767
}
769-
continue;
768+
goto next;
770769
}
771770
/* if the job is flagged to not be monitored, skip it */
772771
if (ORTE_FLAG_TEST(job, ORTE_JOB_FLAG_DO_NOT_MONITOR)) {
773-
continue;
772+
goto next;
774773
}
775774
/* when checking for job termination, we must be sure to NOT check
776775
* our own job as it - rather obviously - has NOT terminated!
777776
*/
778-
if (job->num_terminated < job->num_procs) {
777+
if (ORTE_JOB_STATE_NOTIFIED != job->state) {
779778
/* we have at least one job that is not done yet - we cannot
780779
* just return, though, as we need to ensure we cleanout the
781780
* job data for the job that just completed
@@ -795,7 +794,10 @@ void orte_state_base_check_all_complete(int fd, short args, void *cbdata)
795794
job->num_terminated, job->num_procs,
796795
(NULL == jdata) ? "UNKNOWN" : orte_job_state_to_str(jdata->state) ));
797796
}
797+
next:
798+
j = opal_hash_table_get_next_key_uint32(orte_job_data, &u32, (void **)&job, nptr, &nptr);
798799
}
800+
799801
/* if a job is still alive, we just return */
800802
if (one_still_alive) {
801803
OPAL_OUTPUT_VERBOSE((2, orte_state_base_framework.framework_output,

0 commit comments

Comments
 (0)