Starting from:

$30

Parallel Numerical Integration

ECE2036 
Parallel Numerical Integration

Overview. This assignment will use 10 threads to compute in parallel the following integral:
Z +100
0
23.864x
3 + 5.7x
2 − 173.1x + 10.523dx
-5x106
0
5x106
1x107
1.5x107
2x107
2.5x107
-20 0 20 40 60 80 100
Program Requirements.
1
1. The specified integral is to be computed using a numerical technique called the Riemann Sum. The Riemann
sum estimates the value of an integral by computing the area of a series of rectangles at equidistant points along
the x–axis. The Riemann sum is characterized by the ∆x value, which specifies the horizontal size of each
rectangle along the x–axis. The height of each rectangle is the average of f(x) and f(x + ∆x). The figure
below shows the specified integral with ∆x value of 5.0. Since we are integrating between 0 and 100.0, this
value of ∆x results in the summation of 20 rectangles to get the final value of the integral. In general, it is
expected that smaller ∆x value result in more accurate results at the expense of additional computation.
2. The program must compute the Riemann sum using 10 threads.
3. The value of the integral must be calculated 7 times, using varying ∆x values, starting from 1.0 and ending with
0.000001, dividing by 10.0 for each iteration. This means the number of rectangles summed varies from 100 to
100,000,000.
4. The Makefile provided actually compiles the program twice and makes two different executable binaries. The
first one uses a 32–bit float value for all floating point values. The second one uses a 64–bit double value for
the floating point values. The executable binaries are called integration-float and integration-double
respectively.
5. Since the integral we are computing is in fact analytically integrable, we can compute the “correct” value as:
5.966x
4 + 1.9x
3 − 86.55x
2 + 10.523x + C|
+100
0 = 5.9763555230000e + 08;
6. For each of the seven different ∆x values, print out the ∆x, the computed integral, and the error quantity (the
absolute value of the computed value minus the correct value). Use the printf function for this, with the
format string ”%3.6f” for the ∆x value, and ”%15.13e” for both the computed area and the error value.
Obtaining the skeleton files. Once logged into deepthought19, you can get all of the required materials for this
assignment by running the command:
rsync -avu /nethome/ECE2036/NumericalIntegration .
DON’T FORGET THE PERIOD AT THE END OF THE RSYNC COMMAND. The final argument above (the
period) tells rsync where to write the files. The period indicates “the current working directory”.
This will create a subdirectory called NumericalIntegration with the files you need.
Copy the skeleton integration-skeleton.cc as follows:
cd NumericalIntegration
cp integration-skeleton.cc integration.cc
Subroutines provided in gthread.h
1. CreateThread();
See the discussion of CreateThread in the lecture notes handout on threads.
2. EndThread();
See the discussion of EndThread in the lecture notes handout on threads.
3. WaitAllThreads();
See the discussion of WaitAllThreads in the lecture notes handout on threads.
2
4. LockMutex(gthread mutex t m);
Claims the lock on the specified mutex. See the discussion of LockMutex in the lecture notes handout on
mutual exclusion.
5. UnlockMutex(gthread mutex t m);
Releases the lock on the specified mutex. See the discussion of UnlockMutex in the lecture notes handout on
mutual exclusion.
IMPORTANT NOTE: Variables of type gthread mutex t should be initialized to NULL. If the mutex
is a global variable this happens automatically.
Turning in your program As before, use the turnin-ece2036a or turnin-ece2036b script.
3

More products