2. NUMERICAL INTEGRATION ON A MESH Convert the numerical integration program given in Figure 5.8 to run on a 2-D Mesh multicomputer topology. A new technique for adding the local sums will be required, which is more suited to multicomputers. Try to design the program so that it specifically performs well on a 2-D Mesh. To test your program, use the following function for integration: float f(float t) { } return sqrt (4 - t*t) ); Perform the integration between the boundary points a = 0 and 6 = 2. The result of this integration program should be a good approximation to the value of pi. /* PROGRAM Numerical Integration */ #define numproc 40 /*number of processes*/ #define numpoints 30 /*number of points per process*/ float a,b, w, globalsum, answer; int i; spinlock L; float f(float t) /*Function to be integrated*/ { ... /*Compute value of f(t) */ } void Integrate (int myindex) { } float localsum = 0; float t; int j; tamyindex* (b-a)/numproc; /*My start position */ for (j = 1; j <= numpoints; j++) { } localsum = localsum + f(t); /* Add next point */ t = t + w; localsum w * localsum; Lock (L); globalsum = globalsum+localsum; /* atomic update*/ Unlock (L); main() { } /* Initialize values of end points "a" and "b"*/ w = (b-a)/(numproc*numpoints); /* spacing of points*/ forall i = 0 to numproc-1 do /*Create processes*/ Integrate (i); answer globalsum + w/2* (f(b)-f(a)); /* end points*/ Figure 5.8 Parallel numerical integration.
2. NUMERICAL INTEGRATION ON A MESH Convert the numerical integration program given in Figure 5.8 to run on a 2-D Mesh multicomputer topology. A new technique for adding the local sums will be required, which is more suited to multicomputers. Try to design the program so that it specifically performs well on a 2-D Mesh. To test your program, use the following function for integration: float f(float t) { } return sqrt (4 - t*t) ); Perform the integration between the boundary points a = 0 and 6 = 2. The result of this integration program should be a good approximation to the value of pi. /* PROGRAM Numerical Integration */ #define numproc 40 /*number of processes*/ #define numpoints 30 /*number of points per process*/ float a,b, w, globalsum, answer; int i; spinlock L; float f(float t) /*Function to be integrated*/ { ... /*Compute value of f(t) */ } void Integrate (int myindex) { } float localsum = 0; float t; int j; tamyindex* (b-a)/numproc; /*My start position */ for (j = 1; j <= numpoints; j++) { } localsum = localsum + f(t); /* Add next point */ t = t + w; localsum w * localsum; Lock (L); globalsum = globalsum+localsum; /* atomic update*/ Unlock (L); main() { } /* Initialize values of end points "a" and "b"*/ w = (b-a)/(numproc*numpoints); /* spacing of points*/ forall i = 0 to numproc-1 do /*Create processes*/ Integrate (i); answer globalsum + w/2* (f(b)-f(a)); /* end points*/ Figure 5.8 Parallel numerical integration.
C++ for Engineers and Scientists
4th Edition
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Bronson, Gary J.
Chapter13: Structures
Section: Chapter Questions
Problem 4PP
Related questions
Question
I have to develop an efficient parallel numerical integration program on a 2-D mesh but I'm struggling. And it has to be in Cstar

Transcribed Image Text:2. NUMERICAL INTEGRATION ON A MESH
Convert the numerical integration program given in Figure 5.8 to run on a
2-D Mesh multicomputer topology. A new technique for adding the local sums
will be required, which is more suited to multicomputers. Try to design the
program so that it specifically performs well on a 2-D Mesh.
To test your program, use the following function for integration:
float f(float t) {
}
return sqrt (4 - t*t) );
Perform the integration between the boundary points a = 0 and 6 = 2. The result
of this integration program should be a good approximation to the value of pi.

Transcribed Image Text:/* PROGRAM Numerical Integration */
#define numproc 40 /*number of processes*/
#define numpoints 30 /*number of points per process*/
float a,b, w, globalsum, answer;
int i;
spinlock L;
float f(float t) /*Function to be integrated*/
{
...
/*Compute value of f(t) */
}
void Integrate (int myindex)
{
}
float localsum = 0;
float t;
int j;
tamyindex* (b-a)/numproc; /*My start position */
for (j = 1; j <= numpoints; j++) {
}
localsum = localsum + f(t); /* Add next point */
t = t + w;
localsum w * localsum;
Lock (L);
globalsum = globalsum+localsum; /* atomic update*/
Unlock (L);
main()
{
}
/* Initialize values of end points "a" and "b"*/
w = (b-a)/(numproc*numpoints); /* spacing of points*/
forall i = 0 to numproc-1 do /*Create processes*/
Integrate (i);
answer globalsum + w/2* (f(b)-f(a)); /* end points*/
Figure 5.8 Parallel numerical integration.
Expert Solution

This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
Step by step
Solved in 2 steps

Recommended textbooks for you

C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr

C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning

Systems Architecture
Computer Science
ISBN:
9781305080195
Author:
Stephen D. Burd
Publisher:
Cengage Learning

C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr

C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning

Systems Architecture
Computer Science
ISBN:
9781305080195
Author:
Stephen D. Burd
Publisher:
Cengage Learning
Programming Logic & Design Comprehensive
Computer Science
ISBN:
9781337669405
Author:
FARRELL
Publisher:
Cengage

Operations Research : Applications and Algorithms
Computer Science
ISBN:
9780534380588
Author:
Wayne L. Winston
Publisher:
Brooks Cole

EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT