Top Banner
ZSIM TUTORIAL –MEMORY SYSTEM NATHAN BECKMANN MICRO 2015 – W AIKIKI HAWAII – 5 DEC 2015
126

ZSIM TUTORIAL MEMORY SYSTEMzsim.csail.mit.edu/tutorial/slides/memory.pdf · Example: “A day in the life of a memory request” 4 Core Memory Core L1I L1D L1I L1D Cache Array Replac

Jul 27, 2020

Download

Documents

dariahiddleston
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: ZSIM TUTORIAL MEMORY SYSTEMzsim.csail.mit.edu/tutorial/slides/memory.pdf · Example: “A day in the life of a memory request” 4 Core Memory Core L1I L1D L1I L1D Cache Array Replac

ZSIM TUTORIAL – MEMORY SYSTEM

NATHAN BECKMANN

MICRO 2015 – WAIKIKI HAWAII – 5 DEC 2015

Page 2: ZSIM TUTORIAL MEMORY SYSTEMzsim.csail.mit.edu/tutorial/slides/memory.pdf · Example: “A day in the life of a memory request” 4 Core Memory Core L1I L1D L1I L1D Cache Array Replac

What we’ll talk about

ZSim has a full-featured memory system (originally designed for caches)

2

Core

Memory

Page 3: ZSIM TUTORIAL MEMORY SYSTEMzsim.csail.mit.edu/tutorial/slides/memory.pdf · Example: “A day in the life of a memory request” 4 Core Memory Core L1I L1D L1I L1D Cache Array Replac

What we’ll talk about

ZSim has a full-featured memory system (originally designed for caches)

2

Core

MemoryCache

Page 4: ZSIM TUTORIAL MEMORY SYSTEMzsim.csail.mit.edu/tutorial/slides/memory.pdf · Example: “A day in the life of a memory request” 4 Core Memory Core L1I L1D L1I L1D Cache Array Replac

What we’ll talk about

ZSim has a full-featured memory system (originally designed for caches)

2

Core

Memory

L1I

L1D

Cache

L2

Page 5: ZSIM TUTORIAL MEMORY SYSTEMzsim.csail.mit.edu/tutorial/slides/memory.pdf · Example: “A day in the life of a memory request” 4 Core Memory Core L1I L1D L1I L1D Cache Array Replac

What we’ll talk about

ZSim has a full-featured memory system (originally designed for caches)

2

Core

Memory

L1I

L1D

Cache

ArrayReplac

ement

L2

Page 6: ZSIM TUTORIAL MEMORY SYSTEMzsim.csail.mit.edu/tutorial/slides/memory.pdf · Example: “A day in the life of a memory request” 4 Core Memory Core L1I L1D L1I L1D Cache Array Replac

What we’ll talk about

ZSim has a full-featured memory system (originally designed for caches)

2

Core

Memory

L1I

L1D

Cache

ArrayReplac

ement

Contention Model

L2

Page 7: ZSIM TUTORIAL MEMORY SYSTEMzsim.csail.mit.edu/tutorial/slides/memory.pdf · Example: “A day in the life of a memory request” 4 Core Memory Core L1I L1D L1I L1D Cache Array Replac

What we’ll talk about

ZSim has a full-featured memory system (originally designed for caches)

2

Core

Memory

Core

L1I

L1D

L1I

L1D

Cache

ArrayReplac

ement

Contention Model

L2

L2

Page 8: ZSIM TUTORIAL MEMORY SYSTEMzsim.csail.mit.edu/tutorial/slides/memory.pdf · Example: “A day in the life of a memory request” 4 Core Memory Core L1I L1D L1I L1D Cache Array Replac

What we’ll talk about

ZSim has a full-featured memory system (originally designed for caches)

2

Core

Memory

Core

L1I

L1D

L1I

L1D

Cache

ArrayReplac

ement

Contention Model

Cohe

renc

e

L2

L2

Cohe

renc

eC

ohe

renc

e

Page 9: ZSIM TUTORIAL MEMORY SYSTEMzsim.csail.mit.edu/tutorial/slides/memory.pdf · Example: “A day in the life of a memory request” 4 Core Memory Core L1I L1D L1I L1D Cache Array Replac

What we’ll talk about

ZSim has a full-featured memory system (originally designed for caches)

2

Core

Memory

Core

L1I

L1D

L1I

L1D

Cache

ArrayReplac

ement

Contention Model

Cohe

renc

e

NoC

L2

L2

Cohe

renc

eC

ohe

renc

e

Page 10: ZSIM TUTORIAL MEMORY SYSTEMzsim.csail.mit.edu/tutorial/slides/memory.pdf · Example: “A day in the life of a memory request” 4 Core Memory Core L1I L1D L1I L1D Cache Array Replac

What we’ll talk about

ZSim has a full-featured memory system (originally designed for caches)

2

Core

Memory

Core

L1I

L1D

L1I

L1D

Cache

ArrayReplac

ement

Contention Model

Cohe

renc

e

NoC

L2

L2

Cohe

renc

eC

ohe

renc

e

Dir

ect

ory

Pre

fetc

her

Pre

fetc

her

Page 11: ZSIM TUTORIAL MEMORY SYSTEMzsim.csail.mit.edu/tutorial/slides/memory.pdf · Example: “A day in the life of a memory request” 4 Core Memory Core L1I L1D L1I L1D Cache Array Replac

What we’ll talk about

ZSim has a full-featured memory system (originally designed for caches)

2

Core

Memory

Core

L1I

L1D

L1I

L1D

Cache

ArrayReplac

ement

Contention Model

Cohe

renc

e

NoC

Filter

$Fi

lter

$

L2

L2

Cohe

renc

eC

ohe

renc

e

Dir

ect

ory

Pre

fetc

her

Pre

fetc

her

Page 12: ZSIM TUTORIAL MEMORY SYSTEMzsim.csail.mit.edu/tutorial/slides/memory.pdf · Example: “A day in the life of a memory request” 4 Core Memory Core L1I L1D L1I L1D Cache Array Replac

What we’ll talk about

ZSim has a full-featured memory system (originally designed for caches)

2

Core

Memory

Core

L1I

L1D

L1I

L1D

Cache

ArrayReplac

ement

Contention Model

Cohe

renc

e

NoC

Filter

$Fi

lter

$

L2

L2

Cohe

renc

eC

ohe

renc

e

Dir

ect

ory

Pre

fetc

her

Pre

fetc

her

Modular design!

Page 13: ZSIM TUTORIAL MEMORY SYSTEMzsim.csail.mit.edu/tutorial/slides/memory.pdf · Example: “A day in the life of a memory request” 4 Core Memory Core L1I L1D L1I L1D Cache Array Replac

Topics covered3

ZSim memory system design & important classes/files

Configuration options & available models

How to extend zsim yourself (with example!)

Page 14: ZSIM TUTORIAL MEMORY SYSTEMzsim.csail.mit.edu/tutorial/slides/memory.pdf · Example: “A day in the life of a memory request” 4 Core Memory Core L1I L1D L1I L1D Cache Array Replac

Example: “A day in the life of a memory request”4

Core

Memory

Core

L1I

L1D

L1I

L1D

Cache

ArrayReplac

ement

Contention Model

Cohe

renc

e

NoC

Filter

$Fi

lter

$

L2

L2

Cohe

renc

eC

ohe

renc

e

Dir

ect

ory

Pre

fetc

her

Pre

fetc

her

Bound-phase function simulation

Some components add weave-phase modeling

Page 15: ZSIM TUTORIAL MEMORY SYSTEMzsim.csail.mit.edu/tutorial/slides/memory.pdf · Example: “A day in the life of a memory request” 4 Core Memory Core L1I L1D L1I L1D Cache Array Replac

Example: “A day in the life of a memory request”4

Core

Memory

Core

L1I

L1D

L1I

L1D

Cache

ArrayReplac

ement

Contention Model

Cohe

renc

e

NoC

Filter

$Fi

lter

$

L2

L2

Cohe

renc

eC

ohe

renc

e

Dir

ect

ory

Pre

fetc

her

Pre

fetc

her

MemReq

Bound-phase function simulation

Some components add weave-phase modeling

Page 16: ZSIM TUTORIAL MEMORY SYSTEMzsim.csail.mit.edu/tutorial/slides/memory.pdf · Example: “A day in the life of a memory request” 4 Core Memory Core L1I L1D L1I L1D Cache Array Replac

Example: “A day in the life of a memory request”4

Core

Memory

Core

L1I

L1D

L1I

L1D

Cache

ArrayReplac

ement

Contention Model

Cohe

renc

e

NoC

Filter

$Fi

lter

$

L2

L2

Cohe

renc

eC

ohe

renc

e

Dir

ect

ory

Pre

fetc

her

Pre

fetc

her

MemReq

load()/store()

Bound-phase function simulation

Some components add weave-phase modeling

