Question: Optimization ( 2 0 points ) Consider the following code for calculating the dot product of two vectors of double precision floating point numbers. double

Optimization (20 points)
Consider the following code for calculating the dot product of two vectors of double
precision floating point numbers.
double dot_prod(double A[], double B[], int n){
int i;
double r=0;
for r=r+A[i]***B[i];r7CPEr=0r=r+(A[i]**B[i]+A[i+1]**B[i+1]);i++r=r+A[i]**B[i];r72=3.5CPE;i; i++(i=0;i
r=r+(A[i]**B[i]+A[i+1]**B[i+1]);
for ( ;i; i++)
r=r+A[i]**B[i];
return r;
}
(5 points) What is the theoretically optimal CPE for this loop?
72=3.5CPE, since the critical path is still addition, but now two elements will
be added in each iteration.
 Optimization (20 points) Consider the following code for calculating the dot

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!