分享

How is an array stored in memory and brought to cache?

 橘子悦读 2013-11-14

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.

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 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.

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.

    本站是提供个人知识管理的网络存储空间,所有内容均由用户发布,不代表本站观点。请注意甄别内容中的联系方式、诱导购买等信息,谨防诈骗。如发现有害或侵权内容,请点击一键举报。
    转藏 分享 献花(0

    0条评论

    发表

    请遵守用户 评论公约

    类似文章 更多