2004-11-01 19:16:05 +03:00
|
|
|
/*
|
2005-11-05 22:57:48 +03:00
|
|
|
* Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
|
|
|
|
* 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.
|
2004-11-28 23:09:25 +03:00
|
|
|
* Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
|
|
|
|
* 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.
|
2007-01-05 01:30:28 +03:00
|
|
|
* Copyright (c) 2006-2007 Cisco Systems, Inc. All rights reserved.
|
2004-11-22 04:38:40 +03:00
|
|
|
* $COPYRIGHT$
|
|
|
|
*
|
|
|
|
* Additional copyrights may follow
|
|
|
|
*
|
2004-11-01 19:16:05 +03:00
|
|
|
* $HEADER$
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "ompi_config.h"
|
|
|
|
|
2005-01-20 03:03:23 +03:00
|
|
|
#ifdef HAVE_UNISTD_H
|
2004-11-05 10:52:30 +03:00
|
|
|
#include <unistd.h>
|
2005-01-20 03:03:23 +03:00
|
|
|
#endif
|
2006-03-31 04:31:15 +04:00
|
|
|
#ifdef HAVE_SYS_TYPES_H
|
|
|
|
#include <sys/types.h>
|
|
|
|
#endif
|
|
|
|
#ifdef HAVE_SYS_PARAM_H
|
|
|
|
#include <sys/param.h>
|
|
|
|
#endif
|
|
|
|
#ifdef HAVE_NETDB_H
|
|
|
|
#include <netdb.h>
|
|
|
|
#endif
|
2004-11-05 10:52:30 +03:00
|
|
|
|
2006-09-22 19:04:04 +04:00
|
|
|
#include "opal/mca/backtrace/backtrace.h"
|
2006-02-12 04:33:29 +03:00
|
|
|
#include "orte/util/proc_info.h"
|
2005-07-03 16:07:29 +04:00
|
|
|
#include "orte/runtime/runtime.h"
|
2005-09-13 00:25:01 +04:00
|
|
|
#include "orte/mca/ns/ns.h"
|
2006-09-15 01:29:51 +04:00
|
|
|
#include "orte/mca/errmgr/errmgr.h"
|
2006-03-31 04:31:15 +04:00
|
|
|
#include "ompi/communicator/communicator.h"
|
2005-09-13 00:25:01 +04:00
|
|
|
#include "ompi/proc/proc.h"
|
2006-03-31 04:31:15 +04:00
|
|
|
#include "ompi/runtime/mpiruntime.h"
|
|
|
|
#include "ompi/runtime/params.h"
|
2004-11-01 19:16:05 +03:00
|
|
|
|
2004-12-14 18:47:31 +03:00
|
|
|
|
2004-11-01 19:16:05 +03:00
|
|
|
int
|
|
|
|
ompi_mpi_abort(struct ompi_communicator_t* comm,
|
|
|
|
int errcode,
|
|
|
|
bool kill_remote_of_intercomm)
|
|
|
|
{
|
2006-09-22 19:04:04 +04:00
|
|
|
int count = 0, i, ret = OMPI_SUCCESS;
|
2006-03-31 04:31:15 +04:00
|
|
|
char hostname[MAXHOSTNAMELEN];
|
2006-04-01 16:41:48 +04:00
|
|
|
pid_t pid = 0;
|
2006-09-22 19:04:04 +04:00
|
|
|
orte_process_name_t *abort_procs;
|
|
|
|
orte_std_cntr_t nabort_procs;
|
|
|
|
|
2004-11-01 19:16:05 +03:00
|
|
|
|
2005-04-13 22:07:55 +04:00
|
|
|
/* Corner case: if we're being called as a result of the
|
|
|
|
OMPI_ERR_INIT_FINALIZE macro (meaning that this is before
|
2005-04-15 20:38:44 +04:00
|
|
|
MPI_INIT or after MPI_FINALIZE), then just abort nothing MPI or
|
|
|
|
ORTE has been setup yet. */
|
2005-04-13 22:07:55 +04:00
|
|
|
|
2005-04-15 20:38:44 +04:00
|
|
|
if (!ompi_mpi_initialized || ompi_mpi_finalized) {
|
2006-09-22 19:04:04 +04:00
|
|
|
orte_errmgr.error_detected(errcode, NULL);
|
2005-09-28 00:26:38 +04:00
|
|
|
}
|
|
|
|
|
2006-03-31 04:31:15 +04:00
|
|
|
/* If we're going to print anything, get the hostname and PID of
|
|
|
|
this process */
|
|
|
|
|
|
|
|
if (ompi_mpi_abort_print_stack ||
|
|
|
|
0 != ompi_mpi_abort_delay) {
|
|
|
|
gethostname(hostname, sizeof(hostname));
|
|
|
|
pid = getpid();
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Should we print a stack trace? */
|
|
|
|
|
|
|
|
if (ompi_mpi_abort_print_stack) {
|
2006-09-22 19:04:04 +04:00
|
|
|
char **messages;
|
|
|
|
int len, i;
|
|
|
|
|
|
|
|
if (OMPI_SUCCESS == opal_backtrace_buffer(&messages, &len)) {
|
|
|
|
for (i = 0; i < len; ++i) {
|
|
|
|
fprintf(stderr, "[%s:%d] [%d] func:%s\n", hostname, (int) pid,
|
|
|
|
i, messages[i]);
|
|
|
|
fflush(stderr);
|
|
|
|
}
|
|
|
|
free(messages);
|
|
|
|
} else {
|
2007-01-05 01:30:28 +03:00
|
|
|
/* This will print an message if it's unable to print the
|
|
|
|
backtrace, so we don't need an additional "else" clause
|
|
|
|
if opal_backtrace_print() is not supported. */
|
|
|
|
opal_backtrace_print(stderr);
|
2006-03-31 04:31:15 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Should we wait for a while before aborting? */
|
|
|
|
|
|
|
|
if (0 != ompi_mpi_abort_delay) {
|
|
|
|
if (ompi_mpi_abort_delay < 0) {
|
2007-01-05 01:30:28 +03:00
|
|
|
fprintf(stderr ,"[%s:%d] Looping forever (MCA parameter mpi_abort_delay is < 0)\n",
|
2006-03-31 04:31:15 +04:00
|
|
|
hostname, (int) pid);
|
|
|
|
fflush(stderr);
|
|
|
|
while (1) {
|
|
|
|
sleep(5);
|
|
|
|
}
|
|
|
|
} else {
|
2007-01-05 01:30:28 +03:00
|
|
|
fprintf(stderr, "[%s:%d] Delaying for %d seconds before aborting\n",
|
2006-03-31 04:31:15 +04:00
|
|
|
hostname, (int) pid, ompi_mpi_abort_delay);
|
|
|
|
do {
|
|
|
|
sleep(1);
|
|
|
|
} while (--ompi_mpi_abort_delay > 0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-09-22 19:04:04 +04:00
|
|
|
/* abort local procs in the communicator. If the communicator is
|
|
|
|
an intercommunicator AND the abort has explicitly requested
|
|
|
|
that we abort the remote procs, then do that as well. */
|
|
|
|
nabort_procs = ompi_comm_size(comm);
|
2005-09-28 00:26:38 +04:00
|
|
|
|
2006-09-22 19:04:04 +04:00
|
|
|
if (kill_remote_of_intercomm) {
|
|
|
|
/* ompi_comm_remote_size() returns 0 if not an intercomm, so
|
|
|
|
this is cool */
|
|
|
|
nabort_procs += ompi_comm_remote_size(comm);
|
2005-04-15 20:38:44 +04:00
|
|
|
}
|
2005-04-13 22:07:55 +04:00
|
|
|
|
2006-10-05 09:07:43 +04:00
|
|
|
abort_procs = (orte_process_name_t*)malloc(sizeof(orte_process_name_t) * nabort_procs);
|
2006-09-22 19:04:04 +04:00
|
|
|
if (NULL == abort_procs) {
|
|
|
|
/* quick clean orte and get out */
|
|
|
|
orte_errmgr.error_detected(errcode,
|
|
|
|
"Abort unable to malloc memory to kill procs",
|
|
|
|
NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* put all the local procs in the abort list */
|
|
|
|
for (i = 0 ; i < ompi_comm_size(comm) ; ++i) {
|
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_EQUAL != orte_ns.compare_fields(ORTE_NS_CMP_ALL,
|
2006-09-22 19:04:04 +04:00
|
|
|
&comm->c_local_group->grp_proc_pointers[i]->proc_name,
|
|
|
|
orte_process_info.my_name)) {
|
|
|
|
assert(count <= nabort_procs);
|
|
|
|
abort_procs[count++] = comm->c_local_group->grp_proc_pointers[i]->proc_name;
|
|
|
|
} else {
|
|
|
|
/* don't terminate me just yet */
|
|
|
|
nabort_procs--;
|
|
|
|
}
|
2004-12-14 18:47:31 +03:00
|
|
|
}
|
|
|
|
|
2006-09-22 19:04:04 +04:00
|
|
|
/* if requested, kill off remote procs too */
|
|
|
|
if (kill_remote_of_intercomm) {
|
|
|
|
for (i = 0 ; i < ompi_comm_remote_size(comm) ; ++i) {
|
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_EQUAL != orte_ns.compare_fields(ORTE_NS_CMP_ALL,
|
2006-09-22 19:04:04 +04:00
|
|
|
&comm->c_remote_group->grp_proc_pointers[i]->proc_name,
|
|
|
|
orte_process_info.my_name)) {
|
|
|
|
assert(count <= nabort_procs);
|
|
|
|
abort_procs[count++] =
|
|
|
|
comm->c_remote_group->grp_proc_pointers[i]->proc_name;
|
2004-11-01 19:16:05 +03:00
|
|
|
} else {
|
2006-09-22 19:04:04 +04:00
|
|
|
/* don't terminate me just yet */
|
|
|
|
nabort_procs--;
|
2004-11-01 19:16:05 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2006-09-22 19:04:04 +04:00
|
|
|
|
|
|
|
if (nabort_procs > 0) {
|
|
|
|
ret = orte_errmgr.abort_procs_request(abort_procs, nabort_procs);
|
|
|
|
if (OMPI_SUCCESS != ret) {
|
|
|
|
orte_errmgr.error_detected(ret,
|
|
|
|
"Open MPI failed to abort procs as requested (%d). Exiting.",
|
|
|
|
ret, NULL);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* now that we've aborted everyone else, gracefully die. */
|
|
|
|
orte_errmgr.error_detected(errcode, NULL);
|
2006-09-15 01:29:51 +04:00
|
|
|
|
2004-11-01 19:16:05 +03:00
|
|
|
return OMPI_SUCCESS;
|
|
|
|
}
|