Jump to content
  • Advertisement
Sign in to follow this  
kayX

Cache

This topic is 4980 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

int ha; for(int i=count-1; i>=0; i--) { ha = array; } Correct me if im wrong, but as i know, when an array of lets say int is accessed, the processor actually fetch more then just that 1 int into the cache. My question is, from what range does the processor fetch? does the processor get the memory fom i + 64k or position is in the middle (32k + 1 + 32k)? if it fetches forward, than the above code would be a cache miss? or my whole understanding of cache is wrong?

Share this post


Link to post
Share on other sites
Advertisement
Generally speaking, when a word is accessed, a "cache line" will be filled. Depending on the address accessed, the word may be at the start, in the middle or at the end of the line.

For example, if you fetch a word from address 0x00001008, the processor may fetch, depending on the cache line size:

0x00001008 - 0x0000100f
0x00001000 - 0x0000100f

or one of many other possible sets of words.

To answer your question more directly, iterating down through memory shouldn't cause more cache misses than iterating upwards.

Share this post


Link to post
Share on other sites
thanks! i did some test and the speed is almost identical. just wana be sure. i can now iterate down without doubts. thanks again

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!