C++ for Engineers and Scientists
C++ for Engineers and Scientists
4th Edition
ISBN: 9781133187844
Author: Bronson, Gary J.
Publisher: Course Technology Ptr
expand_more
expand_more
format_list_bulleted
Bartleby Related Questions Icon
Related questions
Question
I have to develop an efficient parallel numerical integration
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
Check MarkThis question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
bartleby
Step by stepSolved in 2 steps
Knowledge Booster
Background pattern image
Recommended textbooks for you
- Text book imageC++ for Engineers and ScientistsComputer ScienceISBN:9781133187844Author:Bronson, Gary J.Publisher:Course Technology PtrText book imageC++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage LearningText book imageSystems ArchitectureComputer ScienceISBN:9781305080195Author:Stephen D. BurdPublisher:Cengage Learning
- Text book imageProgramming Logic & Design ComprehensiveComputer ScienceISBN:9781337669405Author:FARRELLPublisher:CengageText book imageOperations Research : Applications and AlgorithmsComputer ScienceISBN:9780534380588Author:Wayne L. WinstonPublisher:Brooks ColeText book imageEBK JAVA PROGRAMMINGComputer ScienceISBN:9781337671385Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENT
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