Documentation
¶
Index ¶
- Constants
- func BuildChampSimCoherenceTree(cpuNodeIDs []int, l2NodeID int, memCtrlNodeID int, dramNodeIDs []int, ...) (*coherence.CoherenceTree, error)
- func BuildChampSimCoherenceTreeWithHADirectory(cpuNodeIDs []int, l2NodeID int, haNodeID int, dramNodeIDs []int, ...) (*coherence.CoherenceTree, error)
- func BuildRingCoherenceTree(config RingTopologyConfig, nodeIDs *RingTopologyNodeIDs, ...) (*coherence.CoherenceTree, error)
- func GetCPUToL2Mapping(config RingTopologyConfig, nodeIDs *RingTopologyNodeIDs) map[int]int
- func GetHAToDRAMMapping(nodeIDs *RingTopologyNodeIDs) map[int]int
- func GetL2ToL3Mapping(config RingTopologyConfig, nodeIDs *RingTopologyNodeIDs) map[int]int
- func GetL3ToHAMapping(nodeIDs *RingTopologyNodeIDs) map[int]int
- func GetRingNeighbors(nodeIDs *RingTopologyNodeIDs, haID int) (int, int)
- func NewMemoryRequestPacket(sourceID, targetID int, addr, vaddr, instrID uint64, isWrite bool, data uint64) packet.Packet
- func NewMemoryResponsePacket(sourceID, targetID int, addr, data, instrID, cycle uint64) packet.Packet
- type AddressMappingStrategy
- type CPUNodeHandler
- type DRAMNodeHandler
- type FlowSimMemoryAdapter
- type L2CacheNodeHandler
- type L2CacheStats
- type MemoryControllerHandler
- type MemoryControllerStats
- type MemoryRequestPayload
- type MemoryResponsePayload
- type RingTopologyConfig
- type RingTopologyNodeIDs
Constants ¶
const ( PacketTypeMemoryRequest = 1 // 内存请求(Load/Store) PacketTypeMemoryResponse = 2 // 内存响应(Fill) )
Packet 类型常量
Variables ¶
This section is empty.
Functions ¶
func BuildChampSimCoherenceTree ¶
func BuildChampSimCoherenceTree( cpuNodeIDs []int, l2NodeID int, memCtrlNodeID int, dramNodeIDs []int, config coherence.AddressMappingConfig, ) (*coherence.CoherenceTree, error)
BuildChampSimCoherenceTree 为 ChampSim 拓扑构建一致性树 参数:
- cpuNodeIDs: CPU 节点 IDs
- l2NodeID: L2 Cache 节点 ID(带 Directory)
- memCtrlNodeID: Memory Controller 节点 ID
- dramNodeIDs: DRAM 节点 IDs
- config: 地址映射配置
func BuildChampSimCoherenceTreeWithHADirectory ¶
func BuildChampSimCoherenceTreeWithHADirectory( cpuNodeIDs []int, l2NodeID int, haNodeID int, dramNodeIDs []int, config coherence.AddressMappingConfig, ) (*coherence.CoherenceTree, error)
BuildChampSimCoherenceTreeWithHADirectory 为 ChampSim 拓扑构建一致性树(Directory 在 HA) 参数:
- cpuNodeIDs: CPU 节点 IDs
- l2NodeID: L2 Cache 节点 ID(无 Directory)
- haNodeID: Home Agent 节点 ID(带 Directory)
- dramNodeIDs: DRAM 节点 IDs
- config: 地址映射配置
func BuildRingCoherenceTree ¶
func BuildRingCoherenceTree( config RingTopologyConfig, nodeIDs *RingTopologyNodeIDs, addrConfig coherence.AddressMappingConfig, ) (*coherence.CoherenceTree, error)
BuildRingCoherenceTree 为 Ring 拓扑构建一致性树 每个 HA 作为一个 Directory,管理其对应的 L3 及其下属的 CPU 和 L2 添加一个虚拟根节点(ID = 1000)作为所有 HA 的父节点,用于跨 Domain 路由
func GetCPUToL2Mapping ¶
func GetCPUToL2Mapping(config RingTopologyConfig, nodeIDs *RingTopologyNodeIDs) map[int]int
GetCPUToL2Mapping 获取 CPU 到 L2 的映射关系
func GetHAToDRAMMapping ¶
func GetHAToDRAMMapping(nodeIDs *RingTopologyNodeIDs) map[int]int
GetHAToDRAMMapping 获取 HA 到 DRAM 的映射关系
func GetL2ToL3Mapping ¶
func GetL2ToL3Mapping(config RingTopologyConfig, nodeIDs *RingTopologyNodeIDs) map[int]int
GetL2ToL3Mapping 获取 L2 到 L3 的映射关系
func GetL3ToHAMapping ¶
func GetL3ToHAMapping(nodeIDs *RingTopologyNodeIDs) map[int]int
GetL3ToHAMapping 获取 L3 到 HA 的映射关系
func GetRingNeighbors ¶
func GetRingNeighbors(nodeIDs *RingTopologyNodeIDs, haID int) (int, int)
GetRingNeighbors 获取 Ring 上的邻居节点 返回 (左邻居, 右邻居)
func NewMemoryRequestPacket ¶
func NewMemoryRequestPacket( sourceID, targetID int, addr, vaddr, instrID uint64, isWrite bool, data uint64, ) packet.Packet
NewMemoryRequestPacket 创建内存请求 Packet
参数: - sourceID: 源节点ID(CPU节点) - targetID: 目标节点ID(DRAM节点) - addr: 物理地址 - vaddr: 虚拟地址 - instrID: 指令ID - isWrite: 是否为写操作 - data: 数据(仅Store时有效)
Types ¶
type AddressMappingStrategy ¶
type AddressMappingStrategy int
AddressMappingStrategy 地址映射策略
const ( // 使用地址的低位 bits 来选择通道(交错映射) MappingInterleaved AddressMappingStrategy = iota // 使用地址范围来选择通道 MappingRanged )
type CPUNodeHandler ¶
type CPUNodeHandler struct {
// contains filtered or unexported fields
}
CPUNodeHandler 实现 NodeHandler 接口
处理逻辑: 1. 接收来自DRAM的响应包,填充到Cache 2. 执行CPU的Tick,产生新的load/store请求 3. 从MemoryAdapter获取Cache miss请求,发送到DRAM
func NewCPUNodeHandler ¶
func NewCPUNodeHandler( nodeID, dramID int, cpu *cpu.O3CPU, l1dCache *cache.SetAssociativeCache, memoryAdapter *FlowSimMemoryAdapter, outputQueue *queue.OutputQueue, ) *CPUNodeHandler
NewCPUNodeHandler 创建 CPU Node Handler
参数: - nodeID: CPU节点ID - dramID: DRAM节点ID - cpu: O3CPU实例 - l1dCache: L1D Cache实例 - memoryAdapter: FlowSim Memory Adapter(连接Cache和网络) - outputQueue: 输出队列(发送到DRAM)
func (*CPUNodeHandler) GetCPUStats ¶
func (h *CPUNodeHandler) GetCPUStats() cpu.O3CPUStats
GetCPUStats 返回 CPU 统计信息
func (*CPUNodeHandler) GetCacheStats ¶
func (h *CPUNodeHandler) GetCacheStats() interface{}
GetCacheStats 返回 Cache 统计信息
type DRAMNodeHandler ¶
type DRAMNodeHandler struct {
// contains filtered or unexported fields
}
DRAMNodeHandler 实现 NodeHandler 接口
处理逻辑: 1. 接收来自CPU的内存请求 2. 将请求发送到DRAM Channel 3. 执行DRAM的Tick 4. 收集完成的请求,发送响应包回CPU
func NewDRAMNodeHandler ¶
func NewDRAMNodeHandler( nodeID, cpuID int, dramChannel *dram.DRAMChannel, outputQueue *queue.OutputQueue, ) *DRAMNodeHandler
NewDRAMNodeHandler 创建 DRAM Node Handler
参数: - nodeID: DRAM节点ID - cpuID: CPU节点ID - dramChannel: DRAM Channel实例 - outputQueue: 输出队列(发送到CPU)
func (*DRAMNodeHandler) GetDRAMStats ¶
func (h *DRAMNodeHandler) GetDRAMStats() dram.DRAMStats
GetDRAMStats 获取 DRAM 统计信息
type FlowSimMemoryAdapter ¶
type FlowSimMemoryAdapter struct {
// contains filtered or unexported fields
}
FlowSimMemoryAdapter 实现 MemoryInterface
将 Cache 的内存请求转换为待发送的网络包 不直接操作 DRAM,而是将请求加入队列
func NewFlowSimMemoryAdapter ¶
func NewFlowSimMemoryAdapter() *FlowSimMemoryAdapter
NewFlowSimMemoryAdapter 创建 FlowSim Memory Adapter
func (*FlowSimMemoryAdapter) GetPendingRequests ¶
func (a *FlowSimMemoryAdapter) GetPendingRequests() []MemoryRequestPayload
GetPendingRequests 获取所有待发送的请求
CPU Node 调用此方法来获取需要发送的请求 调用后会清空队列
func (*FlowSimMemoryAdapter) GetQueueSize ¶
func (a *FlowSimMemoryAdapter) GetQueueSize() int
GetQueueSize 获取当前队列大小(用于调试)
func (*FlowSimMemoryAdapter) SendRequest ¶
func (a *FlowSimMemoryAdapter) SendRequest(reqInterface interface{}) bool
SendRequest 实现 MemoryInterface.SendRequest
将请求添加到队列,稍后由 CPU Node 发送到网络
func (*FlowSimMemoryAdapter) SetCycle ¶
func (a *FlowSimMemoryAdapter) SetCycle(cycle uint64)
SetCycle 实现 MemoryInterface.SetCycle
func (*FlowSimMemoryAdapter) Tick ¶
func (a *FlowSimMemoryAdapter) Tick()
Tick 实现 MemoryInterface.Tick
在 flow_sim 模式下,Tick 由 Network 统一管理 这里不需要做任何事情
type L2CacheNodeHandler ¶
type L2CacheNodeHandler struct {
// contains filtered or unexported fields
}
L2CacheNodeHandler 实现共享 L2 Cache 的 NodeHandler 支持多个上游 L1 Cache 和 MESI 协议
func NewL2CacheNodeHandler ¶
func NewL2CacheNodeHandler( nodeID int, cpuNodeIDs []int, memCtrlID int, l2Cache *cache.SetAssociativeCache, outputQueues []*queue.OutputQueue, ) *L2CacheNodeHandler
NewL2CacheNodeHandler 创建 L2 Cache Node Handler
func (*L2CacheNodeHandler) GetCacheStats ¶
func (h *L2CacheNodeHandler) GetCacheStats() interface{}
GetCacheStats 获取底层 Cache 统计
func (*L2CacheNodeHandler) GetStats ¶
func (h *L2CacheNodeHandler) GetStats() L2CacheStats
GetStats 获取统计信息
type L2CacheStats ¶
type L2CacheStats struct {
Accesses uint64
Hits uint64
Misses uint64
CoherenceStats cache.CoherenceStats
InvalidatesSent uint64
Writebacks uint64
}
L2CacheStats L2 Cache 统计信息
type MemoryControllerHandler ¶
type MemoryControllerHandler struct {
// contains filtered or unexported fields
}
MemoryControllerHandler Memory Controller 节点处理器
func NewMemoryControllerHandler ¶
func NewMemoryControllerHandler( nodeID int, upstreamNodeIDs []int, dramChannelIDs []int, outputQueues []*queue.OutputQueue, strategy AddressMappingStrategy, ) *MemoryControllerHandler
NewMemoryControllerHandler 创建 Memory Controller Handler
func (*MemoryControllerHandler) GetStats ¶
func (h *MemoryControllerHandler) GetStats() MemoryControllerStats
GetStats 获取统计信息
type MemoryControllerStats ¶
type MemoryControllerStats struct {
TotalRequests uint64
RequestsPerChannel []uint64 // 每个通道的请求数
Responses uint64
}
MemoryControllerStats Memory Controller 统计
type MemoryRequestPayload ¶
type MemoryRequestPayload struct {
Address uint64 `json:"address"` // 物理地址
VAddress uint64 `json:"v_address"` // 虚拟地址
InstrID uint64 `json:"instr_id"` // 指令ID
IsWrite bool `json:"is_write"` // 是否为写操作
Data uint64 `json:"data"` // 数据(仅Store时有效)
}
MemoryRequestPayload 内存请求的 Payload
对应 ChampSim 的 DRAM_PACKET 或 Cache 的 miss request
func ParseMemoryRequestPayload ¶
func ParseMemoryRequestPayload(pkt packet.Packet) (*MemoryRequestPayload, error)
ParseMemoryRequestPayload 解析内存请求 Payload
type MemoryResponsePayload ¶
type MemoryResponsePayload struct {
Address uint64 `json:"address"` // 物理地址
Data uint64 `json:"data"` // 返回的数据
InstrID uint64 `json:"instr_id"` // 指令ID(用于通知CPU)
Cycle uint64 `json:"cycle"` // 完成周期
}
MemoryResponsePayload 内存响应的 Payload
对应 ChampSim 的 fill response
func ParseMemoryResponsePayload ¶
func ParseMemoryResponsePayload(pkt packet.Packet) (*MemoryResponsePayload, error)
ParseMemoryResponsePayload 解析内存响应 Payload
type RingTopologyConfig ¶
type RingTopologyConfig struct {
NumClusters int // L3 集群数量 (默认 8)
CPUsPerL3 int // 每个 L3 下的 CPU 数量 (默认 4)
L2PerCPU int // 每个 CPU 的 L2 数量 (默认 1)
// 节点 ID 起始位置
CPUIDStart int // CPU ID 起始 (默认 0)
L2IDStart int // L2 ID 起始 (默认 32)
L3IDStart int // L3 ID 起始 (默认 64)
HAIDStart int // HA ID 起始 (默认 72)
DRAMIDStart int // DRAM ID 起始 (默认 80)
}
RingTopologyConfig Ring 拓扑配置
func DefaultRingTopologyConfig ¶
func DefaultRingTopologyConfig() RingTopologyConfig
DefaultRingTopologyConfig 默认配置:32 核系统
type RingTopologyNodeIDs ¶
RingTopologyNodeIDs Ring 拓扑的节点 ID 集合
func BuildRingTopologyNodeIDs ¶
func BuildRingTopologyNodeIDs(config RingTopologyConfig) *RingTopologyNodeIDs
BuildRingTopologyNodeIDs 构建 Ring 拓扑的节点 ID