cache

package
v3.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 6, 2024 License: MIT Imports: 5 Imported by: 5

Documentation

Overview

Package cache provides the basic commonly used utility data structures for cache implementation.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Block

type Block struct {
	PID          vm.PID
	Tag          uint64
	WayID        int
	SetID        int
	CacheAddress uint64
	IsValid      bool
	IsDirty      bool
	ReadCount    int
	IsLocked     bool
	DirtyMask    []bool
}

A Block of a cache is the information that is associated with a cache line

type Directory

type Directory interface {
	Lookup(pid vm.PID, address uint64) *Block
	FindVictim(address uint64) *Block
	Visit(block *Block)
	TotalSize() uint64
	WayAssociativity() int
	GetSets() []Set
	Reset()
}

A Directory stores the information about what is stored in the cache.

type DirectoryImpl

type DirectoryImpl struct {
	NumSets       int
	NumWays       int
	BlockSize     int
	AddrConverter mem.AddressConverter

	Sets []Set
	// contains filtered or unexported fields
}

A DirectoryImpl is the default implementation of a Directory

The directory can translate from the request address (can be either virtual address or physical address) to the cache based address.

func NewDirectory

func NewDirectory(
	set, way, blockSize int,
	victimFinder VictimFinder,
) *DirectoryImpl

NewDirectory returns a new directory object

func (*DirectoryImpl) FindVictim

func (d *DirectoryImpl) FindVictim(addr uint64) *Block

FindVictim returns a block that can be used to stored data at address addr.

If it is valid, the cache controller need to decide what to do to evict the the data in the block

func (*DirectoryImpl) GetSets

func (d *DirectoryImpl) GetSets() []Set

GetSets returns all the sets in a directory

func (*DirectoryImpl) Lookup

func (d *DirectoryImpl) Lookup(PID vm.PID, reqAddr uint64) *Block

Lookup finds the block that reqAddr. If the reqAddr is valid in the cache, return the block information. Otherwise, return nil

func (*DirectoryImpl) Reset

func (d *DirectoryImpl) Reset()

Reset will mark all the blocks in the directory invalid

func (*DirectoryImpl) TotalSize

func (d *DirectoryImpl) TotalSize() uint64

TotalSize returns the maximum number of bytes can be stored in the cache

func (*DirectoryImpl) Visit

func (d *DirectoryImpl) Visit(block *Block)

Visit moves the block to the end of the LRUQueue

func (*DirectoryImpl) WayAssociativity

func (d *DirectoryImpl) WayAssociativity() int

WayAssociativity returns the number of ways per set in the cache.

type FlushReq

type FlushReq struct {
	sim.MsgMeta
	InvalidateAllCachelines bool
	DiscardInflight         bool
	PauseAfterFlushing      bool
}

FlushReq is the request send to a cache unit to request it to flush all the cache lines.

func (*FlushReq) Meta

func (r *FlushReq) Meta() *sim.MsgMeta

Meta returns the meta data associated with the message.

type FlushReqBuilder

type FlushReqBuilder struct {
	// contains filtered or unexported fields
}

FlushReqBuilder can build flush requests.

func (FlushReqBuilder) Build

func (b FlushReqBuilder) Build() *FlushReq

Build creates a new FlushReq

func (FlushReqBuilder) DiscardInflight

func (b FlushReqBuilder) DiscardInflight() FlushReqBuilder

DiscardInflight allows the flush request to build to discard all inflight requests.

func (FlushReqBuilder) InvalidateAllCacheLines

func (b FlushReqBuilder) InvalidateAllCacheLines() FlushReqBuilder

InvalidateAllCacheLines allows the flush request to build to invalidate all the cachelines in a cache unit.

func (FlushReqBuilder) PauseAfterFlushing

func (b FlushReqBuilder) PauseAfterFlushing() FlushReqBuilder

PauseAfterFlushing sets the flush request to build to pause the cache unit from processing future request until restart request is received.

func (FlushReqBuilder) WithDst

func (b FlushReqBuilder) WithDst(dst sim.Port) FlushReqBuilder

WithDst sets the destination of the message to build.

func (FlushReqBuilder) WithSendTime

func (b FlushReqBuilder) WithSendTime(t sim.VTimeInSec) FlushReqBuilder

WithSendTime sets the send time of the message to build.

func (FlushReqBuilder) WithSrc

func (b FlushReqBuilder) WithSrc(src sim.Port) FlushReqBuilder

WithSrc sets the source of the message to build

type FlushRsp

type FlushRsp struct {
	sim.MsgMeta
	RspTo string
}

FlushRsp is the respond sent from the a cache unit for finishing a cache flush

func (*FlushRsp) Meta

func (r *FlushRsp) Meta() *sim.MsgMeta

Meta returns the meta data associated with the message.

type FlushRspBuilder

type FlushRspBuilder struct {
	// contains filtered or unexported fields
}

FlushRspBuilder can build data ready responds.

func (FlushRspBuilder) Build

func (b FlushRspBuilder) Build() *FlushRsp

