Docsity

Cache Performance: Understanding Cache Organizations and Reducing Misses, Slides of Assembly Language Programming

Toggle sidebar
bg1
Chapter 7.2 - Memory2 1
Execution_Time =
Instruction_Count Cycle_Time
(ideal CPI + Memory_Stalls/Inst + Other_Stalls/Inst)
Memory_Stalls/Inst =
Instruction Miss Rate Instruction Miss Penalty +
Loads/Inst Load Miss Rate Load Miss Penalty +
Stores/Inst Store Miss Rate Store Miss Penalty
Average Memory Access time (AMAT) =
(Hit RateL1 Hit TimeL1) + (Miss RateL1 Miss TimeL1)
Recap: Cache Performance
docsity.com
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19
pf1a
pf1b
pf1c
pf1d
pf1e
pf1f
pf20
pf21
pf22
pf23
pf24
pf25
pf26
pf27
pf28
pf29
pf2a
pf2b
pf2c
pf2d
pf2e
pf2f
pf30
pf31
pf32
pf33
pf34
pf35

Partial preview of the text

Download Cache Performance: Understanding Cache Organizations and Reducing Misses and more Slides Assembly Language Programming in PDF only on Docsity!

Chapter 7.2 - Memory

1

Execution_Time

Instruction_Count

^ Cycle_Time

(ideal CPI + Memory_Stalls/Inst + Other_Stalls/Inst)

Memory_Stalls/Inst =Instruction Miss Rate

^ Instruction Miss Penalty +

Loads/Inst

^ Load Miss Rate

^ Load Miss Penalty +

Stores/Inst

^ Store Miss Rate

^ Store Miss Penalty

Average Memory Access time (AMAT)

(Hit Rate

^ Hit TimeL^

) + (Miss RateL

^ Miss TimeL^

)L

Recap: Cache Performance

docsity.com

Chapter 7.2 - Memory

2

Processor Memory$ MEM

reference stream<op, addr>, <op, addr>, <op, addr>, <op, addr>,.. .op: i-fetch, read, write

Optimize the memory system organizationto minimize the average memory access timefor typical workloads

The Art of Memory System Design^ Workload orBenchmarkprograms

docsity.com

Chapter 7.2 - Memory

4

-^ Block 12 placed in 8 block cache:^ – Fully associative, direct mapped, 2-way set associative– S.A. Mapping = Block Number Modulo Number Sets

Blockno.

Direct mapped:block 12 can goonly into block 4(12 mod 8)

Blockno.

Set associative:block 12 can goanywhere in set0 (12 mod 4) SetSet^01

SetSet^23

Blockno.

Fully associative:block 12 can goanywhere Block-frame address0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1

Where can a block be placed in the Cache?Blockno.

docsity.com

Chapter 7.2 - Memory

5

Cache Organizations I : Direct

Mapped Cache

-^ For a 2

N^ byte cache: ^ 1 KB Direct

−Mapped Cache with 32 Byte Lines

  • The upper-most (32 -

N ) bits are always the Cache Tag

  • The lowest

M^ bits are the Byte Select (Block Size = 2

M )

  • One cache miss, pull in complete “Cache Block” (or “Cache Line”)

Cache Index

:

Cache Data

Byte 0

:

Cache Tag

Example: 0x

Ex: 0x

Stored as partof the cache “state”0x

Valid Bit :

Byte 1

Byte 31

:

Byte 32

Byte 33

Byte 63

:

Byte 992

Byte 1023

:

Cache Tag

Byte SelectEx: 0x

Block address

docsity.com

Chapter 7.2 - Memory

7

Disadvantage of Set Associative Cache• N way Set Associative Cache

vs. Direct Mapped Cache:

-^ N^ comparators

vs. 1 ;

– Extra MUX delay for the data ;– Data comes AFTER Hit/Miss decision and set selection.• In a direct

mapped cache, Cache Block is available BEFORE Hit/Miss:

-^ Possible to assume a hit and continue. Recover later if miss.

Cache DataCache Block 0

Cache Tag

Valid

:^

Cache DataCache Block 0

Cache Tag

Valid

:^

Cache Index Mux

1 Sel

Sel

Cache Block

Compare

Adr Tag

Compare

OR Hit

docsity.com

Chapter 7.2 - Memory

8

-^ Fully

Associative Cache: – Forget about the Cache Index.– Compare the Cache Tags of

all cache entries in parallel

.

-^ Example

: Block Size = 32 B blocks, we need

N^ 27-bit comparators.

