Collective Communication II

2.1 Scatter
Purpose of scatter operation:
  • to send different chunks of data to different processes
  • not the same as broadcast (same chunk goes to all)
  • Scatter requires contiguous data, uniform message size 

    Scatter

     

    For our first example, let's compare scatter and scatterv. Recall that the purpose of a scatter is to send out different chunks of data to different tasks--that is, you're trying to split up your data among the remote processes. Recall also that a scatter is not the same as a broadcast--in a broadcast, the same chunk of data is being sent to everybody. As you can see from the figure, the basic MPI_Scatter requires that the sender's data are stored in contiguous memory addresses and that the chunks are uniform in size. Thus, the first N data items are sent to the first process in the communicator, the next N items go to the second process, and so on. However, for some applications this might be overly restrictive. What if some processes need fewer than N items, for instance? Should you just pad out the sending buffer with unnecessary data? The answer is no: you should use MPI_Scatterv instead.