This source file includes following definitions.
- MPI_Alltoallw
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_Alltoallw = PMPI_Alltoallw
39 #endif
40 #define MPI_Alltoallw PMPI_Alltoallw
41 #endif
42
43 static const char FUNC_NAME[] = "MPI_Alltoallw";
44
45
46 int MPI_Alltoallw(const void *sendbuf, const int sendcounts[],
47 const int sdispls[], const MPI_Datatype sendtypes[],
48 void *recvbuf, const int recvcounts[], const int rdispls[],
49 const MPI_Datatype recvtypes[], MPI_Comm comm)
50 {
51 int i, size, err;
52
53 SPC_RECORD(OMPI_SPC_ALLTOALLW, 1);
54
55 MEMCHECKER(
56 ptrdiff_t recv_ext;
57 ptrdiff_t send_ext;
58
59 memchecker_comm(comm);
60
61 size = OMPI_COMM_IS_INTER(comm)?ompi_comm_remote_size(comm):ompi_comm_size(comm);
62 for ( i = 0; i < size; i++ ) {
63 if (MPI_IN_PLACE != sendbuf) {
64 memchecker_datatype(sendtypes[i]);
65 ompi_datatype_type_extent(sendtypes[i], &send_ext);
66 memchecker_call(&opal_memchecker_base_isdefined,
67 (char *)(sendbuf)+sdispls[i]*send_ext,
68 sendcounts[i], sendtypes[i]);
69 }
70 memchecker_datatype(recvtypes[i]);
71 ompi_datatype_type_extent(recvtypes[i], &recv_ext);
72 memchecker_call(&opal_memchecker_base_isaddressable,
73 (char *)(recvbuf)+rdispls[i]*recv_ext,
74 recvcounts[i], recvtypes[i]);
75 }
76 );
77
78 if (MPI_PARAM_CHECK) {
79
80
81
82 err = MPI_SUCCESS;
83 OMPI_ERR_INIT_FINALIZE(FUNC_NAME);
84 if (ompi_comm_invalid(comm)) {
85 return OMPI_ERRHANDLER_INVOKE(MPI_COMM_WORLD, MPI_ERR_COMM,
86 FUNC_NAME);
87 }
88
89 if (MPI_IN_PLACE == sendbuf) {
90 sendcounts = recvcounts;
91 sdispls = rdispls;
92 sendtypes = recvtypes;
93 }
94
95 if ((NULL == sendcounts) || (NULL == sdispls) || (NULL == sendtypes) ||
96 (NULL == recvcounts) || (NULL == rdispls) || (NULL == recvtypes) ||
97 (MPI_IN_PLACE == sendbuf && OMPI_COMM_IS_INTER(comm)) ||
98 MPI_IN_PLACE == recvbuf) {
99 return OMPI_ERRHANDLER_INVOKE(comm, MPI_ERR_ARG, FUNC_NAME);
100 }
101
102 size = OMPI_COMM_IS_INTER(comm)?ompi_comm_remote_size(comm):ompi_comm_size(comm);
103 for (i = 0; i < size; ++i) {
104 OMPI_CHECK_DATATYPE_FOR_SEND(err, sendtypes[i], sendcounts[i]);
105 OMPI_ERRHANDLER_CHECK(err, comm, err, FUNC_NAME);
106 OMPI_CHECK_DATATYPE_FOR_RECV(err, recvtypes[i], recvcounts[i]);
107 OMPI_ERRHANDLER_CHECK(err, comm, err, FUNC_NAME);
108 }
109
110 if (MPI_IN_PLACE != sendbuf && !OMPI_COMM_IS_INTER(comm)) {
111 size_t sendtype_size, recvtype_size;
112 int me = ompi_comm_rank(comm);
113 ompi_datatype_type_size(sendtypes[me], &sendtype_size);
114 ompi_datatype_type_size(recvtypes[me], &recvtype_size);
115 if ((sendtype_size*sendcounts[me]) != (recvtype_size*recvcounts[me])) {
116 return OMPI_ERRHANDLER_INVOKE(comm, MPI_ERR_TRUNCATE, FUNC_NAME);
117 }
118 }
119 }
120
121 OPAL_CR_ENTER_LIBRARY();
122
123
124 err = comm->c_coll->coll_alltoallw(sendbuf, sendcounts, sdispls, (ompi_datatype_t **) sendtypes,
125 recvbuf, recvcounts, rdispls, (ompi_datatype_t **) recvtypes,
126 comm, comm->c_coll->coll_alltoallw_module);
127 OMPI_ERRHANDLER_RETURN(err, comm, err, FUNC_NAME);
128 }
129