-^ By definition: Conflict Miss = 0 for a fully associative cache

:

Cache Data

0 Byte 0

Cache Tag (27 bits long)^ :

Valid Bit :

Byte 1

Byte 31

:

Byte 32

Byte 33

Byte 63

:

Cache Tag

Byte SelectEx: 0x

Cache Organizations III : Fully = = = = =

Associative Cache

docsity.com

Chapter 7.2 - Memory

10

Here’s the Cache We’ll Be Touching

Initially thecache is empty.

Set Address

V^

Tag^

Data (Can hold a 32-byte cache line.)

N

N

N

N

N

N

N

N

N

N

N

N

N

N

N

N

Cache:1.^ Is Direct Mapped2.^ Contains 512bytes.3.^ Has 16 sets.4.^ Each set can hold32 bytes – 1 cacheline.

docsity.com

Chapter 7.2 - Memory

11

Doing Some Cache Action

We want to READdata from address

1090 = 010|0010|

Set Address

V^

Tag^

Data (Always holds a 32-byte cache line.)

N

N

N

N

N

N

N

N

N

N

N

N

N

N

N

N

Add.^ Tag^

Set^

Offset

256

Y^ 00000….

Data from memory loc. 1088 - 1119

docsity.com

Chapter 7.2 - Memory

13

Doing Some Cache Action

We want to READdata from address

5000 = 1001|1100|

Set Address

V^

Tag^

Data (Always holds a 32-byte cache line.)

N

N

Y^

Data from memory loc. 1088 - 1119

N

N

N

N

N

N

N

N

N

N

Y^

Data from memory loc. 1440 - 1471

N

Y N

Data from memory loc. 4992 - 5023

Add.^ Tag^

Set^

Offset

256

docsity.com

Chapter 7.2 - Memory

14

Doing Some Cache Action

We want to READdata from address

1470 = 0010|1101|

Set Address

V^

Tag^

Data (Always holds a 32-byte cache line.)

N

N

Y^

Data from memory loc. 1088 - 1119

N

N

N

N

N

N

N

N

N

Y^

Data from memory loc. 4992 - 5023

Y^

Data from memory loc. 1440 - 1471

N

Y N

Data from memory loc. 1440 - 1471

Add.^ Tag^

Set^

Offset

256

docsity.com

Chapter 7.2 - Memory

16

Doing Some Cache Action

We want to WRITEdata from address

256 = 0000|1000|

Set Address

V^

Tag^

Data (Always holds a 32-byte cache line.)

N

N

Y^

Data from memory loc. 1600 - 1631

N

N

N

N

N

N

N

N

N

Y^

Data from memory loc. 4992 - 5023

Y^

Data from memory loc. 1440 - 1471

N

Y N

Data from memory loc. 256 - 287

Add.^ Tag^

Set^

Offset

256

docsity.com

Chapter 7.2 - Memory

17

Doing Some Cache Action

We want to WRITEdata from address

1620 = 0011|0010|

Set Address

V^

Tag^

Data (Always holds a 32-byte cache line.)

N

N

Y^

Data from memory loc. 1060 - 1091

N

N

N

N

N

Y^

Data from memory loc. 256 - 287

N

N

N

Y^

Data from memory loc. 4992 - 5023

Y^

Data from memory loc. 1440 - 1471

N

Y N

Data from memory loc. 1600 - 1631

Add.^ Tag^

Set^

Offset

256

docsity.com

Chapter 7.2 - Memory

19

1 Compulsory (cold start or process migration, first reference): firstaccess to a block.^ – “Cold” fact of life: not a whole lot you can do about it (pre-load?)–

Note

: If you are going to run “billions” of instruction, Compulsory Misses

are^ insignificant

. If locality is low, compulsary misses reverse the benefit

of even using a cache.

2 Capacity:^ – Cache cannot contain

simultaneously

all blocks accessed by the

program;– Solution: increase cache size.

3 Conflict (collision):^ – Multiple memory locations mapped to the

same cache

location;

– Solution 1: increase cache size;– Solution 2: increase associativity. 4 Coherence (Invalidation): other process (

e.g. , I/O, other Processor)

updates shared memory.

Sources of Cache Misses

docsity.com

Chapter 7.2 - Memory

20

Four Basic Questions for Caches • Q1: Where can a block be placed in the upper level? (Block placement) • Q2: How is a block found if it is in the upper level? (Block identification) • Q3: Which block should be replaced on a miss? (Block replacement) • Q4: What happens on a write? (Write strategy)

and Memory Hierarchies

docsity.com