Measure and compare the average performance of the


Measure and compare the average performance of the following code (suppose as is large enough). Describe your method, justify why your method is reasonable, and attach your running code and experiment results. This idea is Loop unrolling for performance improvement.

1a) 

double ComputeSum(int numIterations) {

int i;

double sum = 0.0; for (i = 0; i < numIterations; i++) { sum += 1.0;

}

return sum;

}

1b) double ComputeSum (int numIterations) { double sum0, sum1, sum2, sum3, sum4, sum5, sum6, sum7; int i;

double sum = 0.0;

sum0 = sum1 = sum2 = sum3 = sum4 = sum5 = sum6 = sum7 = 0.0;

for (i = 0; (i+7) < numIterations; i += 8) { sum0 += 1.0; sum1 += 1.0; sum2 += 1.0; sum3 += 1.0; sum4 += 1.0;

sum5 += 1.0; sum6 += 1.0; sum7 += 1.0;

}

sum = sum0 + sum1 + sum2 + sum3 +sum4 +sum5 + sum6 + sum7; for (;i

}

return sum;

}

Solution Preview :

Prepared by a verified Expert
Basic Computer Science: Measure and compare the average performance of the
Reference No:- TGS02551653

Now Priced at $10 (50% Discount)

Recommended (91%)

Rated (4.3/5)