2004-03-19 09:12:43 +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-03-19 09:12:43 +03:00
|
|
|
* $HEADER$
|
|
|
|
*/
|
|
|
|
|
2004-10-20 05:03:09 +04:00
|
|
|
#include "ompi_config.h"
|
2004-03-19 09:12:43 +03:00
|
|
|
#include <stdlib.h>
|
|
|
|
#include <stdarg.h>
|
|
|
|
|
|
|
|
#include "util/output.h"
|
|
|
|
#include "errhandler/errhandler.h"
|
|
|
|
#include "errhandler/errhandler_predefined.h"
|
2004-08-12 05:14:45 +04:00
|
|
|
#include "errhandler/errcode.h"
|
2004-06-18 19:47:17 +04:00
|
|
|
#include "communicator/communicator.h"
|
2004-09-06 16:06:27 +04:00
|
|
|
#include "file/file.h"
|
|
|
|
#include "win/win.h"
|
2004-06-18 19:47:17 +04:00
|
|
|
#include "runtime/runtime.h"
|
2004-10-22 20:06:05 +04:00
|
|
|
#include "util/printf.h"
|
2004-03-19 09:12:43 +03:00
|
|
|
|
2004-09-21 03:01:40 +04:00
|
|
|
/*
|
|
|
|
* Local functions
|
|
|
|
*/
|
2004-11-01 19:05:31 +03:00
|
|
|
static void backend_fatal(char *type, struct ompi_communicator_t *comm,
|
|
|
|
char *name, int *error_code, va_list arglist);
|
2004-09-21 03:01:40 +04:00
|
|
|
static void out(char *str, char *arg);
|
|
|
|
|
|
|
|
|
2004-09-06 16:06:27 +04:00
|
|
|
void ompi_mpi_errors_are_fatal_comm_handler(struct ompi_communicator_t **comm,
|
|
|
|
int *error_code, ...)
|
2004-03-19 09:12:43 +03:00
|
|
|
{
|
2004-09-21 03:01:40 +04:00
|
|
|
char *name;
|
2004-11-01 19:05:31 +03:00
|
|
|
struct ompi_communicator_t *abort_comm;
|
2004-03-19 09:12:43 +03:00
|
|
|
va_list arglist;
|
2004-06-23 00:21:35 +04:00
|
|
|
|
2004-03-19 09:12:43 +03:00
|
|
|
va_start(arglist, error_code);
|
2004-06-18 19:47:17 +04:00
|
|
|
|
2004-09-21 03:01:40 +04:00
|
|
|
if (NULL != comm) {
|
|
|
|
name = (*comm)->c_name;
|
2004-11-01 19:05:31 +03:00
|
|
|
abort_comm = *comm;
|
2004-06-23 00:21:35 +04:00
|
|
|
} else {
|
2004-09-21 03:01:40 +04:00
|
|
|
name = NULL;
|
2004-11-01 19:05:31 +03:00
|
|
|
abort_comm = NULL;
|
2004-06-23 00:21:35 +04:00
|
|
|
}
|
2004-11-01 19:05:31 +03:00
|
|
|
backend_fatal("communicator", abort_comm, name, error_code, arglist);
|
2004-03-19 09:12:43 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-09-06 16:06:27 +04:00
|
|
|
void ompi_mpi_errors_are_fatal_file_handler(struct ompi_file_t **file,
|
|
|
|
int *error_code, ...)
|
|
|
|
{
|
2004-09-21 03:01:40 +04:00
|
|
|
char *name;
|
2004-11-01 19:05:31 +03:00
|
|
|
struct ompi_communicator_t *abort_comm;
|
2004-09-06 16:06:27 +04:00
|
|
|
va_list arglist;
|
|
|
|
|
|
|
|
va_start(arglist, error_code);
|
|
|
|
|
2004-09-21 03:01:40 +04:00
|
|
|
if (NULL != file) {
|
|
|
|
name = (*file)->f_filename;
|
2004-11-01 19:05:31 +03:00
|
|
|
abort_comm = (*file)->f_comm;
|
2004-09-06 16:06:27 +04:00
|
|
|
} else {
|
2004-09-21 03:01:40 +04:00
|
|
|
name = NULL;
|
2004-11-01 19:05:31 +03:00
|
|
|
abort_comm = NULL;
|
2004-09-06 16:06:27 +04:00
|
|
|
}
|
2004-11-01 19:05:31 +03:00
|
|
|
backend_fatal("file", abort_comm, name, error_code, arglist);
|
2004-09-06 16:06:27 +04:00
|
|
|
}
|
|
|
|
|
2004-09-21 03:01:40 +04:00
|
|
|
|
2004-12-14 05:35:03 +03:00
|
|
|
#if OMPI_WANT_MPI2_ONE_SIDED
|
2004-09-06 16:06:27 +04:00
|
|
|
void ompi_mpi_errors_are_fatal_win_handler(struct ompi_win_t **win,
|
|
|
|
int *error_code, ...)
|
|
|
|
{
|
2004-09-21 03:01:40 +04:00
|
|
|
char *name;
|
2004-11-01 19:05:31 +03:00
|
|
|
struct ompi_communicator_t *abort_comm = NULL;
|
2004-09-06 16:06:27 +04:00
|
|
|
va_list arglist;
|
|
|
|
|
|
|
|
va_start(arglist, error_code);
|
|
|
|
|
2004-09-21 03:01:40 +04:00
|
|
|
if (NULL != win) {
|
|
|
|
name = (*win)->w_name;
|
2004-09-06 16:06:27 +04:00
|
|
|
} else {
|
2004-09-21 03:01:40 +04:00
|
|
|
name = NULL;
|
2004-09-06 16:06:27 +04:00
|
|
|
}
|
2004-11-01 19:05:31 +03:00
|
|
|
backend_fatal("win", abort_comm, name, error_code, arglist);
|
2004-09-06 16:06:27 +04:00
|
|
|
}
|
2004-12-14 05:35:03 +03:00
|
|
|
#endif
|
2004-09-21 03:01:40 +04:00
|
|
|
|
2004-09-06 16:06:27 +04:00
|
|
|
void ompi_mpi_errors_return_comm_handler(struct ompi_communicator_t **comm,
|
|
|
|
int *error_code, ...)
|
|
|
|
{
|
|
|
|
/* Don't need anything more -- just need this function to exist */
|
|
|
|
}
|
|
|
|
|
2004-09-21 03:01:40 +04:00
|
|
|
|
2004-09-06 16:06:27 +04:00
|
|
|
void ompi_mpi_errors_return_file_handler(struct ompi_file_t **file,
|
|
|
|
int *error_code, ...)
|
|
|
|
{
|
|
|
|
/* Don't need anything more -- just need this function to exist */
|
|
|
|
}
|
|
|
|
|
2004-09-21 03:01:40 +04:00
|
|
|
|
2004-12-14 05:35:03 +03:00
|
|
|
#if OMPI_WANT_MPI2_ONE_SIDED
|
2004-09-06 16:06:27 +04:00
|
|
|
void ompi_mpi_errors_return_win_handler(struct ompi_win_t **win,
|
|
|
|
int *error_code, ...)
|
2004-03-19 09:12:43 +03:00
|
|
|
{
|
|
|
|
/* Don't need anything more -- just need this function to exist */
|
|
|
|
}
|
2004-12-14 05:35:03 +03:00
|
|
|
#endif
|
2004-09-21 03:01:40 +04:00
|
|
|
|
|
|
|
|
|
|
|
static void out(char *str, char *arg)
|
|
|
|
{
|
|
|
|
if (ompi_mpi_initialized && !ompi_mpi_finalized) {
|
|
|
|
if (NULL != arg) {
|
|
|
|
ompi_output(0, str, arg);
|
|
|
|
} else {
|
|
|
|
ompi_output(0, str);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (NULL != arg) {
|
|
|
|
fprintf(stderr, str, arg);
|
|
|
|
} else {
|
|
|
|
fprintf(stderr, str);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-11-01 19:05:31 +03:00
|
|
|
static void backend_fatal(char *type, struct ompi_communicator_t *comm,
|
|
|
|
char *name, int *error_code,
|
2004-09-21 03:01:40 +04:00
|
|
|
va_list arglist)
|
|
|
|
{
|
|
|
|
char *arg;
|
2004-11-15 05:48:54 +03:00
|
|
|
char str[MPI_MAX_PROCESSOR_NAME * 2];
|
2004-09-21 03:01:40 +04:00
|
|
|
|
|
|
|
fflush(stdout);
|
|
|
|
fflush(stderr);
|
|
|
|
arg = va_arg(arglist, char*);
|
|
|
|
if (NULL != arg) {
|
|
|
|
out("*** An error occurred in %s\n", arg);
|
|
|
|
} else {
|
|
|
|
out("*** An error occurred\n", NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (NULL != name && ompi_mpi_initialized && !ompi_mpi_finalized) {
|
2004-11-15 05:48:54 +03:00
|
|
|
/* Don't use asprintf() here because there may be stack / heap
|
|
|
|
corruption by the time we're invoked, so just do it on the
|
|
|
|
stack */
|
|
|
|
str[0] = '\0';
|
|
|
|
strcat(str, type);
|
|
|
|
strcat(str, " ");
|
|
|
|
strcat(str, name);
|
|
|
|
out("*** on %s", str);
|
2004-09-21 03:01:40 +04:00
|
|
|
} else if (!ompi_mpi_initialized) {
|
|
|
|
out("*** before MPI was initialized\n", NULL);
|
|
|
|
} else if (ompi_mpi_finalized) {
|
|
|
|
out("*** after MPI was finalized\n", NULL);
|
|
|
|
} else if (NULL == name) {
|
|
|
|
out("*** on a NULL %s\n", type);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (NULL != error_code) {
|
|
|
|
char *tmp = ompi_mpi_errcode_get_string(*error_code);
|
|
|
|
if (NULL != tmp) {
|
|
|
|
out("*** %s\n", tmp);
|
|
|
|
} else {
|
|
|
|
char intbuf[32];
|
|
|
|
snprintf(intbuf, 32, "%d", *error_code);
|
|
|
|
out("*** Error code: %d (no associated error message)\n", intbuf);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
out("*** MPI_ERRORS_ARE_FATAL (goodbye)\n", NULL);
|
|
|
|
va_end(arglist);
|
|
|
|
|
|
|
|
/* Should we do something more intelligent here? */
|
2004-11-01 19:05:31 +03:00
|
|
|
if (comm == NULL) {
|
|
|
|
comm = &ompi_mpi_comm_self;
|
|
|
|
}
|
|
|
|
|
|
|
|
ompi_mpi_abort(comm, 1, false);
|
2004-09-21 03:01:40 +04:00
|
|
|
}
|