- retval = mpi_coll_alltoallv_fun(sendbuf, sendcounts, senddisps, sendtype, recvbuf, recvcounts, recvdisps, recvtype,
- comm);
- TRACE_smpi_collective_out(rank, -1, __FUNCTION__);
+ 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;
+ }
+
+ extra->datatype1 = encode_datatype(sendtmptype, &known);
+ int dt_size_send = 1;
+ dt_size_send = smpi_datatype_size(sendtmptype);
+
+ for (i = 0; i < size; i++) { // copy data to avoid bad free
+ extra->send_size += sendtmpcounts[i] * dt_size_send;
+ extra->sendcounts[i] = sendtmpcounts[i] * dt_size_send;
+ }
+ extra->num_processes = size;
+ TRACE_smpi_collective_in(rank, -1, __FUNCTION__, extra);
+ retval = mpi_coll_alltoallv_fun(sendtmpbuf, sendtmpcounts, sendtmpdisps, sendtmptype, recvbuf, recvcounts,
+ recvdisps, recvtype, comm);
+ TRACE_smpi_collective_out(rank, -1, __FUNCTION__);
+
+ if (sendbuf == MPI_IN_PLACE) {
+ xbt_free(sendtmpbuf);
+ xbt_free(sendtmpcounts);
+ xbt_free(sendtmpdisps);
+ }