Page 17: ZSIM TUTORIAL MEMORY SYSTEMzsim.csail.mit.edu/tutorial/slides/memory.pdf · Example: “A day in the life of a memory request” 4 Core Memory Core L1I L1D L1I L1D Cache Array Replac

Example: “A day in the life of a memory request”4

Core

Memory

Core

L1I

L1D

L1I

L1D

Cache

ArrayReplac

ement

Contention Model

Cohe

renc

e

NoC

Filter

$Fi

lter

$

L2

L2

Cohe

renc

eC

ohe

renc

e

Dir

ect

ory

Pre

fetc

her

Pre

fetc

her

MemReq

load()/store()

access()

Bound-phase function simulation

Some components add weave-phase modeling

Page 18: ZSIM TUTORIAL MEMORY SYSTEMzsim.csail.mit.edu/tutorial/slides/memory.pdf · Example: “A day in the life of a memory request” 4 Core Memory Core L1I L1D L1I L1D Cache Array Replac

Example: “A day in the life of a memory request”4

Core

Memory

Core

L1I

L1D

L1I

L1D

Cache

ArrayReplac

ement

Contention Model

Cohe

renc

e

NoC

Filter

$Fi

lter

$

L2

L2

Cohe

renc

eC

ohe

renc

e

Dir

ect

ory

Pre

fetc

her

Pre

fetc

her

MemReq

load()/store()

access()

Bound-phase function simulation

Some components add weave-phase modeling

Page 19: ZSIM TUTORIAL MEMORY SYSTEMzsim.csail.mit.edu/tutorial/slides/memory.pdf · Example: “A day in the life of a memory request” 4 Core Memory Core L1I L1D L1I L1D Cache Array Replac

Example: “A day in the life of a memory request”4

Core

Memory

Core

L1I

L1D

L1I

L1D

Cache

ArrayReplac

ement

Contention Model

Cohe

renc

e

NoC

Filter

$Fi

lter

$

L2

L2

Cohe

renc

eC

ohe

renc

e

Dir

ect

ory

Pre

fetc

her

Pre

fetc

her

MemReq

load()/store()

access()

access()

Bound-phase function simulation

Some components add weave-phase modeling

Page 20: ZSIM TUTORIAL MEMORY SYSTEMzsim.csail.mit.edu/tutorial/slides/memory.pdf · Example: “A day in the life of a memory request” 4 Core Memory Core L1I L1D L1I L1D Cache Array Replac

Example: “A day in the life of a memory request”4

Core

Memory

Core

L1I

L1D

L1I

L1D

Cache

ArrayReplac

ement

Contention Model

Cohe

renc

e

NoC

Filter

$Fi

lter

$

L2

L2

Cohe

renc

eC

ohe

renc

e

Dir

ect

ory

Pre

fetc

her

Pre

fetc

her

MemReq

load()/store()

access()

access()

Latency

Bound-phase function simulation

Some components add weave-phase modeling

Page 21: ZSIM TUTORIAL MEMORY SYSTEMzsim.csail.mit.edu/tutorial/slides/memory.pdf · Example: “A day in the life of a memory request” 4 Core Memory Core L1I L1D L1I L1D Cache Array Replac

Example: “A day in the life of a memory request”4

Core

Memory

Core

L1I

L1D

L1I

L1D

Cache

ArrayReplac

ement

Contention Model

Cohe

renc

e

NoC

Filter

$Fi

lter

$

L2

L2

Cohe

renc

eC

ohe

renc

e

Dir

ect

ory

Pre

fetc

her

Pre

fetc

her

MemReq

load()/store()

access()

access()

Latency

Bound-phase function simulation

Some components add weave-phase modeling

Page 22: ZSIM TUTORIAL MEMORY SYSTEMzsim.csail.mit.edu/tutorial/slides/memory.pdf · Example: “A day in the life of a memory request” 4 Core Memory Core L1I L1D L1I L1D Cache Array Replac

Example: “A day in the life of a memory request”4

Core

Memory

Core

L1I

L1D

L1I

L1D

Cache

ArrayReplac

ement

Contention Model

Cohe

renc

e

NoC

Filter

$Fi

lter

$

L2

L2

Cohe

renc

eC

ohe

renc

e

Dir

ect

ory

Pre

fetc

her

Pre

fetc

her

MemReq

load()/store()

access()

access()

Latency

MemReq

access()

Bound-phase function simulation

Some components add weave-phase modeling

Page 23: ZSIM TUTORIAL MEMORY SYSTEMzsim.csail.mit.edu/tutorial/slides/memory.pdf · Example: “A day in the life of a memory request” 4 Core Memory Core L1I L1D L1I L1D Cache Array Replac

Example: “A day in the life of a memory request”4

Core

Memory

Core

L1I

L1D

L1I

L1D

Cache

ArrayReplac

ement

Contention Model

Cohe

renc

e

NoC

Filter

$Fi

lter

$

L2

L2

Cohe

renc

eC

ohe

renc

e

Dir

ect

ory

Pre

fetc

her

Pre

fetc

her

MemReq

load()/store()

access()

access()

Latency

MemReq

access()

Bound-phase function simulation

Some components add weave-phase modeling

Page 24: ZSIM TUTORIAL MEMORY SYSTEMzsim.csail.mit.edu/tutorial/slides/memory.pdf · Example: “A day in the life of a memory request” 4 Core Memory Core L1I L1D L1I L1D Cache Array Replac

Example: “A day in the life of a memory request”4

Core

Memory

Core

L1I

L1D

L1I

L1D

Cache

ArrayReplac

ement

Contention Model

Cohe

renc

e

NoC

Filter

$Fi

lter

$

L2

L2

Cohe

renc

eC

ohe

renc

e

Dir

ect

ory

Pre

fetc

her

Pre

fetc

her

MemReq

load()/store()

access()

access()

Latency

access()

Bound-phase function simulation

Some components add weave-phase modeling

Page 25: ZSIM TUTORIAL MEMORY SYSTEMzsim.csail.mit.edu/tutorial/slides/memory.pdf · Example: “A day in the life of a memory request” 4 Core Memory Core L1I L1D L1I L1D Cache Array Replac

Example: “A day in the life of a memory request”4

Core

Memory

Core

L1I

L1D

L1I

L1D

Cache

ArrayReplac

ement

Contention Model

Cohe

renc

e

NoC

Filter

$Fi

lter

$

L2

L2

Cohe

renc

eC

ohe

renc

e

Dir

ect

ory

Pre

fetc

her

Pre

fetc

her

MemReq

load()/store()

access()

access()

Latency

access()

Bound-phase function simulation

Some components add weave-phase modeling

Page 26: ZSIM TUTORIAL MEMORY SYSTEMzsim.csail.mit.edu/tutorial/slides/memory.pdf · Example: “A day in the life of a memory request” 4 Core Memory Core L1I L1D L1I L1D Cache Array Replac

Example: “A day in the life of a memory request”4

Core

Memory

Core

L1I

L1D

L1I

L1D

Cache

ArrayReplac

ement

Contention Model

Cohe

renc

e

NoC

Filter

$Fi

lter

$

L2

L2

Cohe

renc

eC

ohe

renc

e

Dir

ect

ory

Pre

fetc

her

Pre

fetc

her

MemReq

load()/store()

access()

access()

Latency

access()

Bound-phase function simulation

Some components add weave-phase modeling

Page 27: ZSIM TUTORIAL MEMORY SYSTEMzsim.csail.mit.edu/tutorial/slides/memory.pdf · Example: “A day in the life of a memory request” 4 Core Memory Core L1I L1D L1I L1D Cache Array Replac

Example: “A day in the life of a memory request”4

Core

Memory

Core

L1I

L1D

L1I

L1D

Cache

ArrayReplac

ement

Contention Model

Cohe

renc

e

NoC

Filter

$Fi

lter

$

L2

L2

Cohe

renc

eC

ohe

renc

e

Dir

ect

ory

Pre

fetc

her

Pre

fetc

her

MemReq

load()/store()

access()

access()

Latency

access()

InvReq

Bound-phase function simulation

Some components add weave-phase modeling

Page 28: ZSIM TUTORIAL MEMORY SYSTEMzsim.csail.mit.edu/tutorial/slides/memory.pdf · Example: “A day in the life of a memory request” 4 Core Memory Core L1I L1D L1I L1D Cache Array Replac

Example: “A day in the life of a memory request”4

Core

Memory

Core

L1I

L1D

L1I

L1D

Cache

ArrayReplac

ement

Contention Model

Cohe

renc

e

NoC

Filter

$Fi

lter

$

L2

L2

Cohe

renc

eC

ohe

renc

e

Dir

ect

ory

Pre

fetc

her

Pre

fetc

her

MemReq

load()/store()

access()

access()

Latency

access()

InvReq

invalidate()

Bound-phase function simulation

Some components add weave-phase modeling

Page 29: ZSIM TUTORIAL MEMORY SYSTEMzsim.csail.mit.edu/tutorial/slides/memory.pdf · Example: “A day in the life of a memory request” 4 Core Memory Core L1I L1D L1I L1D Cache Array Replac

