- /* Paint my rows my color */
- for (i=begin_row; i<end_row ;i++)
- for (j=0; j<MAX_PROCESSES; j++)
- table[i][j] = rank + 10;
-
- /* Gather everybody's result together - sort of like an */
- /* inefficient allgather */
- for (i=0; i<participants; i++) {
- void *sendbuf = (i == rank ? MPI_IN_PLACE : &table[begin_row][0]);
- MPI_Gatherv(sendbuf, send_count, MPI_INT,
- &table[0][0], recv_counts, displs, MPI_INT,
- i, MPI_COMM_WORLD);
- }
+ /* Fill in the displacements and recv_counts */
+ for (i = 0; i < participants; i++) {
+ displs[i] = i * block_size * MAX_PROCESSES;
+ recv_counts[i] = send_count;
+ }