types of cache misses
play

Types of Cache Misses Cold (compulsory) miss Occurs on - PowerPoint PPT Presentation

University of Washington University of Washington Types of Cache Misses Cold (compulsory) miss Occurs on very first access to a block The


  1. University ¡of ¡Washington ¡ University ¡of ¡Washington ¡ Types ¡of ¡Cache ¡Misses ¡  Cold ¡(compulsory) ¡miss ¡  Occurs ¡on ¡very ¡first ¡access ¡to ¡a ¡block ¡ The ¡Hardware/So<ware ¡Interface ¡  Conflict ¡miss ¡ CSE351 ¡Winter ¡2013 ¡  Occurs ¡when ¡some ¡block ¡is ¡evicted ¡out ¡of ¡the ¡cache, ¡but ¡then ¡that ¡block ¡ is ¡referenced ¡again ¡later ¡  Conflict ¡misses ¡occur ¡when ¡the ¡cache ¡is ¡large ¡enough, ¡but ¡mulDple ¡data ¡ blocks ¡all ¡map ¡to ¡the ¡same ¡slot ¡ Memory ¡and ¡Caches ¡II ¡  e.g., ¡if ¡blocks ¡0 ¡and ¡8 ¡map ¡to ¡the ¡same ¡cache ¡slot, ¡then ¡referencing ¡ 0, ¡8, ¡0, ¡8, ¡... ¡would ¡miss ¡every ¡Dme ¡  Conflict ¡misses ¡may ¡be ¡reduced ¡by ¡increasing ¡the ¡associaDvity ¡of ¡ the ¡cache ¡  Capacity ¡miss ¡  Occurs ¡when ¡the ¡set ¡of ¡acDve ¡cache ¡blocks ¡(the ¡working ¡set) ¡is ¡larger ¡ than ¡the ¡cache ¡(just ¡won’t ¡fit) ¡ 2 ¡ Winter ¡2013 ¡ Memory ¡and ¡Caches ¡II ¡ University ¡of ¡Washington ¡ University ¡of ¡Washington ¡ General ¡Cache ¡OrganizaJon ¡(S, ¡E, ¡B) ¡ Cache ¡Read ¡ • Locate ¡set ¡ • Check ¡if ¡any ¡line ¡in ¡set ¡ has ¡matching ¡tag ¡ E ¡= ¡2 e ¡lines ¡per ¡set ¡ E ¡= ¡2 e ¡lines ¡per ¡set ¡ • Yes ¡+ ¡line ¡valid: ¡hit ¡ • Locate ¡data ¡star?ng ¡ set ¡ at ¡offset ¡ line ¡ Address ¡of ¡byte ¡in ¡memory: ¡ t ¡bits ¡ s ¡bits ¡ b ¡bits ¡ S ¡= ¡2 s ¡sets ¡ S ¡= ¡2 s ¡sets ¡ tag ¡ set ¡ block ¡ index ¡ offset ¡ data ¡begins ¡at ¡this ¡offset ¡ cache ¡size: ¡ S ¡x ¡E ¡x ¡B ¡ ¡data ¡bytes ¡ v ¡ tag ¡ 0 ¡ 1 ¡ 2 ¡ B-­‑1 ¡ v ¡ tag ¡ 0 ¡ 1 ¡ 2 ¡ B-­‑1 ¡ valid ¡bit ¡ valid ¡bit ¡ B ¡= ¡2 b ¡bytes ¡of ¡data ¡per ¡cache ¡line ¡(the ¡data ¡block) ¡ B ¡= ¡2 b ¡bytes ¡of ¡data ¡per ¡cache ¡line ¡(the ¡data ¡block) ¡ 3 ¡ 4 ¡ Winter ¡2013 ¡ Memory ¡and ¡Caches ¡II ¡ Winter ¡2013 ¡ Memory ¡and ¡Caches ¡II ¡

  2. University ¡of ¡Washington ¡ University ¡of ¡Washington ¡ Example: ¡Direct-­‑Mapped ¡Cache ¡(E ¡= ¡1) ¡ Example: ¡Direct-­‑Mapped ¡Cache ¡(E ¡= ¡1) ¡ Direct-­‑mapped: ¡One ¡line ¡per ¡set ¡ Direct-­‑mapped: ¡One ¡line ¡per ¡set ¡ Assume: ¡cache ¡block ¡size ¡8 ¡bytes ¡ Assume: ¡cache ¡block ¡size ¡8 ¡bytes ¡ Address ¡of ¡int: ¡ Address ¡of ¡int: ¡ valid? ¡ ¡ ¡+ ¡ match?: ¡yes ¡= ¡hit ¡ v ¡ tag ¡ 0 ¡ 1 ¡ 2 ¡ 3 ¡ 4 ¡ 5 ¡ 6 ¡ 7 ¡ t ¡bits ¡ 0…01 ¡ 100 ¡ t ¡bits ¡ 0…01 ¡ 100 ¡ v ¡ tag ¡ 0 ¡ 1 ¡ 2 ¡ 3 ¡ 4 ¡ 5 ¡ 6 ¡ 7 ¡ v ¡ tag tag ¡ ¡ 0 ¡ 1 ¡ 2 ¡ 3 ¡ 4 ¡ 5 ¡ 6 ¡ 7 ¡ find ¡set ¡ S ¡= ¡2 s ¡sets ¡ v ¡ tag ¡ 0 ¡ 1 ¡ 2 ¡ 3 ¡ 4 ¡ 5 ¡ 6 ¡ 7 ¡ block ¡offset ¡ v ¡ tag ¡ 0 ¡ 1 ¡ 2 ¡ 3 ¡ 4 ¡ 5 ¡ 6 ¡ 7 ¡ 5 ¡ 6 ¡ Winter ¡2013 ¡ Memory ¡and ¡Caches ¡II ¡ Winter ¡2013 ¡ Memory ¡and ¡Caches ¡II ¡ University ¡of ¡Washington ¡ University ¡of ¡Washington ¡ Assume ¡sum, ¡i, ¡j ¡in ¡registers ¡ Address ¡of ¡an ¡aligned ¡element ¡ Example: ¡Direct-­‑Mapped ¡Cache ¡(E ¡= ¡1) ¡ Example ¡(for ¡E ¡= ¡1) ¡ of ¡a: ¡ ¡ aa...ayyyyxxxx000 Assume: ¡cold ¡(empty) ¡cache ¡ Direct-­‑mapped: ¡One ¡line ¡per ¡set ¡ int sum_array_rows(double a[16][16]) 3 ¡bits ¡for ¡set, ¡5 ¡bits ¡for ¡offset ¡ Assume: ¡cache ¡block ¡size ¡8 ¡bytes ¡ { aa...ayyy yxx xx000 int i, j; 1,0: ¡ aa...a000 100 00000 2,0: ¡ aa...a001 000 00000 0,0: ¡ aa...a000 000 00000 0,4: ¡ aa...a000 001 00000 double sum = 0; Address ¡of ¡int: ¡ for (i = 0; i < 16; i++) valid? ¡ ¡ ¡+ ¡ match?: ¡yes ¡= ¡hit ¡ 0,0 ¡ 0,1 ¡ 0,2 ¡ 0,3 ¡ 4,0 ¡ 4,1 ¡ 4,2 ¡ 4,3 ¡ 2,0 ¡ 2,1 ¡ 2,2 ¡ 2,3 ¡ 0,0 ¡ 0,1 ¡ 0,2 ¡ 0,3 ¡ t ¡bits ¡ 0…01 ¡ 100 ¡ for (j = 0; j < 16; j++) 0,4 ¡ 0,5 ¡ 0,6 ¡ 0,7 ¡ sum += a[i][j]; return sum; 0,8 ¡ 0,9 ¡ 0,a ¡ 0,b ¡ v ¡ tag ¡ 0 ¡ 1 ¡ 2 ¡ 3 ¡ 4 ¡ 5 ¡ 6 ¡ 7 ¡ } 0,c ¡ 0,d ¡ 0,e ¡ 0,f ¡ 1,0 ¡ 1,1 ¡ 1,2 ¡ 1,3 ¡ 3,0 ¡ 3,1 ¡ 3,2 ¡ 3,3 ¡ 1,0 ¡ 1,1 ¡ 1,2 ¡ 1,3 ¡ int sum_array_cols(double a[16][16]) block ¡offset ¡ { 1,4 ¡ 1,5 ¡ 1,6 ¡ 1,7 ¡ int i, j; 1,8 ¡ 1,9 ¡ 1,a ¡ 1,b ¡ double sum = 0; int ¡(4 ¡Bytes) ¡is ¡here ¡ 1,c ¡ 1,d ¡ 1,e ¡ 1,f ¡ for (j = 0; j < 16; j++) for (i = 0; i < 16; i++) 32 ¡B ¡= ¡4 ¡doubles ¡ 32 ¡B ¡= ¡4 ¡doubles ¡ sum += a[i][j]; No ¡match: ¡old ¡line ¡is ¡evicted ¡and ¡replaced ¡ return sum; 4 ¡misses ¡per ¡row ¡of ¡array ¡ every ¡access ¡a ¡miss ¡ } 4*16 ¡= ¡64 ¡misses ¡ 16*16 ¡= ¡256 ¡misses 7 ¡ 8 ¡ Winter ¡2013 ¡ Memory ¡and ¡Caches ¡II ¡ Winter ¡2013 ¡ Memory ¡and ¡Caches ¡II ¡

  3. University ¡of ¡Washington ¡ University ¡of ¡Washington ¡ Example ¡(for ¡E ¡= ¡1) ¡ In ¡this ¡example, ¡cache ¡blocks ¡are ¡ E-­‑way ¡Set-­‑AssociaJve ¡Cache ¡(Here: ¡E ¡= ¡2) ¡ 16 ¡bytes; ¡8 ¡sets ¡in ¡cache ¡ ¡How ¡many ¡block ¡offset ¡bits? ¡ E ¡= ¡2: ¡Two ¡lines ¡per ¡set ¡ float dotprod(float x[8], float y[8]) ¡How ¡many ¡set ¡index ¡bits? ¡ Assume: ¡cache ¡block ¡size ¡8 ¡bytes ¡ Address ¡of ¡short ¡int: ¡ { ¡ float sum = 0; Address ¡bits: ¡it....t ¡sss ¡bbbb ¡ t ¡bits ¡ 0…01 ¡ 100 ¡ int i; ¡B ¡= ¡16 ¡= ¡2 b : ¡b=4 ¡offset ¡bits ¡ ¡S ¡= ¡ ¡ ¡8 ¡= ¡2 s : ¡s=3 ¡index ¡bits ¡ for (i = 0; i < 8; i++) ¡ v tag ¡ 0 1 2 3 4 5 6 7 v tag ¡ 0 1 2 3 4 5 6 7 sum += x[i]*y[i]; 0: ¡ ¡000....0 ¡000 ¡0000 ¡ return sum; 128: ¡000....1 ¡000 ¡0000 ¡ } find ¡set ¡ 160: ¡000....1 ¡010 ¡0000 ¡ v tag ¡ 0 1 2 3 4 5 6 7 v tag ¡ 0 1 2 3 4 5 6 7 ¡ x[0] ¡ x[1] ¡ x[2] ¡ x[3] ¡ x[0] ¡ x[1] ¡ x[2] ¡ x[3] ¡ y[0] ¡ y[1] ¡ y[2] ¡ y[3] ¡ y[0] ¡ y[1] ¡ y[2] ¡ y[3] ¡ x[0] ¡ x[1] ¡ x[2] ¡ x[3] ¡ x[0] ¡ x[1] ¡ x[2] ¡ x[3] ¡ v tag ¡ 0 1 2 3 4 5 6 7 v tag ¡ 0 1 2 3 4 5 6 7 x[4] ¡ x[5] ¡ x[6] ¡ x[7] ¡ if ¡x ¡and ¡y ¡have ¡aligned ¡ ¡ if ¡x ¡and ¡y ¡have ¡unaligned ¡ ¡ y[0] ¡ y[1] ¡ y[2] ¡ y[3] ¡ starJng ¡addresses, ¡ ¡ starJng ¡addresses, ¡ ¡ y[4] ¡ y[5] ¡ y[6] ¡ y[7] ¡ e.g., ¡&x[0] ¡= ¡0, ¡&y[0] ¡= ¡128 ¡ e.g., ¡&x[0] ¡= ¡0, ¡&y[0] ¡= ¡160 ¡ v tag ¡ 0 1 2 3 4 5 6 7 v tag ¡ 0 1 2 3 4 5 6 7 9 ¡ 10 ¡ Winter ¡2013 ¡ Memory ¡and ¡Caches ¡II ¡ Winter ¡2013 ¡ Memory ¡and ¡Caches ¡II ¡ University ¡of ¡Washington ¡ University ¡of ¡Washington ¡ E-­‑way ¡Set-­‑AssociaJve ¡Cache ¡(Here: ¡E ¡= ¡2) ¡ E-­‑way ¡Set-­‑AssociaJve ¡Cache ¡(Here: ¡E ¡= ¡2) ¡ E ¡= ¡2: ¡Two ¡lines ¡per ¡set ¡ E ¡= ¡2: ¡Two ¡lines ¡per ¡set ¡ Assume: ¡cache ¡block ¡size ¡8 ¡bytes ¡ Assume: ¡cache ¡block ¡size ¡8 ¡bytes ¡ Address ¡of ¡short ¡int: ¡ Address ¡of ¡short ¡int: ¡ t ¡bits ¡ 0…01 ¡ 100 ¡ t ¡bits ¡ 0…01 ¡ 100 ¡ compare ¡ both ¡ compare ¡ both ¡ valid? ¡ ¡+ ¡ ¡ match: ¡yes ¡= ¡hit ¡ valid? ¡ ¡+ ¡ ¡ match: ¡yes ¡= ¡hit ¡ tag ¡ v tag ¡ 0 1 2 3 4 5 6 7 v tag ¡ 0 1 2 3 4 5 6 7 v tag ¡ 0 1 2 3 4 5 6 7 v tag ¡ 0 1 2 3 4 5 6 7 block ¡offset ¡ block ¡offset ¡ short ¡int ¡(2 ¡Bytes) ¡is ¡here ¡ No ¡match: ¡ ¡ • One ¡line ¡in ¡set ¡is ¡selected ¡for ¡evicJon ¡and ¡replacement ¡ • Replacement ¡policies: ¡random, ¡least ¡recently ¡used ¡(LRU), ¡… ¡ 11 ¡ 12 ¡ Winter ¡2013 ¡ Memory ¡and ¡Caches ¡II ¡ Winter ¡2013 ¡ Memory ¡and ¡Caches ¡II ¡

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend