1 #include "colls_private.h"
3 // now only work with power of two processes
6 smpi_coll_tuned_allgather_rhv(void *sbuf, int send_count,
7 MPI_Datatype send_type, void *rbuf,
8 int recv_count, MPI_Datatype recv_type,
12 MPI_Aint s_extent, r_extent;
14 // local int variables
15 int i, dst, send_base_offset, recv_base_offset, send_chunk, recv_chunk,
16 send_offset, recv_offset;
18 int tag = COLL_TAG_ALLGATHER;
22 // get size of the communicator, followed by rank
23 num_procs = smpi_comm_size(comm);
25 if((num_procs&(num_procs-1)))
26 THROWF(arg_error,0, "allgather rhv algorithm can't be used with non power of two number of processes ! ");
28 rank = smpi_comm_rank(comm);
30 // get size of single element's type for send buffer and recv buffer
31 s_extent = smpi_datatype_get_extent(send_type);
32 r_extent = smpi_datatype_get_extent(recv_type);
34 // multiply size of each element by number of elements to send or recv
35 send_chunk = s_extent * send_count;
36 recv_chunk = r_extent * recv_count;
38 if (send_chunk != recv_chunk) {
39 XBT_WARN("MPI_allgather_rhv use default MPI_allgather.");
40 smpi_mpi_allgather(sbuf, send_count, send_type, rbuf, recv_count,
45 // compute starting offset location to perform local copy
46 int size = num_procs / 2;
49 while (mask < num_procs) {
57 // printf("node %d base_offset %d\n",rank,base_offset);
59 //perform a remote copy
62 smpi_mpi_sendrecv(sbuf, send_count, send_type, dst, tag,
63 (char *)rbuf + base_offset * recv_chunk, recv_count, recv_type, dst, tag,
70 curr_count = recv_count;
72 // destination pair for both send and recv
76 send_base_offset = base_offset;
78 recv_base_offset = base_offset - i;
81 recv_base_offset = base_offset + i;
83 send_offset = send_base_offset * recv_chunk;
84 recv_offset = recv_base_offset * recv_chunk;
86 // printf("node %d send to %d in phase %d s_offset = %d r_offset = %d count = %d\n",rank,dst,phase, send_base_offset, recv_base_offset, curr_count);
88 smpi_mpi_sendrecv((char *)rbuf + send_offset, curr_count, recv_type, dst, tag,
89 (char *)rbuf + recv_offset, curr_count, recv_type, dst, tag,