1 /* Copyright (c) 2013-2019. The SimGrid Team.
2 * All rights reserved. */
4 /* This program is free software; you can redistribute it and/or modify it
5 * under the terms of the license (GNU LGPL) which comes with this package. */
7 #include "../colls_private.hpp"
12 * Openmpi calls this routine when the message size sent to each rank < 2000 bytes and size < 12
13 * FIXME: uh, check smpi_pmpi again, but this routine is called for > 12, not
18 int Coll_alltoallv_bruck::alltoallv(const void *sendbuf, const int *sendcounts, const int *senddisps,
19 MPI_Datatype sendtype, void *recvbuf,
20 const int *recvcounts,const int *recvdisps, MPI_Datatype recvtype,
23 int system_tag = COLL_TAG_ALLTOALLV;
24 int i, rank, size, err, count;
29 // FIXME: check implementation
32 XBT_DEBUG("<%d> algorithm alltoall_bruck() called.", rank);
34 sendtype->extent(&lb, &sendext);
35 recvtype->extent(&lb, &recvext);
36 /* Local copy from self */
38 Datatype::copy((char *)sendbuf + senddisps[rank] * sendext,
39 sendcounts[rank], sendtype,
40 (char *)recvbuf + recvdisps[rank] * recvext,
41 recvcounts[rank], recvtype);
42 if (err == MPI_SUCCESS && size > 1) {
43 /* Initiate all send/recv to/from others. */
45 int bblock = 4; // MPIR_PARAM_ALLTOALL_THROTTLE
46 // if (bblock == 0) bblock = comm_size;
48 // MPI_Request* requests = new MPI_Request[2 * (bblock - 1)];
50 /* post only bblock isends/irecvs at a time as suggested by Tony Ladd */
51 for (ii = 0; ii < size; ii += bblock) {
52 MPI_Request* requests = new MPI_Request[2 * bblock];
54 ss = size - ii < bblock ? size - ii : bblock;
57 /* do the communication -- post ss sends and receives: */
58 for (i = 0; i < ss; i++) {
59 dst = (rank + i + ii) % size;
61 XBT_DEBUG("<%d> skip request creation [src = %d, recvcount = %d]", rank, i, recvcounts[dst]);
66 Request::irecv((char*)recvbuf + recvdisps[dst] * recvext, recvcounts[dst], recvtype, dst, system_tag, comm);
69 /* Now create all sends */
70 for (i = 0; i < ss; i++) {
71 dst = (rank - i - ii + size) % size;
73 XBT_DEBUG("<%d> skip request creation [dst = %d, sendcount = %d]", rank, i, sendcounts[dst]);
77 Request::isend((char*)sendbuf + senddisps[dst] * sendext, sendcounts[dst], sendtype, dst, system_tag, comm);
80 /* Wait for them all. */
81 // Colls::startall(count, requests);
82 XBT_DEBUG("<%d> wait for %d requests", rank, count);
83 Request::waitall(count, requests, MPI_STATUSES_IGNORE);