Commit fb5c4f68 authored by David Goodell's avatar David Goodell
Browse files

[svn-r6982] use new MPI_OBJ CS

There are probably more uses out there that I am missing at this point.

No reviewer.
parent a023ea7b
......@@ -86,9 +86,11 @@ int MPI_Comm_set_name(MPI_Comm comm, char *comm_name)
# endif /* HAVE_ERROR_CHECKING */
/* ... body of routine ... */
MPIU_THREAD_CS_ENTER(MPI_OBJ, comm_ptr);
MPIU_Strncpy( comm_ptr->name, comm_name, MPI_MAX_OBJECT_NAME );
MPIU_THREAD_CS_EXIT(MPI_OBJ, comm_ptr);
/* ... end of body of routine ... */
#ifdef HAVE_ERROR_CHECKING
......
......@@ -287,10 +287,12 @@ int MPIR_Comm_split_impl(MPID_Comm *comm_ptr, int color, int key, MPID_Comm **ne
}
/* Inherit the error handler (if any) */
MPIU_THREAD_CS_ENTER(MPI_OBJ, comm_ptr);
(*newcomm_ptr)->errhandler = comm_ptr->errhandler;
if (comm_ptr->errhandler) {
MPIR_Errhandler_add_ref( comm_ptr->errhandler );
}
MPIU_THREAD_CS_EXIT(MPI_OBJ, comm_ptr);
/* Notify the device of this new communicator */
MPID_Dev_comm_create_hook( *newcomm_ptr );
......
......@@ -1030,10 +1030,12 @@ int MPIR_Comm_copy( MPID_Comm *comm_ptr, int size, MPID_Comm **outcomm_ptr )
}
/* Inherit the error handler (if any) */
MPIU_THREAD_CS_ENTER(MPI_OBJ, comm_ptr);
newcomm_ptr->errhandler = comm_ptr->errhandler;
if (comm_ptr->errhandler) {
MPIR_Errhandler_add_ref( comm_ptr->errhandler );
}
MPIU_THREAD_CS_EXIT(MPI_OBJ, comm_ptr);
/* Notify the device of the new communicator */
MPID_Dev_comm_create_hook(newcomm_ptr);
......@@ -1140,6 +1142,7 @@ static int comm_delete(MPID_Comm * comm_ptr, int isDisconnect)
MPIR_Free_contextid( comm_ptr->recvcontext_id );
/* We need to release the error handler */
/* no MPI_OBJ CS needed */
if (comm_ptr->errhandler &&
! (HANDLE_GET_KIND(comm_ptr->errhandler->handle) ==
HANDLE_KIND_BUILTIN) ) {
......
......@@ -557,11 +557,13 @@ int MPI_Intercomm_create(MPI_Comm local_comm, int local_leader,
}
/* Inherit the error handler (if any) */
MPIU_THREAD_CS_ENTER(MPI_OBJ, comm_ptr);
newcomm_ptr->errhandler = comm_ptr->errhandler;
if (comm_ptr->errhandler) {
MPIR_Errhandler_add_ref( comm_ptr->errhandler );
}
MPIU_THREAD_CS_EXIT(MPI_OBJ, comm_ptr);
/* Notify the device of this new communicator */
MPID_Dev_comm_create_hook( newcomm_ptr );
mpi_errno = MPIR_Comm_commit(newcomm_ptr);
......
......@@ -53,6 +53,7 @@
int MPI_Comm_call_errhandler(MPI_Comm comm, int errorcode)
{
int mpi_errno = MPI_SUCCESS;
int in_cs = FALSE;
MPID_Comm *comm_ptr = NULL;
MPIU_THREADPRIV_DECL;
MPID_MPI_STATE_DECL(MPID_STATE_MPI_COMM_CALL_ERRHANDLER);
......@@ -77,6 +78,9 @@ int MPI_Comm_call_errhandler(MPI_Comm comm, int errorcode)
/* Convert MPI object handles to object pointers */
MPID_Comm_get_ptr( comm, comm_ptr );
MPIU_THREAD_CS_ENTER(MPI_OBJ, comm_ptr); /* protect access to comm_ptr->errhandler */
in_cs = TRUE;
/* Validate parameters and objects (post conversion) */
# ifdef HAVE_ERROR_CHECKING
......@@ -149,6 +153,9 @@ int MPI_Comm_call_errhandler(MPI_Comm comm, int errorcode)
/* ... end of body of routine ... */
fn_exit:
if (in_cs)
MPIU_THREAD_CS_EXIT(MPI_OBJ, comm_ptr);
MPID_MPI_FUNC_EXIT(MPID_STATE_MPI_COMM_CALL_ERRHANDLER);
return mpi_errno;
......
......@@ -31,9 +31,11 @@
#define FCNAME MPIU_QUOTE(FUNCNAME)
void MPIR_Comm_get_errhandler_impl(MPID_Comm *comm_ptr, MPID_Errhandler **errhandler_ptr)
{
MPIU_THREAD_CS_ENTER(MPI_OBJ, comm_ptr);
*errhandler_ptr = comm_ptr->errhandler;
if (comm_ptr->errhandler)
MPIR_Errhandler_add_ref(comm_ptr->errhandler);
MPIU_THREAD_CS_EXIT(MPI_OBJ, comm_ptr);
return;
}
......
......@@ -30,6 +30,9 @@
void MPIR_Comm_set_errhandler_impl(MPID_Comm *comm_ptr, MPID_Errhandler *errhandler_ptr)
{
int in_use;
MPIU_THREAD_CS_ENTER(MPI_OBJ, comm_ptr);
/* We don't bother with the case where the errhandler is NULL;
in this case, the error handler was the original, MPI_ERRORS_ARE_FATAL,
which is builtin and can never be freed. */
......@@ -43,6 +46,7 @@ void MPIR_Comm_set_errhandler_impl(MPID_Comm *comm_ptr, MPID_Errhandler *errhand
MPIR_Errhandler_add_ref(errhandler_ptr);
comm_ptr->errhandler = errhandler_ptr;
MPIU_THREAD_CS_EXIT(MPI_OBJ, comm_ptr);
return;
}
......
......@@ -242,6 +242,7 @@ int MPIR_Err_return_comm( MPID_Comm *comm_ptr, const char fcname[],
int errcode )
{
const int error_class = ERROR_GET_CLASS(errcode);
MPID_Errhandler *errhandler = NULL;
int rc;
MPIU_THREADPRIV_DECL;
......@@ -263,32 +264,48 @@ int MPIR_Err_return_comm( MPID_Comm *comm_ptr, const char fcname[],
MPIU_DBG_MSG_FMT(ERRHAND, TERSE, (MPIU_DBG_FDEST, "MPIR_Err_return_comm(comm_ptr=%p, fcname=%s, errcode=%d)", comm_ptr, fcname, errcode));
if (!comm_ptr || comm_ptr->errhandler == NULL) {
/* Try to replace with the default handler, which is the one on
MPI_COMM_WORLD. This gives us correct behavior for the
case where the error handler on MPI_COMM_WORLD has been changed. */
if (MPIR_Process.comm_world)
{
comm_ptr = MPIR_Process.comm_world;
}
if (comm_ptr) {
MPIU_THREAD_CS_ENTER(MPI_OBJ, comm_ptr);
errhandler = comm_ptr->errhandler;
MPIU_THREAD_CS_EXIT(MPI_OBJ, comm_ptr);
}
if (MPIR_Err_is_fatal(errcode) ||
comm_ptr == NULL || comm_ptr->errhandler == NULL ||
comm_ptr->errhandler->handle == MPI_ERRORS_ARE_FATAL) {
if (errhandler == NULL) {
/* Try to replace with the default handler, which is the one on
MPI_COMM_WORLD. This gives us correct behavior for the
case where the error handler on MPI_COMM_WORLD has been changed. */
if (MPIR_Process.comm_world)
{
comm_ptr = MPIR_Process.comm_world;
}
}
if (MPIR_Err_is_fatal(errcode) || comm_ptr == NULL) {
/* Calls MPID_Abort */
handleFatalError( comm_ptr, fcname, errcode );
/* never get here */
}
MPIU_Assert(comm_ptr != NULL);
/* comm_ptr may have changed to comm_world. Keep this locked as long as we
* are using the errhandler to prevent it from disappearing out from under
* us. */
MPIU_THREAD_CS_ENTER(MPI_OBJ, comm_ptr);
errhandler = comm_ptr->errhandler;
if (errhandler == NULL || errhandler->handle == MPI_ERRORS_ARE_FATAL) {
MPIU_THREAD_CS_EXIT(MPI_OBJ, comm_ptr);
/* Calls MPID_Abort */
handleFatalError( comm_ptr, fcname, errcode );
/* never get here */
}
/* Check for the special case of a user-provided error code */
errcode = checkForUserErrcode( errcode );
if (comm_ptr->errhandler->handle == MPI_ERRORS_RETURN ||
comm_ptr->errhandler->handle == MPIR_ERRORS_THROW_EXCEPTIONS)
{
return errcode;
}
else
if (errhandler->handle != MPI_ERRORS_RETURN &&
errhandler->handle != MPIR_ERRORS_THROW_EXCEPTIONS)
{
/* The user error handler may make calls to MPI routines, so the
* nesting counter must be incremented before the handler is called */
......@@ -324,6 +341,8 @@ int MPIR_Err_return_comm( MPID_Comm *comm_ptr, const char fcname[],
MPIR_Nest_decr();
}
MPIU_THREAD_CS_EXIT(MPI_OBJ, comm_ptr);
return errcode;
}
......
......@@ -54,6 +54,7 @@ int MPI_Win_call_errhandler(MPI_Win win, int errorcode)
{
int mpi_errno = MPI_SUCCESS;
MPID_Win *win_ptr = NULL;
int in_cs = FALSE;
MPIU_THREADPRIV_DECL;
MPID_MPI_STATE_DECL(MPID_STATE_MPI_WIN_CALL_ERRHANDLER);
......@@ -93,7 +94,10 @@ int MPI_Win_call_errhandler(MPI_Win win, int errorcode)
# endif /* HAVE_ERROR_CHECKING */
/* ... body of routine ... */
MPIU_THREAD_CS_ENTER(MPI_OBJ, win_ptr);
in_cs = TRUE;
if (!win_ptr->errhandler ||
win_ptr->errhandler->handle == MPI_ERRORS_ARE_FATAL) {
mpi_errno = MPIR_Err_return_win( win_ptr, "MPI_Win_call_errhandler", errorcode );
......@@ -141,6 +145,9 @@ int MPI_Win_call_errhandler(MPI_Win win, int errorcode)
/* ... end of body of routine ... */
fn_exit:
if (in_cs)
MPIU_THREAD_CS_EXIT(MPI_OBJ, win_ptr);
MPID_MPI_FUNC_EXIT(MPID_STATE_MPI_WIN_CALL_ERRHANDLER);
return mpi_errno;
......
......@@ -91,7 +91,9 @@ int MPI_Win_get_errhandler(MPI_Win win, MPI_Errhandler *errhandler)
# endif /* HAVE_ERROR_CHECKING */
/* ... body of routine ... */
MPIU_THREAD_CS_ENTER(MPI_OBJ, win_ptr);
if (win_ptr->errhandler) {
*errhandler = win_ptr->errhandler->handle;
MPIR_Errhandler_add_ref(win_ptr->errhandler);
......@@ -100,7 +102,9 @@ int MPI_Win_get_errhandler(MPI_Win win, MPI_Errhandler *errhandler)
/* Use the default */
*errhandler = MPI_ERRORS_ARE_FATAL;
}
MPIU_THREAD_CS_EXIT(MPI_OBJ, win_ptr);
/* ... end of body of routine ... */
#ifdef HAVE_ERROR_CHECKING
......
......@@ -103,6 +103,8 @@ int MPI_Win_set_errhandler(MPI_Win win, MPI_Errhandler errhandler)
/* ... body of routine ... */
MPIU_THREAD_CS_ENTER(MPI_OBJ, win_ptr);
if (win_ptr->errhandler != NULL) {
MPIR_Errhandler_release_ref(win_ptr->errhandler,&in_use);
if (!in_use) {
......@@ -113,6 +115,8 @@ int MPI_Win_set_errhandler(MPI_Win win, MPI_Errhandler errhandler)
MPIR_Errhandler_add_ref(errhan_ptr);
win_ptr->errhandler = errhan_ptr;
MPIU_THREAD_CS_EXIT(MPI_OBJ, win_ptr);
/* ... end of body of routine ... */
#ifdef HAVE_ERROR_CHECKING
......
......@@ -165,6 +165,7 @@ int MPI_Finalize( void )
* At this point, we will release any user-defined error handlers on
* comm self and comm world
*/
/* no MPI_OBJ CS needed here */
if (MPIR_Process.comm_world->errhandler &&
! (HANDLE_GET_KIND(MPIR_Process.comm_world->errhandler->handle) ==
HANDLE_KIND_BUILTIN) ) {
......
......@@ -102,6 +102,7 @@ int MPI_Win_free(MPI_Win *win)
if (mpi_errno != MPI_SUCCESS) goto fn_fail;
/* We need to release the error handler */
/* no MPI_OBJ CS is needed here */
if (win_ptr->errhandler &&
! (HANDLE_GET_KIND(win_ptr->errhandler->handle) ==
HANDLE_KIND_BUILTIN) ) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment