-:    0:Source:/home/MPI/testing/mpich2/mpich2/src/mpi/pt2pt/request_get_status.c
        -:    0:Graph:request_get_status.gcno
        -:    0:Data:request_get_status.gcda
        -:    0:Runs:511
        -:    0:Programs:137
        -:    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:
        -:   11:/* -- Begin Profiling Symbol Block for routine MPI_Request_get_status */
        -:   12:#if defined(HAVE_PRAGMA_WEAK)
        -:   13:#pragma weak MPI_Request_get_status = PMPI_Request_get_status
        -:   14:#elif defined(HAVE_PRAGMA_HP_SEC_DEF)
        -:   15:#pragma _HP_SECONDARY_DEF PMPI_Request_get_status  MPI_Request_get_status
        -:   16:#elif defined(HAVE_PRAGMA_CRI_DUP)
        -:   17:#pragma _CRI duplicate MPI_Request_get_status as PMPI_Request_get_status
        -:   18:#endif
        -:   19:/* -- End Profiling Symbol Block */
        -:   20:
        -:   21:/* Define MPICH_MPI_FROM_PMPI if weak symbols are not supported to build
        -:   22:   the MPI routines */
        -:   23:#ifndef MPICH_MPI_FROM_PMPI
        -:   24:#undef MPI_Request_get_status
        -:   25:#define MPI_Request_get_status PMPI_Request_get_status
        -:   26:
        -:   27:#endif
        -:   28:
        -:   29:#undef FUNCNAME
        -:   30:#define FUNCNAME MPI_Request_get_status
        -:   31:
        -:   32:/*@
        -:   33:   MPI_Request_get_status - Nondestructive test for the completion of a Request
        -:   34:
        -:   35:Input Parameter:
        -:   36:.  request - request (handle).  May be 'MPI_REQUEST_NULL'.
        -:   37:
        -:   38:Output Parameters:
        -:   39:+  flag - true if operation has completed (logical)
        -:   40:-  status - status object (Status).  May be 'MPI_STATUS_IGNORE'.
        -:   41:
        -:   42:   Notes:
        -:   43:   Unlike 'MPI_Test', 'MPI_Request_get_status' does not deallocate or
        -:   44:   deactivate the request.  A call to one of the test/wait routines or 
        -:   45:   'MPI_Request_free' should be made to release the request object.
        -:   46:
        -:   47:.N ThreadSafe
        -:   48:
        -:   49:.N Fortran
        -:   50:
        -:   51:.N Errors
        -:   52:.N MPI_SUCCESS
        -:   53:@*/
        -:   54:int MPI_Request_get_status(MPI_Request request, int *flag, MPI_Status *status)
        5:   55:{
        -:   56:    static const char FCNAME[] = "MPI_Request_get_status";
        5:   57:    int mpi_errno = MPI_SUCCESS;
        5:   58:    MPID_Request *request_ptr = NULL;
        -:   59:    MPID_MPI_STATE_DECL(MPID_STATE_MPI_REQUEST_GET_STATUS);
        -:   60:
        5:   61:    MPIR_ERRTEST_INITIALIZED_ORDIE();
        -:   62:    
        -:   63:    MPID_MPI_FUNC_ENTER(MPID_STATE_MPI_REQUEST_GET_STATUS);
        -:   64:
        -:   65:    /* Check the arguments */
        -:   66:#   ifdef HAVE_ERROR_CHECKING
        -:   67:    {
        -:   68:        MPID_BEGIN_ERROR_CHECKS;
        -:   69:        {
        5:   70:	    MPIR_ERRTEST_REQUEST_OR_NULL(request, mpi_errno);
        5:   71:	    MPIR_ERRTEST_ARGNULL(flag, "flag", mpi_errno);
        -:   72:	    /* NOTE: MPI_STATUS_IGNORE != NULL */
        5:   73:	    MPIR_ERRTEST_ARGNULL(status, "status", mpi_errno);
        5:   74:	    if (mpi_errno) goto fn_fail;
        -:   75:	}
        -:   76:        MPID_END_ERROR_CHECKS;
        -:   77:    }
        -:   78:#   endif /* HAVE_ERROR_CHECKING */
        -:   79:
        -:   80:    /* If this is a null request handle, then return an empty status */
        5:   81:    if (request == MPI_REQUEST_NULL) {
        4:   82:        *flag = 1;
        4:   83:        MPIR_Status_set_empty(status);
        -:   84:        /* the above macro doesn't set MPI_ERROR */
        4:   85:        if (status != MPI_STATUS_IGNORE)
        2:   86:            status->MPI_ERROR = MPI_SUCCESS;
        -:   87:        goto fn_exit;
        -:   88:    }
        -:   89:
        -:   90:    /* Convert MPI object handles to object pointers */
        1:   91:    MPID_Request_get_ptr( request, request_ptr );
        -:   92:
        -:   93:    /* Validate parameters if error checking is enabled */
        -:   94:#   ifdef HAVE_ERROR_CHECKING
        -:   95:    {
        -:   96:        MPID_BEGIN_ERROR_CHECKS;
        -:   97:        {
        -:   98:	    /* Validate request_ptr */
        1:   99:            MPID_Request_valid_ptr( request_ptr, mpi_errno );
        1:  100:            if (mpi_errno) goto fn_fail;
        -:  101:        }
        -:  102:        MPID_END_ERROR_CHECKS;
        -:  103:    }
        -:  104:#   endif /* HAVE_ERROR_CHECKING */
        -:  105:
        -:  106:    /* ... body of routine ...  */
        -:  107:
        1:  108:    if (*request_ptr->cc_ptr != 0) {
        -:  109:	/* request not complete. poke the progress engine. Req #3130 */
    #####:  110:	mpi_errno = MPID_Progress_test();
    #####:  111:	if (mpi_errno != MPI_SUCCESS) goto fn_fail;
        -:  112:    }
        -:  113:    
        1:  114:    if (*request_ptr->cc_ptr == 0)
        -:  115:    {
        1:  116:	switch(request_ptr->kind)
        -:  117:	{
        -:  118:        case MPID_REQUEST_SEND:
        -:  119:        {
    #####:  120:            if (status != MPI_STATUS_IGNORE)
        -:  121:            {
    #####:  122:                status->cancelled = request_ptr->status.cancelled;
        -:  123:            }
    #####:  124:            mpi_errno = request_ptr->status.MPI_ERROR;
    #####:  125:            break;
        -:  126:        }
        -:  127:        
        -:  128:        case MPID_REQUEST_RECV:
        -:  129:        {
        1:  130:            MPIR_Request_extract_status(request_ptr, status);
        1:  131:            mpi_errno = request_ptr->status.MPI_ERROR;
        1:  132:            break;
        -:  133:        }
        -:  134:        
        -:  135:        case MPID_PREQUEST_SEND:
        -:  136:        {
    #####:  137:            MPID_Request * prequest_ptr = request_ptr->partner_request;
        -:  138:            
    #####:  139:            if (prequest_ptr != NULL)
        -:  140:            {
    #####:  141:		if (prequest_ptr->kind != MPID_UREQUEST)
        -:  142:		{
    #####:  143:		    if (status != MPI_STATUS_IGNORE)
        -:  144:		    {
    #####:  145:			status->cancelled = request_ptr->status.cancelled;
        -:  146:		    }
    #####:  147:		    mpi_errno = prequest_ptr->status.MPI_ERROR;
        -:  148:		}
        -:  149:		else
        -:  150:		{
        -:  151:		    /* This is needed for persistent Bsend requests */
    #####:  152:		    MPIU_THREADPRIV_DECL;
    #####:  153:		    MPIU_THREADPRIV_GET;
    #####:  154:		    MPIR_Nest_incr();
        -:  155:		    {
        -:  156:			int rc;
        -:  157:			
    #####:  158:			rc = MPIR_Grequest_query(prequest_ptr);
    #####:  159:			if (mpi_errno == MPI_SUCCESS)
        -:  160:			{
    #####:  161:			    mpi_errno = rc;
        -:  162:			}
    #####:  163:			if (status != MPI_STATUS_IGNORE)
        -:  164:			{
    #####:  165:			    status->cancelled = prequest_ptr->status.cancelled;
        -:  166:			}
    #####:  167:			if (mpi_errno == MPI_SUCCESS)
        -:  168:			{
    #####:  169:			    mpi_errno = prequest_ptr->status.MPI_ERROR;
        -:  170:			}
        -:  171:		    }
    #####:  172:		    MPIR_Nest_decr();
        -:  173:		}
        -:  174:            }
        -:  175:            else
        -:  176:            {
    #####:  177:                if (request_ptr->status.MPI_ERROR != MPI_SUCCESS)
        -:  178:                {
        -:  179:                    /* if the persistent request failed to start then 
        -:  180:                       make the error code available */
    #####:  181:                    if (status != MPI_STATUS_IGNORE)
        -:  182:                    {
    #####:  183:                        status->cancelled = request_ptr->status.cancelled;
        -:  184:                    }
    #####:  185:                    mpi_errno = request_ptr->status.MPI_ERROR;
        -:  186:                }
        -:  187:                else
        -:  188:                {
    #####:  189:                    MPIR_Status_set_empty(status);
        -:  190:                }
        -:  191:            }
        -:  192:	    
        -:  193:            break;
        -:  194:        }
        -:  195:        
        -:  196:        case MPID_PREQUEST_RECV:
        -:  197:        {
    #####:  198:            MPID_Request * prequest_ptr = request_ptr->partner_request;
        -:  199:            
    #####:  200:            if (prequest_ptr != NULL)
        -:  201:            {
    #####:  202:                MPIR_Request_extract_status(prequest_ptr, status);
    #####:  203:                mpi_errno = prequest_ptr->status.MPI_ERROR;
        -:  204:            }
        -:  205:            else
        -:  206:            {
        -:  207:                /* if the persistent request failed to start then
        -:  208:                   make the error code available */
    #####:  209:                mpi_errno = request_ptr->status.MPI_ERROR;
    #####:  210:                MPIR_Status_set_empty(status);
        -:  211:            }
        -:  212:	    
        -:  213:            break;
        -:  214:        }
        -:  215:
        -:  216:        case MPID_UREQUEST:
        -:  217:        {
    #####:  218:	    MPIU_THREADPRIV_DECL;
    #####:  219:	    MPIU_THREADPRIV_GET;
    #####:  220:	    MPIR_Nest_incr();
        -:  221:	    {
        -:  222:		int rc;
        -:  223:		
    #####:  224:		rc = MPIR_Grequest_query(request_ptr);
    #####:  225:		if (mpi_errno == MPI_SUCCESS)
        -:  226:		{
    #####:  227:		    mpi_errno = rc;
        -:  228:		}
    #####:  229:		if (status != MPI_STATUS_IGNORE)
        -:  230:		{
    #####:  231:		    status->cancelled = request_ptr->status.cancelled;
        -:  232:		}
    #####:  233:		MPIR_Request_extract_status(request_ptr, status);
        -:  234:	    }
    #####:  235:	    MPIR_Nest_decr();
        -:  236:	    
        -:  237:            break;
        -:  238:        }
        -:  239:        
        -:  240:        default:
        -:  241:            break;
        -:  242:	}
        -:  243:
        1:  244:	*flag = TRUE;
        -:  245:    }
        -:  246:    else
        -:  247:    {
    #####:  248:	*flag = FALSE;
        -:  249:    }
        -:  250:
        -:  251:    /* --BEGIN ERROR HANDLING-- */
        1:  252:    if (mpi_errno != MPI_SUCCESS) goto fn_fail;
        -:  253:    /* --END ERROR HANDLING-- */
        -:  254:
        -:  255:    /* ... end of body of routine ... */
        -:  256:    
        5:  257:  fn_exit:
        -:  258:    MPID_MPI_FUNC_EXIT(MPID_STATE_MPI_REQUEST_GET_STATUS);
        5:  259:    return mpi_errno;
        -:  260:
    #####:  261:  fn_fail:
        -:  262:    /* --BEGIN ERROR HANDLING-- */
        -:  263:#   ifdef HAVE_ERROR_CHECKING
        -:  264:    {
    #####:  265:	mpi_errno = MPIR_Err_create_code(mpi_errno, MPIR_ERR_RECOVERABLE,
        -:  266:	    FCNAME, __LINE__, MPI_ERR_OTHER, "**mpi_request_get_status",
        -:  267:	    "**mpi_request_get_status %R %p %p", request, flag, status);
        -:  268:    }
        -:  269:#   endif
    #####:  270:    mpi_errno = MPIR_Err_return_comm( 0, FCNAME, mpi_errno );
    #####:  271:    goto fn_exit;
        -:  272:    /* --END ERROR HANDLING-- */
        -:  273:}