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

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

DEFINITIONS

This source file includes following definitions.
  1. ompi_waitsome_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) 2006-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_WAITSOME = ompi_waitsome_f
  32 #pragma weak pmpi_waitsome = ompi_waitsome_f
  33 #pragma weak pmpi_waitsome_ = ompi_waitsome_f
  34 #pragma weak pmpi_waitsome__ = ompi_waitsome_f
  35 
  36 #pragma weak PMPI_Waitsome_f = ompi_waitsome_f
  37 #pragma weak PMPI_Waitsome_f08 = ompi_waitsome_f
  38 #else
  39 OMPI_GENERATE_F77_BINDINGS (PMPI_WAITSOME,
  40                            pmpi_waitsome,
  41                            pmpi_waitsome_,
  42                            pmpi_waitsome__,
  43                            pompi_waitsome_f,
  44                            (MPI_Fint *incount, MPI_Fint *array_of_requests, MPI_Fint *outcount, MPI_Fint *array_of_indices, MPI_Fint *array_of_statuses, MPI_Fint *ierr),
  45                            (incount, array_of_requests, outcount, array_of_indices, array_of_statuses, ierr) )
  46 #endif
  47 #endif
  48 
  49 #if OPAL_HAVE_WEAK_SYMBOLS
  50 #pragma weak MPI_WAITSOME = ompi_waitsome_f
  51 #pragma weak mpi_waitsome = ompi_waitsome_f
  52 #pragma weak mpi_waitsome_ = ompi_waitsome_f
  53 #pragma weak mpi_waitsome__ = ompi_waitsome_f
  54 
  55 #pragma weak MPI_Waitsome_f = ompi_waitsome_f
  56 #pragma weak MPI_Waitsome_f08 = ompi_waitsome_f
  57 #else
  58 #if ! OMPI_BUILD_MPI_PROFILING
  59 OMPI_GENERATE_F77_BINDINGS (MPI_WAITSOME,
  60                            mpi_waitsome,
  61                            mpi_waitsome_,
  62                            mpi_waitsome__,
  63                            ompi_waitsome_f,
  64                            (MPI_Fint *incount, MPI_Fint *array_of_requests, MPI_Fint *outcount, MPI_Fint *array_of_indices, MPI_Fint *array_of_statuses, MPI_Fint *ierr),
  65                            (incount, array_of_requests, outcount, array_of_indices, array_of_statuses, ierr) )
  66 #else
  67 #define ompi_waitsome_f pompi_waitsome_f
  68 #endif
  69 #endif
  70 
  71 
  72 static const char FUNC_NAME[] = "MPI_WAITSOME";
  73 
  74 
  75 void ompi_waitsome_f(MPI_Fint *incount, MPI_Fint *array_of_requests,
  76                     MPI_Fint *outcount, MPI_Fint *array_of_indices,
  77                     MPI_Fint *array_of_statuses, MPI_Fint *ierr)
  78 {
  79     int c_ierr;
  80     MPI_Request *c_req;
  81     MPI_Status  *c_status;
  82     int i;
  83     OMPI_SINGLE_NAME_DECL(outcount);
  84     OMPI_ARRAY_NAME_DECL(array_of_indices);
  85 
  86     /* Shortcut to avoid malloc(0) if *count==0.  We're intentionally
  87        skipping other parameter error checks. */
  88     if (OPAL_UNLIKELY(0 == OMPI_FINT_2_INT(*incount))) {
  89         *outcount = OMPI_INT_2_FINT(MPI_UNDEFINED);
  90         *ierr = OMPI_INT_2_FINT(MPI_SUCCESS);
  91         return;
  92     }
  93 
  94     c_req = (MPI_Request *) malloc(OMPI_FINT_2_INT(*incount) *
  95                    (sizeof(MPI_Request) + sizeof(MPI_Status)));
  96     if (NULL == c_req) {
  97         c_ierr = OMPI_ERRHANDLER_INVOKE(MPI_COMM_WORLD,
  98                                         MPI_ERR_NO_MEM,
  99                                         FUNC_NAME);
 100         if (NULL != ierr) *ierr = OMPI_INT_2_FINT(c_ierr);
 101         return;
 102     }
 103     c_status = (MPI_Status*) (c_req + OMPI_FINT_2_INT(*incount));
 104 
 105     for (i = 0; i < OMPI_FINT_2_INT(*incount); ++i) {
 106         c_req[i] = PMPI_Request_f2c(array_of_requests[i]);
 107     }
 108 
 109     OMPI_ARRAY_FINT_2_INT_ALLOC(array_of_indices, *incount);
 110     c_ierr = PMPI_Waitsome(OMPI_FINT_2_INT(*incount), c_req,
 111                           OMPI_SINGLE_NAME_CONVERT(outcount),
 112                           OMPI_ARRAY_NAME_CONVERT(array_of_indices),
 113                           c_status);
 114     if (NULL != ierr) *ierr = OMPI_INT_2_FINT(c_ierr);
 115 
 116     if (MPI_SUCCESS == c_ierr) {
 117         OMPI_SINGLE_INT_2_FINT(outcount);
 118         OMPI_ARRAY_INT_2_FINT(array_of_indices, *incount);
 119 
 120         /* Increment indexes by one for fortran conventions */
 121 
 122         if (MPI_UNDEFINED != OMPI_FINT_2_INT(*outcount)) {
 123             for (i = 0; i < OMPI_FINT_2_INT(*outcount); ++i) {
 124                 array_of_requests[OMPI_INT_2_FINT(array_of_indices[i])] =
 125                     c_req[OMPI_INT_2_FINT(array_of_indices[i])]->req_f_to_c_index;
 126                 ++array_of_indices[i];
 127             }
 128         }
 129         if (!OMPI_IS_FORTRAN_STATUSES_IGNORE(array_of_statuses)) {
 130             for (i = 0; i < OMPI_FINT_2_INT(*incount); ++i) {
 131                 if (!OMPI_IS_FORTRAN_STATUS_IGNORE(&array_of_statuses[i])) {
 132                     PMPI_Status_c2f(&c_status[i], &array_of_statuses[i * (sizeof(MPI_Status) / sizeof(int))]);
 133                 }
 134             }
 135         }
 136     }
 137     free(c_req);
 138 }

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