+ 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));
+ sendtmptypes = static_cast<MPI_Datatype*>(xbt_malloc(size * sizeof(MPI_Datatype)));
+ memcpy(sendtmptypes, recvtypes, size * sizeof(MPI_Datatype));
+ }
+
+ for (int i = 0; i < size; i++) { // copy data to avoid bad free
+ send_size += sendtmpcounts[i] * sendtmptypes[i]->size();
+ trace_sendcounts->push_back(sendtmpcounts[i] * sendtmptypes[i]->size());
+ }
+
+ TRACE_smpi_comm_in(rank, request == MPI_REQUEST_IGNORED ? "PMPI_Alltoallw" : "PMPI_Ialltoallw",
+ new simgrid::instr::VarCollTIData(request == MPI_REQUEST_IGNORED ? "alltoallv" : "ialltoallv", -1,
+ send_size, trace_sendcounts, recv_size, trace_recvcounts,
+ simgrid::smpi::Datatype::encode(sendtmptypes[0]),
+ simgrid::smpi::Datatype::encode(recvtypes[0])));
+
+ int retval;
+ if (request == MPI_REQUEST_IGNORED)
+ retval = simgrid::smpi::Colls::alltoallw(sendtmpbuf, sendtmpcounts, sendtmpdisps, sendtmptypes, recvbuf, recvcounts,
+ recvdisps, recvtypes, comm);
+ else
+ retval = simgrid::smpi::Colls::ialltoallw(sendtmpbuf, sendtmpcounts, sendtmpdisps, sendtmptypes, recvbuf,
+ recvcounts, recvdisps, recvtypes, comm, request);
+
+ TRACE_smpi_comm_out(rank);
+ if (sendbuf == MPI_IN_PLACE) {
+ xbt_free(sendtmpbuf);
+ xbt_free(sendtmpcounts);
+ xbt_free(sendtmpdisps);
+ xbt_free(sendtmptypes);
+ }