CSCI 476: Trapezoid Rule Using OpenMP
Overview
Rewrite your MPI trapezoid program to use OpenMP instead of MPI. You may use BOTH API-s if you’d like.
Requirements
Incorporate the following features.
Use good style. For example, declare variables right before they are needed.
Obtain
a,b,n, andp(number of threads) from the user.Allow for
nnot being divisible byp. Split the work using an OpenMPparallel fordirective. Use the attribute syntax RATHER than the pragmas.Use a reduction clause to compute the area in your
integrateTrapfunction. Also, try usingstd::atomic<double>without a reduction clause, or acriticaloratomicdirective. Do they produce the same results?Define the
integrateTrapfunction so it takes a function to integrate as before.
Input
Input a, b, n, and
p from the user.
Use PRECISELY the format below with the EXACT same SPACING and SPELLING.
a ==> 0.0
b ==> 1.0
n ==> 1000
p ==> 4
Sample Output
Use PRECISELY the format shown below with the EXACT same spacing and spelling.
Sample Output
(no spaces before the following line)
a ==> 0.0
b ==> 1.0
n ==> 1000
p ==> 4
With n = 1000 trapezoids, our estimate
of the integral from x.x to x.x = xxxx.xxxx.
(no spaces after the preceding line)
What to Submit
Submit your source file TrapezoiOmp.cc. You must demo
your solution for any credit, integrating at least TWO different
functions with known results.
Gary M. Zoppetti, Ph.D.