Question

home / study / engineering / computer science / computer science questions and answers / linear...

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)

0 0
Add a comment Improve this question Transcribed image text
Answer #1

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.

Add a comment
Know the answer?
Add Answer to:
home / study / engineering / computer science / computer science questions and answers / linear...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT