4 ms·
How can you? Do you know of a CPU that has specific instructions to handle cache allocations?
by HugoDaniel 5y ago
How can you? Do you know of a CPU that has specific instructions to handle cache allocations?
- cnity 5y agoYou simply take advantage of the fact that an entire cache line is fetched when reading from memory, and keep data that is frequently used together close to each other in memory.
- ratww 5y agoIf you have an array of small structures, all you have to do is access all of them in one go with a for() loop and you're already taking advantage of the cache. This is enforced in ECS frameworks, btw: it's how a "System" is implemented. However, if your code has random access, there's no point in using arrays of structures. The compiler would have to modify the order of execution of instructions inside your method to take advantage of how the data is laid out.
- HugoDaniel 5y agoSure there are great benefits in sequential access, some of these can even be calculated to some extent. However your reply does not answer the question. Do you know of any CPU that has specific instructions to handle cache? How can you be sure that you are gaming cache lines when even the mnemonics are mostly virtualised through all the pipeline and jump/memory pattern predictions?
- ratww 5y agoMy reply is answering the first question, How can you?. Not the second.