Caching Mapping / 缓存映射

Cache映射的三种方式,全相联(Fully Associative cache),直接相连(Direct-Mapped cache),组映射(k set-associative cache)

Terminology

Cache line

Data is transferred between memory and cache in blocks of fixed size, called cache lines or cache blocks. When a cache line is copied from memory into the cache, a cache entry is created. The cache entry will include the copied data as well as the requested memory location (called a tag).

Fully associative cache

内存块可以放入任意cache line, 所谓见缝插针。

优点:缓存利用率/命中率高
缺点:寻找cache时需要遍历

Direct-Mapped cache

每个内存块只能被放入固定的cache line. 例如主存有M块, cache line有C个。
那么内存块n会被装入cache line index = n mod C

优点: 寻找cache时,可以直接从内存块地址计算出cache line。 缺点: 同余的内存块争抢cache line, cache 利用率和命中率低(conflict miss)

k Set-Associative cache

cache line 被划分为k个一组, 内存块通过直接相连映射到cache line组,而在组内使用全相连。

e.g. cache line 被分为 G = C/k 组。
内存块n 对应cache set index = n mod G
在该组的k个cache line 中,可以选择任意位置存放。

优点:前面两种的trade-off 缺点:conflict miss 仍然存在

edited 20.04.2024
created 08.06.2021
EOF

[+] click to leave a comment [+]
the comment system on this blog works via email. The button
below will generate a mailto: link based on this page's url 
and invoke your email client - please edit the comment there!

[optional] even better, encrypt the email with my public key

- don't modify the subject field
- specify a nickname, otherwise your comment will be shown as   
  anonymous
- your email address will not be disclosed
- you agree that the comment is to be made public.
- to take down a comment, send the request via email.

>> SEND COMMENT <<




2024-05-04 ♦ Live A/V Show in Rochester via Paloma Kop ♦ RSS Feed April 21, 2024
Live audiovisual show in Rochester, NY... Read more↗

2024-04-21 via mrshll.com April 21, 2024
Well, it's real now. We are moving to Nashville. I came to Boston in 2009 to study computer science and stayed for the career opportunities, loud and then quiet music scene (where I met Alejandra), and the wonderful friends we've made over the ye…

Āyen, Pōm, and ITGBTW Remixes via Helvetica Blanc April 19, 2024
The newest Wormsong entry, Āyen, marks the beginning of a little interactivity in the narrative. After each entry goes live, I'll post a choice on Patreon. All patrons can vote, and their choices will allow us to explore the Realms together! I don'…

Generated by openring from webring