CMSC 476: Trapezoid Rule Using MPI
Overview
Rewrite the trapezoid program from class.
Requirements
Incorporate the following features.
Use good style. For example, declare variables right before they are needed.
Obtain
a,b, andnfrom the user on process 0. Broadcast (MPI_Bcast) these values to the other processes.Allow for
nnot being divisible byp. Split the work using our partitioning formula. Do NOT definelocalNto ben / p.Define the
integrateTrapfunction so it takes a function to integrate. Usestd::function(slow) or a template parameterMyFunction(BETTER) passed by universal reference.Use
MPI_Reduceto reduce the local sums to process 0.
Input Specification
Input a, b, and n from the
user on process 0.
Use PRECISELY the format below with the EXACT same SPACING and SPELLING.
a ==> 0.0
b ==> 1.0
n ==> 1000
Output Specification
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
With n = 1000 trapezoids, our estimate
of the integral from 0.0 to 1.0 = xx.xxxxx.
(no spaces after the preceding line)
Required Types, Concepts, and Functions
template<...>
ReturnType
integrateTrap (...)What to Submit
Submit your source file Trapezoid.cc. You must demo your
solution for any credit, integrating at least TWO different functions
with known results.
Gary M. Zoppetti, Ph.D.