Documentation
¶
Index ¶
- func NewTracedInPort(original ahead_port.InPort, link *Link) ahead_port.InPort
- type BufferedLinkType
- func (h *BufferedLinkType) AddToSlot(pkt ahead_port.PacketWithCycle, targetCycle int)
- func (h *BufferedLinkType) CanAcceptPacket(cycle int, targetCycle int) bool
- func (h *BufferedLinkType) CanSendPacket(cycle int, downstreamReady bool) bool
- func (h *BufferedLinkType) CheckSpace(cycle int) bool
- func (h *BufferedLinkType) ClearSlot(cycle int)
- func (h *BufferedLinkType) GetBandwidth() int
- func (h *BufferedLinkType) GetLatency() int
- func (h *BufferedLinkType) GetOccupancy(currentCycle int) []int
- func (h *BufferedLinkType) GetSlot(cycle int) []ahead_port.PacketWithCycle
- func (h *BufferedLinkType) GetSlots() [][]ahead_port.PacketWithCycle
- func (h *BufferedLinkType) GetTotalBackpressure() int
- func (h *BufferedLinkType) IncrementBackpressure()
- func (h *BufferedLinkType) Init(l *Link)
- func (h *BufferedLinkType) Process(l *Link, cycle int, targetCycle int, incoming []packet.Packet) error
- func (h *BufferedLinkType) Reset()
- func (h *BufferedLinkType) UpdateSlot(cycle int, packets []ahead_port.PacketWithCycle)
- type BufferlessLinkType
- type Link
- func (l *Link) AdvanceTo(targetCycle int) error
- func (l *Link) Bandwidth() int
- func (l *Link) CurrentCycle() int
- func (l *Link) ExportState(cfg state.ExportConfig) state.LinkState
- func (l *Link) GetDownstreamPort() *ahead_port.Port
- func (l *Link) GetHandler() LinkHandler
- func (l *Link) GetTraceEvents() []trace.TraceEvent
- func (l *Link) GetUpstreamPort() *ahead_port.Port
- func (l *Link) GetVisualState() string
- func (l *Link) ID() int
- func (l *Link) Init()
- func (l *Link) Latency() int
- func (l *Link) Name() string
- func (l *Link) PendingPacketCount() int
- func (l *Link) SetDownstreamPort(port ahead_port.InPort)
- func (l *Link) SetTickHook(hook func(cycle int))
- func (l *Link) SetTracer(t *trace.TraceRecorder)
- func (l *Link) SetUpstreamPort(port ahead_port.OutPort)
- func (l *Link) SnapshotOccupancy() []int
- func (l *Link) SourceID() int
- func (l *Link) TargetID() int
- func (l *Link) Tick(cycle int, targetCycle int) error
- func (l *Link) TraceID() int
- func (l *Link) UpdateUpstreamReady(cycle int, ready bool)
- type LinkHandler
- type LinkType
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewTracedInPort ¶ added in v0.2.0
func NewTracedInPort(original ahead_port.InPort, link *Link) ahead_port.InPort
NewTracedInPort returns the original port when tracing is disabled.
Types ¶
type BufferedLinkType ¶ added in v0.2.0
type BufferedLinkType struct {
// contains filtered or unexported fields
}
BufferedLinkType implements buffered flow control with backpressure.
Mechanism: - Ring buffer (slots) stores packets during transit (latency cycles) - Backpressure counter tracks accumulated delays when downstream is not ready - Bandwidth limit enforces maximum packets per slot
func NewBufferedLinkHandler ¶
func NewBufferedLinkHandler(latency, bandwidth int) *BufferedLinkType
NewBufferedLinkHandler is deprecated. Use NewBufferedLinkType instead. Deprecated: Use NewBufferedLinkType.
func NewBufferedLinkType ¶ added in v0.2.0
func NewBufferedLinkType(latency, bandwidth int) *BufferedLinkType
NewBufferedLinkType creates a BufferedLinkType.
func (*BufferedLinkType) AddToSlot ¶ added in v0.2.0
func (h *BufferedLinkType) AddToSlot(pkt ahead_port.PacketWithCycle, targetCycle int)
func (*BufferedLinkType) CanAcceptPacket ¶ added in v0.2.0
func (h *BufferedLinkType) CanAcceptPacket(cycle int, targetCycle int) bool
func (*BufferedLinkType) CanSendPacket ¶ added in v0.2.0
func (h *BufferedLinkType) CanSendPacket(cycle int, downstreamReady bool) bool
func (*BufferedLinkType) CheckSpace ¶ added in v0.2.0
func (h *BufferedLinkType) CheckSpace(cycle int) bool
func (*BufferedLinkType) ClearSlot ¶ added in v0.2.0
func (h *BufferedLinkType) ClearSlot(cycle int)
func (*BufferedLinkType) GetBandwidth ¶ added in v0.2.0
func (h *BufferedLinkType) GetBandwidth() int
func (*BufferedLinkType) GetLatency ¶ added in v0.2.0
func (h *BufferedLinkType) GetLatency() int
func (*BufferedLinkType) GetOccupancy ¶ added in v0.2.0
func (h *BufferedLinkType) GetOccupancy(currentCycle int) []int
GetOccupancy returns the pending packet count per slot for buffered links.
func (*BufferedLinkType) GetSlot ¶ added in v0.2.0
func (h *BufferedLinkType) GetSlot(cycle int) []ahead_port.PacketWithCycle
func (*BufferedLinkType) GetSlots ¶ added in v0.2.0
func (h *BufferedLinkType) GetSlots() [][]ahead_port.PacketWithCycle
func (*BufferedLinkType) GetTotalBackpressure ¶ added in v0.2.0
func (h *BufferedLinkType) GetTotalBackpressure() int
func (*BufferedLinkType) IncrementBackpressure ¶ added in v0.2.0
func (h *BufferedLinkType) IncrementBackpressure()
func (*BufferedLinkType) Init ¶ added in v0.2.0
func (h *BufferedLinkType) Init(l *Link)
ReadyDepth returns the number of cycles to pre-mark as ready for bootstrapping. For buffered links, we need to fill the pipeline (latency) plus one for cycle 0.
func (*BufferedLinkType) Process ¶ added in v0.2.0
func (h *BufferedLinkType) Process(l *Link, cycle int, targetCycle int, incoming []packet.Packet) error
Process implements the LinkHandler interface for BufferedLinkType.
func (*BufferedLinkType) Reset ¶ added in v0.2.0
func (h *BufferedLinkType) Reset()
Reset resets the handler state.
func (*BufferedLinkType) UpdateSlot ¶ added in v0.2.0
func (h *BufferedLinkType) UpdateSlot(cycle int, packets []ahead_port.PacketWithCycle)
type BufferlessLinkType ¶ added in v0.2.0
type BufferlessLinkType struct {
// contains filtered or unexported fields
}
BufferlessLinkType implements an always-ready flow control strategy without physical buffering. It attempts to send packets immediately. If downstream is busy, packets are kept in l.pendingPackets. BufferlessLinkType implements an always-ready flow control strategy without physical buffering. It attempts to send packets immediately. If downstream is busy, packets are kept in pending map.
func NewBufferlessLinkHandler ¶
func NewBufferlessLinkHandler() *BufferlessLinkType
NewBufferlessLinkHandler is deprecated. Use NewBufferlessLinkType instead. Deprecated: Use NewBufferlessLinkType.
func NewBufferlessLinkType ¶ added in v0.2.0
func NewBufferlessLinkType() *BufferlessLinkType
NewBufferlessLinkType creates a BufferlessLinkType. NewBufferlessLinkType creates a BufferlessLinkType.
func (*BufferlessLinkType) GetOccupancy ¶ added in v0.2.0
func (h *BufferlessLinkType) GetOccupancy(currentCycle int) []int
GetOccupancy returns the pending packets distribution relative to current cycle (handled by Link).
func (*BufferlessLinkType) Init ¶ added in v0.2.0
func (h *BufferlessLinkType) Init(l *Link)
ReadyDepth returns the number of cycles to pre-mark as ready for bootstrapping. Bufferless links are always ready, but need at least cycle 0 to start.
func (*BufferlessLinkType) Process ¶ added in v0.2.0
func (h *BufferlessLinkType) Process(l *Link, cycle int, targetCycle int, incoming []packet.Packet) error
Process implements the LinkHandler interface for BufferlessLinkType.
func (*BufferlessLinkType) Reset ¶ added in v0.2.0
func (h *BufferlessLinkType) Reset()
Reset resets the handler state.
type Link ¶
type Link struct {
// contains filtered or unexported fields
}
Link represents a directed edge in the topology. Link receives packets from upstream and forwards them to downstream with latency and bandwidth constraints.
func NewLinkWithHandler ¶
func NewLinkWithHandler(sourceID, targetID, latency, bandwidth int, handler LinkHandler) *Link
NewLinkWithHandler is deprecated. Use NewLinkWithType instead. Deprecated: Use NewLinkWithType.
func NewLinkWithType ¶ added in v0.2.0
NewLinkWithType creates a new Link with a custom link type.
func (*Link) AdvanceTo ¶
AdvanceTo progresses the link up to and including the target cycle. It executes cycles from l.currentCycle to targetCycle.
func (*Link) CurrentCycle ¶
CurrentCycle returns the current simulation cycle of the link.
func (*Link) ExportState ¶ added in v0.2.0
func (l *Link) ExportState(cfg state.ExportConfig) state.LinkState
ExportState exports the state of the Link.
func (*Link) GetDownstreamPort ¶ added in v0.2.0
func (l *Link) GetDownstreamPort() *ahead_port.Port
GetDownstreamPort returns the downstream Port for profiling. Returns nil if the port is not a concrete *Port type.
func (*Link) GetHandler ¶
func (l *Link) GetHandler() LinkHandler
GetHandler returns the handler for this link.
func (*Link) GetTraceEvents ¶ added in v0.2.0
func (l *Link) GetTraceEvents() []trace.TraceEvent
func (*Link) GetUpstreamPort ¶ added in v0.2.0
func (l *Link) GetUpstreamPort() *ahead_port.Port
GetUpstreamPort returns the upstream Port for profiling. Returns nil if the port is not a concrete *Port type.
func (*Link) GetVisualState ¶
GetVisualState returns the visual representation of this link.
func (*Link) Init ¶
func (l *Link) Init()
Init initializes the link after being connected to the network.
func (*Link) PendingPacketCount ¶
PendingPacketCount returns the number of buffered packets. Note: This relies on SnapshotOccupancy now.
func (*Link) SetDownstreamPort ¶
func (l *Link) SetDownstreamPort(port ahead_port.InPort)
SetDownstreamPort sets the port for sending data to downstream.
func (*Link) SetTickHook ¶
SetTickHook registers a callback invoked after each successful Tick.
func (*Link) SetTracer ¶ added in v0.2.0
func (l *Link) SetTracer(t *trace.TraceRecorder)
SetTracer registers the link with the global tracer.
func (*Link) SetUpstreamPort ¶
func (l *Link) SetUpstreamPort(port ahead_port.OutPort)
SetUpstreamPort sets the port for receiving data from upstream.
func (*Link) SnapshotOccupancy ¶
SnapshotOccupancy reports the pending packet count per slot/offset.
func (*Link) UpdateUpstreamReady ¶
UpdateUpstreamReady updates the ready state of the upstream port for a specific cycle. This is useful for custom LinkHandlers to signal backpressure.
type LinkHandler ¶
type LinkHandler = LinkType
LinkHandler is a deprecated alias for LinkType. Use LinkType instead. Deprecated: Use LinkType.
func CreateLinkHandler ¶
func CreateLinkHandler(handlerType string, latency, bandwidth int) LinkHandler
CreateLinkHandler is deprecated. Use CreateLinkType instead. Deprecated: Use CreateLinkType.
type LinkType ¶ added in v0.2.0
type LinkType interface {
// Process handles data for the current cycle.
// It is responsible for:
// 1. Sending packets to downstream (via l.toDownstream)
// 2. Buffering packets that cannot be sent (via internal state)
// 3. Updating the ready state for upstream (via l.fromUpstream.UpdateReady)
//
// Parameters:
// l: reference to the parent Link
// cycle: current simulation cycle
// targetCycle: the upper bound cycle for this run (inclusive).
// incoming: packets received from upstream in this cycle
Process(l *Link, cycle int, targetCycle int, incoming []packet.Packet) error
// Reset resets the link type state.
Reset()
// Init initializes the link type after being connected to the network.
// It handles bootstrapping tasks like initial ready signaling.
// If initialReady is specified on the link, it should be honored.
Init(l *Link)
// GetOccupancy returns the number of pending packets per future cycle offset.
// Index i corresponds to packets scheduled for (CurrentCycle + i).
GetOccupancy(currentCycle int) []int
}
LinkType defines the behavior for specific link types. It handles packet processing, flow control, and readiness signaling. Different link types implement different buffering and flow control strategies.
func CreateLinkType ¶ added in v0.2.0
CreateLinkType is a factory function that creates link types by name.
Supported link types: - "buffered": BufferedLinkType with ring buffer and backpressure - "bufferless": BufferlessLinkType (always-ready, no physical buffering)
Parameters: - typeName: type of link ("buffered", "bufferless") - latency: latency parameter (used by buffered, ignored by bufferless) - bandwidth: bandwidth parameter (used by buffered, ignored by bufferless)
Returns: - LinkType instance, or panic if typeName is unknown