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

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

DEFINITIONS

This source file includes following definitions.
  1. ompi_testsome_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_TESTSOME = ompi_testsome_f
  32 #pragma weak pmpi_testsome = ompi_testsome_f
  33 #pragma weak pmpi_testsome_ = ompi_testsome_f
  34 #pragma weak pmpi_testsome__ = ompi_testsome_f
  35 
  36 #pragma weak PMPI_Testsome_f = ompi_testsome_f
  37 #pragma weak PMPI_Testsome_f08 = ompi_testsome_f
  38 #else
  39 OMPI_GENERATE_F77_BINDINGS (PMPI_TESTSOME,
  40                            pmpi_testsome,
  41                            pmpi_testsome_,
  42                            pmpi_testsome__,
  43                            pompi_testsome_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_TESTSOME = ompi_testsome_f
  51 #pragma weak mpi_testsome = ompi_testsome_f
  52 #pragma weak mpi_testsome_ = ompi_testsome_f
  53 #pragma weak mpi_testsome__ = ompi_testsome_f
  54 
  55 #pragma weak MPI_Testsome_f = ompi_testsome_f
  56 #pragma weak MPI_Testsome_f08 = ompi_testsome_f
  57 #else
  58 #if ! OMPI_BUILD_MPI_PROFILING
  59 OMPI_GENERATE_F77_BINDINGS (MPI_TESTSOME,
  60                            mpi_testsome,
  61                            mpi_testsome_,
  62                            mpi_testsome__,
  63                            ompi_testsome_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_testsome_f pompi_testsome_f
  68 #endif
  69 #endif
  70 
  71 
  72 static const char FUNC_NAME[] = "MPI_TESTSOME";
  73 
  74 
  75 void ompi_testsome_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     MPI_Request *c_req;
  80     MPI_Status *c_status;
  81     int i, c_ierr;
  82     OMPI_SINGLE_NAME_DECL(outcount);
  83     OMPI_ARRAY_NAME_DECL(array_of_indices);
  84 
  85     /* Shortcut to avoid malloc(0) if *count==0.  We're intentionally
  86        skipping other parameter error checks. */
  87     if (OPAL_UNLIKELY(0 == OMPI_FINT_2_INT(*incount))) {
  88         *outcount = OMPI_INT_2_FINT(MPI_UNDEFINED);
  89         *ierr = OMPI_INT_2_FINT(MPI_SUCCESS);
  90         return;
  91     }
  92 
  93     c_req = (MPI_Request *) malloc(OMPI_FINT_2_INT(*incount) *
  94                    (sizeof(MPI_Request) + sizeof(MPI_Status)));
  95     if (NULL == c_req) {
  96         c_ierr = OMPI_ERRHANDLER_INVOKE(MPI_COMM_WORLD,
  97                                         MPI_ERR_NO_MEM,
  98                                         FUNC_NAME);
  99         if (NULL != ierr) *ierr = OMPI_INT_2_FINT(c_ierr);
 100         return;
 101     }
 102     c_status = (MPI_Status*) (c_req + OMPI_FINT_2_INT(*incount));
 103 
 104     for (i = 0; i < OMPI_FINT_2_INT(*incount); ++i) {
 105         c_req[i] = PMPI_Request_f2c(array_of_requests[i]);
 106     }
 107 
 108     OMPI_ARRAY_FINT_2_INT_ALLOC(array_of_indices, OMPI_FINT_2_INT(*incount));
 109     c_ierr = PMPI_Testsome(OMPI_FINT_2_INT(*incount), c_req,
 110                           OMPI_SINGLE_NAME_CONVERT(outcount),
 111                           OMPI_ARRAY_NAME_CONVERT(array_of_indices),
 112                           c_status);
 113     if (NULL != ierr) *ierr = OMPI_INT_2_FINT(c_ierr);
 114 
 115     OMPI_SINGLE_INT_2_FINT(outcount);
 116     OMPI_ARRAY_INT_2_FINT(array_of_indices, *incount);
 117 
 118     if (MPI_SUCCESS == c_ierr) {
 119         if (MPI_UNDEFINED != OMPI_FINT_2_INT(*outcount)) {
 120             for (i = 0; i < OMPI_FINT_2_INT(*outcount); ++i) {
 121                 array_of_requests[OMPI_INT_2_FINT(array_of_indices[i])] =
 122                     c_req[OMPI_INT_2_FINT(array_of_indices[i])]->req_f_to_c_index;
 123                 ++array_of_indices[i];
 124             }
 125         }
 126         if (!OMPI_IS_FORTRAN_STATUSES_IGNORE(array_of_statuses)) {
 127             for (i = 0; i < OMPI_FINT_2_INT(*outcount); ++i) {
 128                 if (!OMPI_IS_FORTRAN_STATUS_IGNORE(&array_of_statuses[i])) {
 129                     PMPI_Status_c2f(&c_status[i], &array_of_statuses[i * (sizeof(MPI_Status) / sizeof(int))]);
 130                 }
 131             }
 132         }
 133     }
 134     free(c_req);
 135 }

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