Example: “A day in the life of a memory request”4

Core

Memory

Core

L1I

L1D

L1I

L1D

Cache

ArrayReplac

ement

Contention Model

Cohe

renc

e

NoC

Filter

$Fi

lter

$

L2

L2

Cohe

renc

eC

ohe

renc

e

Dir

ect

ory

Pre

fetc

her

Pre

fetc

her

MemReq

load()/store()

access()

access()

Latency

access()

InvReq

invalidate()

invalidate()

Bound-phase function simulation

Some components add weave-phase modeling

Page 30: ZSIM TUTORIAL MEMORY SYSTEMzsim.csail.mit.edu/tutorial/slides/memory.pdf · Example: “A day in the life of a memory request” 4 Core Memory Core L1I L1D L1I L1D Cache Array Replac

Example: “A day in the life of a memory request”4

Core

Memory

Core

L1I

L1D

L1I

L1D

Cache

ArrayReplac

ement

Contention Model

Cohe

renc

e

NoC

Filter

$Fi

lter

$

L2

L2

Cohe

renc

eC

ohe

renc

e

Dir

ect

ory

Pre

fetc

her

Pre

fetc

her

MemReq

load()/store()

access()

access()

Latency

access()

invalidate()

invalidate()

Bound-phase function simulation

Some components add weave-phase modeling

Page 31: ZSIM TUTORIAL MEMORY SYSTEMzsim.csail.mit.edu/tutorial/slides/memory.pdf · Example: “A day in the life of a memory request” 4 Core Memory Core L1I L1D L1I L1D Cache Array Replac

Example: “A day in the life of a memory request”4

Core

Memory

Core

L1I

L1D

L1I

L1D

Cache

ArrayReplac

ement

Contention Model

Cohe

renc

e

NoC

Filter

$Fi

lter

$

L2

L2

Cohe

renc

eC

ohe

renc

e

Dir

ect

ory

Pre

fetc

her

Pre

fetc

her

MemReq

load()/store()

access()

access()

Latency

access()

invalidate()

invalidate()

access()

Bound-phase function simulation

Some components add weave-phase modeling

Page 32: ZSIM TUTORIAL MEMORY SYSTEMzsim.csail.mit.edu/tutorial/slides/memory.pdf · Example: “A day in the life of a memory request” 4 Core Memory Core L1I L1D L1I L1D Cache Array Replac

Example: “A day in the life of a memory request”4

Core

Memory

Core

L1I

L1D

L1I

L1D

Cache

ArrayReplac

ement

Contention Model

Cohe

renc

e

NoC

Filter

$Fi

lter

$

L2

L2

Cohe

renc

eC

ohe

renc

e

Dir

ect

ory

Pre

fetc

her

Pre

fetc

her

MemReq

load()/store()

access()

access()

Latency

access()

invalidate()

invalidate()

access()

lookup()

Bound-phase function simulation

Some components add weave-phase modeling

Page 33: ZSIM TUTORIAL MEMORY SYSTEMzsim.csail.mit.edu/tutorial/slides/memory.pdf · Example: “A day in the life of a memory request” 4 Core Memory Core L1I L1D L1I L1D Cache Array Replac

Example: “A day in the life of a memory request”4

Core

Memory

Core

L1I

L1D

L1I

L1D

Cache

ArrayReplac

ement

Contention Model

Cohe

renc

e

NoC

Filter

$Fi

lter

$

L2

L2

Cohe

renc

eC

ohe

renc

e

Dir

ect

ory

Pre

fetc

her

Pre

fetc

her

MemReq

load()/store()

access()

access()

Latency

access()

invalidate()

invalidate()

access()

cands

rankCands()lookup()

Bound-phase function simulation

Some components add weave-phase modeling

Page 34: ZSIM TUTORIAL MEMORY SYSTEMzsim.csail.mit.edu/tutorial/slides/memory.pdf · Example: “A day in the life of a memory request” 4 Core Memory Core L1I L1D L1I L1D Cache Array Replac

Example: “A day in the life of a memory request”4

Core

Memory

Core

L1I

L1D

L1I

L1D

Cache

ArrayReplac

ement

Contention Model

Cohe

renc

e

NoC

Filter

$Fi

lter

$

L2

L2

Cohe

renc

eC

ohe

renc

e

Dir

ect

ory

Pre

fetc

her

Pre

fetc

her

MemReq

load()/store()

access()

access()

Latency

access()

invalidate()

invalidate()

access()

cands

rankCands()lookup()

Bound-phase function simulation

Some components add weave-phase modeling

Page 35: ZSIM TUTORIAL MEMORY SYSTEMzsim.csail.mit.edu/tutorial/slides/memory.pdf · Example: “A day in the life of a memory request” 4 Core Memory Core L1I L1D L1I L1D Cache Array Replac

Example: “A day in the life of a memory request”4

Core

Memory

Core

L1I

L1D

L1I

L1D

Cache

ArrayReplac

ement

Contention Model

Cohe

renc

e

NoC

Filter

$Fi

lter

$

L2

L2

Cohe

renc

eC

ohe

renc

e

Dir

ect

ory

Pre

fetc

her

Pre

fetc

her MemReq

load()/store()

access()

access()

Latency

access()

invalidate()

invalidate()

access()

cands

rankCands()lookup()

Bound-phase function simulation

Some components add weave-phase modeling

Page 36: ZSIM TUTORIAL MEMORY SYSTEMzsim.csail.mit.edu/tutorial/slides/memory.pdf · Example: “A day in the life of a memory request” 4 Core Memory Core L1I L1D L1I L1D Cache Array Replac

Important ZSim memory classes5

MemReq

Page 37: ZSIM TUTORIAL MEMORY SYSTEMzsim.csail.mit.edu/tutorial/slides/memory.pdf · Example: “A day in the life of a memory request” 4 Core Memory Core L1I L1D L1I L1D Cache Array Replac

MemReq6

Represents an in-flight memory request

Important fields:

uint64_t lineAddr – shifted address

AccessType type – GETS, GETX, PUTS, PUTX

uint64_t cycle – requesting cycle

MESIState* state – coherence state (M, E, S, or I)

Important methods:

N/A

Page 38: ZSIM TUTORIAL MEMORY SYSTEMzsim.csail.mit.edu/tutorial/slides/memory.pdf · Example: “A day in the life of a memory request” 4 Core Memory Core L1I L1D L1I L1D Cache Array Replac

Important ZSim memory classes7

MemReq

Page 39: ZSIM TUTORIAL MEMORY SYSTEMzsim.csail.mit.edu/tutorial/slides/memory.pdf · Example: “A day in the life of a memory request” 4 Core Memory Core L1I L1D L1I L1D Cache Array Replac

Important ZSim memory classes7

MemReq MemObject

Page 40: ZSIM TUTORIAL MEMORY SYSTEMzsim.csail.mit.edu/tutorial/slides/memory.pdf · Example: “A day in the life of a memory request” 4 Core Memory Core L1I L1D L1I L1D Cache Array Replac

MemObject8

Generic interface for things that handle memory requests

Important fields:

N/A

Important methods:

uint64_t access(MemReq& req) – performs an access and returns completion time

Page 41: ZSIM TUTORIAL MEMORY SYSTEMzsim.csail.mit.edu/tutorial/slides/memory.pdf · Example: “A day in the life of a memory request” 4 Core Memory Core L1I L1D L1I L1D Cache Array Replac

Implementing a simple model for main memory9

class SimpleMemory : public MemObject {

uint64_t latency;

g_string name;

public:

SimpleMemory(uint64_t _latency, g_string _name)

: latency(_latency), name(_name) {};

const char* getName() { return name.c_str(); }

uint64_t access(MemReq& req) {

switch (req.type) {

case PUTS: case PUTX: // write

*req.state = I;

case GETS:

*req.state = req.is(MemReq::NOEXCL)? S : E;

case GETX:

*req.state = M;

}

return req.cycle + latency;

}

};

Page 42: ZSIM TUTORIAL MEMORY SYSTEMzsim.csail.mit.edu/tutorial/slides/memory.pdf · Example: “A day in the life of a memory request” 4 Core Memory Core L1I L1D L1I L1D Cache Array Replac

Implementing a simple model for main memory9

class SimpleMemory : public MemObject {

uint64_t latency;

g_string name;

public:

SimpleMemory(uint64_t _latency, g_string _name)

: latency(_latency), name(_name) {};

const char* getName() { return name.c_str(); }

uint64_t access(MemReq& req) {

switch (req.type) {

case PUTS: case PUTX: // write

*req.state = I;

case GETS:

*req.state = req.is(MemReq::NOEXCL)? S : E;

case GETX:

*req.state = M;

}

return req.cycle + latency;

}

};

Set co

here

nce

in re

qu

esto

r

