1 #include "colls_private.h"
3 /*****************************************************************************
5 * Function: alltoall_spreading_simple
10 send_buff: send input buffer
11 send_count: number of elements to send
12 send_type: data type of elements being sent
13 recv_buff: receive output buffer
14 recv_count: number of elements to received
15 recv_type: data type of elements being received
18 * Descrp: Let i -> j denote the communication from node i to node j. The
19 order of communications for node i is i -> i + 1, i -> i + 2, ...,
24 ****************************************************************************/
25 int smpi_coll_tuned_alltoall_simple(void *send_buff, int send_count,
26 MPI_Datatype send_type,
27 void *recv_buff, int recv_count,
28 MPI_Datatype recv_type, MPI_Comm comm)
30 int i, rank, size, nreqs, src, dst, tag = COLL_TAG_ALLTOALL;
38 MPI_Status s, *statuses;
41 size = smpi_comm_size(comm);
42 rank = smpi_comm_rank(comm);
43 sndinc = smpi_datatype_get_extent(send_type);
44 rcvinc = smpi_datatype_get_extent(recv_type);
48 /* Allocate arrays of requests. */
50 nreqs = 2 * (size - 1);
52 req = (MPI_Request *) xbt_malloc(nreqs * sizeof(MPI_Request));
53 statuses = (MPI_Status *) xbt_malloc(nreqs * sizeof(MPI_Status));
59 /* simple optimization */
61 psnd = ((char *) send_buff) + (rank * sndinc);
62 prcv = ((char *) recv_buff) + (rank * rcvinc);
63 smpi_mpi_sendrecv(psnd, send_count, send_type, rank, tag,
64 prcv, recv_count, recv_type, rank, tag, comm, &s);
67 /* Initiate all send/recv to/from others. */
70 qreq = req + size - 1;
71 prcv = (char *) recv_buff;
72 psnd = (char *) send_buff;
73 for (i = 0; i < size; i++) {
74 src = dst = (rank + i) % size;
79 *(preq++) = smpi_mpi_recv_init(prcv + (src * rcvinc), recv_count, recv_type, src,
81 *(qreq++) = smpi_mpi_send_init(psnd + (dst * sndinc), send_count, send_type, dst,
85 /* Start all the requests. */
87 smpi_mpi_startall(nreqs, req);
89 /* Wait for them all. */
91 smpi_mpi_waitall(nreqs, req, statuses);
97 xbt_free((char *) req);