2004-03-20 04:54:18 +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.
|
|
|
|
* $COPYRIGHT$
|
|
|
|
*
|
|
|
|
* Additional copyrights may follow
|
|
|
|
*
|
2004-03-19 09:12:43 +03:00
|
|
|
* $HEADER$
|
|
|
|
*/
|
|
|
|
|
2004-06-07 19:33:53 +04:00
|
|
|
#include "ompi_config.h"
|
2004-03-19 09:12:43 +03:00
|
|
|
|
|
|
|
#include "communicator/communicator.h"
|
|
|
|
#include "win/win.h"
|
|
|
|
#include "file/file.h"
|
|
|
|
#include "errhandler/errhandler.h"
|
|
|
|
#include "errhandler/errhandler_predefined.h"
|
2004-06-07 19:33:53 +04:00
|
|
|
#include "class/ompi_pointer_array.h"
|
2004-03-19 09:12:43 +03:00
|
|
|
|
|
|
|
|
2004-03-19 22:01:09 +03:00
|
|
|
/*
|
|
|
|
* Table for Fortran <-> C errhandler handle conversion
|
|
|
|
*/
|
2004-06-07 19:33:53 +04:00
|
|
|
ompi_pointer_array_t *ompi_errhandler_f_to_c_table;
|
2004-03-19 09:12:43 +03:00
|
|
|
|
2004-03-19 22:01:09 +03:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Class information
|
|
|
|
*/
|
2004-06-07 19:33:53 +04:00
|
|
|
static void ompi_errhandler_construct(ompi_errhandler_t *eh);
|
|
|
|
static void ompi_errhandler_destruct(ompi_errhandler_t *eh);
|
2004-03-19 09:12:43 +03:00
|
|
|
|
|
|
|
|
2004-04-21 02:17:20 +04:00
|
|
|
/*
|
|
|
|
* Class instance
|
|
|
|
*/
|
2004-06-07 19:33:53 +04:00
|
|
|
OBJ_CLASS_INSTANCE(ompi_errhandler_t, ompi_object_t, ompi_errhandler_construct,
|
|
|
|
ompi_errhandler_destruct);
|
2004-03-19 09:12:43 +03:00
|
|
|
|
|
|
|
|
2004-09-09 18:38:04 +04:00
|
|
|
ompi_errhandler_t ompi_mpi_errhandler_null;
|
|
|
|
ompi_errhandler_t ompi_mpi_errors_are_fatal;
|
|
|
|
ompi_errhandler_t ompi_mpi_errors_return;
|
2004-03-19 09:12:43 +03:00
|
|
|
|
|
|
|
/*
|
2004-06-07 19:33:53 +04:00
|
|
|
* Initialize OMPI errhandler infrastructure
|
2004-03-19 09:12:43 +03:00
|
|
|
*/
|
2004-06-07 19:33:53 +04:00
|
|
|
int ompi_errhandler_init(void)
|
2004-03-19 09:12:43 +03:00
|
|
|
{
|
2004-06-07 19:33:53 +04:00
|
|
|
/* initialize ompi_errhandler_f_to_c_table */
|
2004-03-19 09:12:43 +03:00
|
|
|
|
2004-06-07 19:33:53 +04:00
|
|
|
ompi_errhandler_f_to_c_table = OBJ_NEW(ompi_pointer_array_t);
|
|
|
|
if (NULL == ompi_errhandler_f_to_c_table){
|
|
|
|
return OMPI_ERROR;
|
2004-03-19 09:12:43 +03:00
|
|
|
}
|
|
|
|
|
2004-05-01 00:11:07 +04:00
|
|
|
/* Initialize the predefined error handlers */
|
2004-06-07 19:33:53 +04:00
|
|
|
OBJ_CONSTRUCT( &ompi_mpi_errhandler_null, ompi_errhandler_t );
|
|
|
|
if( ompi_mpi_errhandler_null.eh_f_to_c_index != OMPI_ERRHANDLER_NULL_FORTRAN )
|
|
|
|
return OMPI_ERROR;
|
2004-09-09 18:38:04 +04:00
|
|
|
ompi_mpi_errhandler_null.eh_mpi_object_type = OMPI_ERRHANDLER_TYPE_PREDEFINED;
|
|
|
|
ompi_mpi_errhandler_null.eh_fortran_function = false;
|
|
|
|
ompi_mpi_errhandler_null.eh_comm_fn = NULL;
|
|
|
|
ompi_mpi_errhandler_null.eh_file_fn = NULL;
|
|
|
|
ompi_mpi_errhandler_null.eh_win_fn = NULL ;
|
|
|
|
ompi_mpi_errhandler_null.eh_fort_fn = NULL;
|
|
|
|
strncpy (ompi_mpi_errhandler_null.eh_name, "MPI_ERRHANDLER_NULL",
|
|
|
|
strlen("MPI_ERRHANDLER_NULL")+1 );
|
|
|
|
|
2004-03-19 09:12:43 +03:00
|
|
|
|
2004-06-07 19:33:53 +04:00
|
|
|
OBJ_CONSTRUCT( &ompi_mpi_errors_are_fatal, ompi_errhandler_t );
|
|
|
|
if( ompi_mpi_errors_are_fatal.eh_f_to_c_index != OMPI_ERRORS_ARE_FATAL_FORTRAN )
|
|
|
|
return OMPI_ERROR;
|
2004-09-09 18:38:04 +04:00
|
|
|
ompi_mpi_errors_are_fatal.eh_mpi_object_type = OMPI_ERRHANDLER_TYPE_PREDEFINED;
|
|
|
|
ompi_mpi_errors_are_fatal.eh_fortran_function = false;
|
|
|
|
ompi_mpi_errors_are_fatal.eh_comm_fn = ompi_mpi_errors_are_fatal_comm_handler;
|
|
|
|
ompi_mpi_errors_are_fatal.eh_file_fn = ompi_mpi_errors_are_fatal_file_handler;
|
|
|
|
ompi_mpi_errors_are_fatal.eh_win_fn = ompi_mpi_errors_are_fatal_win_handler ;
|
|
|
|
ompi_mpi_errors_are_fatal.eh_fort_fn = NULL;
|
|
|
|
strncpy (ompi_mpi_errors_are_fatal.eh_name, "MPI_ERRORS_ARE_FATAL",
|
|
|
|
strlen("MPI_ERRORS_ARE_FATAL")+1 );
|
2004-03-19 09:12:43 +03:00
|
|
|
|
2004-06-07 19:33:53 +04:00
|
|
|
OBJ_CONSTRUCT( &ompi_mpi_errors_return, ompi_errhandler_t );
|
|
|
|
if( ompi_mpi_errors_return.eh_f_to_c_index != OMPI_ERRORS_RETURN_FORTRAN )
|
|
|
|
return OMPI_ERROR;
|
2004-09-09 18:38:04 +04:00
|
|
|
ompi_mpi_errors_return.eh_mpi_object_type = OMPI_ERRHANDLER_TYPE_PREDEFINED;
|
|
|
|
ompi_mpi_errors_return.eh_fortran_function = false;
|
|
|
|
ompi_mpi_errors_return.eh_comm_fn = ompi_mpi_errors_return_comm_handler;
|
|
|
|
ompi_mpi_errors_return.eh_file_fn = ompi_mpi_errors_return_file_handler;
|
|
|
|
ompi_mpi_errors_return.eh_win_fn = ompi_mpi_errors_return_win_handler;
|
|
|
|
ompi_mpi_errors_return.eh_fort_fn = NULL;
|
|
|
|
strncpy (ompi_mpi_errors_return.eh_name, "MPI_ERRORS_RETURN",
|
|
|
|
strlen("MPI_ERRORS_RETURN")+1 );
|
2004-03-19 09:12:43 +03:00
|
|
|
|
|
|
|
/* All done */
|
|
|
|
|
2004-06-07 19:33:53 +04:00
|
|
|
return OMPI_SUCCESS;
|
2004-03-19 09:12:43 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Clean up the errorhandler resources
|
|
|
|
*/
|
2004-06-07 19:33:53 +04:00
|
|
|
int ompi_errhandler_finalize(void)
|
2004-03-19 09:12:43 +03:00
|
|
|
{
|
|
|
|
/* Remove errhandler F2C table */
|
|
|
|
|
2004-06-07 19:33:53 +04:00
|
|
|
OBJ_RELEASE(ompi_errhandler_f_to_c_table);
|
2004-03-19 09:12:43 +03:00
|
|
|
|
|
|
|
/* All done */
|
|
|
|
|
2004-06-07 19:33:53 +04:00
|
|
|
return OMPI_SUCCESS;
|
2004-03-26 08:00:29 +03:00
|
|
|
}
|
2004-03-19 20:29:39 +03:00
|
|
|
|
|
|
|
|
2004-06-07 19:33:53 +04:00
|
|
|
ompi_errhandler_t *ompi_errhandler_create(ompi_errhandler_type_t object_type,
|
2004-09-06 16:06:27 +04:00
|
|
|
ompi_errhandler_generic_handler_fn_t *func)
|
2004-03-19 20:29:39 +03:00
|
|
|
{
|
2004-06-07 19:33:53 +04:00
|
|
|
ompi_errhandler_t *new_errhandler;
|
2004-03-19 20:29:39 +03:00
|
|
|
|
|
|
|
/* Create a new object and ensure that it's valid */
|
|
|
|
|
2004-06-07 19:33:53 +04:00
|
|
|
new_errhandler = OBJ_NEW(ompi_errhandler_t);
|
2004-08-28 20:49:40 +04:00
|
|
|
if (NULL != new_errhandler) {
|
2004-06-07 19:33:53 +04:00
|
|
|
if (OMPI_ERROR == new_errhandler->eh_f_to_c_index) {
|
2004-03-19 20:29:39 +03:00
|
|
|
OBJ_RELEASE(new_errhandler);
|
|
|
|
new_errhandler = NULL;
|
|
|
|
} else {
|
|
|
|
|
|
|
|
/* The new object is valid -- initialize it. If this is being
|
|
|
|
created from fortran, the fortran MPI API wrapper function
|
|
|
|
will override the eh_fortran_field directly. We cast the
|
|
|
|
function pointer type to the fortran type arbitrarily -- it
|
|
|
|
only has to be a function pointer in order to store properly,
|
|
|
|
it doesn't matter what type it is (we'll cast it to the Right
|
|
|
|
type when we *use* it). */
|
|
|
|
|
|
|
|
new_errhandler->eh_mpi_object_type = object_type;
|
|
|
|
new_errhandler->eh_fortran_function = false;
|
2004-09-06 16:06:27 +04:00
|
|
|
switch (object_type ) {
|
|
|
|
case (OMPI_ERRHANDLER_TYPE_COMM):
|
|
|
|
new_errhandler->eh_comm_fn = (MPI_Comm_errhandler_fn *)func;
|
|
|
|
break;
|
|
|
|
case (OMPI_ERRHANDLER_TYPE_FILE):
|
|
|
|
new_errhandler->eh_file_fn = (MPI_File_errhandler_fn *)func;
|
|
|
|
break;
|
|
|
|
case (OMPI_ERRHANDLER_TYPE_WIN):
|
|
|
|
new_errhandler->eh_win_fn = (MPI_Win_errhandler_fn *)func;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
new_errhandler->eh_fort_fn = (ompi_errhandler_fortran_handler_fn_t *)func;
|
2004-03-19 20:29:39 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* All done */
|
2004-08-28 20:49:40 +04:00
|
|
|
|
|
|
|
return new_errhandler;
|
2004-03-19 20:29:39 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**************************************************************************
|
|
|
|
*
|
|
|
|
* Static functions
|
|
|
|
*
|
|
|
|
**************************************************************************/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Errhandler constructor
|
|
|
|
*/
|
2004-06-07 19:33:53 +04:00
|
|
|
static void ompi_errhandler_construct(ompi_errhandler_t *new_errhandler)
|
2004-03-19 20:29:39 +03:00
|
|
|
{
|
2004-10-20 03:58:12 +04:00
|
|
|
size_t ret_val;
|
2004-03-19 20:29:39 +03:00
|
|
|
|
|
|
|
/* assign entry in fortran <-> c translation array */
|
|
|
|
|
2004-06-07 19:33:53 +04:00
|
|
|
ret_val = ompi_pointer_array_add(ompi_errhandler_f_to_c_table,
|
2004-10-20 03:58:12 +04:00
|
|
|
new_errhandler);
|
2004-03-19 20:29:39 +03:00
|
|
|
new_errhandler->eh_f_to_c_index = ret_val;
|
2004-09-06 16:06:27 +04:00
|
|
|
|
2004-10-20 15:02:57 +04:00
|
|
|
new_errhandler->eh_fortran_function = false;
|
2004-09-06 16:06:27 +04:00
|
|
|
|
|
|
|
new_errhandler->eh_comm_fn = NULL;
|
|
|
|
new_errhandler->eh_win_fn = NULL;
|
|
|
|
new_errhandler->eh_file_fn = NULL;
|
|
|
|
new_errhandler->eh_fort_fn = NULL;
|
|
|
|
|
|
|
|
memset (new_errhandler->eh_name, 0, MPI_MAX_OBJECT_NAME);
|
2004-03-19 20:29:39 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Errhandler destructor
|
|
|
|
*/
|
2004-06-07 19:33:53 +04:00
|
|
|
static void ompi_errhandler_destruct(ompi_errhandler_t *errhandler)
|
2004-03-19 20:29:39 +03:00
|
|
|
{
|
2004-06-07 19:33:53 +04:00
|
|
|
/* reset the ompi_errhandler_f_to_c_table entry - make sure that the
|
2004-03-19 20:29:39 +03:00
|
|
|
entry is in the table */
|
|
|
|
|
2004-06-07 19:33:53 +04:00
|
|
|
if (NULL!= ompi_pointer_array_get_item(ompi_errhandler_f_to_c_table,
|
2004-03-19 20:29:39 +03:00
|
|
|
errhandler->eh_f_to_c_index)) {
|
2004-06-07 19:33:53 +04:00
|
|
|
ompi_pointer_array_set_item(ompi_errhandler_f_to_c_table,
|
2004-03-19 20:29:39 +03:00
|
|
|
errhandler->eh_f_to_c_index, NULL);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|