This source file includes following definitions.
- MPI_Alltoallv
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25 #include "ompi_config.h"
26 #include <stdio.h>
27
28 #include "ompi/mpi/c/bindings.h"
29 #include "ompi/runtime/params.h"
30 #include "ompi/communicator/communicator.h"
31 #include "ompi/errhandler/errhandler.h"
32 #include "ompi/datatype/ompi_datatype.h"
33 #include "ompi/memchecker.h"
34 #include "ompi/runtime/ompi_spc.h"
35
36 #if OMPI_BUILD_MPI_PROFILING
37 #if OPAL_HAVE_WEAK_SYMBOLS
38 #pragma weak MPI_Alltoallv = PMPI_Alltoallv
39 #endif
40 #define MPI_Alltoallv PMPI_Alltoallv
41 #endif
42
43 static const char FUNC_NAME[] = "MPI_Alltoallv";
44
45
46 int MPI_Alltoallv(const void *sendbuf, const int sendcounts[],
47 const int sdispls[], MPI_Datatype sendtype,
48 void *recvbuf, const int recvcounts[], const int rdispls[],
49 MPI_Datatype recvtype, MPI_Comm comm)
50 {
51 int i, size, err;
52
53 SPC_RECORD(OMPI_SPC_ALLTOALLV, 1);
54
55 MEMCHECKER(
56 ptrdiff_t recv_ext;
57 ptrdiff_t send_ext;
58
59 if (MPI_IN_PLACE != sendbuf) {
60 memchecker_datatype(sendtype);
61 ompi_datatype_type_extent(sendtype, &send_ext);
62 }
63 memchecker_datatype(recvtype);
64 ompi_datatype_type_extent(recvtype, &recv_ext);
65
66 memchecker_comm(comm);
67
68 size = OMPI_COMM_IS_INTER(comm)?ompi_comm_remote_size(comm):ompi_comm_size(comm);
69 for ( i = 0; i < size; i++ ) {
70 if (MPI_IN_PLACE != sendbuf) {
71
72 memchecker_call(&opal_memchecker_base_isdefined,
73 (char *)(sendbuf)+sdispls[i]*send_ext,
74 sendcounts[i], sendtype);
75 }
76
77 memchecker_call(&opal_memchecker_base_isaddressable,
78 (char *)(recvbuf)+rdispls[i]*recv_ext,
79 recvcounts[i], recvtype);
80 }
81 );
82
83 if (MPI_PARAM_CHECK) {
84
85
86
87 err = MPI_SUCCESS;
88 OMPI_ERR_INIT_FINALIZE(FUNC_NAME);
89 if (ompi_comm_invalid(comm)) {
90 return OMPI_ERRHANDLER_INVOKE(MPI_COMM_WORLD, MPI_ERR_COMM,
91 FUNC_NAME);
92 }
93
94 if (MPI_IN_PLACE == sendbuf) {
95 sendcounts = recvcounts;
96 sdispls = rdispls;
97 sendtype = recvtype;
98 }
99
100 if ((NULL == sendcounts) || (NULL == sdispls) ||
101 (NULL == recvcounts) || (NULL == rdispls) ||
102 (MPI_IN_PLACE == sendbuf && OMPI_COMM_IS_INTER(comm)) ||
103 MPI_IN_PLACE == recvbuf) {
104 return OMPI_ERRHANDLER_INVOKE(comm, MPI_ERR_ARG, FUNC_NAME);
105 }
106
107 size = OMPI_COMM_IS_INTER(comm)?ompi_comm_remote_size(comm):ompi_comm_size(comm);
108 for (i = 0; i < size; ++i) {
109 OMPI_CHECK_DATATYPE_FOR_SEND(err, sendtype, sendcounts[i]);
110 OMPI_ERRHANDLER_CHECK(err, comm, err, FUNC_NAME);
111 OMPI_CHECK_DATATYPE_FOR_RECV(err, recvtype, recvcounts[i]);
112 OMPI_ERRHANDLER_CHECK(err, comm, err, FUNC_NAME);
113 }
114
115 if (MPI_IN_PLACE != sendbuf && !OMPI_COMM_IS_INTER(comm)) {
116 size_t sendtype_size, recvtype_size;
117 int me = ompi_comm_rank(comm);
118 ompi_datatype_type_size(sendtype, &sendtype_size);
119 ompi_datatype_type_size(recvtype, &recvtype_size);
120 if ((sendtype_size*sendcounts[me]) != (recvtype_size*recvcounts[me])) {
121 return OMPI_ERRHANDLER_INVOKE(comm, MPI_ERR_TRUNCATE, FUNC_NAME);
122 }
123 }
124 }
125
126 OPAL_CR_ENTER_LIBRARY();
127
128
129 err = comm->c_coll->coll_alltoallv(sendbuf, sendcounts, sdispls, sendtype,
130 recvbuf, recvcounts, rdispls, recvtype,
131 comm, comm->c_coll->coll_alltoallv_module);
132 OMPI_ERRHANDLER_RETURN(err, comm, err, FUNC_NAME);
133 }
134