root/ompi/mpi/fortran/mpif-h/testany_f.c

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

DEFINITIONS

This source file includes following definitions.
  1. ompi_testany_f

   1 /*
   2  * Copyright (c) 2004-2005 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-2005 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) 2011-2012 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 
  22 #include "ompi_config.h"
  23 
  24 #include "ompi/mpi/fortran/mpif-h/bindings.h"
  25 #include "ompi/mpi/fortran/base/constants.h"
  26 #include "ompi/errhandler/errhandler.h"
  27 #include "ompi/communicator/communicator.h"
  28 
  29 #if OMPI_BUILD_MPI_PROFILING
  30 #if OPAL_HAVE_WEAK_SYMBOLS
  31 #pragma weak PMPI_TESTANY = ompi_testany_f
  32 #pragma weak pmpi_testany = ompi_testany_f
  33 #pragma weak pmpi_testany_ = ompi_testany_f
  34 #pragma weak pmpi_testany__ = ompi_testany_f
  35 
  36 #pragma weak PMPI_Testany_f = ompi_testany_f
  37 #pragma weak PMPI_Testany_f08 = ompi_testany_f
  38 #else
  39 OMPI_GENERATE_F77_BINDINGS (PMPI_TESTANY,
  40                            pmpi_testany,
  41                            pmpi_testany_,
  42                            pmpi_testany__,
  43                            pompi_testany_f,
  44                            (MPI_Fint *count, MPI_Fint *array_of_requests, MPI_Fint *indx, ompi_fortran_logical_t *flag, MPI_Fint *status, MPI_Fint *ierr),
  45                            (count, array_of_requests, indx, flag, status, ierr) )
  46 #endif
  47 #endif
  48 
  49 #if OPAL_HAVE_WEAK_SYMBOLS
  50 #pragma weak MPI_TESTANY = ompi_testany_f
  51 #pragma weak mpi_testany = ompi_testany_f
  52 #pragma weak mpi_testany_ = ompi_testany_f
  53 #pragma weak mpi_testany__ = ompi_testany_f
  54 
  55 #pragma weak MPI_Testany_f = ompi_testany_f
  56 #pragma weak MPI_Testany_f08 = ompi_testany_f
  57 #else
  58 #if ! OMPI_BUILD_MPI_PROFILING
  59 OMPI_GENERATE_F77_BINDINGS (MPI_TESTANY,
  60                            mpi_testany,
  61                            mpi_testany_,
  62                            mpi_testany__,
  63                            ompi_testany_f,
  64                            (MPI_Fint *count, MPI_Fint *array_of_requests, MPI_Fint *indx, ompi_fortran_logical_t *flag, MPI_Fint *status, MPI_Fint *ierr),
  65                            (count, array_of_requests, indx, flag, status, ierr) )
  66 #else
  67 #define ompi_testany_f pompi_testany_f
  68 #endif
  69 #endif
  70 
  71 
  72 static const char FUNC_NAME[] = "MPI_TESTANY";
  73 
  74 
  75 void ompi_testany_f(MPI_Fint *count, MPI_Fint *array_of_requests, MPI_Fint *indx, ompi_fortran_logical_t *flag, MPI_Fint *status, MPI_Fint *ierr)
  76 {
  77     MPI_Request *c_req;
  78     MPI_Status c_status;
  79     int i, c_ierr;
  80     OMPI_LOGICAL_NAME_DECL(flag);
  81     OMPI_SINGLE_NAME_DECL(indx);
  82 
  83     /* Shortcut to avoid malloc(0) if *count==0.  We're intentionally
  84        skipping other parameter error checks. */
  85     if (OPAL_UNLIKELY(0 == OMPI_FINT_2_INT(*count))) {
  86         *flag = OMPI_FORTRAN_VALUE_TRUE;
  87         *indx = OMPI_INT_2_FINT(MPI_UNDEFINED);
  88         PMPI_Status_c2f(&ompi_status_empty, status);
  89         *ierr = OMPI_INT_2_FINT(MPI_SUCCESS);
  90         return;
  91     }
  92 
  93     c_req = (MPI_Request *) malloc(OMPI_FINT_2_INT(*count) * sizeof(MPI_Request));
  94     if (c_req == NULL) {
  95         c_ierr = OMPI_ERRHANDLER_INVOKE(MPI_COMM_WORLD,
  96                                         MPI_ERR_NO_MEM,
  97                                         FUNC_NAME);
  98         if (NULL != ierr) *ierr = OMPI_INT_2_FINT(c_ierr);
  99         return;
 100     }
 101 
 102     for (i = 0; i < OMPI_FINT_2_INT(*count); ++i) {
 103         c_req[i] = PMPI_Request_f2c(array_of_requests[i]);
 104     }
 105 
 106     c_ierr = PMPI_Testany(OMPI_FINT_2_INT(*count), c_req,
 107                          OMPI_SINGLE_NAME_CONVERT(indx),
 108                          OMPI_LOGICAL_SINGLE_NAME_CONVERT(flag),
 109                          &c_status);
 110     if (NULL != ierr) *ierr = OMPI_INT_2_FINT(c_ierr);
 111 
 112     OMPI_SINGLE_INT_2_LOGICAL(flag);
 113     if (MPI_SUCCESS == c_ierr) {
 114 
 115         /* Increment index by one for fortran conventions.  Note that
 116            all Fortran compilers have FALSE==0; we just need to check
 117            for any nonzero value (because TRUE is not always 1) */
 118 
 119         OMPI_SINGLE_INT_2_FINT(indx);
 120         if (*flag &&
 121             MPI_UNDEFINED != *(OMPI_SINGLE_NAME_CONVERT(indx))) {
 122             array_of_requests[OMPI_INT_2_FINT(*indx)] =
 123                 c_req[OMPI_INT_2_FINT(*indx)]->req_f_to_c_index;
 124             ++(*indx);
 125         }
 126         if (!OMPI_IS_FORTRAN_STATUS_IGNORE(status)) {
 127             PMPI_Status_c2f(&c_status, status);
 128         }
 129     }
 130     free(c_req);
 131 }

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