When is it not possible to exploit spatial locality in cache?


When is it not possible to exploit spatial locality in cache?



We are given a processor whose instructions operate on 8 - byte operands and whose instructions are also encoded using 8 bytes. We are using a 16 kilo-byte,
4-way set associative cache that contains 1024 sets. The cache has 4 * 1024 = 4096 cache lines in total. That means, each cache line is 16KB=4096 = 4 bytes, so each operand and each instruction needs to be stored in two cache lines, which will require 2 accesses to the cache for each load/store operation and instruction fetches. We are told that the cache cannot apply spatial locality, but why? What does spatial locality mean in this context?




1 Answer
1



So your machine doesn't have single byte loads/stores at all?



If every load is a full cache line (or multiple whole cache lines), then bringing a line into cache for one load will never benefit another load that's spatially nearby.



(Unless you have hardware prefetching to detect sequential accesses and start fetching adjacent cache lines...)





No, the machine doesn't have single byte loads stores. Isn't the definition of spatial locality that "nearby data will be accessed in the near future"?
– jannè
2 days ago





@jannè: yes. exactly. If your cache lines are so small that loading a value doesn't bring in any nearby values you didn't actually load, then spatial locality in your code doesn't help you.
– Peter Cordes
2 days ago






By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Comments

Popular posts from this blog

paramiko-expect timeout is happening after executing the command

Export result set on Dbeaver to CSV

Opening a url is failing in Swift