Page 43: ZSIM TUTORIAL MEMORY SYSTEMzsim.csail.mit.edu/tutorial/slides/memory.pdf · Example: “A day in the life of a memory request” 4 Core Memory Core L1I L1D L1I L1D Cache Array Replac

Implementing a simple model for main memory9

class SimpleMemory : public MemObject {

uint64_t latency;

g_string name;

public:

SimpleMemory(uint64_t _latency, g_string _name)

: latency(_latency), name(_name) {};

const char* getName() { return name.c_str(); }

uint64_t access(MemReq& req) {

switch (req.type) {

case PUTS: case PUTX: // write

*req.state = I;

case GETS:

*req.state = req.is(MemReq::NOEXCL)? S : E;

case GETX:

*req.state = M;

}

return req.cycle + latency;

}

};

Set co

here

nce

in re

qu

esto

r

Completion cycle

Page 44: ZSIM TUTORIAL MEMORY SYSTEMzsim.csail.mit.edu/tutorial/slides/memory.pdf · Example: “A day in the life of a memory request” 4 Core Memory Core L1I L1D L1I L1D Cache Array Replac

Important ZSim memory classes10

MemReq MemObject

“is a”

Page 45: ZSIM TUTORIAL MEMORY SYSTEMzsim.csail.mit.edu/tutorial/slides/memory.pdf · Example: “A day in the life of a memory request” 4 Core Memory Core L1I L1D L1I L1D Cache Array Replac

Important ZSim memory classes10

MemReq MemObject

SimpleMemory MD1Memory DDRMemory

“is a”

Page 46: ZSIM TUTORIAL MEMORY SYSTEMzsim.csail.mit.edu/tutorial/slides/memory.pdf · Example: “A day in the life of a memory request” 4 Core Memory Core L1I L1D L1I L1D Cache Array Replac

Memory controllers11

Different models for main memory

SimpleMemory: fixed-latency, no contention

Important fields: latency

MD1Memory: contention modeled using M/D/1 queue

Important fields: megabytesPerSecond (bandwidth), zeroLoadLatency, etc.

DDRMemory & DRAMSimMemory: detailed modeling of DDR timings

Important fields: lots of configuration parameters (CAS, RAS, bus MHz)

Timings modeled in weave-phase

Requires TimingCore or OOO core models

Similar accuracy, but DDRMemory is much faster

Page 47: ZSIM TUTORIAL MEMORY SYSTEMzsim.csail.mit.edu/tutorial/slides/memory.pdf · Example: “A day in the life of a memory request” 4 Core Memory Core L1I L1D L1I L1D Cache Array Replac

Important ZSim memory classes12

MemReq MemObject

SimpleMemory MD1Memory DDRMemory

“is a”

Page 48: ZSIM TUTORIAL MEMORY SYSTEMzsim.csail.mit.edu/tutorial/slides/memory.pdf · Example: “A day in the life of a memory request” 4 Core Memory Core L1I L1D L1I L1D Cache Array Replac

Important ZSim memory classes12

MemReq

InvReq

MemObject

SimpleMemory MD1Memory DDRMemory BaseCache

“is a”

Page 49: ZSIM TUTORIAL MEMORY SYSTEMzsim.csail.mit.edu/tutorial/slides/memory.pdf · Example: “A day in the life of a memory request” 4 Core Memory Core L1I L1D L1I L1D Cache Array Replac

InvReq13

Represents an invalidation request from coherence controller/directory

Important fields:

uint64_t lineAddr – shifted address

InvType type – INV, INVX, FWD

uint64_t cycle – requesting cycle

Important methods:

N/A

Page 50: ZSIM TUTORIAL MEMORY SYSTEMzsim.csail.mit.edu/tutorial/slides/memory.pdf · Example: “A day in the life of a memory request” 4 Core Memory Core L1I L1D L1I L1D Cache Array Replac

BaseCache14

Generic interface for cache-like objects

Important fields:

N/A

Important methods:

void setParents(…) – register the caches above it in the hierarchy

void setChildren(…) – register the caches below it in the hierarchy

uint64_t invalidate(const InvReq& req) – invalidate line locally & in children

uint64_t access(MemReq& req)

Page 51: ZSIM TUTORIAL MEMORY SYSTEMzsim.csail.mit.edu/tutorial/slides/memory.pdf · Example: “A day in the life of a memory request” 4 Core Memory Core L1I L1D L1I L1D Cache Array Replac

Important ZSim memory classes15

MemReq

InvReq

MemObject

SimpleMemory MD1Memory DDRMemory BaseCache

“is a”

Page 52: ZSIM TUTORIAL MEMORY SYSTEMzsim.csail.mit.edu/tutorial/slides/memory.pdf · Example: “A day in the life of a memory request” 4 Core Memory Core L1I L1D L1I L1D Cache Array Replac

Important ZSim memory classes15

MemReq

InvReq

MemObject

SimpleMemory MD1Memory DDRMemory BaseCache

Cache

“is a”

Page 53: ZSIM TUTORIAL MEMORY SYSTEMzsim.csail.mit.edu/tutorial/slides/memory.pdf · Example: “A day in the life of a memory request” 4 Core Memory Core L1I L1D L1I L1D Cache Array Replac

Cache16

Inclusive cache

Contains tag array, coherence controller, replacement policy (discussed later)

Adds logic to control these components

Important fields (that aren’t discussed later):

uint32_t accLat – access latency

uint32_t invLat – invalidation latency

Important methods:

void setParents(…) – register the caches above it in the hierarchy

void setChildren(…) – register the caches below it in the hierarchy

uint64_t invalidate(const InvReq& req) – invalidate line locally & in children

uint64_t access(MemReq& req)

Page 54: ZSIM TUTORIAL MEMORY SYSTEMzsim.csail.mit.edu/tutorial/slides/memory.pdf · Example: “A day in the life of a memory request” 4 Core Memory Core L1I L1D L1I L1D Cache Array Replac

How ZSim allows concurrency17

L2

L1 L1

Core Core

L3

Page 55: ZSIM TUTORIAL MEMORY SYSTEMzsim.csail.mit.edu/tutorial/slides/memory.pdf · Example: “A day in the life of a memory request” 4 Core Memory Core L1I L1D L1I L1D Cache Array Replac

How ZSim allows concurrency17

L2

L1 L1

Core Core

L3

Page 56: ZSIM TUTORIAL MEMORY SYSTEMzsim.csail.mit.edu/tutorial/slides/memory.pdf · Example: “A day in the life of a memory request” 4 Core Memory Core L1I L1D L1I L1D Cache Array Replac

How ZSim allows concurrency17

L2

L1 L1

Core Core

L3

Page 57: ZSIM TUTORIAL MEMORY SYSTEMzsim.csail.mit.edu/tutorial/slides/memory.pdf · Example: “A day in the life of a memory request” 4 Core Memory Core L1I L1D L1I L1D Cache Array Replac

How ZSim allows concurrency17

L2

L1 L1

Core Core

L3

Page 58: ZSIM TUTORIAL MEMORY SYSTEMzsim.csail.mit.edu/tutorial/slides/memory.pdf · Example: “A day in the life of a memory request” 4 Core Memory Core L1I L1D L1I L1D Cache Array Replac

How ZSim allows concurrency17

L2

L1 L1

Core Core

L3

Page 59: ZSIM TUTORIAL MEMORY SYSTEMzsim.csail.mit.edu/tutorial/slides/memory.pdf · Example: “A day in the life of a memory request” 4 Core Memory Core L1I L1D L1I L1D Cache Array Replac

How ZSim allows concurrency17

L2

L1 L1

Core Core

L3

Page 60: ZSIM TUTORIAL MEMORY SYSTEMzsim.csail.mit.edu/tutorial/slides/memory.pdf · Example: “A day in the life of a memory request” 4 Core Memory Core L1I L1D L1I L1D Cache Array Replac

How ZSim allows concurrency18

Naïve “big lock” implementation won’t work

L2

L1 L1

Core Core

L3

Page 61: ZSIM TUTORIAL MEMORY SYSTEMzsim.csail.mit.edu/tutorial/slides/memory.pdf · Example: “A day in the life of a memory request” 4 Core Memory Core L1I L1D L1I L1D Cache Array Replac

How ZSim allows concurrency18

Naïve “big lock” implementation won’t work

L2

L1 L1

Core Core

L3

Page 62: ZSIM TUTORIAL MEMORY SYSTEMzsim.csail.mit.edu/tutorial/slides/memory.pdf · Example: “A day in the life of a memory request” 4 Core Memory Core L1I L1D L1I L1D Cache Array Replac

There is concurrency available!

How ZSim allows concurrency19

L2

L1 L1

Core Core

L3

MemReq MemReq

Page 63: ZSIM TUTORIAL MEMORY SYSTEMzsim.csail.mit.edu/tutorial/slides/memory.pdf · Example: “A day in the life of a memory request” 4 Core Memory Core L1I L1D L1I L1D Cache Array Replac

