1
1

Add new macro for checking (!ompi_mpi_initialized ||

ompi_mpi_finalized) which will invoke the errors_are_fatal error
handler directly.  Updated src/mpi/c/send.c to show this as an
example.  Also updated send.c to properly check for invalid comm and
invoke the errorhandler on MPI_COMM_WORLD as a result.

This commit was SVN r1412.
Этот коммит содержится в:
Jeff Squyres 2004-06-18 15:47:17 +00:00
родитель 392115b9d5
Коммит b9553f509f
4 изменённых файлов: 47 добавлений и 20 удалений

Просмотреть файл

@ -11,6 +11,8 @@
#include "mpi.h"
#include "class/ompi_object.h"
#include "class/ompi_pointer_array.h"
#include "runtime/runtime.h"
#include "errhandler/errhandler_predefined.h"
/*
* These must correspond to the fortran handle indices
@ -92,6 +94,19 @@ extern ompi_errhandler_t ompi_mpi_errors_return;
extern ompi_pointer_array_t *ompi_errhandler_f_to_c_table;
/**
* This is the macro to check the state of MPI and determine whether
* it was properly initialized and not yet finalized.
*
* This macro directly invokes the ompi_mpi_errors_are_fatal_handler()
* when an error occurs because MPI_COMM_WORLD does not exist (because
* we're before MPI_Init() or after MPI_Finalize()).
*/
#define OMPI_ERR_INIT_FINALIZE \
if (!ompi_mpi_initialized || ompi_mpi_finalized) { \
ompi_mpi_errors_are_fatal_handler(NULL, NULL); \
}
/**
* This is the macro to invoke to directly invoke an MPI error
* handler.

Просмотреть файл

@ -12,10 +12,12 @@
#include "util/output.h"
#include "errhandler/errhandler.h"
#include "errhandler/errhandler_predefined.h"
#include "communicator/communicator.h"
#include "runtime/runtime.h"
void ompi_mpi_errors_are_fatal_handler(ompi_communicator_t **comm,
int *error_code, ...)
void ompi_mpi_errors_are_fatal_handler(struct ompi_communicator_t **comm,
int *error_code, ...)
{
va_list arglist;
#if __STDC__
@ -24,10 +26,22 @@ void ompi_mpi_errors_are_fatal_handler(ompi_communicator_t **comm,
va_start(arglist);
#endif
ompi_output(0, "*** An error occurred in %s", va_arg(arglist, char *));
ompi_output(0, "*** on communicator %s", (*comm)->c_name);
ompi_output(0, "*** error code: %d\n", *error_code);
if (comm != NULL && ompi_mpi_initialized && !ompi_mpi_finalized) {
ompi_output(0, "*** on communicator %s", (*comm)->c_name);
} else if (!ompi_mpi_initialized) {
ompi_output(0, "*** before MPI was initialized");
} else if (ompi_mpi_finalized) {
ompi_output(0, "*** after MPI was finalized");
} else if (NULL == comm) {
ompi_output(0, "*** on a NULL communicator");
}
if (NULL != error_code) {
ompi_output(0, "*** error code: %d\n", *error_code);
}
/* JMS: Should print the error string as well */
ompi_output(0, "*** MPI_ERRORS_ARE_FATAL");
ompi_output(0, "*** MPI_ERRORS_ARE_FATAL (goodbye)");
va_end(arglist);
/* Should we do something more intelligent here? */
@ -36,7 +50,7 @@ void ompi_mpi_errors_are_fatal_handler(ompi_communicator_t **comm,
}
void ompi_mpi_errors_return_handler(ompi_communicator_t **comm,
void ompi_mpi_errors_return_handler(struct ompi_communicator_t **comm,
int *error_code, ...)
{
/* Don't need anything more -- just need this function to exist */

Просмотреть файл

@ -5,22 +5,17 @@
#ifndef OMPI_ERRHANDLER_PREDEFINED_H
#define OMPI_ERRHANDLER_PREDEFINED_H
#include "errhandler/errhandler.h"
#include "communicator/communicator.h"
/**
* Handler function for MPI_ERRORS_ARE_FATAL
*/
void ompi_mpi_errors_are_fatal_handler(ompi_communicator_t **comm,
void ompi_mpi_errors_are_fatal_handler(struct ompi_communicator_t **comm,
int *error_code, ...);
/**
* Handler function for MPI_ERRORS_RETURN
*/
void ompi_mpi_errors_return_handler(ompi_communicator_t **comm,
void ompi_mpi_errors_return_handler(struct ompi_communicator_t **comm,
int *error_code, ...);
#endif /* OMPI_ERRHANDLER_PREDEFINED_H */

Просмотреть файл

@ -8,7 +8,7 @@
#include "runtime/runtime.h"
#include "mpi/c/bindings.h"
#include "mca/pml/pml.h"
#include "errhandler/errhandler.h"
#if OMPI_HAVE_WEAK_SYMBOLS && OMPI_PROFILING_DEFINES
#pragma weak MPI_Send = PMPI_Send
@ -18,6 +18,9 @@
#include "mpi/c/profile/defines.h"
#endif
static char FUNC_NAME[] = "MPI_Send";
int MPI_Send(void *buf, int count, MPI_Datatype type, int dest,
int tag, MPI_Comm comm)
{
@ -28,23 +31,23 @@ int MPI_Send(void *buf, int count, MPI_Datatype type, int dest,
if ( MPI_PARAM_CHECK ) {
int rc = MPI_SUCCESS;
if ( OMPI_MPI_INVALID_STATE ) {
rc = MPI_ERR_INTERN;
OMPI_ERR_INIT_FINALIZE;
if (ompi_comm_invalid(comm)) {
return OMPI_ERRHANDLER_INVOKE(MPI_COMM_WORLD, MPI_ERR_COMM,
FUNC_NAME);
} else if (count < 0) {
rc = MPI_ERR_COUNT;
} else if (type == MPI_DATATYPE_NULL) {
rc = MPI_ERR_TYPE;
} else if (tag < 0 || tag > MPI_TAG_UB_VALUE) {
rc = MPI_ERR_TAG;
} else if (ompi_comm_invalid(comm)) {
rc = MPI_ERR_COMM;
} else if (ompi_comm_peer_invalid(comm, dest)) {
rc = MPI_ERR_RANK;
}
OMPI_ERRHANDLER_CHECK(rc, comm, rc, "MPI_Send");
OMPI_ERRHANDLER_CHECK(rc, comm, rc, FUNC_NAME);
}
rc = mca_pml.pml_send(buf, count, type, dest, tag, MCA_PML_BASE_SEND_STANDARD, comm);
OMPI_ERRHANDLER_RETURN(rc, comm, rc, "MPI_Send");
OMPI_ERRHANDLER_RETURN(rc, comm, rc, FUNC_NAME);
}