Collective communication using scatter

The scatter functionality is very similar to a scatter broadcast but has one major difference, while comm.bcast sends the same data to all listening processes, comm.scatter can send the chunks of data in an array to different processes. The following figure illustrates the functionality of scatter:

Collective communication using scatter

Scattering data from process 0 to processes 1, 2, 3, 4

The comm.scatter function takes the elements of the array and distributes them to the processes according to their rank, for which the first element will be sent to the process zero, the second element to the process 1, and so on. The function implemented in

Get Python Parallel Programming Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.