ãã£ãã·ã¥ãšã¯
Cache, Cache Archtecture.
ããé åããä»ã®é åãžæ å ±ã転éããé, ãã®è»¢éé 延ã極åé èœåãã転éå¹çãåäžãããããã«èæ¡ãããèšæ¶éå±€ã®å®çŸæ段.
ããšãã°,
- Memory -> Cache -> CPU
- Memory -> Cache -> HDD
ðãã£ãã·ã¥ã¡ã¢ãª
ã³ã³ãã¥ãŒã¿ã«ããããã£ãã·ã¥æ©èœãæ ãã¡ã¢ãª.
Locality
å±ææ§.
Programs tend to use data and instructions with addresses near or equal to those they have used recently.
æéçå±ææ§ (è±: temporal locality)
ããæç¹ã§åç §ããããªãœãŒã¹ãè¿ãå°æ¥ã«ãåã³åç §ãããå¯èœæ§ãé«ãããšãè¡šãæŠå¿µ
空éçå±ææ§ (è±: spatial locality)
ãããªãœãŒã¹ãåç §ããããšã, ãã®è¿åã®ãªãœãŒã¹ãåç §ãããå¯èœæ§ãé«ãããšãè¡šãæŠå¿µ
é次çå±ææ§ (è±: sequential locality)
ã¡ã¢ãªãé次ã¢ã¯ã»ã¹ããããšããæŠå¿µ
Associativity
ãã£ãã·ã¥ã¡ã¢ãªã¯ããŒã¿ã Block (Line) ãšåŒã¶ããçšåºŠãŸãšãŸã£ãåäœã§ç®¡çãã. è€æ°ã»ããã®ã¿ã°ãæãŠã°åããšã³ããªã¢ãã¬ã¹ã§ãè€æ°ããŒã¿ã®æ ŒçŽãè¡ãããšãå¯èœãšãªã. ãã®ã¿ã°ã®ã»ããæ° (ãŠãšã€) ãé£æ³åºŠãšåŒã¶. ããŒã¿æ ŒçŽæ§é ã®çžéã¯é£æ³åºŠã®çžéã§ããã.
ãã€ã¬ã¯ããããæ¹åŒ (Direct Mapped)
1 çµã®ã¿ã°ã«ããæ§æ (é£æ³åºŠ 1) ãããããŒã¿æ ŒçŽæ§é . ã¢ãã¬ã¹ã«ããäžæã«é 眮ã決ãŸããã, ã¿ã°ã®æ§é ãéåžžã«åçŽ.
ã ã, åäžãšã³ããªã«ç°ãªããã¬ãŒã ã¢ãã¬ã¹ã転éããããšå¿ ãã©ã€ã³ã®å ¥ãæ¿ããçºçãã.
ã»ããã¢ãœã·ã¢ãã£ãæ¹åŒ (Set Associative)
è€æ°ã®ã¿ã°ã«ããæ§æ (é£æ³åºŠ 2 以äž) ãããããŒã¿æ ŒçŽæ§é .
åäžãšã³ããªã«ç°ãªããã¬ãŒã ã¢ãã¬ã¹ã®ããŒã¿ãè€æ°æ ŒçŽããããšãã§ãã. é£æ³åºŠãäžããã»ã©ãã£ãã·ã¥ãããçã¯äžæããã補é ã¯å°é£ã«ãªã£ãŠãããã, ã·ã¹ãã ã«ãããã©ã³ã¹ã®ããå®è£ ãç°ãªã.
ãã«ã¢ãœã·ã¢ãã£ãæ¹åŒ (Fully Associative)
ãšã³ããªã¢ãã¬ã¹ã«ããæ¯ãåãã¯ãªã, å šãŠã®ã©ã€ã³ãæ€çŽ¢å¯Ÿè±¡ãšãªãæ§é . åŸã£ãŠé£æ³åºŠã¯ã©ã€ã³æ°åãšãªã. ãã£ãã·ã¥ã¹ã©ãã·ã³ã°ã¯èµ·ããé£ããããçã¯æãåªããŠããã, å®è£ ã³ã¹ããè€é床ã®é¢ããéåžžçšããããããšã¯ãªã.
General Cache Organization
Block (Line), Set ãšããæŠå¿µãèžãŸã, äžè¬çãªãã£ãã·ã¥æ§é ã¯ä»¥äžã«ãªã.
Cache Structure
Cache size = Block size x é£æ³æ° (2 ã®åæ°) x Set æ° (2 ã®åæ°)
Block | ⊠| Block |
---|---|---|
Block | ⊠| Block |
Block | ⊠| Block |
Block | ⊠| Block |
Block | ⊠| Block |
Set Structure
1 Set ã¯, Block ã®éå.éåã® size ã associativity.
Block | ⊠| Block |
Block Structure
- tags ⊠åäž set ã®ãªãã§äžäœã«èå¥ããããã®æ å ±.
- set index ⊠xxx åã®ã¢ãã¬ã¹ã yyy åã«å§çž®ããããã®ããã·ã¥ããŒ. ãããäœãããã«ãªãã㯠associativity ã®æ±ºãæ¹æ¬¡ç¬¬.
- block offset ⊠x bit ã 2 ã®åæ° bit ã«åããããã® offset.
- data ⊠ã¡ã€ã³ã¡ã¢ãªããããŒãããããŒã¿
tags | set index | block offset | data |