C++ for Engineers and Scientists
C++ for Engineers and Scientists
4th Edition
ISBN: 9781133187844
Author: Bronson, Gary J.
Publisher: Course Technology Ptr
Bartleby Related Questions Icon

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.
[画像:/* 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.]
expand button
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
Check Mark
Knowledge Booster
Background pattern image
Recommended textbooks for you
Text book image
C++ for Engineers and Scientists
Computer Science
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Course Technology Ptr
Text book image
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning
Text book image
Systems Architecture
Computer Science
ISBN:9781305080195
Author:Stephen D. Burd
Publisher:Cengage Learning
Text book image
Programming Logic & Design Comprehensive
Computer Science
ISBN:9781337669405
Author:FARRELL
Publisher:Cengage
Text book image
Operations Research : Applications and Algorithms
Computer Science
ISBN:9780534380588
Author:Wayne L. Winston
Publisher:Brooks Cole
Text book image
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781337671385
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT