why is MPI_Scatterv 's recvcount a fixed int and sendcount an array?

1k views Asked by At

this is the synopsis of MPI_Scatterv()

    int MPI_Scatterv(const void *sendbuf, const int *sendcounts, const int *displs,
             MPI_Datatype sendtype, void *recvbuf, int recvcount,
             MPI_Datatype recvtype,
             int root, MPI_Comm comm)

I cannot seem to understand how this works. IF MPI_Scatterv() is sending different chunk sized elements that are stored in *sendcounts then why is recvcount a fixed integer and not an array of chunk sizes as well?

and also since its a fixed integer, what should the value be. should it be equal to the maximum value of the sendcount array? For example if I have

   int sendcount[4] = {1,5,10,8};

should recvcount be equal to 10 ?

1

There are 1 answers

0
Zulan On BEST ANSWER

sendcounts specify the actual chunk sizes to be sent. recvcount specifies the size of the local receive buffer, e.g. recvcount=sendcounts[rank].

In detail it is a bit more complex: The size of the receive buffer needs to be at least large enough to store the chunk for a given rank. If different types are involved the type extents also matter.