2005-03-14 20:57:21 +00:00
|
|
|
/*
|
2007-03-16 23:11:45 +00:00
|
|
|
* Copyright (c) 2004-2007 The Trustees of Indiana University and Indiana
|
2005-11-05 19:57:48 +00:00
|
|
|
* University Research and Technology
|
|
|
|
* Corporation. All rights reserved.
|
|
|
|
* Copyright (c) 2004-2005 The University of Tennessee and The University
|
|
|
|
* of Tennessee Research Foundation. All rights
|
|
|
|
* reserved.
|
2006-02-08 17:40:11 +00:00
|
|
|
* Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
|
2005-03-14 20:57:21 +00:00
|
|
|
* University of Stuttgart. All rights reserved.
|
2005-03-24 12:43:37 +00:00
|
|
|
* Copyright (c) 2004-2005 The Regents of the University of California.
|
|
|
|
* All rights reserved.
|
2005-03-14 20:57:21 +00:00
|
|
|
* $COPYRIGHT$
|
2006-02-08 17:40:11 +00:00
|
|
|
*
|
2005-03-14 20:57:21 +00:00
|
|
|
* Additional copyrights may follow
|
2006-02-08 17:40:11 +00:00
|
|
|
*
|
2005-03-14 20:57:21 +00:00
|
|
|
* $HEADER$
|
|
|
|
*/
|
2005-09-19 15:29:14 +00:00
|
|
|
#include "orte_config.h"
|
2006-09-14 21:29:51 +00:00
|
|
|
#include "orte/orte_constants.h"
|
|
|
|
|
2005-12-12 20:04:00 +00:00
|
|
|
#ifdef HAVE_SYS_TIME_H
|
2005-10-27 17:04:10 +00:00
|
|
|
#include <sys/time.h>
|
2005-12-12 20:04:00 +00:00
|
|
|
#endif /* HAVE_SYS_TIME_H */
|
2005-03-14 20:57:21 +00:00
|
|
|
#include <errno.h>
|
2005-12-12 20:04:00 +00:00
|
|
|
#ifdef HAVE_UNISTD_H
|
2005-03-14 20:57:21 +00:00
|
|
|
#include <unistd.h>
|
2005-12-12 20:04:00 +00:00
|
|
|
#endif /* HAVE_UNISTD_H */
|
|
|
|
#ifdef HAVE_STRING_H
|
2005-03-14 20:57:21 +00:00
|
|
|
#include <string.h>
|
2005-12-12 20:04:00 +00:00
|
|
|
#endif /* HAVE_STRING_H */
|
2005-03-14 20:57:21 +00:00
|
|
|
|
2006-10-17 16:06:17 +00:00
|
|
|
#include "opal/class/opal_list.h"
|
2005-09-19 15:29:14 +00:00
|
|
|
#include "opal/util/trace.h"
|
2006-09-29 13:19:44 +00:00
|
|
|
#include "opal/util/output.h"
|
2006-10-20 15:27:29 +00:00
|
|
|
#include "opal/mca/base/mca_base_param.h"
|
|
|
|
#include "opal/util/opal_environ.h"
|
2007-05-01 11:27:36 +00:00
|
|
|
#include "opal/threads/condition.h"
|
2005-09-19 15:29:14 +00:00
|
|
|
|
|
|
|
#include "orte/mca/errmgr/errmgr.h"
|
2006-09-14 21:29:51 +00:00
|
|
|
#include "orte/mca/rds/rds.h"
|
|
|
|
#include "orte/mca/ras/ras.h"
|
|
|
|
#include "orte/mca/rmaps/rmaps.h"
|
|
|
|
#include "orte/mca/pls/pls.h"
|
2005-09-19 15:29:14 +00:00
|
|
|
#include "orte/mca/gpr/gpr.h"
|
|
|
|
#include "orte/mca/iof/iof.h"
|
|
|
|
#include "orte/mca/ns/ns.h"
|
2006-08-16 16:35:09 +00:00
|
|
|
#include "orte/mca/smr/smr.h"
|
2007-03-16 23:11:45 +00:00
|
|
|
#if OPAL_ENABLE_FT == 1
|
|
|
|
#include "orte/mca/snapc/snapc.h"
|
|
|
|
#endif
|
2006-09-14 21:29:51 +00:00
|
|
|
#include "orte/mca/rmgr/base/rmgr_private.h"
|
2006-11-13 18:51:18 +00:00
|
|
|
#include "orte/mca/rmgr/base/base.h"
|
2005-09-19 15:29:14 +00:00
|
|
|
#include "orte/mca/rmgr/urm/rmgr_urm.h"
|
2005-03-14 20:57:21 +00:00
|
|
|
|
|
|
|
|
2006-09-14 21:29:51 +00:00
|
|
|
static int orte_rmgr_urm_setup_job(
|
2005-03-14 20:57:21 +00:00
|
|
|
orte_app_context_t** app_context,
|
2006-08-15 19:54:10 +00:00
|
|
|
orte_std_cntr_t num_context,
|
2006-11-13 18:51:18 +00:00
|
|
|
orte_jobid_t* jobid,
|
|
|
|
opal_list_t *attrs);
|
2005-03-14 20:57:21 +00:00
|
|
|
|
2006-09-14 21:29:51 +00:00
|
|
|
static int orte_rmgr_urm_spawn_job(
|
2005-03-14 20:57:21 +00:00
|
|
|
orte_app_context_t** app_context,
|
2006-08-15 19:54:10 +00:00
|
|
|
orte_std_cntr_t num_context,
|
2005-03-14 20:57:21 +00:00
|
|
|
orte_jobid_t* jobid,
|
2006-09-19 01:45:05 +00:00
|
|
|
orte_std_cntr_t num_connect,
|
|
|
|
orte_process_name_t *connect,
|
2006-02-08 17:40:11 +00:00
|
|
|
orte_rmgr_cb_fn_t cbfn,
|
2006-10-17 16:06:17 +00:00
|
|
|
orte_proc_state_t cb_conditions,
|
|
|
|
opal_list_t *attributes);
|
2005-03-14 20:57:21 +00:00
|
|
|
|
2006-09-14 21:29:51 +00:00
|
|
|
static int orte_rmgr_urm_module_init(void);
|
|
|
|
|
|
|
|
static int orte_rmgr_urm_module_finalize(void);
|
2005-03-31 23:22:44 +00:00
|
|
|
|
|
|
|
|
2005-03-14 20:57:21 +00:00
|
|
|
orte_rmgr_base_module_t orte_rmgr_urm_module = {
|
2006-09-14 21:29:51 +00:00
|
|
|
orte_rmgr_urm_module_init,
|
|
|
|
orte_rmgr_urm_setup_job,
|
|
|
|
orte_rmgr_urm_spawn_job,
|
2006-09-19 01:45:05 +00:00
|
|
|
orte_rmgr_base_connect,
|
|
|
|
orte_rmgr_base_disconnect,
|
2006-09-14 21:29:51 +00:00
|
|
|
orte_rmgr_urm_module_finalize,
|
|
|
|
/** SUPPORT FUNCTIONS ***/
|
2006-10-17 16:06:17 +00:00
|
|
|
orte_rmgr_base_find_attribute,
|
|
|
|
orte_rmgr_base_add_attribute,
|
2006-10-18 20:02:16 +00:00
|
|
|
orte_rmgr_base_merge_attributes,
|
2006-10-17 16:06:17 +00:00
|
|
|
orte_rmgr_base_delete_attribute,
|
2006-09-14 21:29:51 +00:00
|
|
|
orte_rmgr_base_get_app_context,
|
|
|
|
orte_rmgr_base_put_app_context,
|
|
|
|
orte_rmgr_base_check_context_cwd,
|
|
|
|
orte_rmgr_base_check_context_app,
|
2007-03-16 23:11:45 +00:00
|
|
|
orte_rmgr_base_set_proc_info,
|
2007-07-02 16:45:40 +00:00
|
|
|
orte_rmgr_base_get_proc_info,
|
|
|
|
orte_rmgr_base_set_universe_size,
|
|
|
|
orte_rmgr_base_get_universe_size
|
2005-03-14 20:57:21 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2006-09-14 21:29:51 +00:00
|
|
|
|
2005-03-31 15:47:37 +00:00
|
|
|
/*
|
2006-09-14 21:29:51 +00:00
|
|
|
* Since we were selected, complete the init
|
|
|
|
* by starting the comm system
|
2005-03-31 15:47:37 +00:00
|
|
|
*/
|
2006-09-14 21:29:51 +00:00
|
|
|
static int orte_rmgr_urm_module_init(void)
|
2005-03-31 15:47:37 +00:00
|
|
|
{
|
|
|
|
int rc;
|
2006-09-14 21:29:51 +00:00
|
|
|
|
|
|
|
if (ORTE_SUCCESS != (rc = orte_rmgr_base_comm_start())) {
|
2005-03-31 15:47:37 +00:00
|
|
|
ORTE_ERROR_LOG(rc);
|
|
|
|
}
|
2006-09-14 21:29:51 +00:00
|
|
|
return rc;
|
2005-03-31 15:47:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-03-14 20:57:21 +00:00
|
|
|
/*
|
2006-09-14 21:29:51 +00:00
|
|
|
* Setup the job
|
2005-03-14 20:57:21 +00:00
|
|
|
*/
|
|
|
|
|
2006-11-13 18:51:18 +00:00
|
|
|
static int orte_rmgr_urm_setup_job(orte_app_context_t** app_context,
|
|
|
|
orte_std_cntr_t num_context,
|
|
|
|
orte_jobid_t* jobid,
|
|
|
|
opal_list_t *attrs)
|
2005-03-14 20:57:21 +00:00
|
|
|
{
|
|
|
|
int rc;
|
2006-10-20 15:27:29 +00:00
|
|
|
orte_std_cntr_t i;
|
2006-11-13 18:51:18 +00:00
|
|
|
orte_attribute_t *attr;
|
|
|
|
orte_jobid_t *jptr;
|
2006-10-20 15:27:29 +00:00
|
|
|
|
2005-09-19 15:29:14 +00:00
|
|
|
OPAL_TRACE(1);
|
2006-02-08 17:40:11 +00:00
|
|
|
|
2006-11-13 18:51:18 +00:00
|
|
|
/* check for given jobid */
|
|
|
|
if (NULL != (attr = orte_rmgr.find_attribute(attrs, ORTE_RMGR_USE_GIVEN_JOBID))) {
|
|
|
|
if (ORTE_SUCCESS != (rc = orte_dss.get((void**)&jptr, attr->value, ORTE_JOBID))) {
|
|
|
|
ORTE_ERROR_LOG(rc);
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
*jobid = *jptr;
|
|
|
|
} else {
|
|
|
|
/* allocate a jobid */
|
Bring over the update to terminate orteds that are generated by a dynamic spawn such as comm_spawn. This introduces the concept of a job "family" - i.e., jobs that have a parent/child relationship. Comm_spawn'ed jobs have a parent (the one that spawned them). We track that relationship throughout the lineage - i.e., if a comm_spawned job in turn calls comm_spawn, then it has a parent (the one that spawned it) and a "root" job (the original job that started things).
Accordingly, there are new APIs to the name service to support the ability to get a job's parent, root, immediate children, and all its descendants. In addition, the terminate_job, terminate_orted, and signal_job APIs for the PLS have been modified to accept attributes that define the extent of their actions. For example, doing a "terminate_job" with an attribute of ORTE_NS_INCLUDE_DESCENDANTS will terminate the given jobid AND all jobs that descended from it.
I have tested this capability on a MacBook under rsh, Odin under SLURM, and LANL's Flash (bproc). It worked successfully on non-MPI jobs (both simple and including a spawn), and MPI jobs (again, both simple and with a spawn).
This commit was SVN r12597.
2006-11-14 19:34:59 +00:00
|
|
|
if (ORTE_SUCCESS != (rc = orte_ns.create_jobid(jobid, attrs))) {
|
2006-11-13 18:51:18 +00:00
|
|
|
ORTE_ERROR_LOG(rc);
|
|
|
|
return rc;
|
|
|
|
}
|
2005-03-14 20:57:21 +00:00
|
|
|
}
|
|
|
|
|
2006-10-20 15:27:29 +00:00
|
|
|
/* for each app_context, we need to purge their environment of HNP
|
|
|
|
* MCA component selection directives
|
|
|
|
*/
|
|
|
|
for (i=0; i < num_context; i++) {
|
2006-10-20 16:50:13 +00:00
|
|
|
orte_rmgr_base_purge_mca_params(&app_context[i]->env);
|
2006-10-20 15:27:29 +00:00
|
|
|
}
|
|
|
|
|
2005-10-07 22:24:52 +00:00
|
|
|
/* create and initialize job segment */ /* JJH C/N mapping before this */
|
2006-02-08 17:40:11 +00:00
|
|
|
if (ORTE_SUCCESS !=
|
|
|
|
(rc = orte_rmgr_base_put_app_context(*jobid, app_context,
|
2005-03-14 20:57:21 +00:00
|
|
|
num_context))) {
|
2005-03-31 15:47:37 +00:00
|
|
|
ORTE_ERROR_LOG(rc);
|
2005-03-14 20:57:21 +00:00
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
2006-09-14 21:29:51 +00:00
|
|
|
/* set a default job state of INIT. We need this so that
|
|
|
|
* orterun doesn't report an error from the registry if
|
|
|
|
* the spawn fails for some reason. Otherwise, orterun
|
|
|
|
* will try to get the job state (to see why we exited)
|
|
|
|
* and will find nothing
|
|
|
|
*/
|
|
|
|
if (ORTE_SUCCESS != (rc = orte_smr.set_job_state(*jobid, ORTE_JOB_STATE_INIT))) {
|
|
|
|
ORTE_ERROR_LOG(rc);
|
|
|
|
return rc;
|
2006-06-08 18:27:17 +00:00
|
|
|
}
|
|
|
|
|
2006-09-14 21:29:51 +00:00
|
|
|
return ORTE_SUCCESS;
|
2006-06-08 18:27:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-06-06 17:39:23 +00:00
|
|
|
/* the xconnect functionality in this RMGR component is only utilized
|
|
|
|
* when a singleton does a dynamic spawn. Hence, the "parent" jobid
|
|
|
|
* is just my own
|
|
|
|
*/
|
|
|
|
static void orte_rmgr_urm_xconnect_callback(orte_gpr_notify_data_t *data, void *cbdata)
|
|
|
|
{
|
|
|
|
orte_gpr_value_t **values;
|
|
|
|
orte_jobid_t child;
|
|
|
|
int rc;
|
|
|
|
|
|
|
|
OPAL_TRACE(1);
|
|
|
|
|
|
|
|
/* we made sure in the subscriptions that at least one
|
|
|
|
* value is always returned
|
|
|
|
* get the jobid from the segment name in the first value
|
|
|
|
*/
|
|
|
|
values = (orte_gpr_value_t**)(data->values)->addr;
|
|
|
|
if (ORTE_SUCCESS != (rc = orte_schema.extract_jobid_from_segment_name(&child,
|
|
|
|
values[0]->segment))) {
|
|
|
|
ORTE_ERROR_LOG(rc);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ORTE_SUCCESS != (rc = orte_rmgr_base_xconnect(child, ORTE_PROC_MY_NAME->jobid))) {
|
|
|
|
ORTE_ERROR_LOG(rc);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* signal that the application has completed xconnect */
|
|
|
|
OPAL_THREAD_LOCK(&mca_rmgr_urm_component.lock);
|
|
|
|
mca_rmgr_urm_component.xconnect = true;
|
|
|
|
/* if the launch is also done, then spawn complete */
|
|
|
|
if (mca_rmgr_urm_component.launched) {
|
|
|
|
mca_rmgr_urm_component.done = true;
|
|
|
|
mca_rmgr_urm_component.rc = ORTE_SUCCESS;
|
|
|
|
opal_condition_signal(&mca_rmgr_urm_component.cond);
|
|
|
|
}
|
|
|
|
OPAL_THREAD_UNLOCK(&mca_rmgr_urm_component.lock);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2005-06-01 19:23:23 +00:00
|
|
|
static void orte_rmgr_urm_wireup_stdin(orte_jobid_t jobid)
|
|
|
|
{
|
|
|
|
int rc;
|
|
|
|
orte_process_name_t* name;
|
|
|
|
|
2005-09-19 15:29:14 +00:00
|
|
|
OPAL_TRACE(1);
|
2006-02-08 17:40:11 +00:00
|
|
|
|
2005-06-01 19:23:23 +00:00
|
|
|
if (ORTE_SUCCESS != (rc = orte_ns.create_process_name(&name, 0, jobid, 0))) {
|
|
|
|
ORTE_ERROR_LOG(rc);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (ORTE_SUCCESS != (rc = orte_iof.iof_push(name, ORTE_NS_CMP_JOBID, ORTE_IOF_STDIN, 0))) {
|
|
|
|
ORTE_ERROR_LOG(rc);
|
|
|
|
}
|
2007-03-30 13:43:50 +00:00
|
|
|
free(name);
|
2005-06-01 19:23:23 +00:00
|
|
|
}
|
|
|
|
|
2005-03-14 20:57:21 +00:00
|
|
|
|
|
|
|
static void orte_rmgr_urm_callback(orte_gpr_notify_data_t *data, void *cbdata)
|
|
|
|
{
|
2006-03-29 01:26:16 +00:00
|
|
|
orte_rmgr_cb_fn_t cbfunc;
|
|
|
|
union {
|
|
|
|
orte_rmgr_cb_fn_t func;
|
|
|
|
void * ptr;
|
|
|
|
} cbfunc_union;
|
2005-07-18 18:49:00 +00:00
|
|
|
orte_gpr_value_t **values, *value;
|
2005-03-14 20:57:21 +00:00
|
|
|
orte_gpr_keyval_t** keyvals;
|
|
|
|
orte_jobid_t jobid;
|
2006-08-15 19:54:10 +00:00
|
|
|
orte_std_cntr_t i, j, k;
|
2005-05-01 00:47:35 +00:00
|
|
|
int rc;
|
2005-03-14 20:57:21 +00:00
|
|
|
|
2005-09-19 15:29:14 +00:00
|
|
|
OPAL_TRACE(1);
|
2006-02-08 17:40:11 +00:00
|
|
|
|
2006-09-14 21:29:51 +00:00
|
|
|
/* ISO C forbids conversion of object pointer to function
|
2006-03-29 01:26:16 +00:00
|
|
|
pointer. So we do this, which is the same thing, but without
|
|
|
|
the warning from GCC */
|
|
|
|
cbfunc_union.ptr = cbdata;
|
|
|
|
cbfunc = cbfunc_union.func;
|
|
|
|
|
2005-06-24 16:59:37 +00:00
|
|
|
/* we made sure in the subscriptions that at least one
|
|
|
|
* value is always returned
|
|
|
|
* get the jobid from the segment name in the first value
|
|
|
|
*/
|
2005-07-18 18:49:00 +00:00
|
|
|
values = (orte_gpr_value_t**)(data->values)->addr;
|
2005-06-24 16:59:37 +00:00
|
|
|
if (ORTE_SUCCESS != (rc =
|
|
|
|
orte_schema.extract_jobid_from_segment_name(&jobid,
|
|
|
|
values[0]->segment))) {
|
2005-03-14 20:57:21 +00:00
|
|
|
ORTE_ERROR_LOG(rc);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2005-07-18 18:49:00 +00:00
|
|
|
for(i = 0, k=0; k < data->cnt &&
|
|
|
|
i < (data->values)->size; i++) {
|
|
|
|
if (NULL != values[i]) {
|
|
|
|
k++;
|
|
|
|
value = values[i];
|
|
|
|
/* determine the state change */
|
|
|
|
keyvals = value->keyvals;
|
|
|
|
for(j=0; j<value->cnt; j++) {
|
|
|
|
orte_gpr_keyval_t* keyval = keyvals[j];
|
2006-02-08 17:40:11 +00:00
|
|
|
if(strcmp(keyval->key, ORTE_PROC_NUM_AT_INIT) == 0) {
|
|
|
|
(*cbfunc)(jobid,ORTE_PROC_STATE_INIT);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if(strcmp(keyval->key, ORTE_PROC_NUM_LAUNCHED) == 0) {
|
|
|
|
(*cbfunc)(jobid,ORTE_PROC_STATE_LAUNCHED);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if(strcmp(keyval->key, ORTE_PROC_NUM_RUNNING) == 0) {
|
|
|
|
(*cbfunc)(jobid,ORTE_PROC_STATE_RUNNING);
|
|
|
|
continue;
|
|
|
|
}
|
2005-07-18 18:49:00 +00:00
|
|
|
if(strcmp(keyval->key, ORTE_PROC_NUM_AT_STG1) == 0) {
|
|
|
|
(*cbfunc)(jobid,ORTE_PROC_STATE_AT_STG1);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if(strcmp(keyval->key, ORTE_PROC_NUM_AT_STG2) == 0) {
|
2005-09-20 19:12:59 +00:00
|
|
|
(*cbfunc)(jobid,ORTE_PROC_STATE_AT_STG2);
|
2005-07-18 18:49:00 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if(strcmp(keyval->key, ORTE_PROC_NUM_AT_STG3) == 0) {
|
|
|
|
(*cbfunc)(jobid,ORTE_PROC_STATE_AT_STG3);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if(strcmp(keyval->key, ORTE_PROC_NUM_FINALIZED) == 0) {
|
2007-03-16 23:11:45 +00:00
|
|
|
#if OPAL_ENABLE_FT == 1
|
|
|
|
/* Stop tracking this job */
|
|
|
|
if(ORTE_SUCCESS != (rc = orte_snapc.release_job(jobid))) {
|
|
|
|
ORTE_ERROR_LOG(rc);
|
|
|
|
}
|
|
|
|
#endif
|
2005-07-18 18:49:00 +00:00
|
|
|
(*cbfunc)(jobid,ORTE_PROC_STATE_FINALIZED);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if(strcmp(keyval->key, ORTE_PROC_NUM_TERMINATED) == 0) {
|
2007-03-16 23:11:45 +00:00
|
|
|
#if OPAL_ENABLE_FT == 1
|
|
|
|
/* Stop tracking this job */
|
|
|
|
if(ORTE_SUCCESS != (rc = orte_snapc.release_job(jobid))) {
|
|
|
|
ORTE_ERROR_LOG(rc);
|
|
|
|
}
|
|
|
|
#endif
|
2005-07-18 18:49:00 +00:00
|
|
|
(*cbfunc)(jobid,ORTE_PROC_STATE_TERMINATED);
|
|
|
|
continue;
|
|
|
|
}
|
2005-03-14 20:57:21 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-02-08 17:40:11 +00:00
|
|
|
/**
|
|
|
|
* define a callback point for completing the wireup of the stdin for io forwarding
|
|
|
|
*/
|
|
|
|
static void orte_rmgr_urm_wireup_callback(orte_gpr_notify_data_t *data, void *cbdata)
|
|
|
|
{
|
|
|
|
orte_gpr_value_t **values;
|
|
|
|
orte_jobid_t jobid;
|
|
|
|
int rc;
|
|
|
|
|
|
|
|
OPAL_TRACE(1);
|
|
|
|
|
|
|
|
/* we made sure in the subscriptions that at least one
|
|
|
|
* value is always returned
|
|
|
|
* get the jobid from the segment name in the first value
|
|
|
|
*/
|
|
|
|
values = (orte_gpr_value_t**)(data->values)->addr;
|
|
|
|
if (ORTE_SUCCESS != (rc = orte_schema.extract_jobid_from_segment_name(&jobid, values[0]->segment))) {
|
|
|
|
ORTE_ERROR_LOG(rc);
|
|
|
|
return;
|
|
|
|
}
|
2006-11-13 18:51:18 +00:00
|
|
|
|
|
|
|
opal_output(orte_rmgr_base.rmgr_output, "rmgr_urm:wireup_callback called for job %ld", (long)jobid);
|
|
|
|
|
2006-02-08 17:40:11 +00:00
|
|
|
orte_rmgr_urm_wireup_stdin(jobid);
|
2007-05-18 13:29:11 +00:00
|
|
|
|
|
|
|
/* signal that we can leave */
|
2007-05-01 11:27:36 +00:00
|
|
|
OPAL_THREAD_LOCK(&mca_rmgr_urm_component.lock);
|
2007-06-06 17:39:23 +00:00
|
|
|
mca_rmgr_urm_component.launched = true;
|
|
|
|
/* if the xconnect is also done, then spawn complete */
|
|
|
|
if (mca_rmgr_urm_component.xconnect) {
|
|
|
|
mca_rmgr_urm_component.done = true;
|
|
|
|
mca_rmgr_urm_component.rc = ORTE_SUCCESS;
|
|
|
|
opal_condition_signal(&mca_rmgr_urm_component.cond);
|
|
|
|
}
|
2007-05-18 13:29:11 +00:00
|
|
|
OPAL_THREAD_UNLOCK(&mca_rmgr_urm_component.lock);
|
2006-02-08 17:40:11 +00:00
|
|
|
}
|
|
|
|
|
2007-05-18 13:29:11 +00:00
|
|
|
/*
|
|
|
|
* callback that tells us when we can leave the spawn function and return to caller
|
|
|
|
*/
|
|
|
|
static void app_terminated(orte_gpr_notify_data_t *data, void *cbdata)
|
|
|
|
{
|
|
|
|
/* signal that we can leave */
|
|
|
|
OPAL_THREAD_LOCK(&mca_rmgr_urm_component.lock);
|
|
|
|
mca_rmgr_urm_component.done = true;
|
|
|
|
opal_condition_signal(&mca_rmgr_urm_component.cond);
|
|
|
|
OPAL_THREAD_UNLOCK(&mca_rmgr_urm_component.lock);
|
|
|
|
}
|
2007-05-01 11:27:36 +00:00
|
|
|
|
2005-03-14 20:57:21 +00:00
|
|
|
/*
|
|
|
|
* Shortcut for the multiple steps involved in spawning a new job.
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
2006-09-14 21:29:51 +00:00
|
|
|
static int orte_rmgr_urm_spawn_job(
|
2005-03-14 20:57:21 +00:00
|
|
|
orte_app_context_t** app_context,
|
2006-08-15 19:54:10 +00:00
|
|
|
orte_std_cntr_t num_context,
|
2005-03-14 20:57:21 +00:00
|
|
|
orte_jobid_t* jobid,
|
2006-09-19 01:45:05 +00:00
|
|
|
orte_std_cntr_t num_connect,
|
|
|
|
orte_process_name_t *connect,
|
2006-02-08 17:40:11 +00:00
|
|
|
orte_rmgr_cb_fn_t cbfunc,
|
2006-10-17 16:06:17 +00:00
|
|
|
orte_proc_state_t cb_conditions,
|
|
|
|
opal_list_t *attributes)
|
2005-03-14 20:57:21 +00:00
|
|
|
{
|
|
|
|
int rc;
|
|
|
|
orte_process_name_t* name;
|
2006-09-29 13:19:44 +00:00
|
|
|
struct timeval urmstart, urmstop;
|
2007-06-06 17:39:23 +00:00
|
|
|
orte_attribute_t *flow, *attr;
|
2006-11-02 05:15:24 +00:00
|
|
|
uint8_t flags, *fptr;
|
2007-06-06 17:39:23 +00:00
|
|
|
orte_proc_state_t *gate;
|
2006-02-08 17:40:11 +00:00
|
|
|
|
2005-09-19 15:29:14 +00:00
|
|
|
OPAL_TRACE(1);
|
2006-02-08 17:40:11 +00:00
|
|
|
|
2006-09-29 13:19:44 +00:00
|
|
|
/* check for timing request - get start time if so */
|
|
|
|
if (mca_rmgr_urm_component.timing) {
|
|
|
|
if (0 != gettimeofday(&urmstart, NULL)) {
|
|
|
|
opal_output(0, "rmgr_urm: could not obtain start time");
|
|
|
|
urmstart.tv_sec = 0;
|
|
|
|
urmstart.tv_usec = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-05-01 11:27:36 +00:00
|
|
|
/* mark that the spawn is not done */
|
|
|
|
OPAL_THREAD_LOCK(&mca_rmgr_urm_component.lock);
|
2007-06-06 17:39:23 +00:00
|
|
|
mca_rmgr_urm_component.xconnect = false;
|
2007-05-01 11:27:36 +00:00
|
|
|
mca_rmgr_urm_component.done = false;
|
2007-06-06 17:39:23 +00:00
|
|
|
mca_rmgr_urm_component.launched = false;
|
2007-05-18 13:29:11 +00:00
|
|
|
mca_rmgr_urm_component.rc = ORTE_ERR_FAILED_TO_START;
|
2007-05-01 11:27:36 +00:00
|
|
|
OPAL_THREAD_UNLOCK(&mca_rmgr_urm_component.lock);
|
|
|
|
|
2006-11-02 05:15:24 +00:00
|
|
|
/* check for any flow directives to control what we do */
|
|
|
|
if (NULL != (flow = orte_rmgr.find_attribute(attributes, ORTE_RMGR_SPAWN_FLOW))) {
|
|
|
|
/* something was specified - get the value */
|
2006-11-03 20:45:22 +00:00
|
|
|
if (ORTE_SUCCESS != (rc = orte_dss.get((void**)&fptr, flow->value, ORTE_UINT8))) {
|
2006-11-02 05:15:24 +00:00
|
|
|
ORTE_ERROR_LOG(rc);
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
flags = *fptr;
|
|
|
|
} else {
|
|
|
|
flags = 0xff;
|
|
|
|
}
|
|
|
|
|
2005-03-14 20:57:21 +00:00
|
|
|
/*
|
|
|
|
* Initialize job segment and allocate resources
|
2005-10-07 22:24:52 +00:00
|
|
|
*/ /* JJH Insert C/N mapping stuff here */
|
2006-10-02 00:46:31 +00:00
|
|
|
|
Bring over the update to terminate orteds that are generated by a dynamic spawn such as comm_spawn. This introduces the concept of a job "family" - i.e., jobs that have a parent/child relationship. Comm_spawn'ed jobs have a parent (the one that spawned them). We track that relationship throughout the lineage - i.e., if a comm_spawned job in turn calls comm_spawn, then it has a parent (the one that spawned it) and a "root" job (the original job that started things).
Accordingly, there are new APIs to the name service to support the ability to get a job's parent, root, immediate children, and all its descendants. In addition, the terminate_job, terminate_orted, and signal_job APIs for the PLS have been modified to accept attributes that define the extent of their actions. For example, doing a "terminate_job" with an attribute of ORTE_NS_INCLUDE_DESCENDANTS will terminate the given jobid AND all jobs that descended from it.
I have tested this capability on a MacBook under rsh, Odin under SLURM, and LANL's Flash (bproc). It worked successfully on non-MPI jobs (both simple and including a spawn), and MPI jobs (again, both simple and with a spawn).
This commit was SVN r12597.
2006-11-14 19:34:59 +00:00
|
|
|
/* Only do this step if we have been asked to do it via the
|
|
|
|
* ORTE_RMGR_SPAWN_FLOW attribute
|
2006-10-02 00:46:31 +00:00
|
|
|
*/
|
2006-11-02 05:15:24 +00:00
|
|
|
if (flags & ORTE_RMGR_SETUP) {
|
|
|
|
if (ORTE_SUCCESS !=
|
Bring over the update to terminate orteds that are generated by a dynamic spawn such as comm_spawn. This introduces the concept of a job "family" - i.e., jobs that have a parent/child relationship. Comm_spawn'ed jobs have a parent (the one that spawned them). We track that relationship throughout the lineage - i.e., if a comm_spawned job in turn calls comm_spawn, then it has a parent (the one that spawned it) and a "root" job (the original job that started things).
Accordingly, there are new APIs to the name service to support the ability to get a job's parent, root, immediate children, and all its descendants. In addition, the terminate_job, terminate_orted, and signal_job APIs for the PLS have been modified to accept attributes that define the extent of their actions. For example, doing a "terminate_job" with an attribute of ORTE_NS_INCLUDE_DESCENDANTS will terminate the given jobid AND all jobs that descended from it.
I have tested this capability on a MacBook under rsh, Odin under SLURM, and LANL's Flash (bproc). It worked successfully on non-MPI jobs (both simple and including a spawn), and MPI jobs (again, both simple and with a spawn).
This commit was SVN r12597.
2006-11-14 19:34:59 +00:00
|
|
|
(rc = orte_rmgr_urm_setup_job(app_context, num_context, jobid, attributes))) {
|
2006-11-02 05:15:24 +00:00
|
|
|
ORTE_ERROR_LOG(rc);
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
}
|
2006-10-31 22:16:51 +00:00
|
|
|
|
2006-12-06 15:59:34 +00:00
|
|
|
if (flags & ORTE_RMGR_RES_DISC) {
|
|
|
|
if (ORTE_SUCCESS != (rc = orte_rds.query(*jobid))) {
|
|
|
|
ORTE_ERROR_LOG(rc);
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-11-02 05:15:24 +00:00
|
|
|
if (flags & ORTE_RMGR_ALLOC) {
|
|
|
|
if (ORTE_SUCCESS != (rc = orte_ras.allocate_job(*jobid, attributes))) {
|
|
|
|
ORTE_ERROR_LOG(rc);
|
|
|
|
return rc;
|
|
|
|
}
|
2006-10-31 22:16:51 +00:00
|
|
|
}
|
2005-10-27 17:04:10 +00:00
|
|
|
|
2006-11-02 05:15:24 +00:00
|
|
|
if (flags & ORTE_RMGR_MAP) {
|
|
|
|
if (ORTE_SUCCESS != (rc = orte_rmaps.map_job(*jobid, attributes))) {
|
|
|
|
ORTE_ERROR_LOG(rc);
|
|
|
|
return rc;
|
|
|
|
}
|
2006-10-31 22:16:51 +00:00
|
|
|
}
|
2005-03-14 20:57:21 +00:00
|
|
|
|
2006-11-13 18:51:18 +00:00
|
|
|
if (flags & ORTE_RMGR_SETUP_TRIGS) {
|
|
|
|
/*
|
|
|
|
* setup I/O forwarding
|
|
|
|
*/
|
2006-09-14 21:29:51 +00:00
|
|
|
|
2006-11-13 18:51:18 +00:00
|
|
|
if (ORTE_SUCCESS != (rc = orte_ns.create_process_name(&name, 0, *jobid, 0))) {
|
|
|
|
ORTE_ERROR_LOG(rc);
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
if (ORTE_SUCCESS != (rc = orte_iof.iof_pull(name, ORTE_NS_CMP_JOBID, ORTE_IOF_STDOUT, 1))) {
|
|
|
|
ORTE_ERROR_LOG(rc);
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
if (ORTE_SUCCESS != (rc = orte_iof.iof_pull(name, ORTE_NS_CMP_JOBID, ORTE_IOF_STDERR, 2))) {
|
|
|
|
ORTE_ERROR_LOG(rc);
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
free(name); /* done with this */
|
2006-03-29 01:26:16 +00:00
|
|
|
|
2007-06-08 22:59:31 +00:00
|
|
|
#if 0
|
|
|
|
{
|
|
|
|
int i = 0;
|
|
|
|
printf("orte_rmgr_urm_wireup_stdin callback: pid %d\n", getpid());
|
|
|
|
while (i == 0) sleep(5);
|
|
|
|
}
|
|
|
|
#endif
|
2006-11-13 18:51:18 +00:00
|
|
|
/* setup the launch system's stage gate counters and subscriptions */
|
|
|
|
if (ORTE_SUCCESS != (rc = orte_rmgr_base_proc_stage_gate_init(*jobid))) {
|
|
|
|
ORTE_ERROR_LOG(rc);
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
2007-05-18 13:29:11 +00:00
|
|
|
/* setup the subscription so we can complete the wireup when all processes reach LAUNCHED. This
|
2007-05-01 11:27:36 +00:00
|
|
|
* function has the dual purpose of setting the conditioned wait variable so that the RMGR
|
|
|
|
* can know that the app has indeed launched, and hence return to the caller
|
|
|
|
*/
|
2006-11-13 18:51:18 +00:00
|
|
|
rc = orte_smr.job_stage_gate_subscribe(*jobid, orte_rmgr_urm_wireup_callback, NULL, ORTE_PROC_STATE_LAUNCHED);
|
2005-03-14 20:57:21 +00:00
|
|
|
if(ORTE_SUCCESS != rc) {
|
|
|
|
ORTE_ERROR_LOG(rc);
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
2007-06-06 17:39:23 +00:00
|
|
|
/* see if we need to setup a cross-connect of ORTE information with the new job */
|
|
|
|
if (NULL != (attr = orte_rmgr.find_attribute(attributes, ORTE_RMGR_XCONNECT_AT_SPAWN))) {
|
|
|
|
/* cross-connect was requested - get the stage gate name where this is to occur */
|
|
|
|
if (ORTE_SUCCESS != (rc = orte_dss.get((void**)&gate, attr->value, ORTE_PROC_STATE))) {
|
|
|
|
ORTE_ERROR_LOG(rc);
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
/* setup the xconnect subscription on the new job so we can complete the procedure */
|
|
|
|
if (ORTE_SUCCESS != (rc = orte_smr.job_stage_gate_subscribe(*jobid,
|
|
|
|
orte_rmgr_urm_xconnect_callback, NULL, *gate))) {
|
|
|
|
ORTE_ERROR_LOG(rc);
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
/* indicate that we don't need to wait for xconnect */
|
|
|
|
OPAL_THREAD_LOCK(&mca_rmgr_urm_component.lock);
|
|
|
|
mca_rmgr_urm_component.xconnect = true;
|
2007-06-06 22:30:34 +00:00
|
|
|
OPAL_THREAD_UNLOCK(&mca_rmgr_urm_component.lock);
|
2007-06-06 17:39:23 +00:00
|
|
|
}
|
|
|
|
|
2007-05-18 13:29:11 +00:00
|
|
|
/* setup the subscription so we will know if things fail to launch */
|
|
|
|
rc = orte_smr.job_stage_gate_subscribe(*jobid, app_terminated, NULL, ORTE_PROC_STATE_TERMINATED);
|
|
|
|
if(ORTE_SUCCESS != rc) {
|
|
|
|
ORTE_ERROR_LOG(rc);
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2006-11-13 18:51:18 +00:00
|
|
|
* Define the ERRMGR's callbacks as required
|
|
|
|
*/
|
|
|
|
if (ORTE_SUCCESS != (rc = orte_errmgr.register_job(*jobid))) {
|
|
|
|
ORTE_ERROR_LOG(rc);
|
|
|
|
return rc;
|
2006-09-29 13:19:44 +00:00
|
|
|
}
|
2006-11-13 18:51:18 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* setup caller's callback
|
|
|
|
*/
|
|
|
|
|
|
|
|
if(NULL != cbfunc) {
|
|
|
|
union {
|
|
|
|
orte_rmgr_cb_fn_t func;
|
|
|
|
void * ptr;
|
|
|
|
} cbfunc_union;
|
|
|
|
void *cbdata;
|
|
|
|
|
|
|
|
/* ISO C forbids conversion of object pointer to function
|
|
|
|
pointer. So we do this, which is the same thing, but without
|
|
|
|
the warning from GCC */
|
|
|
|
cbfunc_union.func = cbfunc;
|
|
|
|
cbdata = cbfunc_union.ptr;
|
|
|
|
|
|
|
|
rc = orte_smr.job_stage_gate_subscribe(*jobid, orte_rmgr_urm_callback, cbdata, cb_conditions);
|
|
|
|
if(ORTE_SUCCESS != rc) {
|
|
|
|
ORTE_ERROR_LOG(rc);
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* check for timing request - get stop time and report elapsed time if so */
|
|
|
|
if (mca_rmgr_urm_component.timing) {
|
|
|
|
if (0 != gettimeofday(&urmstop, NULL)) {
|
|
|
|
opal_output(0, "rmgr_urm: could not obtain stop time");
|
|
|
|
} else {
|
|
|
|
opal_output(0, "rmgr_urm: job setup time is %ld usec",
|
|
|
|
(long int)((urmstop.tv_sec - urmstart.tv_sec)*1000000 +
|
|
|
|
(urmstop.tv_usec - urmstart.tv_usec)));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2007-03-16 23:11:45 +00:00
|
|
|
|
2006-11-13 18:51:18 +00:00
|
|
|
/* if we don't want to launch, then just return here */
|
|
|
|
if (!(flags & ORTE_RMGR_LAUNCH)) {
|
|
|
|
return ORTE_SUCCESS;
|
2006-09-29 13:19:44 +00:00
|
|
|
}
|
2007-03-16 23:11:45 +00:00
|
|
|
|
|
|
|
#if OPAL_ENABLE_FT == 1
|
|
|
|
/*
|
|
|
|
* Wire up the SnapC component to this job
|
|
|
|
*/
|
|
|
|
if(ORTE_SUCCESS != (rc = orte_snapc.setup_job(*jobid))) {
|
|
|
|
ORTE_ERROR_LOG(rc);
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
Bring in the generalized xcast communication system along with the correspondingly revised orted launch. I will send a message out to developers explaining the basic changes. In brief:
1. generalize orte_rml.xcast to become a general broadcast-like messaging system. Messages can now be sent to any tag on the daemons or processes. Note that any message sent via xcast will be delivered to ALL processes in the specified job - you don't get to pick and choose. At a later date, we will introduce an augmented capability that will use the daemons as relays, but will allow you to send to a specified array of process names.
2. extended orte_rml.xcast so it supports more scalable message routing methodologies. At the moment, we support three: (a) direct, which sends the message directly to all recipients; (b) linear, which sends the message to the local daemon on each node, which then relays it to its own local procs; and (b) binomial, which sends the message via a binomial algo across all the daemons, each of which then relays to its own local procs. The crossover points between the algos are adjustable via MCA param, or you can simply demand that a specific algo be used.
3. orteds no longer exhibit two types of behavior: bootproxy or VM. Orteds now always behave like they are part of a virtual machine - they simply launch a job if mpirun tells them to do so. This is another step towards creating an "orteboot" functionality, but also provided a clean system for supporting message relaying.
Note one major impact of this commit: multiple daemons on a node cannot be supported any longer! Only a single daemon/node is now allowed.
This commit is known to break support for the following environments: POE, Xgrid, Xcpu, Windows. It has been tested on rsh, SLURM, and Bproc. Modifications for TM support have been made but could not be verified due to machine problems at LANL. Modifications for SGE have been made but could not be verified. The developers for the non-verified environments will be separately notified along with suggestions on how to fix the problems.
This commit was SVN r15007.
2007-06-12 13:28:54 +00:00
|
|
|
/* setup the orted's stage gate triggers - do this here as, if there are no
|
|
|
|
* new orteds to launch, the trigger will fire immediately and launch
|
|
|
|
* the procs
|
|
|
|
*/
|
|
|
|
if (ORTE_SUCCESS != (rc = orte_rmgr_base_orted_stage_gate_init(*jobid))) {
|
|
|
|
ORTE_ERROR_LOG(rc);
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2005-03-14 20:57:21 +00:00
|
|
|
* launch the job
|
|
|
|
*/
|
2006-09-14 21:29:51 +00:00
|
|
|
if (ORTE_SUCCESS != (rc = orte_pls.launch_job(*jobid))) {
|
2005-03-14 20:57:21 +00:00
|
|
|
ORTE_ERROR_LOG(rc);
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
2007-05-01 11:27:36 +00:00
|
|
|
/* wait for the application to launch */
|
|
|
|
OPAL_THREAD_LOCK(&mca_rmgr_urm_component.lock);
|
|
|
|
while (!mca_rmgr_urm_component.done) {
|
|
|
|
opal_condition_wait(&mca_rmgr_urm_component.cond,
|
|
|
|
&mca_rmgr_urm_component.lock);
|
|
|
|
}
|
|
|
|
OPAL_THREAD_UNLOCK(&mca_rmgr_urm_component.lock);
|
|
|
|
|
Bring the timing instrumentation to the trunk.
If you want to look at our launch and MPI process startup times, you can do so with two MCA params:
OMPI_MCA_orte_timing: set it to anything non-zero and you will get the launch time for different steps in the job launch procedure. The degree of detail depends on the launch environment. rsh will provide you with the average, min, and max launch time for the daemons. SLURM block launches the daemon, so you only get the time to launch the daemons and the total time to launch the job. Ditto for bproc. TM looks more like rsh. Only those four environments are currently supported - anyone interested in extending this capability to other environs is welcome to do so. In all cases, you also get the time to setup the job for launch.
OMPI_MCA_ompi_timing: set it to anything non-zero and you will get the time for mpi_init to reach the compound registry command, the time to execute that command, the time to go from our stage1 barrier to the stage2 barrier, and the time to go from the stage2 barrier to the end of mpi_init. This will be output for each process, so you'll have to compile any statistics on your own. Note: if someone develops a nice parser to do so, it would be really appreciated if you could/would share!
This commit was SVN r12302.
2006-10-25 15:27:47 +00:00
|
|
|
/* check for timing request - get start time if so */
|
|
|
|
if (mca_rmgr_urm_component.timing) {
|
|
|
|
if (0 != gettimeofday(&urmstart, NULL)) {
|
|
|
|
opal_output(0, "rmgr_urm: could not obtain launch stop time");
|
|
|
|
} else {
|
|
|
|
opal_output(0, "rmgr_urm: launch time is %ld usec",
|
|
|
|
(long int)((urmstart.tv_sec - urmstop.tv_sec)*1000000 +
|
|
|
|
(urmstart.tv_usec - urmstop.tv_usec)));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-05-18 13:29:11 +00:00
|
|
|
/* return the status code contained in the component */
|
|
|
|
return mca_rmgr_urm_component.rc;
|
2005-03-14 20:57:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-09-14 21:29:51 +00:00
|
|
|
static int orte_rmgr_urm_module_finalize(void)
|
2005-03-31 23:22:44 +00:00
|
|
|
{
|
2005-04-15 17:04:57 +00:00
|
|
|
int rc;
|
|
|
|
|
2006-09-14 21:29:51 +00:00
|
|
|
/* Cancel pending receive. */
|
|
|
|
if (ORTE_SUCCESS != (rc = orte_rmgr_base_comm_stop())) {
|
2005-04-15 17:04:57 +00:00
|
|
|
ORTE_ERROR_LOG(rc);
|
|
|
|
}
|
|
|
|
|
2006-09-14 21:29:51 +00:00
|
|
|
return rc;
|
2005-03-31 23:22:44 +00:00
|
|
|
}
|
|
|
|
|