Question: Problem 2 ( 1 5 pts ) ` ` ` int main ( void ) { int my _ rank, comm _ sz , n

Problem 2(15 pts)
```
int main(void){
int my_rank, comm_sz, n =1024, local_n;
double a =0.0, b =3.0, h, local_a, local_b;
double local_int, total_int;
int source;
MPI_Init(NULL, NULL);
MPI_Comm_rank(MPI_COMM_WORLD, &my_rank);
MPI_Comm_size(MPI_COMM_WORLD, &comm_sz);
h =(b-a)/n; /* h is the same for all processes */
local_n = n/comm_sz; /* So is the number of trapezoids */
local_a = a + my_rank*local_n*h;
local_b = local_a + local_n*h;
local_int = Trap(local_a, local_b, local_n, h);
if (my_rank !=0){
MPI_Send(&local_int, 1, MPI_DOUBLE, 0,0,
MPI_COMM_WORLD);
```
In parallel programs, we need to use both global variables and local variables. Given the above trapezoidal rule program in MPI. For all variables from line 2 to 5, determine which are local and which are global.
Problem 2 ( 1 5 pts ) ` ` ` int main ( void ) {

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!