- int retval = 0;
-
- smpi_bench_end();
-
- if (comm == MPI_COMM_NULL) {
- retval = MPI_ERR_COMM;
- } else if (sendtype == MPI_DATATYPE_NULL || recvtype == MPI_DATATYPE_NULL) {
- retval = MPI_ERR_TYPE;
- } else if ((sendbuf != MPI_IN_PLACE && (sendcounts == nullptr || senddisps == nullptr)) || recvcounts == nullptr ||
- recvdisps == nullptr) {
- retval = MPI_ERR_ARG;
- } else {
- int rank = simgrid::s4u::this_actor::getPid();
- int size = comm->size();
- int send_size = 0;
- int recv_size = 0;
- std::vector<int>* trace_sendcounts = new std::vector<int>;
- std::vector<int>* trace_recvcounts = new std::vector<int>;
- int dt_size_recv = recvtype->size();
-
- void* sendtmpbuf = static_cast<char*>(sendbuf);
- int* sendtmpcounts = sendcounts;
- int* sendtmpdisps = senddisps;
- MPI_Datatype sendtmptype = sendtype;
- int maxsize = 0;
- for (int i = 0; i < size; i++) { // copy data to avoid bad free
- recv_size += recvcounts[i] * dt_size_recv;
- trace_recvcounts->push_back(recvcounts[i] * dt_size_recv);
- if (((recvdisps[i] + recvcounts[i]) * dt_size_recv) > maxsize)
- maxsize = (recvdisps[i] + recvcounts[i]) * dt_size_recv;
- }
-
- if (sendbuf == MPI_IN_PLACE) {
- sendtmpbuf = static_cast<void*>(xbt_malloc(maxsize));
- memcpy(sendtmpbuf, recvbuf, maxsize);
- sendtmpcounts = static_cast<int*>(xbt_malloc(size * sizeof(int)));
- memcpy(sendtmpcounts, recvcounts, size * sizeof(int));
- sendtmpdisps = static_cast<int*>(xbt_malloc(size * sizeof(int)));
- memcpy(sendtmpdisps, recvdisps, size * sizeof(int));
- sendtmptype = recvtype;
- }
+ return PMPI_Ialltoallw(sendbuf, sendcounts, senddisps, sendtypes, recvbuf, recvcounts, recvdisps, recvtypes, comm, MPI_REQUEST_IGNORED);
+}