Build creates a new FlushRsp

func (FlushRspBuilder) WithDst

func (b FlushRspBuilder) WithDst(dst sim.Port) FlushRspBuilder

WithDst sets the destination of the request to build.

func (FlushRspBuilder) WithRspTo

func (b FlushRspBuilder) WithRspTo(id string) FlushRspBuilder

WithRspTo sets ID of the request that the respond to build is replying to.

func (FlushRspBuilder) WithSendTime

func (b FlushRspBuilder) WithSendTime(
	t sim.VTimeInSec,
) FlushRspBuilder

WithSendTime sets the send time of the message to build.

func (FlushRspBuilder) WithSrc

func (b FlushRspBuilder) WithSrc(src sim.Port) FlushRspBuilder

WithSrc sets the source of the request to build.

type LRUVictimFinder

type LRUVictimFinder struct {
}

LRUVictimFinder evicts the least recently used block to evict

func NewLRUVictimFinder

func NewLRUVictimFinder() *LRUVictimFinder

NewLRUVictimFinder returns a newly constructed lru evictor

func (*LRUVictimFinder) FindVictim

func (e *LRUVictimFinder) FindVictim(set *Set) *Block

FindVictim returns the least recently used block in a set

type MSHR

type MSHR interface {
	Query(pid vm.PID, addr uint64) *MSHREntry
	Add(pid vm.PID, addr uint64) *MSHREntry
	Remove(pid vm.PID, addr uint64) *MSHREntry
	AllEntries() []*MSHREntry
	IsFull() bool
	Reset()
}

MSHR is an interface that controls MSHR entries

func NewMSHR

func NewMSHR(capacity int) MSHR

NewMSHR returns a new MSHR object

type MSHREntry

type MSHREntry struct {
	PID       vm.PID
	Address   uint64
	Requests  []interface{}
	Block     *Block
	ReadReq   *mem.ReadReq
	DataReady *mem.DataReadyRsp
	Data      []byte
}

MSHREntry is an entry in MSHR

func NewMSHREntry

func NewMSHREntry() *MSHREntry

NewMSHREntry returns a new MSHR entry object

type RestartReq

type RestartReq struct {
	sim.MsgMeta
}

RestartReq is the request send to a cache unit to request it unpause the cache

func (*RestartReq) Meta

func (r *RestartReq) Meta() *sim.MsgMeta

Meta returns the meta data associated with the message.

type RestartReqBuilder

type RestartReqBuilder struct {
	// contains filtered or unexported fields
}

RestartReqBuilder can build data ready responds.

func (RestartReqBuilder) Build

func (b RestartReqBuilder) Build() *RestartReq

Build creates a new RestartReq

func (RestartReqBuilder) WithDst

WithDst sets the destination of the request to build.

func (RestartReqBuilder) WithSendTime

func (b RestartReqBuilder) WithSendTime(
	t sim.VTimeInSec,
) RestartReqBuilder

WithSendTime sets the send time of the message to build.

func (RestartReqBuilder) WithSrc

WithSrc sets the source of the request to build.

type RestartRsp

type RestartRsp struct {
	sim.MsgMeta
	RspTo string
}

RestartRsp is the respond sent from the a cache unit for finishing a cache flush

func (*RestartRsp) Meta

func (r *RestartRsp) Meta() *sim.MsgMeta

Meta returns the meta data associated with the message.

type RestartRspBuilder

type RestartRspBuilder struct {
	// contains filtered or unexported fields
}

RestartRspBuilder can build data ready responds.

func (RestartRspBuilder) Build

func (b RestartRspBuilder) Build() *RestartRsp

Build creates a new RestartRsp

func (RestartRspBuilder) WithDst

WithDst sets the destination of the request to build.

func (RestartRspBuilder) WithRspTo

func (b RestartRspBuilder) WithRspTo(id string) RestartRspBuilder

WithRspTo sets ID of the request that the respond to build is replying to.

func (RestartRspBuilder) WithSendTime

func (b RestartRspBuilder) WithSendTime(
	t sim.VTimeInSec,
) RestartRspBuilder

WithSendTime sets the send time of the message to build.

func (RestartRspBuilder) WithSrc

WithSrc sets the source of the request to build.

type Set

type Set struct {
	Blocks   []*Block
	LRUQueue []*Block
}

A Set is a list of blocks where a certain piece memory can be stored at

type VictimFinder

type VictimFinder interface {
	FindVictim(set *Set) *Block
}

A VictimFinder decides with block should be evicted

Directories

Path Synopsis
Package writearound provides a GCN3 GPU L1 cache implementation.
Package writearound provides a GCN3 GPU L1 cache implementation.
Package writeback implements a writeback cache.
Package writeback implements a writeback cache.
Package writeevict provides a RDNA GPU L1 cache implementation.
Package writeevict provides a RDNA GPU L1 cache implementation.
Package writethrough provides a GCN3 GPU L1 cache implementation.
Package writethrough provides a GCN3 GPU L1 cache implementation.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL