1

Assume we have 4 process (rank 0 - rank 3), and rank 0 has the data = [1,2,3,4,5,6]. What I wanna do is

from:

rank 0: [1,2,3,4,5,6], rank 1: [], rank 2: [], rank 3: []

to :

rank 0: [], rank 1: [1,2], rank 2: [3,4], rank 3: [5,6]

basically, rank 0 dispatches data to all others and rank 0 will not be assigned data. I realise there is similar question that can be addressed with MPI_IN_PLACE. I tried but didn't get what I want.

related question

Liang
  • 63
  • 7
  • 1
    From a link in one of the related section, how about [MPI_Scatterv](http://www.open-mpi.org/doc/v1.4/man3/MPI_Scatterv.3.php) – Craig Estey Jul 14 '22 at 19:47
  • 1
    Compute the total length, divide by number or processes minus one, set up an all-to-all. Btw, this has nothing to do with `MPI_IN_PLACE`. – Victor Eijkhout Jul 14 '22 at 19:47
  • 1
    @CraigEstey Thanks for your reply, I am wondering if there is elegant way than MPs_Scatterv – Liang Jul 14 '22 at 21:04
  • @VictorEijkhout Thank you Victor, it could be a solution, but I am still wondering if there is a more straightforward way. Such communication pattern is that Master dispatches data to Slave in Spark. So I think if I missed there is a simple way using MPI_Scatter in MPI. – Liang Jul 14 '22 at 21:07
  • 3
    An other option would be to create an intercommunicator with rank 0 in one group, and the other ranks in the other group. Then you can simply `MPI_Scatter()` (assuming the size of your array is a multiple of the number of non zero ranks). One might see this as an elegant solutions, but others might see it as unnecessarily convoluted with no guarantee it would be faster than `MPI_Scatterv()`. – Gilles Gouaillardet Jul 14 '22 at 22:33
  • 1
    @Liang (Please don't use the terms M & S anymore. All style guides tell you at least to use the term Worker.) Ok, so how would a supervisor process dispatch something to a worker if they don't have it? This is distributed memory. There is no real supervisor that has all the data. Each process has its own data. – Victor Eijkhout Jul 14 '22 at 23:32
  • @GillesGouaillardet Thanks for your suggestion. It seems `MPI_Scatterv()` is a good choice for this question. – Liang Jul 17 '22 at 14:38
  • @VictorEijkhout Sorry for misusing M&S term. And thanks for your advise. But what if only manager process reads data and manager wants to distribute to all workers? – Liang Jul 17 '22 at 14:41
  • 1
    Use scatter or broadcast. – Victor Eijkhout Jul 17 '22 at 14:53

0 Answers0