There is concurrency available!

How ZSim allows concurrency19

L2

L1 L1

Core Core

L3

MemReq

MemReq

Page 64: ZSIM TUTORIAL MEMORY SYSTEMzsim.csail.mit.edu/tutorial/slides/memory.pdf · Example: “A day in the life of a memory request” 4 Core Memory Core L1I L1D L1I L1D Cache Array Replac

There is concurrency available!

How ZSim allows concurrency19

L2

L1 L1

Core Core

L3

MemReq

MemReq

Page 65: ZSIM TUTORIAL MEMORY SYSTEMzsim.csail.mit.edu/tutorial/slides/memory.pdf · Example: “A day in the life of a memory request” 4 Core Memory Core L1I L1D L1I L1D Cache Array Replac

There is concurrency available!

How ZSim allows concurrency19

L2

L1 L1

Core Core

L3MemReq

MemReq

Page 66: ZSIM TUTORIAL MEMORY SYSTEMzsim.csail.mit.edu/tutorial/slides/memory.pdf · Example: “A day in the life of a memory request” 4 Core Memory Core L1I L1D L1I L1D Cache Array Replac

There is concurrency available!

How ZSim allows concurrency19

L2

L1 L1

Core Core

L3MemReq

MemReq

Page 67: ZSIM TUTORIAL MEMORY SYSTEMzsim.csail.mit.edu/tutorial/slides/memory.pdf · Example: “A day in the life of a memory request” 4 Core Memory Core L1I L1D L1I L1D Cache Array Replac

There is concurrency available!

How ZSim allows concurrency19

L2

L1 L1

Core Core

L3MemReq

MemReq

Page 68: ZSIM TUTORIAL MEMORY SYSTEMzsim.csail.mit.edu/tutorial/slides/memory.pdf · Example: “A day in the life of a memory request” 4 Core Memory Core L1I L1D L1I L1D Cache Array Replac

There is concurrency available!

How ZSim allows concurrency19

L2

L1 L1

Core Core

L3

MemReq MemReq

Page 69: ZSIM TUTORIAL MEMORY SYSTEMzsim.csail.mit.edu/tutorial/slides/memory.pdf · Example: “A day in the life of a memory request” 4 Core Memory Core L1I L1D L1I L1D Cache Array Replac

There is concurrency available!

How ZSim allows concurrency19

L2

L1 L1

Core Core

L3

MemReq MemReq

Requires handling many

complex transients!

Page 70: ZSIM TUTORIAL MEMORY SYSTEMzsim.csail.mit.edu/tutorial/slides/memory.pdf · Example: “A day in the life of a memory request” 4 Core Memory Core L1I L1D L1I L1D Cache Array Replac

There is concurrency available!

How ZSim allows concurrency19

L2

L1 L1

Core Core

L3

MemReq MemReq

Requires handling many

complex transients!

Page 71: ZSIM TUTORIAL MEMORY SYSTEMzsim.csail.mit.edu/tutorial/slides/memory.pdf · Example: “A day in the life of a memory request” 4 Core Memory Core L1I L1D L1I L1D Cache Array Replac

How ZSim allows concurrency20

L2

L1 L1

Core Core

L3

Locking each cache leads to deadlock on invalidations

MemReq

Page 72: ZSIM TUTORIAL MEMORY SYSTEMzsim.csail.mit.edu/tutorial/slides/memory.pdf · Example: “A day in the life of a memory request” 4 Core Memory Core L1I L1D L1I L1D Cache Array Replac

How ZSim allows concurrency20

L2

L1 L1

Core Core

L3

Locking each cache leads to deadlock on invalidations

MemReq

MemReq

Page 73: ZSIM TUTORIAL MEMORY SYSTEMzsim.csail.mit.edu/tutorial/slides/memory.pdf · Example: “A day in the life of a memory request” 4 Core Memory Core L1I L1D L1I L1D Cache Array Replac

How ZSim allows concurrency20

L2

L1 L1

Core Core

L3

Locking each cache leads to deadlock on invalidations

MemReq

L1 is waiting on L2 on MemReq

L2 is waiting on L1 on InvReq

Deadlock!

InvReq

MemReq

Page 74: ZSIM TUTORIAL MEMORY SYSTEMzsim.csail.mit.edu/tutorial/slides/memory.pdf · Example: “A day in the life of a memory request” 4 Core Memory Core L1I L1D L1I L1D Cache Array Replac

How ZSim allows concurrency20

L2

L1 L1

Core Core

L3

Locking each cache leads to deadlock on invalidations

MemReq

L1 is waiting on L2 on MemReq

L2 is waiting on L1 on InvReq

Deadlock!

InvReq

MemReq

Page 75: ZSIM TUTORIAL MEMORY SYSTEMzsim.csail.mit.edu/tutorial/slides/memory.pdf · Example: “A day in the life of a memory request” 4 Core Memory Core L1I L1D L1I L1D Cache Array Replac

How ZSim allows concurrency21

Blocks more accesses going up, allows invalidations going down

Caches have two locks: access lock + invalidation lock

Invalidations are prioritized

Accesses acquire both locks

Invalidations need only invalidation lock

Page 76: ZSIM TUTORIAL MEMORY SYSTEMzsim.csail.mit.edu/tutorial/slides/memory.pdf · Example: “A day in the life of a memory request” 4 Core Memory Core L1I L1D L1I L1D Cache Array Replac

How ZSim allows concurrency21

Blocks more accesses going up, allows invalidations going down

Caches have two locks: access lock + invalidation lock

Invalidations are prioritized

Accesses acquire both locks

Invalidations need only invalidation lock

uint64_t Cache::access(MemReq& req) {invLock.acquire(); accLock.acquire();// look up address etcinvLock.release()parent->access(req);// check if we got an invalidation!accLock.release();return completionTime;

}

Page 77: ZSIM TUTORIAL MEMORY SYSTEMzsim.csail.mit.edu/tutorial/slides/memory.pdf · Example: “A day in the life of a memory request” 4 Core Memory Core L1I L1D L1I L1D Cache Array Replac

How ZSim allows concurrency21

Blocks more accesses going up, allows invalidations going down

Caches have two locks: access lock + invalidation lock

Invalidations are prioritized

Accesses acquire both locks

Invalidations need only invalidation lock

uint64_t Cache::access(MemReq& req) {invLock.acquire(); accLock.acquire();// look up address etcinvLock.release()parent->access(req);// check if we got an invalidation!accLock.release();return completionTime;

}

uint64_t Cache::invalidate(InvReq& req) {invLock.acquire();// do invalidationchildren.invalidate(req);invLock.release()return completionTime;

}

Page 78: ZSIM TUTORIAL MEMORY SYSTEMzsim.csail.mit.edu/tutorial/slides/memory.pdf · Example: “A day in the life of a memory request” 4 Core Memory Core L1I L1D L1I L1D Cache Array Replac

How ZSim allows concurrency22

L2

L1 L1

Core Core

L3

MemReq MemReq

Invalidation lock

Access lock

Page 79: ZSIM TUTORIAL MEMORY SYSTEMzsim.csail.mit.edu/tutorial/slides/memory.pdf · Example: “A day in the life of a memory request” 4 Core Memory Core L1I L1D L1I L1D Cache Array Replac

How ZSim allows concurrency22

L2

L1 L1

Core Core

L3

MemReq

MemReq

Invalidation lock

Access lock

Page 80: ZSIM TUTORIAL MEMORY SYSTEMzsim.csail.mit.edu/tutorial/slides/memory.pdf · Example: “A day in the life of a memory request” 4 Core Memory Core L1I L1D L1I L1D Cache Array Replac

How ZSim allows concurrency22

L2

L1 L1

Core Core

L3

MemReq

MemReq

Invalidation lock

Access lock

Page 81: ZSIM TUTORIAL MEMORY SYSTEMzsim.csail.mit.edu/tutorial/slides/memory.pdf · Example: “A day in the life of a memory request” 4 Core Memory Core L1I L1D L1I L1D Cache Array Replac

How ZSim allows concurrency22

L2

L1 L1

Core Core

L3

MemReq

MemReq

Invalidation lock

Access lock

Page 82: ZSIM TUTORIAL MEMORY SYSTEMzsim.csail.mit.edu/tutorial/slides/memory.pdf · Example: “A day in the life of a memory request” 4 Core Memory Core L1I L1D L1I L1D Cache Array Replac

How ZSim allows concurrency22

L2

L1 L1

Core Core

L3

MemReq

MemReq

Invalidation lock

Access lock

Page 83: ZSIM TUTORIAL MEMORY SYSTEMzsim.csail.mit.edu/tutorial/slides/memory.pdf · Example: “A day in the life of a memory request” 4 Core Memory Core L1I L1D L1I L1D Cache Array Replac

How ZSim allows concurrency22

L2

L1 L1

Core Core

L3

MemReq

MemReq

Invalidation lock

Access lock

InvReq

