1 /* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */
2 /*
3  * Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
4  *                         University Research and Technology
5  *                         Corporation.  All rights reserved.
6  * Copyright (c) 2004-2005 The University of Tennessee and The University
7  *                         of Tennessee Research Foundation.  All rights
8  *                         reserved.
9  * Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
10  *                         University of Stuttgart.  All rights reserved.
11  * Copyright (c) 2004-2005 The Regents of the University of California.
12  *                         All rights reserved.
13  * Copyright (c) 2011-2012 Cisco Systems, Inc.  All rights reserved.
14  * Copyright (c) 2013      Los Alamos National Security, LLC. All rights
15  *                         reserved.
16  * Copyright (c) 2015      Research Organization for Information Science
17  *                         and Technology (RIST). All rights reserved.
18  * $COPYRIGHT$
19  *
20  * Additional copyrights may follow
21  *
22  * $HEADER$
23  */
24 
25 #include "ompi_config.h"
26 
27 #include "ompi/mpi/fortran/mpif-h/bindings.h"
28 #include "ompi/mpi/fortran/base/constants.h"
29 
30 #if OMPI_BUILD_MPI_PROFILING
31 #if OPAL_HAVE_WEAK_SYMBOLS
32 #pragma weak PMPI_INEIGHBOR_ALLTOALLV = ompi_ineighbor_alltoallv_f
33 #pragma weak pmpi_ineighbor_alltoallv = ompi_ineighbor_alltoallv_f
34 #pragma weak pmpi_ineighbor_alltoallv_ = ompi_ineighbor_alltoallv_f
35 #pragma weak pmpi_ineighbor_alltoallv__ = ompi_ineighbor_alltoallv_f
36 
37 #pragma weak PMPI_Ineighbor_alltoallv_f = ompi_ineighbor_alltoallv_f
38 #pragma weak PMPI_Ineighbor_alltoallv_f08 = ompi_ineighbor_alltoallv_f
39 #else
40 OMPI_GENERATE_F77_BINDINGS (PMPI_INEIGHBOR_ALLTOALLV,
41                             pmpi_ineighbor_alltoallv,
42                             pmpi_ineighbor_alltoallv_,
43                             pmpi_ineighbor_alltoallv__,
44                             pompi_ineighbor_alltoallv_f,
45                             (char *sendbuf, MPI_Fint *sendcounts, MPI_Fint *sdispls, MPI_Fint *sendtype, char *recvbuf, MPI_Fint *recvcounts, MPI_Fint *rdispls, MPI_Fint *recvtype, MPI_Fint *comm, MPI_Fint *request, MPI_Fint *ierr),
46                             (sendbuf, sendcounts, sdispls, sendtype, recvbuf, recvcounts, rdispls, recvtype, comm, request, ierr) )
47 #endif
48 #endif
49 
50 #if OPAL_HAVE_WEAK_SYMBOLS
51 #pragma weak MPI_INEIGHBOR_ALLTOALLV = ompi_ineighbor_alltoallv_f
52 #pragma weak mpi_ineighbor_alltoallv = ompi_ineighbor_alltoallv_f
53 #pragma weak mpi_ineighbor_alltoallv_ = ompi_ineighbor_alltoallv_f
54 #pragma weak mpi_ineighbor_alltoallv__ = ompi_ineighbor_alltoallv_f
55 
56 #pragma weak MPI_Ineighbor_alltoallv_f = ompi_ineighbor_alltoallv_f
57 #pragma weak MPI_Ineighbor_alltoallv_f08 = ompi_ineighbor_alltoallv_f
58 #else
59 #if ! OMPI_BUILD_MPI_PROFILING
60 OMPI_GENERATE_F77_BINDINGS (MPI_INEIGHBOR_ALLTOALLV,
61                             mpi_ineighbor_alltoallv,
62                             mpi_ineighbor_alltoallv_,
63                             mpi_ineighbor_alltoallv__,
64                             ompi_ineighbor_alltoallv_f,
65                             (char *sendbuf, MPI_Fint *sendcounts, MPI_Fint *sdispls, MPI_Fint *sendtype, char *recvbuf, MPI_Fint *recvcounts, MPI_Fint *rdispls, MPI_Fint *recvtype, MPI_Fint *comm, MPI_Fint *request, MPI_Fint *ierr),
66                             (sendbuf, sendcounts, sdispls, sendtype, recvbuf, recvcounts, rdispls, recvtype, comm, request, ierr) )
67 #else
68 #define ompi_ineighbor_alltoallv_f pompi_ineighbor_alltoallv_f
69 #endif
70 #endif
71 
72 
ompi_ineighbor_alltoallv_f(char * sendbuf,MPI_Fint * sendcounts,MPI_Fint * sdispls,MPI_Fint * sendtype,char * recvbuf,MPI_Fint * recvcounts,MPI_Fint * rdispls,MPI_Fint * recvtype,MPI_Fint * comm,MPI_Fint * request,MPI_Fint * ierr)73 void ompi_ineighbor_alltoallv_f(char *sendbuf, MPI_Fint *sendcounts, MPI_Fint *sdispls,
74                                 MPI_Fint *sendtype, char *recvbuf, MPI_Fint *recvcounts,
75                                 MPI_Fint *rdispls, MPI_Fint *recvtype,
76                                 MPI_Fint *comm, MPI_Fint *request, MPI_Fint *ierr)
77 {
78     MPI_Comm c_comm;
79     MPI_Datatype c_sendtype, c_recvtype;
80     MPI_Request c_request;
81     int size, c_ierr;
82     OMPI_ARRAY_NAME_DECL(sendcounts);
83     OMPI_ARRAY_NAME_DECL(sdispls);
84     OMPI_ARRAY_NAME_DECL(recvcounts);
85     OMPI_ARRAY_NAME_DECL(rdispls);
86 
87     c_comm = PMPI_Comm_f2c(*comm);
88     c_sendtype = PMPI_Type_f2c(*sendtype);
89     c_recvtype = PMPI_Type_f2c(*recvtype);
90 
91     PMPI_Comm_size(c_comm, &size);
92     OMPI_ARRAY_FINT_2_INT(sendcounts, size);
93     OMPI_ARRAY_FINT_2_INT(sdispls, size);
94     OMPI_ARRAY_FINT_2_INT(recvcounts, size);
95     OMPI_ARRAY_FINT_2_INT(rdispls, size);
96 
97     sendbuf = (char *) OMPI_F2C_IN_PLACE(sendbuf);
98     sendbuf = (char *) OMPI_F2C_BOTTOM(sendbuf);
99     recvbuf = (char *) OMPI_F2C_BOTTOM(recvbuf);
100 
101     c_ierr = PMPI_Ineighbor_alltoallv(sendbuf,
102                                      OMPI_ARRAY_NAME_CONVERT(sendcounts),
103                                      OMPI_ARRAY_NAME_CONVERT(sdispls),
104                                      c_sendtype,
105                                      recvbuf,
106                                      OMPI_ARRAY_NAME_CONVERT(recvcounts),
107                                      OMPI_ARRAY_NAME_CONVERT(rdispls),
108                                      c_recvtype, c_comm, &c_request);
109     if (NULL != ierr) *ierr = OMPI_INT_2_FINT(c_ierr);
110     if (MPI_SUCCESS == c_ierr) *request = PMPI_Request_c2f(c_request);
111 
112     OMPI_ARRAY_FINT_2_INT_CLEANUP(sendcounts);
113     OMPI_ARRAY_FINT_2_INT_CLEANUP(sdispls);
114     OMPI_ARRAY_FINT_2_INT_CLEANUP(recvcounts);
115     OMPI_ARRAY_FINT_2_INT_CLEANUP(rdispls);
116 }
117