2005-03-14 23:57:21 +03:00
|
|
|
/*
|
2007-03-17 02:11:45 +03:00
|
|
|
* Copyright (c) 2004-2007 The Trustees of Indiana University and Indiana
|
2005-11-05 22:57:48 +03: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-07 06:32:36 +03:00
|
|
|
* Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
|
2005-03-14 23:57:21 +03:00
|
|
|
* University of Stuttgart. All rights reserved.
|
2005-03-24 15:43:37 +03:00
|
|
|
* Copyright (c) 2004-2005 The Regents of the University of California.
|
|
|
|
* All rights reserved.
|
2005-03-14 23:57:21 +03:00
|
|
|
* $COPYRIGHT$
|
2006-02-07 06:32:36 +03:00
|
|
|
*
|
2005-03-14 23:57:21 +03:00
|
|
|
* Additional copyrights may follow
|
2006-02-07 06:32:36 +03:00
|
|
|
*
|
2005-03-14 23:57:21 +03:00
|
|
|
* $HEADER$
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
#include "orte_config.h"
|
2006-02-12 04:33:29 +03:00
|
|
|
#include "orte/orte_constants.h"
|
2006-02-07 06:32:36 +03:00
|
|
|
|
2005-07-04 03:31:27 +04:00
|
|
|
#include "opal/util/output.h"
|
2006-02-07 06:32:36 +03:00
|
|
|
#include "opal/mca/mca.h"
|
|
|
|
#include "opal/mca/base/base.h"
|
|
|
|
|
|
|
|
#include "orte/dss/dss.h"
|
|
|
|
#include "orte/mca/ns/ns.h"
|
|
|
|
#include "orte/mca/gpr/gpr.h"
|
2006-09-15 01:29:51 +04:00
|
|
|
#include "orte/mca/rml/rml.h"
|
|
|
|
#include "orte/mca/smr/smr.h"
|
2006-02-07 06:32:36 +03:00
|
|
|
#include "orte/mca/errmgr/errmgr.h"
|
|
|
|
#include "orte/mca/schema/schema.h"
|
2007-03-17 02:11:45 +03:00
|
|
|
#include "orte/mca/rmgr/rmgr.h"
|
2005-03-14 23:57:21 +03:00
|
|
|
|
2006-09-15 01:29:51 +04:00
|
|
|
#include "orte/mca/pls/bproc/pls_bproc.h"
|
2005-03-14 23:57:21 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Set the process pid in the job segment and indicate the state
|
|
|
|
* as being launched.
|
|
|
|
*/
|
|
|
|
|
2006-11-11 07:03:45 +03:00
|
|
|
int orte_pls_bproc_set_proc_pid(const orte_process_name_t *name, pid_t pid, int nodenum)
|
2005-03-14 23:57:21 +03:00
|
|
|
{
|
2007-03-17 02:11:45 +03:00
|
|
|
int rc = ORTE_SUCCESS;
|
|
|
|
char * nodename = NULL;
|
2006-11-11 07:03:45 +03:00
|
|
|
|
2007-03-17 02:11:45 +03:00
|
|
|
asprintf(&nodename, "%ld", (long)nodenum);
|
|
|
|
|
|
|
|
if (ORTE_SUCCESS != (rc = orte_rmgr.set_process_pid(name, pid, nodename) ) ) {
|
2005-03-14 23:57:21 +03:00
|
|
|
ORTE_ERROR_LOG(rc);
|
2006-02-09 18:39:06 +03:00
|
|
|
return rc;
|
2005-03-14 23:57:21 +03:00
|
|
|
}
|
|
|
|
|
2006-09-15 01:29:51 +04:00
|
|
|
/* set the process state to LAUNCHED */
|
|
|
|
if (ORTE_SUCCESS != (rc = orte_smr.set_proc_state((orte_process_name_t*)name, ORTE_PROC_STATE_LAUNCHED, 0))) {
|
2006-02-09 18:39:06 +03:00
|
|
|
ORTE_ERROR_LOG(rc);
|
2005-03-14 23:57:21 +03:00
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(ORTE_SUCCESS != (rc = orte_schema.get_proc_tokens(&tokens, &num_tokens, (orte_process_name_t*)name))) {
|
|
|
|
free(segment);
|
|
|
|
ORTE_ERROR_LOG(rc);
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
2006-11-11 07:03:45 +03:00
|
|
|
keys[0] = ORTE_PROC_LOCAL_PID_KEY;
|
2005-03-14 23:57:21 +03:00
|
|
|
keys[1] = NULL;
|
|
|
|
|
|
|
|
rc = orte_gpr.get(
|
|
|
|
ORTE_GPR_KEYS_OR|ORTE_GPR_TOKENS_OR,
|
|
|
|
segment,
|
|
|
|
tokens,
|
|
|
|
keys,
|
|
|
|
&num_values,
|
|
|
|
&values
|
|
|
|
);
|
|
|
|
if(rc != ORTE_SUCCESS) {
|
|
|
|
free(segment);
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(0 == num_values) {
|
|
|
|
rc = ORTE_ERR_NOT_FOUND;
|
|
|
|
ORTE_ERROR_LOG(rc);
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
if(1 != num_values || values[0]->cnt != 1) {
|
|
|
|
rc = ORTE_ERR_NOT_FOUND;
|
|
|
|
ORTE_ERROR_LOG(rc);
|
|
|
|
goto cleanup;
|
|
|
|
}
|
2006-02-07 06:32:36 +03:00
|
|
|
if (ORTE_SUCCESS != (rc = orte_dss.get((void**)&pptr, values[0]->keyvals[0]->value, ORTE_PID))) {
|
|
|
|
ORTE_ERROR_LOG(rc);
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
*pid = *pptr;
|
2005-03-14 23:57:21 +03:00
|
|
|
|
|
|
|
cleanup:
|
|
|
|
if(NULL != values) {
|
|
|
|
for(i=0; i<num_values; i++) {
|
|
|
|
if(NULL != values[i]) {
|
|
|
|
OBJ_RELEASE(values[i]);
|
|
|
|
}
|
|
|
|
}
|
2006-02-07 06:32:36 +03:00
|
|
|
if (NULL != values) free(values);
|
2005-03-14 23:57:21 +03:00
|
|
|
}
|
|
|
|
free(segment);
|
2006-02-07 06:32:36 +03:00
|
|
|
|
2005-03-14 23:57:21 +03:00
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2005-05-01 04:47:35 +04:00
|
|
|
* Retrieve all process pids for the specified job.
|
2005-03-14 23:57:21 +03: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 22:34:59 +03:00
|
|
|
int orte_pls_bproc_get_proc_pids(orte_jobid_t jobid, pid_t **pids, orte_std_cntr_t* num_pids, opal_list_t *attrs)
|
2005-03-14 23:57:21 +03:00
|
|
|
{
|
|
|
|
char *segment;
|
|
|
|
char *keys[2];
|
|
|
|
orte_gpr_value_t** values = NULL;
|
2006-08-15 23:54:10 +04:00
|
|
|
orte_std_cntr_t i, num_values = 0;
|
2006-02-07 06:32:36 +03:00
|
|
|
pid_t *pptr;
|
2005-03-14 23:57:21 +03:00
|
|
|
int rc;
|
|
|
|
|
|
|
|
/* query the job segment on the registry */
|
|
|
|
if(ORTE_SUCCESS != (rc = orte_schema.get_job_segment_name(&segment, jobid))) {
|
|
|
|
ORTE_ERROR_LOG(rc);
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
|
|
|
keys[0] = ORTE_PROC_PID_KEY;
|
|
|
|
keys[1] = NULL;
|
|
|
|
|
|
|
|
rc = orte_gpr.get(
|
|
|
|
ORTE_GPR_KEYS_OR|ORTE_GPR_TOKENS_OR,
|
|
|
|
segment,
|
|
|
|
NULL,
|
|
|
|
keys,
|
|
|
|
&num_values,
|
|
|
|
&values
|
|
|
|
);
|
|
|
|
if(rc != ORTE_SUCCESS) {
|
|
|
|
free(segment);
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(0 == num_values) {
|
|
|
|
*pids = NULL;
|
|
|
|
} else {
|
|
|
|
*pids = (pid_t*)malloc(sizeof(pid_t)*num_values);
|
|
|
|
for(i=0; i<num_values; i++) {
|
2006-02-07 06:32:36 +03:00
|
|
|
if (ORTE_SUCCESS != (rc = orte_dss.get((void**)&pptr, values[i]->keyvals[0]->value, ORTE_PID))) {
|
|
|
|
ORTE_ERROR_LOG(rc);
|
|
|
|
goto cleanup;
|
|
|
|
}
|
2006-02-16 19:18:46 +03:00
|
|
|
(*pids)[i] = *pptr;
|
2005-03-14 23:57:21 +03:00
|
|
|
}
|
2006-02-07 06:32:36 +03:00
|
|
|
}
|
2005-03-14 23:57:21 +03:00
|
|
|
*num_pids = num_values;
|
|
|
|
|
2006-02-07 06:32:36 +03:00
|
|
|
cleanup:
|
2005-03-14 23:57:21 +03:00
|
|
|
if(NULL != values) {
|
|
|
|
for(i=0; i<num_values; i++) {
|
|
|
|
if(NULL != values[i]) {
|
|
|
|
OBJ_RELEASE(values[i]);
|
|
|
|
}
|
|
|
|
}
|
2006-02-07 06:32:36 +03:00
|
|
|
if (NULL != values) free(values);
|
2005-03-14 23:57:21 +03:00
|
|
|
}
|
|
|
|
free(segment);
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Add a key-value to the node segment containing the process pid for
|
|
|
|
* the daemons.
|
|
|
|
*/
|
|
|
|
|
2006-09-15 01:29:51 +04:00
|
|
|
int orte_pls_bproc_set_node_pid(orte_cellid_t cellid, char* node_name, orte_jobid_t jobid, pid_t pid)
|
2005-03-14 23:57:21 +03:00
|
|
|
{
|
2006-02-07 06:32:36 +03:00
|
|
|
orte_gpr_value_t *values[1];
|
|
|
|
char *jobid_string, *key;
|
2005-05-01 04:47:35 +04:00
|
|
|
int rc;
|
2005-03-14 23:57:21 +03:00
|
|
|
|
2006-02-07 06:32:36 +03:00
|
|
|
if (ORTE_SUCCESS != (rc = orte_gpr.create_value(&values[0],
|
|
|
|
ORTE_GPR_OVERWRITE,
|
|
|
|
ORTE_NODE_SEGMENT,
|
|
|
|
1, 0))) {
|
|
|
|
ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);
|
|
|
|
return ORTE_ERR_OUT_OF_RESOURCE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ORTE_SUCCESS != (rc = orte_schema.get_node_tokens(&(values[0]->tokens), &(values[0]->num_tokens), cellid, node_name))) {
|
|
|
|
ORTE_ERROR_LOG(rc);
|
|
|
|
OBJ_RELEASE(values[0]);
|
2005-03-14 23:57:21 +03:00
|
|
|
return rc;
|
2006-02-07 06:32:36 +03:00
|
|
|
}
|
2005-03-14 23:57:21 +03:00
|
|
|
|
2006-02-07 06:32:36 +03:00
|
|
|
if (ORTE_SUCCESS != (rc = orte_ns.convert_jobid_to_string(&jobid_string, jobid))) {
|
|
|
|
ORTE_ERROR_LOG(rc);
|
|
|
|
OBJ_RELEASE(values[0]);
|
|
|
|
return rc;
|
|
|
|
}
|
2005-03-14 23:57:21 +03:00
|
|
|
|
2006-02-07 06:32:36 +03:00
|
|
|
asprintf(&key, "%s-%s", ORTE_PROC_PID_KEY, jobid_string);
|
2005-03-14 23:57:21 +03:00
|
|
|
free(jobid_string);
|
2006-02-09 18:39:06 +03:00
|
|
|
|
2006-02-07 06:32:36 +03:00
|
|
|
if (ORTE_SUCCESS != (rc = orte_gpr.create_keyval(&(values[0]->keyvals[0]), key, ORTE_PID, &pid))) {
|
|
|
|
ORTE_ERROR_LOG(rc);
|
|
|
|
free(key);
|
|
|
|
OBJ_RELEASE(values[0]);
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
free(key);
|
|
|
|
|
2005-03-14 23:57:21 +03:00
|
|
|
rc = orte_gpr.put(1, values);
|
|
|
|
if(ORTE_SUCCESS != rc) {
|
|
|
|
ORTE_ERROR_LOG(rc);
|
|
|
|
}
|
|
|
|
|
2006-02-07 06:32:36 +03:00
|
|
|
OBJ_RELEASE(values[0]);
|
2005-03-14 23:57:21 +03:00
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2006-09-15 01:29:51 +04:00
|
|
|
* Retrieve all daemon pids for the specified job.
|
2005-03-14 23:57:21 +03:00
|
|
|
*/
|
2006-09-15 01:29:51 +04:00
|
|
|
int orte_pls_bproc_get_node_pids(orte_jobid_t jobid, pid_t **pids, orte_std_cntr_t* num_pids)
|
2005-03-14 23:57:21 +03:00
|
|
|
{
|
|
|
|
char *keys[2];
|
|
|
|
orte_gpr_value_t** values = NULL;
|
2006-08-15 23:54:10 +04:00
|
|
|
orte_std_cntr_t i, num_values = 0;
|
2005-03-14 23:57:21 +03:00
|
|
|
int rc;
|
|
|
|
char *jobid_string;
|
2006-02-07 06:32:36 +03:00
|
|
|
pid_t *pptr;
|
2005-03-14 23:57:21 +03:00
|
|
|
|
|
|
|
if(ORTE_SUCCESS != (rc = orte_ns.convert_jobid_to_string(&jobid_string, jobid)))
|
|
|
|
goto cleanup;
|
|
|
|
|
|
|
|
asprintf(&keys[0], "%s-%s", ORTE_PROC_PID_KEY, jobid_string);
|
|
|
|
free(jobid_string);
|
|
|
|
keys[1] = NULL;
|
|
|
|
|
|
|
|
rc = orte_gpr.get(
|
|
|
|
ORTE_GPR_KEYS_OR|ORTE_GPR_TOKENS_OR,
|
|
|
|
ORTE_NODE_SEGMENT,
|
|
|
|
NULL,
|
|
|
|
keys,
|
|
|
|
&num_values,
|
|
|
|
&values
|
|
|
|
);
|
|
|
|
if(rc != ORTE_SUCCESS) {
|
|
|
|
free(keys[0]);
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(0 == num_values) {
|
|
|
|
*pids = NULL;
|
|
|
|
} else {
|
|
|
|
*pids = (pid_t*)malloc(sizeof(pid_t)*num_values);
|
|
|
|
for(i=0; i<num_values; i++) {
|
2006-02-07 06:32:36 +03:00
|
|
|
if (ORTE_SUCCESS != (rc = orte_dss.get((void**)&pptr, values[i]->keyvals[0]->value, ORTE_PID))) {
|
|
|
|
ORTE_ERROR_LOG(rc);
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
*(pids[i]) = *pptr;
|
2005-03-14 23:57:21 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
*num_pids = num_values;
|
|
|
|
|
|
|
|
cleanup:
|
|
|
|
if(NULL != values) {
|
|
|
|
for(i=0; i<num_values; i++)
|
|
|
|
OBJ_RELEASE(values[i]);
|
2006-02-07 06:32:36 +03:00
|
|
|
if (NULL != values) free(values);
|
2005-03-14 23:57:21 +03:00
|
|
|
}
|
|
|
|
free(keys[0]);
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
2006-09-15 01:29:51 +04:00
|
|
|
/*
|
|
|
|
* FUNCTIONS FOR DEALING WITH ABNORMAL TERMINATION OF BPROC
|
|
|
|
* APPLICATION PROCESSES
|
|
|
|
*/
|
|
|
|
int orte_pls_bproc_comm_start(void)
|
|
|
|
{
|
|
|
|
int rc;
|
|
|
|
|
|
|
|
if (mca_pls_bproc_component.recv_issued) {
|
|
|
|
return 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 22:34:59 +03:00
|
|
|
if (ORTE_SUCCESS != (rc = orte_rml.recv_buffer_nb(ORTE_NAME_WILDCARD,
|
2006-09-15 01:29:51 +04:00
|
|
|
ORTE_RML_TAG_BPROC_ABORT,
|
|
|
|
ORTE_RML_PERSISTENT,
|
|
|
|
orte_pls_bproc_recv,
|
|
|
|
NULL))) {
|
|
|
|
ORTE_ERROR_LOG(rc);
|
|
|
|
}
|
|
|
|
mca_pls_bproc_component.recv_issued = true;
|
|
|
|
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int orte_pls_bproc_comm_stop(void)
|
|
|
|
{
|
|
|
|
int rc;
|
|
|
|
|
|
|
|
if (!mca_pls_bproc_component.recv_issued) {
|
|
|
|
return 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 22:34:59 +03:00
|
|
|
if (ORTE_SUCCESS != (rc = orte_rml.recv_cancel(ORTE_NAME_WILDCARD, ORTE_RML_TAG_BPROC_ABORT))) {
|
2006-09-15 01:29:51 +04:00
|
|
|
ORTE_ERROR_LOG(rc);
|
|
|
|
}
|
|
|
|
mca_pls_bproc_component.recv_issued = false;
|
|
|
|
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* handle message from proxies
|
|
|
|
* NOTE: The incoming buffer "buffer" is OBJ_RELEASED by the calling program.
|
|
|
|
* DO NOT RELEASE THIS BUFFER IN THIS CODE
|
|
|
|
*/
|
|
|
|
|
|
|
|
void orte_pls_bproc_recv(int status, orte_process_name_t* sender,
|
|
|
|
orte_buffer_t* buffer, orte_rml_tag_t tag,
|
|
|
|
void* cbdata)
|
|
|
|
{
|
|
|
|
int rc;
|
|
|
|
|
|
|
|
/* we don't care what was in the buffer - just set the state of the sender to ABORTED */
|
|
|
|
if (ORTE_SUCCESS != (rc = orte_smr.set_proc_state(sender, ORTE_PROC_STATE_ABORTED, 0))) {
|
|
|
|
ORTE_ERROR_LOG(rc);
|
|
|
|
}
|
|
|
|
}
|
2005-03-14 23:57:21 +03:00
|
|
|
|