Page 84: ZSIM TUTORIAL MEMORY SYSTEMzsim.csail.mit.edu/tutorial/slides/memory.pdf · Example: “A day in the life of a memory request” 4 Core Memory Core L1I L1D L1I L1D Cache Array Replac

How ZSim allows concurrency22

L2

L1 L1

Core Core

L3

MemReq

MemReq

Invalidation lock

Access lock

InvReq

Page 85: ZSIM TUTORIAL MEMORY SYSTEMzsim.csail.mit.edu/tutorial/slides/memory.pdf · Example: “A day in the life of a memory request” 4 Core Memory Core L1I L1D L1I L1D Cache Array Replac

How ZSim allows concurrency22

L2

L1 L1

Core Core

L3

MemReq

MemReq

Invalidation lock

Access lock

Page 86: ZSIM TUTORIAL MEMORY SYSTEMzsim.csail.mit.edu/tutorial/slides/memory.pdf · Example: “A day in the life of a memory request” 4 Core Memory Core L1I L1D L1I L1D Cache Array Replac

How ZSim allows concurrency22

L2

L1 L1

Core Core

L3MemReq

MemReq

Invalidation lock

Access lock

Page 87: ZSIM TUTORIAL MEMORY SYSTEMzsim.csail.mit.edu/tutorial/slides/memory.pdf · Example: “A day in the life of a memory request” 4 Core Memory Core L1I L1D L1I L1D Cache Array Replac

How ZSim allows concurrency22

L2

L1 L1

Core Core

L3

MemReq

MemReq

Invalidation lock

Access lock

Page 88: ZSIM TUTORIAL MEMORY SYSTEMzsim.csail.mit.edu/tutorial/slides/memory.pdf · Example: “A day in the life of a memory request” 4 Core Memory Core L1I L1D L1I L1D Cache Array Replac

How ZSim allows concurrency22

L2

L1 L1

Core Core

L3

MemReq

MemReq

Invalidation lock

Access lock

Page 89: ZSIM TUTORIAL MEMORY SYSTEMzsim.csail.mit.edu/tutorial/slides/memory.pdf · Example: “A day in the life of a memory request” 4 Core Memory Core L1I L1D L1I L1D Cache Array Replac

How ZSim allows concurrency22

L2

L1 L1

Core Core

L3

MemReq

MemReq

Invalidation lock

Access lock

Page 90: ZSIM TUTORIAL MEMORY SYSTEMzsim.csail.mit.edu/tutorial/slides/memory.pdf · Example: “A day in the life of a memory request” 4 Core Memory Core L1I L1D L1I L1D Cache Array Replac

How ZSim allows concurrency22

L2

L1 L1

Core Core

L3

MemReq MemReq

Invalidation lock

Access lock

Page 91: ZSIM TUTORIAL MEMORY SYSTEMzsim.csail.mit.edu/tutorial/slides/memory.pdf · Example: “A day in the life of a memory request” 4 Core Memory Core L1I L1D L1I L1D Cache Array Replac

Important ZSim memory classes23

MemReq

InvReq

MemObject

SimpleMemory MD1Memory DDRMemory BaseCache

Cache

“is a”

Page 92: ZSIM TUTORIAL MEMORY SYSTEMzsim.csail.mit.edu/tutorial/slides/memory.pdf · Example: “A day in the life of a memory request” 4 Core Memory Core L1I L1D L1I L1D Cache Array Replac

Important ZSim memory classes23

MemReq

InvReq

MemObject

SimpleMemory MD1Memory DDRMemory BaseCache

Cache NUCACache StreamPrefetcher

“is a”

Page 93: ZSIM TUTORIAL MEMORY SYSTEMzsim.csail.mit.edu/tutorial/slides/memory.pdf · Example: “A day in the life of a memory request” 4 Core Memory Core L1I L1D L1I L1D Cache Array Replac

NUCACache24

Page 94: ZSIM TUTORIAL MEMORY SYSTEMzsim.csail.mit.edu/tutorial/slides/memory.pdf · Example: “A day in the life of a memory request” 4 Core Memory Core L1I L1D L1I L1D Cache Array Replac

NUCACache24

Non-uniform cache access: banks distributed around the chip

Important fields:

BankDir* bankDir – see below

g_vector<BaseCache*> banks – the distributed banks

Important methods: none over BaseCache

Page 95: ZSIM TUTORIAL MEMORY SYSTEMzsim.csail.mit.edu/tutorial/slides/memory.pdf · Example: “A day in the life of a memory request” 4 Core Memory Core L1I L1D L1I L1D Cache Array Replac

NUCACache24

Non-uniform cache access: banks distributed around the chip

Important fields:

BankDir* bankDir – see below

g_vector<BaseCache*> banks – the distributed banks

Important methods: none over BaseCache

Supports dynamic NUCA policies via BankDir class

uint32_t preAccess(MemReq& req) – Give destination bank

int32_t getPrevBank(MemReq& req, uint32_t curBank) – Get old bank (if moved)

Page 96: ZSIM TUTORIAL MEMORY SYSTEMzsim.csail.mit.edu/tutorial/slides/memory.pdf · Example: “A day in the life of a memory request” 4 Core Memory Core L1I L1D L1I L1D Cache Array Replac

NUCACache24

Non-uniform cache access: banks distributed around the chip

Important fields:

BankDir* bankDir – see below

g_vector<BaseCache*> banks – the distributed banks

Important methods: none over BaseCache

Supports dynamic NUCA policies via BankDir class

uint32_t preAccess(MemReq& req) – Give destination bank

int32_t getPrevBank(MemReq& req, uint32_t curBank) – Get old bank (if moved)

Wide-ranging support

First-touch, R-NUCA [Hardavellas ISCA’09], [Awasthi HPCA’09], idealized private D-NUCA

[Herrero ISCA’10], Jigsaw [Beckmann PACT’13, Beckmann HPCA’15]

Some yet-to-be-released

Page 97: ZSIM TUTORIAL MEMORY SYSTEMzsim.csail.mit.edu/tutorial/slides/memory.pdf · Example: “A day in the life of a memory request” 4 Core Memory Core L1I L1D L1I L1D Cache Array Replac

NUCACache::access pseudo-code25

uint64_t NUCACache::access(MemReq& req) {

uint32_t bank = bankDir->preAccess(req);

int32_t prevBank = bankDir->getPrevBank(req, bank);

if (prevBank != -1 && bank != prevBank) {

// move the line from prevBank to bank

}

uint64_t completionCycle = banks[bank]->access(req);

return completionCycle;

}

Page 98: ZSIM TUTORIAL MEMORY SYSTEMzsim.csail.mit.edu/tutorial/slides/memory.pdf · Example: “A day in the life of a memory request” 4 Core Memory Core L1I L1D L1I L1D Cache Array Replac

Implementing your own D-NUCA26

Idealized “last-touch” bank dir that migrates lines to wherever they are referenced

uint32_t LastTouchBankDir::preAccess(MemReq& req) {

uint32_t closestBank = nuca->getSortedRTTs(req.childId)[0].second;

return closestBank;

}

int32_t LastTouchBankDir::getPrevBank(MemReq& req, uint32_t currentBank) {

ScopedMutex sm(mutex); // avoid races

auto prevBankId = lineMap.find(req.lineAddr);

if (prevBankId == lineMap.end() || currentBank == *prevBankId) {

return -1;

} else {

uint32_t prevBank = *prevBankId;

*prevBankId = currentBank;

return *prevBank;

}

}

Page 99: ZSIM TUTORIAL MEMORY SYSTEMzsim.csail.mit.edu/tutorial/slides/memory.pdf · Example: “A day in the life of a memory request” 4 Core Memory Core L1I L1D L1I L1D Cache Array Replac

StreamPrefetcher27

Implements stream prefetcher

Important fields:

Entry array[16] – the streams it is following

Important methods: none over BaseCache

Prefetcher will issue its own MemReqs to parents

Validated against Westmere

Page 100: ZSIM TUTORIAL MEMORY SYSTEMzsim.csail.mit.edu/tutorial/slides/memory.pdf · Example: “A day in the life of a memory request” 4 Core Memory Core L1I L1D L1I L1D Cache Array Replac

Important ZSim memory classes28

MemReq

InvReq

MemObject

SimpleMemory MD1Memory DDRMemory BaseCache

Cache NUCACache StreamPrefetcher

“is a”

Page 101: ZSIM TUTORIAL MEMORY SYSTEMzsim.csail.mit.edu/tutorial/slides/memory.pdf · Example: “A day in the life of a memory request” 4 Core Memory Core L1I L1D L1I L1D Cache Array Replac

Important ZSim memory classes28

MemReq

InvReq

MemObject

SimpleMemory MD1Memory DDRMemory BaseCache

Cache NUCACache StreamPrefetcher

TimingCache

NonInclusiveCache

FilterCache

“is a”

