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_ALLTOALLW = ompi_ineighbor_alltoallw_f
33 #pragma weak pmpi_ineighbor_alltoallw = ompi_ineighbor_alltoallw_f
34 #pragma weak pmpi_ineighbor_alltoallw_ = ompi_ineighbor_alltoallw_f
35 #pragma weak pmpi_ineighbor_alltoallw__ = ompi_ineighbor_alltoallw_f
36
37 #pragma weak PMPI_Ineighbor_alltoallw_f = ompi_ineighbor_alltoallw_f
38 #pragma weak PMPI_Ineighbor_alltoallw_f08 = ompi_ineighbor_alltoallw_f
39 #else
40 OMPI_GENERATE_F77_BINDINGS (PMPI_INEIGHBOR_ALLTOALLW,
41 pmpi_ineighbor_alltoallw,
42 pmpi_ineighbor_alltoallw_,
43 pmpi_ineighbor_alltoallw__,
44 pompi_ineighbor_alltoallw_f,
45 (char *sendbuf, MPI_Fint *sendcounts, MPI_Aint *sdispls, MPI_Fint *sendtypes, char *recvbuf, MPI_Fint *recvcounts, MPI_Aint *rdispls, MPI_Fint *recvtypes, MPI_Fint *comm, MPI_Fint *request, MPI_Fint *ierr),
46 (sendbuf, sendcounts, sdispls, sendtypes, recvbuf, recvcounts, rdispls, recvtypes, comm, request, ierr) )
47 #endif
48 #endif
49
50 #if OPAL_HAVE_WEAK_SYMBOLS
51 #pragma weak MPI_INEIGHBOR_ALLTOALLW = ompi_ineighbor_alltoallw_f
52 #pragma weak mpi_ineighbor_alltoallw = ompi_ineighbor_alltoallw_f
53 #pragma weak mpi_ineighbor_alltoallw_ = ompi_ineighbor_alltoallw_f
54 #pragma weak mpi_ineighbor_alltoallw__ = ompi_ineighbor_alltoallw_f
55
56 #pragma weak MPI_Ineighbor_alltoallw_f = ompi_ineighbor_alltoallw_f
57 #pragma weak MPI_Ineighbor_alltoallw_f08 = ompi_ineighbor_alltoallw_f
58 #else
59 #if ! OMPI_BUILD_MPI_PROFILING
60 OMPI_GENERATE_F77_BINDINGS (MPI_INEIGHBOR_ALLTOALLW,
61 mpi_ineighbor_alltoallw,
62 mpi_ineighbor_alltoallw_,
63 mpi_ineighbor_alltoallw__,
64 ompi_ineighbor_alltoallw_f,
65 (char *sendbuf, MPI_Fint *sendcounts, MPI_Aint *sdispls, MPI_Fint *sendtypes, char *recvbuf, MPI_Fint *recvcounts, MPI_Aint *rdispls, MPI_Fint *recvtypes, MPI_Fint *comm, MPI_Fint *request, MPI_Fint *ierr),
66 (sendbuf, sendcounts, sdispls, sendtypes, recvbuf, recvcounts, rdispls, recvtypes, comm, request, ierr) )
67 #else
68 #define ompi_ineighbor_alltoallw_f pompi_ineighbor_alltoallw_f
69 #endif
70 #endif
71
72
ompi_ineighbor_alltoallw_f(char * sendbuf,MPI_Fint * sendcounts,MPI_Aint * sdispls,MPI_Fint * sendtypes,char * recvbuf,MPI_Fint * recvcounts,MPI_Aint * rdispls,MPI_Fint * recvtypes,MPI_Fint * comm,MPI_Fint * request,MPI_Fint * ierr)73 void ompi_ineighbor_alltoallw_f(char *sendbuf, MPI_Fint *sendcounts,
74 MPI_Aint *sdispls, MPI_Fint *sendtypes,
75 char *recvbuf, MPI_Fint *recvcounts,
76 MPI_Aint *rdispls, MPI_Fint *recvtypes,
77 MPI_Fint *comm, MPI_Fint *request, MPI_Fint *ierr)
78 {
79 MPI_Comm c_comm;
80 MPI_Datatype *c_sendtypes, *c_recvtypes;
81 MPI_Request c_request;
82 int size, c_ierr;
83 OMPI_ARRAY_NAME_DECL(sendcounts);
84 OMPI_ARRAY_NAME_DECL(recvcounts);
85
86 c_comm = PMPI_Comm_f2c(*comm);
87 PMPI_Comm_size(c_comm, &size);
88
89 c_sendtypes = (MPI_Datatype *) malloc(size * sizeof(MPI_Datatype));
90 c_recvtypes = (MPI_Datatype *) malloc(size * sizeof(MPI_Datatype));
91
92 OMPI_ARRAY_FINT_2_INT(sendcounts, size);
93 OMPI_ARRAY_FINT_2_INT(recvcounts, size);
94
95 while (size > 0) {
96 c_sendtypes[size - 1] = PMPI_Type_f2c(sendtypes[size - 1]);
97 c_recvtypes[size - 1] = PMPI_Type_f2c(recvtypes[size - 1]);
98 --size;
99 }
100
101 /* Ineighbor_alltoallw does not support MPI_IN_PLACE */
102 sendbuf = (char *) OMPI_F2C_BOTTOM(sendbuf);
103 recvbuf = (char *) OMPI_F2C_BOTTOM(recvbuf);
104
105 c_ierr = PMPI_Ineighbor_alltoallw(sendbuf,
106 OMPI_ARRAY_NAME_CONVERT(sendcounts),
107 sdispls,
108 c_sendtypes,
109 recvbuf,
110 OMPI_ARRAY_NAME_CONVERT(recvcounts),
111 rdispls,
112 c_recvtypes, c_comm, &c_request);
113 if (NULL != ierr) *ierr = OMPI_INT_2_FINT(c_ierr);
114 if (MPI_SUCCESS == c_ierr) *request = PMPI_Request_c2f(c_request);
115
116 OMPI_ARRAY_FINT_2_INT_CLEANUP(sendcounts);
117 OMPI_ARRAY_FINT_2_INT_CLEANUP(recvcounts);
118 free(c_sendtypes);
119 free(c_recvtypes);
120 }
121