Answered step by step
Verified Expert Solution
Question
1 Approved Answer
#include #include #include double f ( double x ) { return sin ( x ) ; } double Trap ( int n , double a
#include
#include
#include
double fdouble x
return sinx;
double Trapint n double a double b double h
double T x;
int i;
T fa fb;
for i ; i n ; i
x a i h;
T fx;
T T h;
return T;
int mainint argc, char argv
int rank, S n;
double a b h locala localb localintegral, integral;
int localn;
MPIInitNULL NULL;
MPICommrankMPICOMMWORLD, &rank;
MPICommsizeMPICOMMWORLD, &S;
if rank
printfEnter a b and n:
;
scanfslf lf d &a &b &n;
h b a n;
MPIBcast&a MPIDOUBLE, MPICOMMWORLD;
MPIBcast&b MPIDOUBLE, MPICOMMWORLD;
MPIBcast&n MPIINT, MPICOMMWORLD;
h b a n;
Compute the interval for each process
localn n S;
locala a rank localn h;
localb locala localn h;
Compute the area under the curve using the trapezoidal
localintegral Traplocala localb localn h;
MPIReduce&localintegral, &integral, MPIDOUBLE, MPISUM, MPICOMMWORLD;
Process
if rank
printfWith n d trapezoids, our estimate of the integral from f to f f
n a b integral;
MPIFinalize;
return ;
I need these parts in code:
execution time
speedup TserialTparallel
efficiency speedup#threads
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started