root/ompi/mpi/c/request_get_status.c

/* [<][>][^][v][top][bottom][index][help] */

DEFINITIONS

This source file includes following definitions.
  1. MPI_Request_get_status

   1 /*
   2  * Copyright (c) 2004-2007 The Trustees of Indiana University and Indiana
   3  *                         University Research and Technology
   4  *                         Corporation.  All rights reserved.
   5  * Copyright (c) 2004-2005 The University of Tennessee and The University
   6  *                         of Tennessee Research Foundation.  All rights
   7  *                         reserved.
   8  * Copyright (c) 2004-2008 High Performance Computing Center Stuttgart,
   9  *                         University of Stuttgart.  All rights reserved.
  10  * Copyright (c) 2004-2005 The Regents of the University of California.
  11  *                         All rights reserved.
  12  * Copyright (c) 2006-2010 Cisco Systems, Inc.  All rights reserved.
  13  * Copyright (c) 2015      Research Organization for Information Science
  14  *                         and Technology (RIST). All rights reserved.
  15  * $COPYRIGHT$
  16  *
  17  * Additional copyrights may follow
  18  *
  19  * $HEADER$
  20  */
  21 #include "ompi_config.h"
  22 #include <stdio.h>
  23 
  24 #include "ompi/mpi/c/bindings.h"
  25 #include "ompi/runtime/params.h"
  26 #include "ompi/communicator/communicator.h"
  27 #include "ompi/errhandler/errhandler.h"
  28 #include "ompi/request/request.h"
  29 #include "ompi/request/grequest.h"
  30 #include "ompi/memchecker.h"
  31 
  32 #if OMPI_BUILD_MPI_PROFILING
  33 #if OPAL_HAVE_WEAK_SYMBOLS
  34 #pragma weak MPI_Request_get_status = PMPI_Request_get_status
  35 #endif
  36 #define MPI_Request_get_status PMPI_Request_get_status
  37 #endif
  38 
  39 static const char FUNC_NAME[] = "MPI_Request_get_status";
  40 
  41 /* Non blocking test for the request status. Upon completion, the request will
  42  * not be freed (unlike the test function). A subsequent call to test, wait
  43  * or free should be executed on the request.
  44  */
  45 int MPI_Request_get_status(MPI_Request request, int *flag,
  46                            MPI_Status *status)
  47 {
  48 #if OPAL_ENABLE_PROGRESS_THREADS == 0
  49     int do_it_once = 0;
  50 #endif
  51 
  52     MEMCHECKER(
  53         memchecker_request(&request);
  54     );
  55 
  56     OPAL_CR_NOOP_PROGRESS();
  57 
  58     if( MPI_PARAM_CHECK ) {
  59         OMPI_ERR_INIT_FINALIZE(FUNC_NAME);
  60         if( (NULL == flag) ) {
  61             return OMPI_ERRHANDLER_INVOKE(MPI_COMM_WORLD, MPI_ERR_ARG, FUNC_NAME);
  62         } else if (NULL == request) {
  63             return OMPI_ERRHANDLER_INVOKE(MPI_COMM_WORLD, MPI_ERR_REQUEST,
  64                                           FUNC_NAME);
  65         }
  66     }
  67 
  68 #if OPAL_ENABLE_PROGRESS_THREADS == 0
  69  recheck_request_status:
  70 #endif
  71     opal_atomic_mb();
  72     if( (request == MPI_REQUEST_NULL) || (request->req_state == OMPI_REQUEST_INACTIVE) ) {
  73         *flag = true;
  74         if( MPI_STATUS_IGNORE != status ) {
  75             *status = ompi_status_empty;
  76         }
  77         return MPI_SUCCESS;
  78     }
  79     if( request->req_complete ) {
  80         *flag = true;
  81         /* If this is a generalized request, we *always* have to call
  82            the query function to get the status (MPI-2:8.2), even if
  83            the user passed STATUS_IGNORE. */
  84         if (OMPI_REQUEST_GEN == request->req_type) {
  85             ompi_grequest_invoke_query(request, &request->req_status);
  86         }
  87         if (MPI_STATUS_IGNORE != status) {
  88             *status = request->req_status;
  89         }
  90         return MPI_SUCCESS;
  91     }
  92 #if OPAL_ENABLE_PROGRESS_THREADS == 0
  93     if( 0 == do_it_once ) {
  94         /* If we run the opal_progress then check the status of the
  95            request before leaving. We will call the opal_progress only
  96            once per call. */
  97         opal_progress();
  98         do_it_once++;
  99         goto recheck_request_status;
 100     }
 101 #endif
 102     *flag = false;
 103     return MPI_SUCCESS;
 104 }

/* [<][>][^][v][top][bottom][index][help] */