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

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

DEFINITIONS

This source file includes following definitions.
  1. ompi_testall_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_TESTALL = ompi_testall_f
  32 #pragma weak pmpi_testall = ompi_testall_f
  33 #pragma weak pmpi_testall_ = ompi_testall_f
  34 #pragma weak pmpi_testall__ = ompi_testall_f
  35 
  36 #pragma weak PMPI_Testall_f = ompi_testall_f
  37 #pragma weak PMPI_Testall_f08 = ompi_testall_f
  38 #else
  39 OMPI_GENERATE_F77_BINDINGS (PMPI_TESTALL,
  40                            pmpi_testall,
  41                            pmpi_testall_,
  42                            pmpi_testall__,
  43                            pompi_testall_f,
  44                            (MPI_Fint *count, MPI_Fint *array_of_requests, ompi_fortran_logical_t *flag, MPI_Fint *array_of_statuses, MPI_Fint *ierr),
  45                            (count, array_of_requests, flag, array_of_statuses, ierr) )
  46 #endif
  47 #endif
  48 
  49 #if OPAL_HAVE_WEAK_SYMBOLS
  50 #pragma weak MPI_TESTALL = ompi_testall_f
  51 #pragma weak mpi_testall = ompi_testall_f
  52 #pragma weak mpi_testall_ = ompi_testall_f
  53 #pragma weak mpi_testall__ = ompi_testall_f
  54 
  55 #pragma weak MPI_Testall_f = ompi_testall_f
  56 #pragma weak MPI_Testall_f08 = ompi_testall_f
  57 #else
  58 #if ! OMPI_BUILD_MPI_PROFILING
  59 OMPI_GENERATE_F77_BINDINGS (MPI_TESTALL,
  60                            mpi_testall,
  61                            mpi_testall_,
  62                            mpi_testall__,
  63                            ompi_testall_f,
  64                            (MPI_Fint *count, MPI_Fint *array_of_requests, ompi_fortran_logical_t *flag, MPI_Fint *array_of_statuses, MPI_Fint *ierr),
  65                            (count, array_of_requests, flag, array_of_statuses, ierr) )
  66 #else
  67 #define ompi_testall_f pompi_testall_f
  68 #endif
  69 #endif
  70 
  71 
  72 static const char FUNC_NAME[] = "MPI_TESTALL";
  73 
  74 void ompi_testall_f(MPI_Fint *count, MPI_Fint *array_of_requests, ompi_fortran_logical_t *flag, MPI_Fint *array_of_statuses, MPI_Fint *ierr)
  75 {
  76     MPI_Request *c_req;
  77     MPI_Status *c_status;
  78     int i, c_ierr;
  79     OMPI_LOGICAL_NAME_DECL(flag);
  80 
  81     /* Shortcut to avoid malloc(0) if *count==0.  We're intentionally
  82        skipping other parameter error checks. */
  83     if (OPAL_UNLIKELY(0 == OMPI_FINT_2_INT(*count))) {
  84         *flag = OMPI_FORTRAN_VALUE_TRUE;
  85         *ierr = OMPI_INT_2_FINT(MPI_SUCCESS);
  86         return;
  87     }
  88 
  89     c_req = (MPI_Request *) malloc(OMPI_FINT_2_INT(*count) *
  90                    (sizeof(MPI_Request) + sizeof(MPI_Status)));
  91     if (NULL == c_req){
  92         c_ierr = OMPI_ERRHANDLER_INVOKE(MPI_COMM_WORLD,
  93                                         MPI_ERR_NO_MEM,
  94                                         FUNC_NAME);
  95         if (NULL != ierr) *ierr = OMPI_INT_2_FINT(c_ierr);
  96         return;
  97     }
  98     c_status = (MPI_Status*) (c_req + OMPI_FINT_2_INT(*count));
  99     for (i = 0; i < OMPI_FINT_2_INT(*count); ++i) {
 100         c_req[i] = PMPI_Request_f2c(array_of_requests[i]);
 101     }
 102 
 103     c_ierr = PMPI_Testall(OMPI_FINT_2_INT(*count), c_req,
 104                          OMPI_LOGICAL_SINGLE_NAME_CONVERT(flag),
 105                          c_status);
 106     if (NULL != ierr) *ierr = OMPI_INT_2_FINT(c_ierr);
 107 
 108     OMPI_SINGLE_INT_2_LOGICAL(flag);
 109 
 110     /* All Fortran Compilers have FALSE == 0, so just check for any
 111        nonzero value (because TRUE is not always == 1) */
 112     if (MPI_SUCCESS == c_ierr && *flag) {
 113         for (i = 0; i < OMPI_FINT_2_INT(*count); ++i) {
 114             array_of_requests[i] = c_req[i]->req_f_to_c_index;
 115             if (!OMPI_IS_FORTRAN_STATUSES_IGNORE(array_of_statuses) &&
 116                 !OMPI_IS_FORTRAN_STATUS_IGNORE(&array_of_statuses[i])) {
 117                 PMPI_Status_c2f(&c_status[i], &array_of_statuses[i * (sizeof(MPI_Status) / sizeof(int))]);
 118             }
 119         }
 120     }
 121 
 122     free(c_req);
 123 }

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