Page 102: ZSIM TUTORIAL MEMORY SYSTEMzsim.csail.mit.edu/tutorial/slides/memory.pdf · Example: “A day in the life of a memory request” 4 Core Memory Core L1I L1D L1I L1D Cache Array Replac

Other caches29

NonInclusiveCache – self explanatory, requires separate directory for

coherence

TimingCache – adds weave-phase models for cache contention

FilterCache – boundary between core models & memory models

Speeds up simulator by accelerating loads & stores

Important methods: uint64_t load/store(Address vAddr, uint64_t curCycle)

FilterCache adds a virtually-indexed, direct-mapped cache to filter accesses before

they reach the more expensive Cache-hierarchy

Filter is kept coherent and checks for timing hazards (eg, OOO store execution)

Page 103: ZSIM TUTORIAL MEMORY SYSTEMzsim.csail.mit.edu/tutorial/slides/memory.pdf · Example: “A day in the life of a memory request” 4 Core Memory Core L1I L1D L1I L1D Cache Array Replac

Important ZSim memory classes30

MemReq

InvReq

MemObject

SimpleMemory MD1Memory DDRMemory BaseCache

Cache NUCACache StreamPrefetcher

TimingCache

NonInclusiveCache

FilterCache

“is a”

“has a”

Page 104: ZSIM TUTORIAL MEMORY SYSTEMzsim.csail.mit.edu/tutorial/slides/memory.pdf · Example: “A day in the life of a memory request” 4 Core Memory Core L1I L1D L1I L1D Cache Array Replac

Important ZSim memory classes30

MemReq

InvReq

MemObject

SimpleMemory MD1Memory DDRMemory BaseCache

Cache NUCACache StreamPrefetcher

TimingCache

NonInclusiveCache

FilterCache

“is a”

“has a”

CacheArray

Page 105: ZSIM TUTORIAL MEMORY SYSTEMzsim.csail.mit.edu/tutorial/slides/memory.pdf · Example: “A day in the life of a memory request” 4 Core Memory Core L1I L1D L1I L1D Cache Array Replac

CacheArray31

Implements a tag array with different organizations

Important fields: None

Important methods:

int32_t lookup(…) – does the array hold this address? If so, which line is it?

uint32_t preinsert(…) – make space (i.e., find a victim to evict)

void postinsert(…) – allocate space (i.e., finalize eviction)

Replacement split into phases to avoid invalidation races

ZSim supports set associative, fully associative, zcaches

Compressed caches in development

Page 106: ZSIM TUTORIAL MEMORY SYSTEMzsim.csail.mit.edu/tutorial/slides/memory.pdf · Example: “A day in the life of a memory request” 4 Core Memory Core L1I L1D L1I L1D Cache Array Replac

Important ZSim memory classes32

MemReq

InvReq

MemObject

SimpleMemory MD1Memory DDRMemory BaseCache

Cache NUCACache StreamPrefetcher

TimingCache

NonInclusiveCache

FilterCache

“is a”

“has a”

CacheArray

Page 107: ZSIM TUTORIAL MEMORY SYSTEMzsim.csail.mit.edu/tutorial/slides/memory.pdf · Example: “A day in the life of a memory request” 4 Core Memory Core L1I L1D L1I L1D Cache Array Replac

Important ZSim memory classes32

MemReq

InvReq

MemObject

SimpleMemory MD1Memory DDRMemory BaseCache

Cache NUCACache StreamPrefetcher

TimingCache

NonInclusiveCache

FilterCache

“is a”

“has a”

CacheArray ReplPolicy

Page 108: ZSIM TUTORIAL MEMORY SYSTEMzsim.csail.mit.edu/tutorial/slides/memory.pdf · Example: “A day in the life of a memory request” 4 Core Memory Core L1I L1D L1I L1D Cache Array Replac

ReplPolicy33

The replacement policy

Important fields: None

Important methods:

void update(uint32_t id, const MemReq* req) – called upon hit

void replaced(uint32_t id) – called upon eviction

template<class C> uint32_t rankCands(const MemReq* req, C cands) – find a victim

For performance, this is optimized at compile time to different arrays

Different versions auto-generated from DECL_RANK_BINDINGS() macro

ZSim supports LRU, pseudo-LRU, NRU, LFU, random, SRRIP, DRRIP, SHiP, PDP,

and many more!

Page 109: ZSIM TUTORIAL MEMORY SYSTEMzsim.csail.mit.edu/tutorial/slides/memory.pdf · Example: “A day in the life of a memory request” 4 Core Memory Core L1I L1D L1I L1D Cache Array Replac

Example: Implementing LRU34

Timestamp-based implementation, evict the oldest line

class LRUReplPolicy : public ReplPolicy {

uint64_t timestamp; // global access count

uint64_t* array; // last-use timestamp per line

uint64_t numLines;

public:

explicit LRUReplPolicy(uint32_t _numLines) : timestamp(1), numLines(_numLines) {

array = gm_calloc<uint64_t>(numLines);

}

~LRUReplPolicy() { gm_free(array); }

void update(uint32_t id, const MemReq* req) { // called upon hit

array[id] = timestamp++;

}

void replaced(uint32_t id) { // called upon eviction

array[id] = 0;

}

Page 110: ZSIM TUTORIAL MEMORY SYSTEMzsim.csail.mit.edu/tutorial/slides/memory.pdf · Example: “A day in the life of a memory request” 4 Core Memory Core L1I L1D L1I L1D Cache Array Replac

Example: Implementing LRU35

Timestamp-based implementation, evict the oldest line

template<typename C>

uint32_t uint32_t rank(const MemReq* req, C cands) {

uint32_t bestCand = -1;

for (auto ci = cands.begin(); ci != cands.end(); ci++) {

if (array[*ci] == 0) { return *ci; }

else if (timestamp – array[*ci] <

timestamp – array[bestCand]) {

bestCand = *ci;

}

}

return bestCand;

}

DECL_RANK_BINDINGS();

};

Page 111: ZSIM TUTORIAL MEMORY SYSTEMzsim.csail.mit.edu/tutorial/slides/memory.pdf · Example: “A day in the life of a memory request” 4 Core Memory Core L1I L1D L1I L1D Cache Array Replac

Important ZSim memory classes36

MemReq

InvReq

MemObject

SimpleMemory MD1Memory DDRMemory BaseCache

Cache NUCACache StreamPrefetcher

TimingCache

NonInclusiveCache

FilterCache

“is a”

“has a”

CacheArray ReplPolicy

Page 112: ZSIM TUTORIAL MEMORY SYSTEMzsim.csail.mit.edu/tutorial/slides/memory.pdf · Example: “A day in the life of a memory request” 4 Core Memory Core L1I L1D L1I L1D Cache Array Replac

Important ZSim memory classes36

MemReq

InvReq

MemObject

SimpleMemory MD1Memory DDRMemory BaseCache

Cache NUCACache StreamPrefetcher

TimingCache

NonInclusiveCache

FilterCache

“is a”

“has a”

CacheArray ReplPolicy

PartReplPolicy

PartitionMonitor

Page 113: ZSIM TUTORIAL MEMORY SYSTEMzsim.csail.mit.edu/tutorial/slides/memory.pdf · Example: “A day in the life of a memory request” 4 Core Memory Core L1I L1D L1I L1D Cache Array Replac

PartReplPolicy37

ZSim implements cache partitioning in the replacement policy

Important fields:

PartitionMapper* mapper – maps MemReqs to a partition

PartitionMonitor* monitor – measure stats about different partitions, e.g. miss curves

Important methods:

void setPartitionSizes(const uint32_t* sizes) – reset partition sizes

ZSim supports way partitioning, idealized LRU partitioning, and Vantage

Page 114: ZSIM TUTORIAL MEMORY SYSTEMzsim.csail.mit.edu/tutorial/slides/memory.pdf · Example: “A day in the life of a memory request” 4 Core Memory Core L1I L1D L1I L1D Cache Array Replac

Important ZSim memory classes38

MemReq

InvReq

MemObject

SimpleMemory MD1Memory DDRMemory BaseCache

Cache NUCACache StreamPrefetcher

TimingCache

NonInclusiveCache

FilterCache

“is a”

“has a”

CacheArray ReplPolicy

PartReplPolicy

PartitionMonitor

Page 115: ZSIM TUTORIAL MEMORY SYSTEMzsim.csail.mit.edu/tutorial/slides/memory.pdf · Example: “A day in the life of a memory request” 4 Core Memory Core L1I L1D L1I L1D Cache Array Replac

Important ZSim memory classes38

MemReq

InvReq

MemObject

SimpleMemory MD1Memory DDRMemory BaseCache

Cache NUCACache StreamPrefetcher

TimingCache

NonInclusiveCache

FilterCache

“is a”

“has a”

CacheArray ReplPolicy

PartReplPolicy

PartitionMonitor

CC

MESITopCC MESIBottomCC

MESICC

