O'Reilly logo

Python Parallel Programming Cookbook by Giancarlo Zaccone

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required