2 * Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
3 * University Research and Technology
4 * Corporation. All rights reserved.
5 * Copyright (c) 2004-2006 The University of Tennessee and The University
6 * of Tennessee Research Foundation. All rights
8 * Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
9 * University of Stuttgart. All rights reserved.
10 * Copyright (c) 2004-2005 The Regents of the University of California.
11 * All rights reserved.
14 * Additional copyrights may follow
19 #include "colls_private.h"
20 #define MCA_COLL_BASE_TAG_ALLTOALL 101
22 int smpi_coll_tuned_alltoall_ompi_pairwise(void *sbuf, int scount,
24 void* rbuf, int rcount,
30 void * tmpsend, *tmprecv;
31 MPI_Aint lb, sext, rext;
33 size = smpi_comm_size(comm);
34 rank = smpi_comm_rank(comm);
37 "coll:tuned:alltoall_ompi_pairwise rank %d", rank);
39 smpi_datatype_extent (sdtype, &lb, &sext);
40 smpi_datatype_extent (rdtype, &lb, &rext);
43 /* Perform pairwise exchange - starting from 1 so the local copy is last */
44 for (step = 1; step < size + 1; step++) {
46 /* Determine sender and receiver for this step. */
47 sendto = (rank + step) % size;
48 recvfrom = (rank + size - step) % size;
50 /* Determine sending and receiving locations */
51 tmpsend = (char*)sbuf + sendto * sext * scount;
52 tmprecv = (char*)rbuf + recvfrom * rext * rcount;
54 /* send and receive */
55 smpi_mpi_sendrecv( tmpsend, scount, sdtype, sendto,
56 MCA_COLL_BASE_TAG_ALLTOALL,
57 tmprecv, rcount, rdtype, recvfrom,
58 MCA_COLL_BASE_TAG_ALLTOALL,
59 comm, MPI_STATUS_IGNORE);