cache

package
v1.8.2 Latest Latest
Warning

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

Go to latest
Published: Mar 26, 2020 License: MIT Imports: 5 Imported by: 0

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

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 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

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 {
	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

func (r *FlushReq) Meta() *akita.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 akita.Port) FlushReqBuilder

WithDst sets the destination of the message to build.

func (FlushReqBuilder) WithSendTime

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

WithSendTime sets the send time of the message to build.

func (FlushReqBuilder) WithSrc

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

WithSrc sets the source of the message to build

type FlushRsp

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

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

Meta returns the meta data accociated 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 akita.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 akita.VTimeInSec,
) FlushRspBuilder

WithSendTime sets the send time of the message to build.

func (FlushRspBuilder) WithSrc

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

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 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

type RestartReq struct {
	akita.MsgMeta
}

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

func (*RestartReq) Meta

func (r *RestartReq) Meta() *akita.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 akita.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 {
	akita.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() *akita.MsgMeta

Meta returns the meta data accociated 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 akita.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 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

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

A VictimFinder decides with block should be evicted

Directories

Path Synopsis
Package writeback implement a writeback cache.=
Package writeback implement a writeback cache.=

Jump to

Keyboard shortcuts

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