1 /* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil ; -*- */
2 /*
3 * (C) 2012 by Argonne National Laboratory.
4 * See COPYRIGHT in top-level directory.
5 */
6
7 #include "mpiimpl.h"
8
9 /* -- Begin Profiling Symbol Block for routine MPIX_Neighbor_alltoallw */
10 #if defined(HAVE_PRAGMA_WEAK)
11 #pragma weak MPIX_Neighbor_alltoallw = PMPIX_Neighbor_alltoallw
12 #elif defined(HAVE_PRAGMA_HP_SEC_DEF)
13 #pragma _HP_SECONDARY_DEF PMPIX_Neighbor_alltoallw MPIX_Neighbor_alltoallw
14 #elif defined(HAVE_PRAGMA_CRI_DUP)
15 #pragma _CRI duplicate MPIX_Neighbor_alltoallw as PMPIX_Neighbor_alltoallw
16 #endif
17 /* -- End Profiling Symbol Block */
18
19 /* Define MPICH_MPI_FROM_PMPI if weak symbols are not supported to build
20 the MPI routines */
21 #ifndef MPICH_MPI_FROM_PMPI
22 #undef MPIX_Neighbor_alltoallw
23 #define MPIX_Neighbor_alltoallw PMPIX_Neighbor_alltoallw
24
25 /* any non-MPI functions go here, especially non-static ones */
26
27 #undef FUNCNAME
28 #define FUNCNAME MPIR_Neighbor_alltoallw_default
29 #undef FCNAME
30 #define FCNAME MPIU_QUOTE(FUNCNAME)
MPIR_Neighbor_alltoallw_default(const void * sendbuf,const int sendcounts[],const MPI_Aint sdispls[],const MPI_Datatype sendtypes[],void * recvbuf,const int recvcounts[],const MPI_Aint rdispls[],const MPI_Datatype recvtypes[],MPID_Comm * comm_ptr)31 int MPIR_Neighbor_alltoallw_default(const void *sendbuf, const int sendcounts[], const MPI_Aint sdispls[], const MPI_Datatype sendtypes[], void *recvbuf, const int recvcounts[], const MPI_Aint rdispls[], const MPI_Datatype recvtypes[], MPID_Comm *comm_ptr)
32 {
33 int mpi_errno = MPI_SUCCESS;
34 MPI_Request req;
35
36 /* just call the nonblocking version and wait on it */
37 mpi_errno = MPIR_Ineighbor_alltoallw_impl(sendbuf, sendcounts, sdispls, sendtypes, recvbuf, recvcounts, rdispls, recvtypes, comm_ptr, &req);
38 if (mpi_errno) MPIU_ERR_POP(mpi_errno);
39 mpi_errno = MPIR_Wait_impl(&req, MPI_STATUS_IGNORE);
40 if (mpi_errno) MPIU_ERR_POP(mpi_errno);
41
42 fn_exit:
43 return mpi_errno;
44 fn_fail:
45 goto fn_exit;
46 }
47
48 #undef FUNCNAME
49 #define FUNCNAME MPIR_Neighbor_alltoallw_impl
50 #undef FCNAME
51 #define FCNAME MPIU_QUOTE(FUNCNAME)
MPIR_Neighbor_alltoallw_impl(const void * sendbuf,const int sendcounts[],const MPI_Aint sdispls[],const MPI_Datatype sendtypes[],void * recvbuf,const int recvcounts[],const MPI_Aint rdispls[],const MPI_Datatype recvtypes[],MPID_Comm * comm_ptr)52 int MPIR_Neighbor_alltoallw_impl(const void *sendbuf, const int sendcounts[], const MPI_Aint sdispls[], const MPI_Datatype sendtypes[], void *recvbuf, const int recvcounts[], const MPI_Aint rdispls[], const MPI_Datatype recvtypes[], MPID_Comm *comm_ptr)
53 {
54 int mpi_errno = MPI_SUCCESS;
55
56 MPIU_Assert(comm_ptr->coll_fns != NULL);
57 MPIU_Assert(comm_ptr->coll_fns->Neighbor_alltoallw != NULL);
58 mpi_errno = comm_ptr->coll_fns->Neighbor_alltoallw(sendbuf, sendcounts, sdispls, sendtypes,
59 recvbuf, recvcounts, rdispls, recvtypes,
60 comm_ptr);
61 if (mpi_errno) MPIU_ERR_POP(mpi_errno);
62
63 fn_exit:
64 return mpi_errno;
65 fn_fail:
66 goto fn_exit;
67 }
68
69 #endif /* MPICH_MPI_FROM_PMPI */
70
71 #undef FUNCNAME
72 #define FUNCNAME MPIX_Neighbor_alltoallw
73 #undef FCNAME
74 #define FCNAME MPIU_QUOTE(FUNCNAME)
75 /*@
76 MPIX_Neighbor_alltoallw - Like MPIX_Neighbor_alltoallv but it allows one to send
77 and receive with different types to and from each neighbor.
78
79 Input Parameters:
80 + sendbuf - starting address of the send buffer (choice)
81 . sendcounts - non-negative integer array (of length outdegree) specifying the number of elements to send to each neighbor
82 . sdispls - integer array (of length outdegree). Entry j specifies the displacement in bytes (relative to sendbuf) from which to take the outgoing data destined for neighbor j (array of integers)
83 . sendtypes - array of datatypes (of length outdegree). Entry j specifies the type of data to send to neighbor j (array of handles)
84 . recvcounts - non-negative integer array (of length indegree) specifying the number of elements that are received from each neighbor
85 . rdispls - integer array (of length indegree). Entry i specifies the displacement in bytes (relative to recvbuf) at which to place the incoming data from neighbor i (array of integers).
86 . recvtypes - array of datatypes (of length indegree). Entry i specifies the type of data received from neighbor i (array of handles).
87 - comm - communicator with topology structure (handle)
88
89 Output Parameters:
90 . recvbuf - starting address of the receive buffer (choice)
91
92 .N ThreadSafe
93
94 .N Fortran
95
96 .N Errors
97 @*/
MPIX_Neighbor_alltoallw(const void * sendbuf,const int sendcounts[],const MPI_Aint sdispls[],const MPI_Datatype sendtypes[],void * recvbuf,const int recvcounts[],const MPI_Aint rdispls[],const MPI_Datatype recvtypes[],MPI_Comm comm)98 int MPIX_Neighbor_alltoallw(const void *sendbuf, const int sendcounts[], const MPI_Aint sdispls[], const MPI_Datatype sendtypes[], void *recvbuf, const int recvcounts[], const MPI_Aint rdispls[], const MPI_Datatype recvtypes[], MPI_Comm comm)
99 {
100 int mpi_errno = MPI_SUCCESS;
101 MPID_Comm *comm_ptr = NULL;
102 MPID_MPI_STATE_DECL(MPID_STATE_MPIX_NEIGHBOR_ALLTOALLW);
103
104 MPIU_THREAD_CS_ENTER(ALLFUNC,);
105 MPID_MPI_FUNC_ENTER(MPID_STATE_MPIX_NEIGHBOR_ALLTOALLW);
106
107 /* Validate parameters, especially handles needing to be converted */
108 # ifdef HAVE_ERROR_CHECKING
109 {
110 MPID_BEGIN_ERROR_CHECKS
111 {
112 MPIR_ERRTEST_COMM(comm, mpi_errno);
113
114 /* TODO more checks may be appropriate */
115 if (mpi_errno != MPI_SUCCESS) goto fn_fail;
116 }
117 MPID_END_ERROR_CHECKS
118 }
119 # endif /* HAVE_ERROR_CHECKING */
120
121 /* Convert MPI object handles to object pointers */
122 MPID_Comm_get_ptr(comm, comm_ptr);
123
124 /* Validate parameters and objects (post conversion) */
125 # ifdef HAVE_ERROR_CHECKING
126 {
127 MPID_BEGIN_ERROR_CHECKS
128 {
129 MPID_Comm_valid_ptr(comm_ptr, mpi_errno);
130 /* TODO more checks may be appropriate (counts, in_place, buffer aliasing, etc) */
131 if (mpi_errno != MPI_SUCCESS) goto fn_fail;
132 }
133 MPID_END_ERROR_CHECKS
134 }
135 # endif /* HAVE_ERROR_CHECKING */
136
137 /* ... body of routine ... */
138
139 mpi_errno = MPIR_Neighbor_alltoallw_impl(sendbuf, sendcounts, sdispls, sendtypes, recvbuf, recvcounts, rdispls, recvtypes, comm_ptr);
140 if (mpi_errno) MPIU_ERR_POP(mpi_errno);
141
142 /* ... end of body of routine ... */
143
144 fn_exit:
145 MPID_MPI_FUNC_EXIT(MPID_STATE_MPIX_NEIGHBOR_ALLTOALLW);
146 MPIU_THREAD_CS_EXIT(ALLFUNC,);
147 return mpi_errno;
148
149 fn_fail:
150 /* --BEGIN ERROR HANDLING-- */
151 # ifdef HAVE_ERROR_CHECKING
152 {
153 mpi_errno = MPIR_Err_create_code(
154 mpi_errno, MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPI_ERR_OTHER,
155 "**mpix_neighbor_alltoallw", "**mpix_neighbor_alltoallw %p %p %p %p %p %p %p %p %C", sendbuf, sendcounts, sdispls, sendtypes, recvbuf, recvcounts, rdispls, recvtypes, comm);
156 }
157 # endif
158 mpi_errno = MPIR_Err_return_comm(NULL, FCNAME, mpi_errno);
159 goto fn_exit;
160 /* --END ERROR HANDLING-- */
161 }
162