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"
21 int smpi_coll_tuned_alltoall_ompi_pairwise(void *sbuf, int scount,
23 void* rbuf, int rcount,
29 void * tmpsend, *tmprecv;
30 MPI_Aint lb, sext, rext;
32 size = smpi_comm_size(comm);
33 rank = smpi_comm_rank(comm);
36 "coll:tuned:alltoall_ompi_pairwise rank %d", rank);
38 smpi_datatype_extent (sdtype, &lb, &sext);
39 smpi_datatype_extent (rdtype, &lb, &rext);
42 /* Perform pairwise exchange - starting from 1 so the local copy is last */
43 for (step = 1; step < size + 1; step++) {
45 /* Determine sender and receiver for this step. */
46 sendto = (rank + step) % size;
47 recvfrom = (rank + size - step) % size;
49 /* Determine sending and receiving locations */
50 tmpsend = (char*)sbuf + sendto * sext * scount;
51 tmprecv = (char*)rbuf + recvfrom * rext * rcount;
53 /* send and receive */
54 smpi_mpi_sendrecv( tmpsend, scount, sdtype, sendto,
56 tmprecv, rcount, rdtype, recvfrom,
58 comm, MPI_STATUS_IGNORE);