-: 0:Source:/home/MPI/testing/mpich2/mpich2/src/mpi/spawn/comm_disconnect.c
-: 0:Graph:comm_disconnect.gcno
-: 0:Data:comm_disconnect.gcda
-: 0:Runs:911
-: 0:Programs:154
-: 1:/* -*- Mode: C; c-basic-offset:4 ; -*- */
-: 2:/*
-: 3: *
-: 4: * (C) 2001 by Argonne National Laboratory.
-: 5: * See COPYRIGHT in top-level directory.
-: 6: */
-: 7:
-: 8:#include "mpiimpl.h"
-: 9:
-: 10:/* -- Begin Profiling Symbol Block for routine MPI_Comm_disconnect */
-: 11:#if defined(HAVE_PRAGMA_WEAK)
-: 12:#pragma weak MPI_Comm_disconnect = PMPI_Comm_disconnect
-: 13:#elif defined(HAVE_PRAGMA_HP_SEC_DEF)
-: 14:#pragma _HP_SECONDARY_DEF PMPI_Comm_disconnect MPI_Comm_disconnect
-: 15:#elif defined(HAVE_PRAGMA_CRI_DUP)
-: 16:#pragma _CRI duplicate MPI_Comm_disconnect as PMPI_Comm_disconnect
-: 17:#endif
-: 18:/* -- End Profiling Symbol Block */
-: 19:
-: 20:/* Define MPICH_MPI_FROM_PMPI if weak symbols are not supported to build
-: 21: the MPI routines */
-: 22:#ifndef MPICH_MPI_FROM_PMPI
-: 23:#undef MPI_Comm_disconnect
-: 24:#define MPI_Comm_disconnect PMPI_Comm_disconnect
-: 25:
-: 26:#endif
-: 27:
-: 28:#undef FUNCNAME
-: 29:#define FUNCNAME MPI_Comm_disconnect
-: 30:
-: 31:/*@
-: 32: MPI_Comm_disconnect - Disconnect from a communicator
-: 33:
-: 34: Input Parameter:
-: 35:. comm - communicator (handle)
-: 36:
-: 37:Notes:
-: 38:This routine waits for all pending communication to complete, then frees the
-: 39:communicator and sets 'comm' to 'MPI_COMM_NULL'. It may not be called
-: 40:with 'MPI_COMM_WORLD' or 'MPI_COMM_SELF'.
-: 41:
-: 42:.N ThreadSafe
-: 43:
-: 44:.N Fortran
-: 45:
-: 46:.N Errors
-: 47:.N MPI_SUCCESS
-: 48:
-: 49:.seealso MPI_Comm_connect, MPI_Comm_join
-: 50:@*/
-: 51:int MPI_Comm_disconnect(MPI_Comm * comm)
2559: 52:{
-: 53: static const char FCNAME[] = "MPI_Comm_disconnect";
2559: 54: int mpi_errno = MPI_SUCCESS;
2559: 55: MPID_Comm *comm_ptr = NULL;
2559: 56: MPIU_THREADPRIV_DECL;
-: 57: MPID_MPI_STATE_DECL(MPID_STATE_MPI_COMM_DISCONNECT);
-: 58:
2559: 59: MPIR_ERRTEST_INITIALIZED_ORDIE();
-: 60:
2559: 61: MPIU_THREAD_CS_ENTER(ALLFUNC,);
-: 62: MPID_MPI_FUNC_ENTER(MPID_STATE_MPI_COMM_DISCONNECT);
-: 63:
-: 64: /* Validate parameters, especially handles needing to be converted */
|
-: 65:# ifdef HAVE_ERROR_CHECKING
-: 66: {
-: 67: MPID_BEGIN_ERROR_CHECKS;
-: 68: {
2559: 69: MPIR_ERRTEST_COMM(*comm, mpi_errno);
2559: 70: if (mpi_errno != MPI_SUCCESS) goto fn_fail;
-: 71: }
-: 72: MPID_END_ERROR_CHECKS;
-: 73: }
-: 74:# endif
-: 75:
-: 76: /* Convert MPI object handles to object pointers */
|
2559: 77: MPID_Comm_get_ptr( *comm, comm_ptr );
-: 78:
-: 79: /* Validate parameters and objects (post conversion) */
|
-: 80:# ifdef HAVE_ERROR_CHECKING
-: 81: {
-: 82: MPID_BEGIN_ERROR_CHECKS;
-: 83: {
-: 84: /* Validate comm_ptr */
2559: 85: MPID_Comm_valid_ptr( comm_ptr, mpi_errno );
-: 86: /* If comm_ptr is not valid, it will be reset to null */
2559: 87: if (mpi_errno)
-: 88: {
#####: 89: goto fn_fail;
-: 90: }
-: 91: }
-: 92: MPID_END_ERROR_CHECKS;
-: 93: }
-: 94:# endif /* HAVE_ERROR_CHECKING */
-: 95:
-: 96: /* ... body of routine ... */
-: 97:
-: 98: /*
-: 99: * Since outstanding I/O bumps the reference count on the communicator,
-: 100: * we wait until we hold the last reference count to
-: 101: * ensure that all communication has completed. The reference count
-: 102: * is 1 when the communicator is created, and it is incremented
-: 103: * only for pending communication operations (and decremented when
-: 104: * those complete).
-: 105: */
-: 106: /* FIXME-MT should we be checking this? */
|
2559: 107: if (MPIU_Object_get_ref(comm_ptr) > 1)
-: 108: {
-: 109: MPID_Progress_state progress_state;
-: 110:
|
#####: 111: MPID_Progress_start(&progress_state);
#####: 112: while (MPIU_Object_get_ref(comm_ptr) > 1)
-: 113: {
#####: 114: mpi_errno = MPID_Progress_wait(&progress_state);
|
-: 115: /* --BEGIN ERROR HANDLING-- */
#####: 116: if (mpi_errno != MPI_SUCCESS)
-: 117: {
-: 118: MPID_Progress_end(&progress_state);
#####: 119: goto fn_fail;
-: 120: }
-: 121: /* --END ERROR HANDLING-- */
-: 122: }
-: 123: MPID_Progress_end(&progress_state);
-: 124: }
-: 125:
|
2559: 126: mpi_errno = MPID_Comm_disconnect(comm_ptr);
|
2559: 127: if (mpi_errno != MPI_SUCCESS) goto fn_fail;
-: 128:
|
2559: 129: *comm = MPI_COMM_NULL;
-: 130:
-: 131: /* ... end of body of routine ... */
-: 132:
2559: 133: fn_exit:
|
-: 134: MPID_MPI_FUNC_EXIT(MPID_STATE_MPI_COMM_DISCONNECT);
|
2559: 135: MPIU_THREAD_CS_EXIT(ALLFUNC,);
2559: 136: return mpi_errno;
-: 137:
|
#####: 138: fn_fail:
-: 139: /* --BEGIN ERROR HANDLING-- */
-: 140:# ifdef HAVE_ERROR_CHECKING
-: 141: {
#####: 142: mpi_errno = MPIR_Err_create_code(
-: 143: mpi_errno, MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPI_ERR_OTHER, "**mpi_comm_disconnect",
-: 144: "**mpi_comm_disconnect %C", *comm);
-: 145: }
-: 146:# endif
#####: 147: mpi_errno = MPIR_Err_return_comm( comm_ptr, FCNAME, mpi_errno );
#####: 148: goto fn_exit;
-: 149: /* --END ERROR HANDLING-- */
-: 150:}
|