Question
Take the following Arc-Length-Integral code to compute the perimeter of an Ellipse code and parallelize it in OpenMP and make a table Like the below
Take the following Arc-Length-Integral code to compute the perimeter of an Ellipse code and parallelize it in OpenMP and make a table Like the below and include it in the comments at the front:
// Timing for 19 ones in a row: //
Threads/cores 1 2 4 //
Time of run: ___ ___ ___
Problem: Compute the perimeter of an Ellipse (axis coordinates (2,0)(0,1)(-2,0)(0,-1)) for the first quarant and the multiply by 4. Use the arc-length integral, aproximated by one million, ten million, one hundred million, and 1 billion line segments...
#define f(x) sqrt(1 - ((x)/2)*((x)/2) ) double x, y, stepsize , length ; int numintervals = 1000000 ; stepsize = 2.0 / (double (numintervals) ;
for (x=0 ; x <=2.0; x += stepsize ) { delta_y = f(x+stepsize) - f(x) ; // delta_y = y1 - y0 = f(x1) - f(x0) where f(x) = sqrt(1 - (x/2)*(x/2) ) length = sqrt( (stepsize*stepsize) + (delta_y*delta_y)) ; }
Test this out in serial mode, then parallelize, then collect table of run-times for 1, 2, and 4 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