cache

package
v1.12.0 Latest Latest
Warning

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

Go to latest
Published: Mar 10, 2021 License: MIT Imports: 5 Imported by: 17

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 BankedLowModuleFinder

type BankedLowModuleFinder struct {
	BankSize   uint64
	LowModules []akita.Port
}

BankedLowModuleFinder defines the lower level modules by address banks

func NewBankedLowModuleFinder

func NewBankedLowModuleFinder(bankSize uint64) *BankedLowModuleFinder

NewBankedLowModuleFinder returns a new BankedLowModuleFinder.

func (*BankedLowModuleFinder) Find

func (f *BankedLowModuleFinder) Find(address uint64) akita.Port

Find returns the port that can provide the data.

type Block

type Block struct {
	PID          ca.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 ca.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

	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 added in v1.1.5

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 added in v1.1.5

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

GetSets returns all the sets in a directory

func (*DirectoryImpl) Lookup

func (d *DirectoryImpl) Lookup(PID ca.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 added in v1.1.5

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 added in v1.1.5

type FlushReq struct {
	akita.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 added in v1.3.0

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

Meta returns the meta data associated with the message.

type FlushReqBuilder added in v1.3.0

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

FlushReqBuilder can build flush requests.

func (FlushReqBuilder) Build added in v1.3.0

func (b FlushReqBuilder) Build() *FlushReq

Build creates a new FlushReq

func (FlushReqBuilder) DiscardInflight added in v1.3.0

func (b FlushReqBuilder) DiscardInflight() FlushReqBuilder

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

func (FlushReqBuilder) InvalidateAllCacheLines added in v1.3.0

func (b FlushReqBuilder) InvalidateAllCacheLines() FlushReqBuilder

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

func (FlushReqBuilder) PauseAfterFlushing added in v1.3.0

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 added in v1.3.0

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

WithDst sets the destination of the message to build.

func (FlushReqBuilder) WithSendTime added in v1.3.0

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

WithSendTime sets the send time of the message to build.

func (FlushReqBuilder) WithSrc added in v1.3.0

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

WithSrc sets the source of the message to build

type FlushRsp added in v1.1.5

type FlushRsp struct {
	akita.MsgMeta
	RspTo string
}

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

func (*FlushRsp) Meta added in v1.3.0

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

Meta returns the meta data accociated with the message.

type FlushRspBuilder added in v1.3.0

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

FlushRspBuilder can build data ready responds.

func (FlushRspBuilder) Build added in v1.3.0

func (b FlushRspBuilder) Build() *FlushRsp

Build creates a new FlushRsp

func (FlushRspBuilder) WithDst added in v1.3.0

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

WithDst sets the destination of the request to build.

func (FlushRspBuilder) WithRspTo added in v1.3.0

func (b FlushRspBuilder) WithRspTo(id string) FlushRspBuilder

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

func (FlushRspBuilder) WithSendTime added in v1.3.0

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

WithSendTime sets the send time of the message to build.

func (FlushRspBuilder) WithSrc added in v1.3.0

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

WithSrc sets the source of the request to build.

type InterleavedLowModuleFinder

type InterleavedLowModuleFinder struct {
	UseAddressSpaceLimitation bool
	LowAddress                uint64
	HighAddress               uint64
	InterleavingSize          uint64
	LowModules                []akita.Port
	ModuleForOtherAddresses   akita.Port
}

InterleavedLowModuleFinder helps find the low module when the low modules maintains interleaved address space

func NewInterleavedLowModuleFinder

func NewInterleavedLowModuleFinder(interleavingSize uint64) *InterleavedLowModuleFinder

NewInterleavedLowModuleFinder creates a new finder for interleaved lower modules

func (*InterleavedLowModuleFinder) Find

func (f *InterleavedLowModuleFinder) Find(address uint64) akita.Port

Find returns the low module that has the data at provided address

type LRUVictimFinder added in v1.1.5

type LRUVictimFinder struct {
}

LRUVictimFinder evicts the least recently used block to evict

func NewLRUVictimFinder added in v1.1.5

func NewLRUVictimFinder() *LRUVictimFinder

NewLRUVictimFinder returns a newly constructed lru evictor

func (*LRUVictimFinder) FindVictim added in v1.1.5

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

FindVictim returns the least recently used block in a set

type LowModuleFinder

type LowModuleFinder interface {
	Find(address uint64) akita.Port
}

LowModuleFinder helps a cache unit or a akita to find the low module that should hold the data at a certain address

type MSHR

type MSHR interface {
	Query(pid ca.PID, addr uint64) *MSHREntry
	Add(pid ca.PID, addr uint64) *MSHREntry
	Remove(pid ca.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       ca.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 added in v1.2.3

type RestartReq struct {
	akita.MsgMeta
}

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

func (*RestartReq) Meta added in v1.3.0

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

Meta returns the meta data associated with the message.

type RestartReqBuilder added in v1.3.0

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

RestartReqBuilder can build data ready responds.

func (RestartReqBuilder) Build added in v1.3.0

func (b RestartReqBuilder) Build() *RestartReq

Build creates a new RestartReq

func (RestartReqBuilder) WithDst added in v1.3.0

WithDst sets the destination of the request to build.

func (RestartReqBuilder) WithSendTime added in v1.3.0

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

WithSendTime sets the send time of the message to build.

func (RestartReqBuilder) WithSrc added in v1.3.0

WithSrc sets the source of the request to build.

type RestartRsp added in v1.2.3

type RestartRsp struct {
	akita.MsgMeta
	RspTo string
}

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

func (*RestartRsp) Meta added in v1.3.0

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

Meta returns the meta data accociated with the message.

type RestartRspBuilder added in v1.3.0

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

RestartRspBuilder can build data ready responds.

func (RestartRspBuilder) Build added in v1.3.0

func (b RestartRspBuilder) Build() *RestartRsp

Build creates a new RestartRsp

func (RestartRspBuilder) WithDst added in v1.3.0

WithDst sets the destination of the request to build.

func (RestartRspBuilder) WithRspTo added in v1.3.0

func (b RestartRspBuilder) WithRspTo(id string) RestartRspBuilder

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

func (RestartRspBuilder) WithSendTime added in v1.3.0

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

WithSendTime sets the send time of the message to build.

func (RestartRspBuilder) WithSrc added in v1.3.0

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 SingleLowModuleFinder

type SingleLowModuleFinder struct {
	LowModule akita.Port
}

SingleLowModuleFinder is used when a unit is connected with only one low module

func (*SingleLowModuleFinder) Find

func (f *SingleLowModuleFinder) Find(address uint64) akita.Port

Find simply returns the solo unit that it connects to

type VictimFinder added in v1.1.5

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

A VictimFinder decides with block should be evicted

Directories

Path Synopsis
Package writeback implements a writeback cache.
Package writeback implements a writeback cache.

Jump to

Keyboard shortcuts

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