Question: Consider the following function for computing the product of an array of n double-precision numbers. We have unrolled the loop by a factor of 3.

Consider the following function for computing the product of an array of n double-precision numbers. We have unrolled the loop by a factor of 3.

double aprod (double a[1, long n) { } long 1; double x, y, z; double r = 1; for (i = 0; i < n-2; i+= 3) { X =

For the line labeled “Product computation,” we can use parentheses to create five different associations of the computation, as follows:

r = r = ((r * x) * y) *z; /* A1 */ (r* (x * y)) * z; /* A2 */ r = r * ((x * y) * z); /* A3 */ r = r * (x * (y

Assume we run these functions on a machine where floating-point multiplication has a latency of 5 clock cycles. Determine the lower bound on the CPE set by the data dependencies of the multiplication.

double aprod (double a[1, long n) { } long 1; double x, y, z; double r = 1; for (i =0; i < n-2; i+= 3) { X = a[i]; y = a[i+1]; z = a[i+2]; r = r * x * y* z; /* Product computation */ } for (i

Step by Step Solution

3.58 Rating (158 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

This problem demonstrates how small changes in a program can yield dramatic performance difference... View full answer

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 Computer Systems A Programmers Perspective Questions!