2004-11-01 19:16:05 +03:00
|
|
|
/*
|
2004-11-22 04:38:40 +03:00
|
|
|
* Copyright (c) 2004-2005 The Trustees of Indiana University.
|
|
|
|
* All rights reserved.
|
|
|
|
* Copyright (c) 2004-2005 The Trustees of the University of Tennessee.
|
|
|
|
* 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.
|
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
|
2004-11-05 10:52:30 +03:00
|
|
|
|
2004-11-01 19:16:05 +03:00
|
|
|
#include "communicator/communicator.h"
|
|
|
|
#include "util/show_help.h"
|
|
|
|
#include "util/proc_info.h"
|
2005-07-03 16:07:29 +04:00
|
|
|
#include "ompi/runtime/mpiruntime.h"
|
|
|
|
#include "orte/runtime/runtime.h"
|
2004-11-01 19:16:05 +03:00
|
|
|
#include "mca/ns/ns.h"
|
2005-04-07 17:05:02 +04:00
|
|
|
#include "mca/rmgr/rmgr.h"
|
2005-03-14 23:57:21 +03:00
|
|
|
|
2004-11-01 19:16:05 +03:00
|
|
|
#include "event/event.h"
|
|
|
|
|
|
|
|
#if HAVE_SIGNAL_H
|
|
|
|
#include <signal.h>
|
|
|
|
#endif
|
|
|
|
|
2004-12-14 18:47:31 +03:00
|
|
|
static
|
|
|
|
int
|
|
|
|
abort_procs(ompi_proc_t **procs, int proc_count,
|
2005-03-14 23:57:21 +03:00
|
|
|
orte_jobid_t my_jobid)
|
2004-12-14 18:47:31 +03:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
int ret = OMPI_SUCCESS;
|
2005-03-14 23:57:21 +03:00
|
|
|
int killret=OMPI_SUCCESS;
|
|
|
|
orte_jobid_t jobid;
|
2004-12-14 18:47:31 +03:00
|
|
|
|
|
|
|
for (i = 0 ; i < proc_count ; ++i) {
|
2005-03-14 23:57:21 +03:00
|
|
|
if (ORTE_SUCCESS != (ret = orte_ns.get_jobid(&jobid, &(procs[i]->proc_name)))) {
|
|
|
|
return ret;
|
|
|
|
}
|
2004-12-14 18:47:31 +03:00
|
|
|
if (jobid == my_jobid) continue;
|
|
|
|
|
2005-04-07 17:05:02 +04:00
|
|
|
killret = orte_rmgr.terminate_job(jobid);
|
|
|
|
|
2004-12-14 18:47:31 +03:00
|
|
|
if (OMPI_SUCCESS != killret) ret = killret;
|
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-11-01 19:16:05 +03:00
|
|
|
int
|
|
|
|
ompi_mpi_abort(struct ompi_communicator_t* comm,
|
|
|
|
int errcode,
|
|
|
|
bool kill_remote_of_intercomm)
|
|
|
|
{
|
2005-03-14 23:57:21 +03:00
|
|
|
orte_jobid_t my_jobid;
|
|
|
|
int ret=OMPI_SUCCESS;
|
2004-11-01 19:16:05 +03:00
|
|
|
|
2004-12-14 18:47:31 +03:00
|
|
|
/* BWB - XXX - Should probably publish the error code somewhere */
|
2004-12-13 18:41:59 +03:00
|
|
|
|
2004-11-01 19:16:05 +03:00
|
|
|
/* Kill everyone in the job. We may make this better someday to
|
|
|
|
actually loop over ompi_rte_kill_proc() to only kill the procs
|
|
|
|
in comm, and additionally to somehow use errorcode. */
|
|
|
|
|
2005-03-14 23:57:21 +03:00
|
|
|
if (ORTE_SUCCESS != (ret = orte_ns.get_jobid(&my_jobid, orte_process_info.my_name))) {
|
|
|
|
return ret;
|
|
|
|
}
|
2004-12-14 18:47:31 +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) {
|
|
|
|
abort();
|
|
|
|
}
|
2005-04-13 22:07:55 +04:00
|
|
|
|
2005-04-15 20:38:44 +04:00
|
|
|
/* kill everyone in the remote group execpt our jobid, if
|
|
|
|
requested */
|
|
|
|
if (kill_remote_of_intercomm && OMPI_COMM_IS_INTER(comm)) {
|
|
|
|
abort_procs(comm->c_remote_group->grp_proc_pointers,
|
|
|
|
comm->c_remote_group->grp_proc_count,
|
2004-12-14 18:47:31 +03:00
|
|
|
my_jobid);
|
|
|
|
}
|
|
|
|
|
2005-04-15 20:38:44 +04:00
|
|
|
/* kill everyone in the local group, except our jobid. */
|
|
|
|
abort_procs(comm->c_local_group->grp_proc_pointers,
|
|
|
|
comm->c_local_group->grp_proc_count,
|
|
|
|
my_jobid);
|
2005-04-07 17:05:02 +04:00
|
|
|
|
|
|
|
ret = orte_rmgr.terminate_job(my_jobid);
|
2004-11-01 19:16:05 +03:00
|
|
|
|
2004-12-13 18:41:59 +03:00
|
|
|
if (OMPI_SUCCESS == ret) {
|
2004-11-01 19:16:05 +03:00
|
|
|
while (1) {
|
2004-12-13 18:41:59 +03:00
|
|
|
/* We should never really get here, since
|
|
|
|
ompi_rte_terminate_job shouldn't return until the job
|
|
|
|
is actually dead. But just in case there are some
|
|
|
|
race conditions, keep progressing the event loop until
|
|
|
|
we get killed */
|
2005-02-16 20:42:07 +03:00
|
|
|
if (!OMPI_ENABLE_PROGRESS_THREADS || ompi_event_progress_thread()) {
|
2004-11-01 19:16:05 +03:00
|
|
|
ompi_event_loop(0);
|
|
|
|
} else {
|
|
|
|
sleep(1000);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
2004-12-13 18:41:59 +03:00
|
|
|
/* If ret isn't OMPI_SUCCESS, then the rest of the job is
|
|
|
|
still running. But we can't really do anything about that, so
|
|
|
|
just exit and let it become Somebody Elses Problem. */
|
2004-11-01 19:16:05 +03:00
|
|
|
abort();
|
|
|
|
}
|
|
|
|
|
|
|
|
return OMPI_SUCCESS;
|
|
|
|
}
|