|
| 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-2020 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 (c) 2025 Triad National Security, LLC. All rights reserved. |
| 16 | + * |
| 17 | + * $COPYRIGHT$ |
| 18 | + * |
| 19 | + * Additional copyrights may follow |
| 20 | + * |
| 21 | + * $HEADER$ |
| 22 | + */ |
| 23 | + |
| 24 | +#include "ompi_config.h" |
| 25 | + |
| 26 | +#include "ompi/mpi/fortran/mpif-h/bindings.h" |
| 27 | +#include "ompi/mpi/fortran/base/constants.h" |
| 28 | +#include "ompi/errhandler/errhandler.h" |
| 29 | +#include "ompi/communicator/communicator.h" |
| 30 | + |
| 31 | +#if OMPI_BUILD_MPI_PROFILING |
| 32 | +#if OPAL_HAVE_WEAK_SYMBOLS |
| 33 | +#pragma weak PMPI_REQUEST_STATUS_GET_ANY = ompi_request_get_status_any_f |
| 34 | +#pragma weak pmpi_request_get_status_any = ompi_request_get_status_any_f |
| 35 | +#pragma weak pmpi_request_get_status_any_ = ompi_request_get_status_any_f |
| 36 | +#pragma weak pmpi_request_get_status_any__ = ompi_request_get_status_any_f |
| 37 | + |
| 38 | +#pragma weak PMPI_Request_get_status_any_f = ompi_request_get_status_any_f |
| 39 | +#pragma weak PMPI_Request_get_status_any_f08 = ompi_request_get_status_any_f |
| 40 | +#else |
| 41 | +OMPI_GENERATE_F77_BINDINGS (PMPI_REQUEST_STATUS_GET_ANY, |
| 42 | + pmpi_request_get_status_any, |
| 43 | + pmpi_request_get_status_any_, |
| 44 | + pmpi_request_get_status_any__, |
| 45 | + pompi_request_get_status_any_f, |
| 46 | + (MPI_Fint *count, MPI_Fint *array_of_requests, MPI_Fint *indx, ompi_fortran_logical_t *flag, MPI_Fint *status, MPI_Fint *ierr), |
| 47 | + (count, array_of_requests, indx, flag, status, ierr)) |
| 48 | +#endif |
| 49 | +#endif |
| 50 | + |
| 51 | +#if OPAL_HAVE_WEAK_SYMBOLS |
| 52 | +#pragma weak MPI_REQUEST_STATUS_GET_ANY = ompi_request_get_status_any_f |
| 53 | +#pragma weak mpi_request_get_status_any = ompi_request_get_status_any_f |
| 54 | +#pragma weak mpi_request_get_status_any_ = ompi_request_get_status_any_f |
| 55 | +#pragma weak mpi_request_get_status_any__ = ompi_request_get_status_any_f |
| 56 | + |
| 57 | +#pragma weak MPI_Request_get_status_any_f = ompi_request_get_status_any_f |
| 58 | +#pragma weak MPI_Request_get_status_any_f08 = ompi_request_get_status_any_f |
| 59 | +#else |
| 60 | +#if ! OMPI_BUILD_MPI_PROFILING |
| 61 | +OMPI_GENERATE_F77_BINDINGS (MPI_REQUEST_STATUS_GET_ANY, |
| 62 | + mpi_request_get_status_any, |
| 63 | + mpi_request_get_status_any_, |
| 64 | + mpi_request_get_status_any__, |
| 65 | + ompi_request_get_status_any_f, |
| 66 | + (MPI_Fint *count, MPI_Fint *array_of_requests, MPI_Fint *indx, ompi_fortran_logical_t *flag, MPI_Fint *status, MPI_Fint *ierr), |
| 67 | + (count, array_of_requests, indx, flag, status, ierr)) |
| 68 | +#else |
| 69 | +#define ompi_request_get_status_any_f pompi_request_get_status_any_f |
| 70 | +#endif |
| 71 | +#endif |
| 72 | + |
| 73 | + |
| 74 | +static const char FUNC_NAME[] = "MPI_REQUEST_STATUS_GET_ANY"; |
| 75 | + |
| 76 | + |
| 77 | +void ompi_request_get_status_any_f(MPI_Fint *count, MPI_Fint *array_of_requests, |
| 78 | + MPI_Fint *indx, ompi_fortran_logical_t *flag, MPI_Fint *status, MPI_Fint *ierr) |
| 79 | +{ |
| 80 | + MPI_Request *c_req; |
| 81 | + MPI_Status c_status; |
| 82 | + int i, c_ierr; |
| 83 | + OMPI_LOGICAL_NAME_DECL(flag); |
| 84 | + OMPI_SINGLE_NAME_DECL(indx); |
| 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(*count))) { |
| 89 | + *indx = OMPI_INT_2_FINT(MPI_UNDEFINED); |
| 90 | + PMPI_Status_c2f(&ompi_status_empty, status); |
| 91 | + *ierr = OMPI_INT_2_FINT(MPI_SUCCESS); |
| 92 | + return; |
| 93 | + } |
| 94 | + |
| 95 | + c_req = (MPI_Request *) malloc(OMPI_FINT_2_INT(*count) * sizeof(MPI_Request)); |
| 96 | + if (NULL == c_req) { |
| 97 | + c_ierr = OMPI_ERRHANDLER_NOHANDLE_INVOKE(MPI_ERR_NO_MEM, |
| 98 | + FUNC_NAME); |
| 99 | + if (NULL != ierr) *ierr = OMPI_INT_2_FINT(c_ierr); |
| 100 | + return; |
| 101 | + } |
| 102 | + |
| 103 | + for (i = 0; i < OMPI_FINT_2_INT(*count); ++i) { |
| 104 | + c_req[i] = PMPI_Request_f2c(array_of_requests[i]); |
| 105 | + } |
| 106 | + |
| 107 | + c_ierr = PMPI_Request_get_status_any(OMPI_FINT_2_INT(*count), c_req, |
| 108 | + OMPI_SINGLE_NAME_CONVERT(indx), OMPI_LOGICAL_SINGLE_NAME_CONVERT(flag), |
| 109 | + &c_status); |
| 110 | + if (NULL != ierr) *ierr = OMPI_INT_2_FINT(c_ierr); |
| 111 | + |
| 112 | + if (MPI_SUCCESS == c_ierr) { |
| 113 | + |
| 114 | + OMPI_SINGLE_INT_2_LOGICAL(flag); |
| 115 | + |
| 116 | + /* Increment index by one for fortran conventions */ |
| 117 | + |
| 118 | + OMPI_SINGLE_INT_2_FINT(indx); |
| 119 | + if (MPI_UNDEFINED != *(OMPI_SINGLE_NAME_CONVERT(indx))) { |
| 120 | + array_of_requests[OMPI_INT_2_FINT(*indx)] = |
| 121 | + c_req[OMPI_INT_2_FINT(*indx)]->req_f_to_c_index; |
| 122 | + ++(*indx); |
| 123 | + } |
| 124 | + if (!OMPI_IS_FORTRAN_STATUS_IGNORE(status)) { |
| 125 | + PMPI_Status_c2f(&c_status, status); |
| 126 | + } |
| 127 | + } |
| 128 | + free(c_req); |
| 129 | +} |
0 commit comments