1 /* Copyright (c) 2013-2014. 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.h"
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
16 int smpi_coll_tuned_alltoallv_bruck(void *sendbuf, int *sendcounts, int *senddisps,
17 MPI_Datatype sendtype, void *recvbuf,
18 int *recvcounts, int *recvdisps, MPI_Datatype recvtype,
21 int system_tag = COLL_TAG_ALLTOALLV;
22 int i, rank, size, err, count;
26 MPI_Request *requests;
28 // FIXME: check implementation
29 rank = smpi_comm_rank(comm);
30 size = smpi_comm_size(comm);
31 XBT_DEBUG("<%d> algorithm alltoall_bruck() called.", rank);
33 smpi_datatype_extent(sendtype, &lb, &sendext);
34 smpi_datatype_extent(recvtype, &lb, &recvext);
35 /* Local copy from self */
37 smpi_datatype_copy((char *)sendbuf + senddisps[rank] * sendext,
38 sendcounts[rank], sendtype,
39 (char *)recvbuf + recvdisps[rank] * recvext,
40 recvcounts[rank], recvtype);
41 if (err == MPI_SUCCESS && size > 1) {
42 /* Initiate all send/recv to/from others. */
44 int bblock = 4;//MPIR_PARAM_ALLTOALL_THROTTLE
45 //if (bblock == 0) bblock = comm_size;
48 // requests = xbt_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 requests = xbt_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]",
62 rank, i, recvcounts[dst]);
66 requests[count]=smpi_mpi_irecv((char *)recvbuf + recvdisps[dst] * recvext, recvcounts[dst],
67 recvtype, dst, system_tag, comm );
70 /* Now create all sends */
71 for ( i=0; i<ss; i++ ) {
72 dst = (rank-i-ii+size) % size;
74 XBT_DEBUG("<%d> skip request creation [dst = %d, sendcount = %d]",
75 rank, i, sendcounts[dst]);
78 requests[count]=smpi_mpi_isend((char *)sendbuf + senddisps[dst] * sendext, sendcounts[dst],
79 sendtype, dst, system_tag, comm);
82 /* Wait for them all. */
83 //smpi_mpi_startall(count, requests);
84 XBT_DEBUG("<%d> wait for %d requests", rank, count);
85 smpi_mpi_waitall(count, requests, MPI_STATUSES_IGNORE);