- int system_tag = 889;
- int i;
- int count;
- MPI_Aint lb = 0;
- MPI_Aint sendext = 0;
- MPI_Aint recvext = 0;
- MPI_Request *requests;
-
- /* Initialize. */
- int rank = comm->rank();
- int size = comm->size();
- XBT_DEBUG("<%d> algorithm basic_alltoallv() called.", rank);
- sendtype->extent(&lb, &sendext);
- recvtype->extent(&lb, &recvext);
- /* Local copy from self */
- int err = Datatype::copy(static_cast<char *>(sendbuf) + senddisps[rank] * sendext, sendcounts[rank], sendtype,
- static_cast<char *>(recvbuf) + recvdisps[rank] * recvext, recvcounts[rank], recvtype);
- if (err == MPI_SUCCESS && size > 1) {
- /* Initiate all send/recv to/from others. */
- requests = xbt_new(MPI_Request, 2 * (size - 1));
- count = 0;
- /* Create all receives that will be posted first */
- for (i = 0; i < size; ++i) {
- if (i != rank && recvcounts[i] != 0) {
- requests[count] = Request::irecv_init(static_cast<char *>(recvbuf) + recvdisps[i] * recvext,
- recvcounts[i], recvtype, i, system_tag, comm);
- count++;
- }else{
- XBT_DEBUG("<%d> skip request creation [src = %d, recvcounts[src] = %d]", rank, i, recvcounts[i]);
- }
- }
- /* Now create all sends */
- for (i = 0; i < size; ++i) {
- if (i != rank && sendcounts[i] != 0) {
- requests[count] = Request::isend_init(static_cast<char *>(sendbuf) + senddisps[i] * sendext,
- sendcounts[i], sendtype, i, system_tag, comm);
- count++;
- }else{
- XBT_DEBUG("<%d> skip request creation [dst = %d, sendcounts[dst] = %d]", rank, i, sendcounts[i]);
- }
- }
- /* Wait for them all. */
- Request::startall(count, requests);
- XBT_DEBUG("<%d> wait for %d requests", rank, count);
- Request::waitall(count, requests, MPI_STATUS_IGNORE);
- for(i = 0; i < count; i++) {
- if(requests[i]!=MPI_REQUEST_NULL)
- Request::unref(&requests[i]);
- }
- xbt_free(requests);
- }
- return err;