Question: In the following program fragment, each process has two integer variables a and b and two integer arrays C[n] and D[n] (where n is the
In the following program fragment, each process has two integer variables a and b and two integer arrays C[n] and D[n] (where n is the number of processes), initialized as shown.

Suppose that n = 4. For each the following, give the values that will be stored in the specified process variable after executing the MPI code below. Use the initial values of a, b, C and D in each case.
a. MPI_Allreduce(&a, &b, 1, MPI_INT, MPI_SUM, MPI_COMM_WORLD);
| Process rank | 0 | 1 | 2 | 3 |
| Value of b |
|
|
|
|
b. MPI_Gather(&a, 1, MPI_INT, D, 1, MPI_INT, 2, MPI_COMM_WORLD);
| Process rank | 0 | 1 | 2 | 3 |
| Value of D |
|
|
|
|
c. MPI_Scatter(C, 1, MPI_INT, &b, 1, MPI_INT, 2, MPI_COMM_WORLD);
| Process rank | 0 | 1 | 2 | 3 |
| Value of C |
|
|
|
|
d. MPI_Scan(&a, &b, 1, MPI_INT, MPI_MAX, MPI_COMM_WORLD);
| Process rank | 0 | 1 | 2 | 3 |
| Value of b
|
|
|
|
|
int main aint arge, char *aEgoy int rank n MEI Corum size MEI COMM WORLD &n MEI ComunrankaMEI COMM WORLD &rank int a rank int b 0; int CIn], D Dn]; 0; i ni i++ t for Cli] rank i D [i] MPI CODE return 0; int main aint arge, char *aEgoy int rank n MEI Corum size MEI COMM WORLD &n MEI ComunrankaMEI COMM WORLD &rank int a rank int b 0; int CIn], D Dn]; 0; i ni i++ t for Cli] rank i D [i] MPI CODE return 0
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
