As another example of code with potential load-store interactions, consider the following function to copy the contents

Question:

As another example of code with potential load-store interactions, consider the following function to copy the contents of one array to another:

1 2 3 4 5 6 void copy_array (long *src, long *dest, long n) { } long i; for (i = 0; i

Critical path s_data load add s_data load add s_data load add sub sub sub Example A Critical path s_data load

Suppose a is an array of length 1,000 initialized so that each element a[i] equals i.

A. What would be the effect of the call copy_array(a+1,a,999)? 

B. What would be the effect of the call copy_array(a,a+1,999)? 

C. Our performance measurements indicate that the call of part A has a CPE of 1.2 (which drops to 1.0 when the loop is unrolled by a factor of 4), while the call of part B has a CPE of 5.0. To what factor do you attribute this performance difference? 

D. What performance would you expect for the call copy_array(a,a,999)?

Fantastic news! We've Found the answer you've been seeking!

Step by Step Answer:

Related Book For  book-img-for-question

Computer Systems A Programmers Perspective

ISBN: 9781292101767

3rd Global Edition

Authors: Randal E. Bryant, David R. O'Hallaron

Question Posted: