Communication in Sub-Grids
Suppose that you have an algorithm, such as matrix multiply, that requires you to communicate within one row or column of a 2D grid.
- For example, broadcast a value to all processes in one row.
MPI_Comm rowcomm;freecoords[0] = 0; freecoords[1] = 1;ierr = MPI_Cart_sub(comm2d, freecoords, &rowcomm)
Defines nrow new communicators, each with the processes of that row. The array freecoords has boolean values specifying whether the elements of that dimension “belong” to the communicator.
- if bcastroot is defined as the root processor in each row, broadcast a value along rows:MPI_Bcast(value, 1, MPI_FLOAT, bcastroot, rowcomm);