數組在內存中的存儲以及如何調入緩存

Here I draw some diagrams to show how arrays look like in memory and in cache. This is not a programming problem, but let's assume we use C not Java.web

The following diagram shows how a 8*8 array/matrix stored in memory by using row-major. If CPU need A[0][7] element, the whole block that contains this element will be brought to cache. In this case, the cache block can fit 8 elements, so it is the whole row that will be brought to cache.this

This diagram shows how CPU request a byte from memory hierarchy. It shows how the requested element looks like in memory and how it is brought to cache.spa

This diagram shows why cache views memory as an array of blocks. The block size is determined by cache block and there are totally #(total memory size/cache block size) memory blocks.orm

相關文章
相關標籤/搜索