12 #include "gadgetconfig.h"
20 #include "../data/allvars.h"
21 #include "../data/dtypes.h"
23 #ifdef MPI_HYPERCUBE_ALLGATHERV
27 int MPI_hypercube_Allgatherv(
void *sendbuf,
int sendcount, MPI_Datatype sendtype,
void *recvbuf,
int *recvcount,
int *displs,
28 MPI_Datatype recvtype, MPI_Comm comm)
30 int ntask, thistask, ptask, ngrp, size_sendtype, size_recvtype;
33 MPI_Comm_rank(comm, &thistask);
34 MPI_Comm_size(comm, &ntask);
36 MPI_Type_size(sendtype, &size_sendtype);
37 MPI_Type_size(recvtype, &size_recvtype);
39 for(ptask = 0; ntask > (1 << ptask); ptask++)
42 for(ngrp = 1; ngrp < (1 << ptask); ngrp++)
44 int recvtask = thistask ^ ngrp;
47 MPI_Sendrecv(sendbuf, sendcount, sendtype, recvtask, TAG, (
char *)recvbuf + displs[recvtask] * size_recvtype,
48 recvcount[recvtask], recvtype, recvtask, TAG, comm, &status);
51 if((
char *)sendbuf != (
char *)recvbuf + displs[thistask] * size_recvtype)
52 memcpy((
char *)recvbuf + displs[thistask] * size_recvtype, sendbuf, sendcount * size_sendtype);
int MPI_hypercube_Allgatherv(void *sendbuf, int sendcount, MPI_Datatype sendtype, void *recvbuf, int *recvcount, int *displs, MPI_Datatype recvtype, MPI_Comm comm)