Page 116: ZSIM TUTORIAL MEMORY SYSTEMzsim.csail.mit.edu/tutorial/slides/memory.pdf · Example: “A day in the life of a memory request” 4 Core Memory Core L1I L1D L1I L1D Cache Array Replac

CC39

Implements coherence across cache levels

Important fields: None

Important methods: void setParents/setChildren(…) – similar to Cache

bool startAccess(MemReq& req)

bool shouldAllocate(const MemReq& req)

uint64_t processEviction(…)

uint64_t processAccess(…)

void endAccess(const MemReq& req)

void startInv()

uint64_t processInv(…)

uint64_t numSharers(uint32_t lineId)

bool isValid(uint32_t lineId)

MESIState getState(uint32_t lineId)

bool isSharer(uint32_t lineId, uint32_t childId)

Page 117: ZSIM TUTORIAL MEMORY SYSTEMzsim.csail.mit.edu/tutorial/slides/memory.pdf · Example: “A day in the life of a memory request” 4 Core Memory Core L1I L1D L1I L1D Cache Array Replac

CC39

Implements coherence across cache levels

Important fields: None

Important methods: void setParents/setChildren(…) – similar to Cache

bool startAccess(MemReq& req)

bool shouldAllocate(const MemReq& req)

uint64_t processEviction(…)

uint64_t processAccess(…)

void endAccess(const MemReq& req)

void startInv()

uint64_t processInv(…)

uint64_t numSharers(uint32_t lineId)

bool isValid(uint32_t lineId)

MESIState getState(uint32_t lineId)

bool isSharer(uint32_t lineId, uint32_t childId)

Regular accesses

Page 118: ZSIM TUTORIAL MEMORY SYSTEMzsim.csail.mit.edu/tutorial/slides/memory.pdf · Example: “A day in the life of a memory request” 4 Core Memory Core L1I L1D L1I L1D Cache Array Replac

CC39

Implements coherence across cache levels

Important fields: None

Important methods: void setParents/setChildren(…) – similar to Cache

bool startAccess(MemReq& req)

bool shouldAllocate(const MemReq& req)

uint64_t processEviction(…)

uint64_t processAccess(…)

void endAccess(const MemReq& req)

void startInv()

uint64_t processInv(…)

uint64_t numSharers(uint32_t lineId)

bool isValid(uint32_t lineId)

MESIState getState(uint32_t lineId)

bool isSharer(uint32_t lineId, uint32_t childId)

Regular accesses

Invalidations

Page 119: ZSIM TUTORIAL MEMORY SYSTEMzsim.csail.mit.edu/tutorial/slides/memory.pdf · Example: “A day in the life of a memory request” 4 Core Memory Core L1I L1D L1I L1D Cache Array Replac

CC39

Implements coherence across cache levels

Important fields: None

Important methods: void setParents/setChildren(…) – similar to Cache

bool startAccess(MemReq& req)

bool shouldAllocate(const MemReq& req)

uint64_t processEviction(…)

uint64_t processAccess(…)

void endAccess(const MemReq& req)

void startInv()

uint64_t processInv(…)

uint64_t numSharers(uint32_t lineId)

bool isValid(uint32_t lineId)

MESIState getState(uint32_t lineId)

bool isSharer(uint32_t lineId, uint32_t childId)

Regular accesses

Invalidations

Querying (e.g., ReplPolicies)

Page 120: ZSIM TUTORIAL MEMORY SYSTEMzsim.csail.mit.edu/tutorial/slides/memory.pdf · Example: “A day in the life of a memory request” 4 Core Memory Core L1I L1D L1I L1D Cache Array Replac

CC naming convention40

Top Parent

Bottom Child

L2

L3

MESITopCC

MESIBottomCC

MESITopCC

MESIBottomCC

Page 121: ZSIM TUTORIAL MEMORY SYSTEMzsim.csail.mit.edu/tutorial/slides/memory.pdf · Example: “A day in the life of a memory request” 4 Core Memory Core L1I L1D L1I L1D Cache Array Replac

Important ZSim memory classes41

MemReq

InvReq

MemObject

SimpleMemory MD1Memory DDRMemory BaseCache

Cache NUCACache StreamPrefetcher

TimingCache

NonInclusiveCache

FilterCache

“is a”

“has a”

CacheArray ReplPolicy

PartReplPolicy

PartitionMonitor

CC

MESITopCC

MESICC

Page 122: ZSIM TUTORIAL MEMORY SYSTEMzsim.csail.mit.edu/tutorial/slides/memory.pdf · Example: “A day in the life of a memory request” 4 Core Memory Core L1I L1D L1I L1D Cache Array Replac

Important ZSim memory classes41

MemReq

InvReq

MemObject

SimpleMemory MD1Memory DDRMemory BaseCache

Cache NUCACache StreamPrefetcher

TimingCache

NonInclusiveCache

FilterCache

“is a”

“has a”

CacheArray ReplPolicy

PartReplPolicy

PartitionMonitor

CC

MESITopCC MESIBottomCC

MESICC MESITerminalCC MESIDirCC

Page 123: ZSIM TUTORIAL MEMORY SYSTEMzsim.csail.mit.edu/tutorial/slides/memory.pdf · Example: “A day in the life of a memory request” 4 Core Memory Core L1I L1D L1I L1D Cache Array Replac

Important ZSim memory classes42

MemReq

InvReq

MemObject

SimpleMemory MD1Memory DDRMemory BaseCache

Cache NUCACache StreamPrefetcher

TimingCache

NonInclusiveCache

FilterCache

“is a”

“has a”

CacheArray ReplPolicy

PartReplPolicy

PartitionMonitor

CC

MESITopCC MESIBottomCC

MESICC MESITerminalCC MESIDirCC

Page 124: ZSIM TUTORIAL MEMORY SYSTEMzsim.csail.mit.edu/tutorial/slides/memory.pdf · Example: “A day in the life of a memory request” 4 Core Memory Core L1I L1D L1I L1D Cache Array Replac

Important ZSim memory classes42

MemReq

InvReq

MemObject

SimpleMemory MD1Memory DDRMemory BaseCache

Cache NUCACache StreamPrefetcher

TimingCache

NonInclusiveCache

FilterCache

“is a”

“has a”

CacheArray ReplPolicy

PartReplPolicy

PartitionMonitor

CC

MESITopCC MESIBottomCC

Network

MESICC MESITerminalCC MESIDirCC

Page 125: ZSIM TUTORIAL MEMORY SYSTEMzsim.csail.mit.edu/tutorial/slides/memory.pdf · Example: “A day in the life of a memory request” 4 Core Memory Core L1I L1D L1I L1D Cache Array Replac

Network43

Tracks round-trip latency between objects in the target system

ZSim does not currently model network contention

Important fields:

string uint32_t delayMap – maps object pairs (by name) to their round-trip

communication latency

Important methods:

Network(const char* filename) – initialize from a network file

uint32_t getRTT(const char* src, const char* dst) – Look up network latency

Will show example network file in Config session later

Page 126: ZSIM TUTORIAL MEMORY SYSTEMzsim.csail.mit.edu/tutorial/slides/memory.pdf · Example: “A day in the life of a memory request” 4 Core Memory Core L1I L1D L1I L1D Cache Array Replac

ZSim memory system44

Class Is a What is it? File

MemReq An in-flight memory request going up the cache hierarchy memory_hierarchy.h

MemObject Base object for anything that takes MemReqs. Provides access method. memory_hierarchy.h

SimpleMemory MemObject Fixed-latency main memory. mem_ctrls.h

MD1Memory MemObject M/D/1 queuing latency model for main memory. mem_ctrls.h

DDRMemory MemObject Full DDR timing simulation, requires TimingEvents. ddr_mem.h

InvReq An invalidation going down the cache hierarchy memory_hierarchy.h

BaseCache MemObject Base object for caches, prefetchers, etc. Provides setChildren/Parents and invalidate methods. memory_hierarchy.h

Cache BaseCache An inclusive cache. cache.h

NonInclusiveCache Cache A non-inclusive cache. non_incl_cache.h

TimingCache Cache Connects timing events through hierarchy for DDR memory models. timing_cache.h

FilterCache Cache Implements optimized load/store methods for efficiency. filter_cache.h

NUCACache BaseCache Cache with distributed banks internally. Maps addresses to banks via BankDir object. nuca_cache.h

StreamPrefetcher BaseCache Streaming prefetcher. prefetcher.h

CacheArray Tracks addresses in cache and structure of array. cache_arrays.h

ReplPolicy A replacement policy. Notified of accesses/evictions through update/replaced methods. Chooses

victim in rankCands method.

repl_policies.h

PartReplPolicy ReplPolicy Implements cache partitioning. Adds setPartitionSizes method and monitoring. part_repl_policies.h

PartitionMonitor Monitors partition miss curves. Provides access and getMissCurve methods. monitor.h

Network getRTT method provides (fixed) latency between two modeled objects. network.h

CC Generic coherence controller (zsim implements MESI). coherence_ctrls.h