home / study / engineering / computer science / computer science questions and answers / linear loop transformations are useful in reductions of cache misses and increase possible ...
Question: Linear loop transformations are useful in reductions of cache misses and increase possible parall...
Linear loop transformations are useful in reductions of cache misses and increase possible parallelization. Consider the following two loops. Which of these loops would yield better performance? Why?
For I = 1, 1000
For J= 1, 1000
c(J) = c(J) + a(I,J)*b(J)
For J=1, 1000
For J=1, 1000
c(J) = c(J) + a(I,J)*b(J)
LINEAR LOOP TRANSFORMATION: -
For I = 1, 1000
For J= 1, 1000
c(J) = c(J) + a(I,J)*b(J)
For J=1, 1000
For J=1, 1000
c(J) = c(J) + a(I,J)*b(J)
*May be it may missing of the loop part B by the inner loop must be
" For I = 1,1000" Then the those two loops of J doesn't have
mean.
*So let's make this correction and answer the question. Here first
loop would yield better performance than second loop.
*The causes of the array in memory is mannaged in a row-major
order.
*Their by the array element a(I,J) and a(I,J+1) will be adjacent in
memory location but the array element a(I,J) and a(I+1,J) will not
be adjacent .
*Since the first loop have adjacent memory location access in
successive iteration of loop and hence locality of reference will
be followed and hence there will be better cache hit in first loop
than second loop.
*Hence the first design will yield better performance in terms of
cache access hit rate.
Please comment for any clarification.
home / study / engineering / computer science / computer science questions and answers / linear...