Skip to content

Commit 4e0788e

Browse files
author
Ralph Castain
committed
Enable PSM to support dynamic processes
Fix comm_spawn to correctly reference the actual parent process that requested the spawn when looking for the parent job object
1 parent 5c9ea56 commit 4e0788e

File tree

7 files changed

+83
-25
lines changed

7 files changed

+83
-25
lines changed

orte/mca/plm/base/plm_base_launch_support.c

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@
7070
#include "orte/runtime/orte_quit.h"
7171
#include "orte/util/name_fns.h"
7272
#include "orte/util/nidmap.h"
73+
#include "orte/util/pre_condition_transports.h"
7374
#include "orte/util/proc_info.h"
7475
#include "orte/util/regex.h"
7576
#include "orte/mca/state/state.h"
@@ -272,6 +273,9 @@ void orte_plm_base_setup_job(int fd, short args, void *cbdata)
272273
int i;
273274
orte_app_context_t *app;
274275
orte_state_caddy_t *caddy = (orte_state_caddy_t*)cbdata;
276+
char *key;
277+
orte_job_t *parent;
278+
orte_process_name_t name, *nptr;
275279

276280
OPAL_OUTPUT_VERBOSE((5, orte_plm_base_framework.framework_output,
277281
"%s plm:base:setup_job",
@@ -308,6 +312,50 @@ void orte_plm_base_setup_job(int fd, short args, void *cbdata)
308312
ORTE_FLAG_SET(caddy->jdata, ORTE_JOB_FLAG_RECOVERABLE);
309313
}
310314

315+
/* setup transport keys in case the MPI layer needs them. If
316+
* this is a dynamic spawn, then use the same keys as the
317+
* parent process had so the new/old procs can communicate.
318+
* Otherwise we can use the jobfam and stepid as unique keys
319+
* because they are unique values assigned by the RM
320+
*/
321+
nptr = &name;
322+
if (orte_get_attribute(&caddy->jdata->attributes, ORTE_JOB_LAUNCH_PROXY, (void**)&nptr, OPAL_NAME)) {
323+
/* get the parent jdata */
324+
if (NULL == (parent = orte_get_job_data_object(name.jobid))) {
325+
ORTE_ERROR_LOG(ORTE_ERR_NOT_FOUND);
326+
ORTE_FORCED_TERMINATE(ORTE_ERROR_DEFAULT_EXIT_CODE);
327+
OBJ_RELEASE(caddy);
328+
return;
329+
}
330+
key = NULL;
331+
if (!orte_get_attribute(&parent->attributes, ORTE_JOB_TRANSPORT_KEY, (void**)&key, OPAL_STRING) ||
332+
NULL == key) {
333+
ORTE_ERROR_LOG(ORTE_ERR_NOT_FOUND);
334+
ORTE_FORCED_TERMINATE(ORTE_ERROR_DEFAULT_EXIT_CODE);
335+
OBJ_RELEASE(caddy);
336+
return;
337+
}
338+
/* record it */
339+
orte_set_attribute(&caddy->jdata->attributes, ORTE_JOB_TRANSPORT_KEY, ORTE_ATTR_LOCAL, key, OPAL_STRING);
340+
/* add the transport key envar to each app */
341+
for (i=0; i < caddy->jdata->apps->size; i++) {
342+
if (NULL == (app = (orte_app_context_t*)opal_pointer_array_get_item(caddy->jdata->apps, i))) {
343+
continue;
344+
}
345+
opal_setenv(OPAL_MCA_PREFIX"orte_precondition_transports", key, true, &app->env);
346+
}
347+
free(key);
348+
} else {
349+
/* this will also record the transport key attribute in the job object, and
350+
* adds the key envar to each app */
351+
if (ORTE_SUCCESS != (rc = orte_pre_condition_transports(caddy->jdata))) {
352+
ORTE_ERROR_LOG(rc);
353+
ORTE_FORCED_TERMINATE(ORTE_ERROR_DEFAULT_EXIT_CODE);
354+
OBJ_RELEASE(caddy);
355+
return;
356+
}
357+
}
358+
311359
/* if app recovery is not defined, set apps to defaults */
312360
for (i=0; i < caddy->jdata->apps->size; i++) {
313361
if (NULL == (app = (orte_app_context_t*)opal_pointer_array_get_item(caddy->jdata->apps, i))) {

orte/mca/plm/base/plm_base_receive.c

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ void orte_plm_base_recv(int status, orte_process_name_t* sender,
127127
orte_exit_code_t exit_code;
128128
int32_t rc=ORTE_SUCCESS, ret;
129129
orte_app_context_t *app, *child_app;
130-
orte_process_name_t name;
130+
orte_process_name_t name, *nptr;
131131
pid_t pid;
132132
bool running;
133133
int i, room;
@@ -162,8 +162,17 @@ void orte_plm_base_recv(int status, orte_process_name_t* sender,
162162
jdata->originator.jobid = sender->jobid;
163163
jdata->originator.vpid = sender->vpid;
164164

165+
/* get the name of the actual spawn parent - i.e., the proc that actually
166+
* requested the spawn */
167+
nptr = &name;
168+
if (!orte_get_attribute(&jdata->attributes, ORTE_JOB_LAUNCH_PROXY, (void**)&nptr, OPAL_NAME)) {
169+
ORTE_ERROR_LOG(ORTE_ERR_NOT_FOUND);
170+
rc = ORTE_ERR_NOT_FOUND;
171+
goto ANSWER_LAUNCH;
172+
}
173+
165174
/* get the parent's job object */
166-
if (NULL != (parent = orte_get_job_data_object(sender->jobid))) {
175+
if (NULL != (parent = orte_get_job_data_object(name.jobid))) {
167176
/* if the prefix was set in the parent's job, we need to transfer
168177
* that prefix to the child's app_context so any further launch of
169178
* orteds can find the correct binary. There always has to be at

orte/orted/orted_submit.c

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1010,14 +1010,6 @@ int orte_submit_job(char *argv[], int *index,
10101010
free(param);
10111011
}
10121012

1013-
/* pre-condition any network transports that require it */
1014-
if (ORTE_SUCCESS != (rc = orte_pre_condition_transports(jdata))) {
1015-
ORTE_ERROR_LOG(rc);
1016-
orte_show_help("help-orterun.txt", "orterun:precondition", false,
1017-
orte_basename, NULL, NULL, rc);
1018-
ORTE_UPDATE_EXIT_STATUS(ORTE_ERROR_DEFAULT_EXIT_CODE);
1019-
return rc;
1020-
}
10211013
/* setup for debugging */
10221014
orte_debugger_init_before_spawn(jdata);
10231015

orte/tools/orterun/orterun.c

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -187,21 +187,21 @@ int orterun(int argc, char *argv[])
187187
}
188188
}
189189

190-
// wait for response and unpack the status, jobid
191-
while (orte_event_base_active && launchst.active) {
192-
opal_event_loop(orte_event_base, OPAL_EVLOOP_ONCE);
193-
}
194-
if (orte_debug_flag) {
195-
opal_output(0, "Job %s has launched",
196-
(NULL == launchst.jdata) ? "UNKNOWN" : ORTE_JOBID_PRINT(launchst.jdata->jobid));
197-
}
198-
if (!orte_event_base_active || ORTE_SUCCESS != launchst.status) {
199-
goto DONE;
200-
}
201-
202-
while (orte_event_base_active && completest.active) {
203-
opal_event_loop(orte_event_base, OPAL_EVLOOP_ONCE);
204-
}
190+
// wait for response and unpack the status, jobid
191+
while (orte_event_base_active && launchst.active) {
192+
opal_event_loop(orte_event_base, OPAL_EVLOOP_ONCE);
193+
}
194+
if (orte_debug_flag) {
195+
opal_output(0, "Job %s has launched",
196+
(NULL == launchst.jdata) ? "UNKNOWN" : ORTE_JOBID_PRINT(launchst.jdata->jobid));
197+
}
198+
if (!orte_event_base_active || ORTE_SUCCESS != launchst.status) {
199+
goto DONE;
200+
}
201+
202+
while (orte_event_base_active && completest.active) {
203+
opal_event_loop(orte_event_base, OPAL_EVLOOP_ONCE);
204+
}
205205

206206
if (ORTE_PROC_IS_HNP) {
207207
/* ensure all local procs are dead */

orte/util/attr.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#include "orte/constants.h"
1515

1616
#include "opal/dss/dss.h"
17+
#include "opal/util/output.h"
1718

1819
#include "orte/mca/errmgr/errmgr.h"
1920

@@ -279,6 +280,8 @@ const char *orte_attr_key_to_str(orte_attribute_key_t key)
279280
return "ORTE_JOB_MULTI_DAEMON_SIM";
280281
case ORTE_JOB_NOTIFY_COMPLETION:
281282
return "ORTE_JOB_NOTIFY_COMPLETION";
283+
case ORTE_JOB_TRANSPORT_KEY:
284+
return "ORTE_JOB_TRANSPORT_KEY";
282285

283286
case ORTE_PROC_NOBARRIER:
284287
return "PROC-NOBARRIER";

orte/util/attr.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,7 @@ typedef uint16_t orte_job_flags_t;
139139
#define ORTE_JOB_TIMESTAMP_OUTPUT (ORTE_JOB_START_KEY + 48) // bool - timestamp stdout/stderr
140140
#define ORTE_JOB_MULTI_DAEMON_SIM (ORTE_JOB_START_KEY + 49) // bool - multiple daemons/node to simulate large cluster
141141
#define ORTE_JOB_NOTIFY_COMPLETION (ORTE_JOB_START_KEY + 50) // bool - notify parent proc when spawned job terminates
142+
#define ORTE_JOB_TRANSPORT_KEY (ORTE_JOB_START_KEY + 51) // string - transport keys assigned to this job
142143

143144
#define ORTE_JOB_MAX_KEY 300
144145

orte/util/pre_condition_transports.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
* Copyright (c) 2010 Cisco Systems, Inc. All rights reserved.
1313
* Copyright (c) 2015 Research Organization for Information Science
1414
* and Technology (RIST). All rights reserved.
15+
* Copyright (c) 2016 Intel, Inc. All rights reserved.
1516
* $COPYRIGHT$
1617
*
1718
* Additional copyrights may follow
@@ -43,6 +44,7 @@
4344
#include "orte/constants.h"
4445
#include "orte/types.h"
4546
#include "orte/mca/errmgr/errmgr.h"
47+
#include "orte/util/attr.h"
4648

4749
#include "orte/util/pre_condition_transports.h"
4850

@@ -161,6 +163,9 @@ int orte_pre_condition_transports(orte_job_t *jdata)
161163
return ORTE_ERR_OUT_OF_RESOURCE;
162164
}
163165

166+
/* record it in case this job executes a dynamic spawn */
167+
orte_set_attribute(&jdata->attributes, ORTE_JOB_TRANSPORT_KEY, ORTE_ATTR_LOCAL, string_key, OPAL_STRING);
168+
164169
if (OPAL_SUCCESS != mca_base_var_env_name ("orte_precondition_transports", &cs_env)) {
165170
ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);
166171
free(string_key);

0 commit comments

Comments
 (0)