12#include "gadgetconfig.h"
20#include "../data/allvars.h"
21#include "../data/dtypes.h"
22#include "../mpi_utils/mpi_utils.h"
26int myMPI_Allgatherv(
void *sendbuf,
int sendcount, MPI_Datatype sendtype,
void *recvbuf,
int *recvcount,
int *displs,
27 MPI_Datatype recvtype, MPI_Comm comm)
29#ifndef MPI_HYPERCUBE_ALLGATHERV
30 return MPI_Allgatherv(sendbuf, sendcount, sendtype, recvbuf, recvcount, displs, recvtype, comm);
32 int ntask, thistask, ptask, ngrp, size_sendtype, size_recvtype;
35 MPI_Comm_rank(comm, &thistask);
36 MPI_Comm_size(comm, &ntask);
38 MPI_Type_size(sendtype, &size_sendtype);
39 MPI_Type_size(recvtype, &size_recvtype);
41 for(ptask = 0; ntask > (1 << ptask); ptask++)
44 for(ngrp = 1; ngrp < (1 << ptask); ngrp++)
46 int recvtask = thistask ^ ngrp;
50 if(sendbuf == MPI_IN_PLACE)
51 myMPI_Sendrecv((
char *)recvbuf + displs[thistask] * size_recvtype, recvcount[thistask], sendtype, recvtask,
TAG,
52 (
char *)recvbuf + displs[recvtask] * size_recvtype, recvcount[recvtask], recvtype, recvtask,
TAG, comm,
55 myMPI_Sendrecv(sendbuf, sendcount, sendtype, recvtask,
TAG, (
char *)recvbuf + displs[recvtask] * size_recvtype,
56 recvcount[recvtask], recvtype, recvtask,
TAG, comm, &status);
60 if(sendbuf != MPI_IN_PLACE)
61 if((
char *)sendbuf != (
char *)recvbuf + displs[thistask] * size_recvtype)
62 memcpy((
char *)recvbuf + displs[thistask] * size_recvtype, sendbuf, sendcount * size_sendtype);
int myMPI_Allgatherv(void *sendbuf, int sendcount, MPI_Datatype sendtype, void *recvbuf, int *recvcount, int *displs, MPI_Datatype recvtype, MPI_Comm comm)
int myMPI_Sendrecv(void *sendbuf, size_t sendcount, MPI_Datatype sendtype, int dest, int sendtag, void *recvbuf, size_t recvcount, MPI_Datatype recvtype, int source, int recvtag, MPI_Comm comm, MPI_Status *status)