Documentation
¶
Index ¶
- func CalibrateCyclesPerUS(duration time.Duration) float64
- func CreatePacket(src, dst int, payload string) packet.Packet
- func GetCPUCycles() uint64
- func NewBufferlessRing(nodeCount int, queueSize int, ringLatency int, queueBandwidth int) ([]*WorkerNode, []*BufferlessRingRouterNode, []Tickable)
- func Pause()
- func SpinWait(minUs, maxUs int)
- func SpinWaitCycles(cycles uint64)
- type BaseNode
- func (n *BaseNode) AddCache(c cache.Cache)
- func (n *BaseNode) AddDirectory(d directory.Directory)
- func (n *BaseNode) AddInputQueue(q InputQueue) error
- func (n *BaseNode) AddOutputQueue(q OutputQueue) error
- func (n *BaseNode) AdvanceTo(targetCycle int) error
- func (n *BaseNode) Caches() []cache.Cache
- func (n *BaseNode) CurrentCycle() int
- func (n *BaseNode) DeleteData(key string)
- func (n *BaseNode) Directories() []directory.Directory
- func (n *BaseNode) GetAllData() map[string]interface{}
- func (n *BaseNode) GetData(key string) interface{}
- func (n *BaseNode) GetOutputQueue(index int) OutputQueue
- func (n *BaseNode) HasData(key string) bool
- func (n *BaseNode) ID() int
- func (n *BaseNode) InjectPacket(pkt packet.Packet) error
- func (n *BaseNode) InputQueues() []InputQueue
- func (n *BaseNode) OutputQueues() []OutputQueue
- func (n *BaseNode) SetData(key string, value interface{})
- func (n *BaseNode) Tick(cycle uint64, _ time.Duration) error
- func (n *BaseNode) UpdateData(modifier func(map[string]interface{}))
- func (n *BaseNode) UpdateKeyData(key string, modifier func(interface{}) interface{})
- type BufferlessRingRouterNode
- func (r *BufferlessRingRouterNode) GetBufferCapacity() int
- func (r *BufferlessRingRouterNode) GetBufferOccupancy() int
- func (r *BufferlessRingRouterNode) GetInjectionBufferOccupancy() int
- func (r *BufferlessRingRouterNode) GetVisualState() string
- func (r *BufferlessRingRouterNode) GetWorkerID() int
- func (r *BufferlessRingRouterNode) Process(cycle uint64, inputs [][]queue.PacketRef) error
- type InputQueue
- type Node
- type NodeHandler
- type OutputQueue
- type Tickable
- type WorkerNode
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CalibrateCyclesPerUS ¶
CalibrateCyclesPerUS measures and returns the number of CPU cycles per microsecond. It samples for the specified duration (e.g. 100ms) to average out noise.
func CreatePacket ¶
CreatePacket is a helper to create a packet (compatibility alias).
func GetCPUCycles ¶
func GetCPUCycles() uint64
GetCPUCycles returns the current value of the CPU time-stamp counter (RDTSC). Implemented in cpu_amd64.s
func NewBufferlessRing ¶
func NewBufferlessRing(nodeCount int, queueSize int, ringLatency int, queueBandwidth int) ([]*WorkerNode, []*BufferlessRingRouterNode, []Tickable)
NewBufferlessRing creates a complete bufferless ring network. Returns slices of workers, routers, and all tickable components (including links).
func Pause ¶
func Pause()
Pause executes the PAUSE instruction to hint the processor that this is a spin-wait loop. Implemented in cpu_amd64.s
func SpinWait ¶
func SpinWait(minUs, maxUs int)
SpinWait simulates processing time by busy-waiting. This is an estimate of GEM5 O3 CPU core execution time for a typical node operation. It occupies the CPU instead of yielding, which better simulates heavy compute loads.
func SpinWaitCycles ¶
func SpinWaitCycles(cycles uint64)
SpinWaitCycles busy-waits for approximately the specified number of CPU cycles. This is more precise than SpinWait (us) if the CPU frequency is stable.
Types ¶
type BaseNode ¶
type BaseNode struct {
// contains filtered or unexported fields
}
BaseNode implements the common logic for all nodes. Specific node types should embed BaseNode and implement NodeHandler.
func NewBaseNode ¶
func NewBaseNode(id int, handler NodeHandler) *BaseNode
NewBaseNode creates a new BaseNode.
func (*BaseNode) AddDirectory ¶
AddDirectory attaches a directory.
func (*BaseNode) AddInputQueue ¶
func (n *BaseNode) AddInputQueue(q InputQueue) error
AddInputQueue registers an InputQueue.
func (*BaseNode) AddOutputQueue ¶
func (n *BaseNode) AddOutputQueue(q OutputQueue) error
AddOutputQueue registers an OutputQueue.
func (*BaseNode) AdvanceTo ¶
AdvanceTo executes the configured cycles sequentially using Background context until the node reaches the target cycle.
func (*BaseNode) CurrentCycle ¶
CurrentCycle returns the current cycle of the node.
func (*BaseNode) DeleteData ¶
DeleteData removes protocol-specific data.
func (*BaseNode) Directories ¶
Directories returns attached directories.
func (*BaseNode) GetAllData ¶
GetAllData returns a copy of all protocol-specific data.
func (*BaseNode) GetOutputQueue ¶
func (n *BaseNode) GetOutputQueue(index int) OutputQueue
GetOutputQueue safely retrieves an output queue by index.
func (*BaseNode) InjectPacket ¶
InjectPacket is a helper to inject a packet into the first output queue.
func (*BaseNode) InputQueues ¶
func (n *BaseNode) InputQueues() []InputQueue
InputQueues returns the registered inputs.
func (*BaseNode) OutputQueues ¶
func (n *BaseNode) OutputQueues() []OutputQueue
OutputQueues returns the registered outputs.
func (*BaseNode) SetData ¶
SetData stores protocol-specific data. Key format recommendation: "{Protocol}_{Key}", e.g., "CHI_Role", "AXI_Config"
func (*BaseNode) Tick ¶
Tick executes one cycle of the node's logic. Order: Receive (Input) -> Process (Handler) -> Send (Output)
func (*BaseNode) UpdateData ¶
UpdateData atomically updates the entire protocol-specific data map.
func (*BaseNode) UpdateKeyData ¶
UpdateKeyData atomically updates a specific key in protocol-specific data.
type BufferlessRingRouterNode ¶
type BufferlessRingRouterNode struct {
*BaseNode // Embed BaseNode for base functionality
// contains filtered or unexported fields
}
BufferlessRingRouterNode implements a router for bufferless ring topology.
Architecture: - 4 ports: ringIn, ringOut, localIn, localOut - Internal buffer ONLY for local injection (ring traffic never buffered) - Routing logic: check packet.TargetID to decide ejection vs. forwarding
Key Design Principles: - Ring traffic NEVER buffered in router (always forwarded immediately) - Packets that cannot eject continue on ring (loop around) - Only local injection needs buffering (when ring temporarily busy) - Backpressure only (no packet dropping)
Queue Assignment: - inputs[0]: ringInQueue (from previous router) - inputs[1]: localInQueue (from local worker) - outputs[0]: ringOutQueue (to next router) - outputs[1]: localOutQueue (to local worker)
func NewBufferlessRingRouter ¶
func NewBufferlessRingRouter(routerID, workerID, bufferCapacity int) *BufferlessRingRouterNode
NewBufferlessRingRouter creates a router node for bufferless ring topology.
Parameters: - routerID: ID of this router node - workerID: ID of the connected worker node - bufferCapacity: internal buffer size for injection queue
func (*BufferlessRingRouterNode) GetBufferCapacity ¶
func (r *BufferlessRingRouterNode) GetBufferCapacity() int
GetBufferCapacity returns the buffer capacity.
func (*BufferlessRingRouterNode) GetBufferOccupancy ¶
func (r *BufferlessRingRouterNode) GetBufferOccupancy() int
GetBufferOccupancy returns the current injection buffer occupancy.
func (*BufferlessRingRouterNode) GetInjectionBufferOccupancy ¶
func (r *BufferlessRingRouterNode) GetInjectionBufferOccupancy() int
GetInjectionBufferOccupancy returns the injection buffer occupancy.
func (*BufferlessRingRouterNode) GetVisualState ¶
func (r *BufferlessRingRouterNode) GetVisualState() string
GetVisualState returns the visual representation of this router. Format depends on global visualization.VisualizationMode.
func (*BufferlessRingRouterNode) GetWorkerID ¶
func (r *BufferlessRingRouterNode) GetWorkerID() int
GetWorkerID returns the ID of the connected worker node.
type InputQueue ¶
type InputQueue interface {
Pick() []packet.Packet
PeekPickTo(out []queue.PacketRef) int
Tick(cycle int) error
Length() int
Capacity() int
IsFull() bool
}
InputQueue describes the behaviors Node needs from an input buffer.
type Node ¶
type Node interface {
ID() int
Tick(cycle uint64, duration time.Duration) error
AddInputQueue(q InputQueue) error
AddOutputQueue(q OutputQueue) error
InputQueues() []InputQueue
OutputQueues() []OutputQueue
AddCache(c cache.Cache)
Caches() []cache.Cache
AddDirectory(d directory.Directory)
Directories() []directory.Directory
InjectPacket(pkt packet.Packet) error
AdvanceTo(targetCycle int) error
CurrentCycle() int
SetData(key string, value interface{})
GetData(key string) interface{}
HasData(key string) bool
DeleteData(key string)
UpdateData(modifier func(map[string]interface{}))
UpdateKeyData(key string, modifier func(interface{}) interface{})
}
Node defines the public interface for all simulation nodes. Node defines the public interface for all simulation nodes.
type NodeHandler ¶
type NodeHandler interface {
// Process handles data for the current cycle.
// It receives packets from all input queues, indexed by queue ID.
// Returns an error if processing fails.
// Implementations should use BaseNode.GetOutputQueue(i).InjectPackets() to send data.
//
// Parameters:
// cycle: current simulation cycle
// inputs: packets received in this cycle from each input queue (inputs[i] comes from InputQueue i)
Process(cycle uint64, inputs [][]queue.PacketRef) error
}
NodeHandler defines the interface that specific node implementations must satisfy.
type OutputQueue ¶
type OutputQueue interface {
Tick(cycle int) error
Length() int
Capacity() int
IsFull() bool
InjectPackets(cycle int, packets []packet.Packet) error
OutBandwidth() int
}
OutputQueue describes the behaviors Node needs from an output buffer.
type WorkerNode ¶
type WorkerNode struct {
*BaseNode
// contains filtered or unexported fields
}
WorkerNode is a concrete node type for general purpose use (e.g. in simulator). It allows injecting custom behavior via hooks.
func (*WorkerNode) GetProcessBuffer ¶
func (w *WorkerNode) GetProcessBuffer() []packet.Packet
GetProcessBuffer returns the last processed packets.
func (*WorkerNode) Process ¶
func (w *WorkerNode) Process(cycle uint64, inputs [][]queue.PacketRef) error
Process implements the NodeHandler interface.
func (*WorkerNode) SetProcessHook ¶
func (w *WorkerNode) SetProcessHook(hook func(cycle uint64, inputs [][]queue.PacketRef) error)
SetProcessHook sets the hook for processing packets.