Documentation
¶
Index ¶
- type CacheConfigSchema
- type ConnectOption
- type DirectoryConfigSchema
- type EdgeSchema
- type Network
- func (n *Network) AddNode(handle *NodeHandle) error
- func (n *Network) AdvanceTo(targetCycle int) error
- func (n *Network) Connect(sourceID int, sourceOutputIdx int, targetID int, targetInputIdx int, ...) (*link.Link, error)
- func (n *Network) ConnectWithHandler(sourceID int, sourceOutputIdx int, targetID int, targetInputIdx int, ...) (*link.Link, error)
- func (n *Network) CurrentCycle() int
- func (n *Network) Reset(schema *NetworkSchema) error
- type NetworkSchema
- type NodeHandle
- type NodeSchema
- type PortSchema
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CacheConfigSchema ¶
type CacheConfigSchema struct {
Capacity int `json:"capacity"`
NumSets int `json:"num_sets"`
ReplacementPolicy string `json:"replacement_policy"`
States string `json:"states"`
}
CacheConfigSchema represents cache configuration in the OpenAPI schema.
type ConnectOption ¶
type ConnectOption func(*connectOptions)
ConnectOption is a functional option for configuring a network connection.
func WithHandler ¶
func WithHandler(handler link.LinkHandler) ConnectOption
WithHandler specifies a custom link handler for the connection.
type DirectoryConfigSchema ¶
type DirectoryConfigSchema struct {
Capacity int `json:"capacity"`
NumSets int `json:"num_sets"`
ReplacementPolicy string `json:"replacement_policy"`
States string `json:"states"`
}
DirectoryConfigSchema represents directory configuration in the OpenAPI schema.
type EdgeSchema ¶
type EdgeSchema struct {
EdgeID int `json:"edge_id"`
SrcNodeID int `json:"src_node_id"`
SrcPortID int `json:"src_port_id"`
DstNodeID int `json:"dst_node_id"`
DstPortID int `json:"dst_port_id"`
PacketTypes []int `json:"packet_types,omitempty"`
}
EdgeSchema represents an edge in the OpenAPI schema.
type Network ¶
type Network struct {
// contains filtered or unexported fields
}
Network manages a collection of nodes and links. Design assumptions: - Network topology is built once (via AddNode/Connect or FromSchema) - After construction, topology is immutable during Advance - No concurrent modifications during Advance (single-threaded execution model) - Advance can be called multiple times sequentially
func (*Network) AddNode ¶
func (n *Network) AddNode(handle *NodeHandle) error
AddNode registers a node handle in the network. Must be called before Advance. Panics if network is frozen.
func (*Network) AdvanceTo ¶
AdvanceTo runs all registered nodes and links in parallel up to the target cycle. On first call, freezes the network topology (no more AddNode/Connect allowed). Can be called multiple times sequentially with increasing target cycles.
func (*Network) Connect ¶
func (n *Network) Connect(sourceID int, sourceOutputIdx int, targetID int, targetInputIdx int, latency int, bandwidth int, opts ...ConnectOption) (*link.Link, error)
Connect wires a source output queue to a target input queue with a Link. Must be called before Advance. Panics if network is frozen.
func (*Network) ConnectWithHandler ¶
func (n *Network) ConnectWithHandler(sourceID int, sourceOutputIdx int, targetID int, targetInputIdx int, latency int, bandwidth int, handler link.LinkHandler) (*link.Link, error)
ConnectWithHandler is a legacy wrapper. Use Connect(..., WithHandler(h)) instead.
func (*Network) CurrentCycle ¶
CurrentCycle returns the maximum cycle reached by the network (based on targetCycle of last AdvanceTo).
func (*Network) Reset ¶
func (n *Network) Reset(schema *NetworkSchema) error
Reset clears the network and rebuilds it from the provided schema. Must be called before any Advance. Panics if network is frozen.
type NetworkSchema ¶
type NetworkSchema struct {
Version string `json:"version,omitempty"`
Nodes []NodeSchema `json:"nodes"`
Edges []EdgeSchema `json:"edges"`
}
NetworkSchema represents the network topology in the OpenAPI schema.
type NodeHandle ¶
type NodeHandle struct {
Node node.Node
Inputs []*queue.InputQueue
Outputs []*queue.OutputQueue
}
NodeHandle keeps the node instance together with the concrete queues used to connect links.
type NodeSchema ¶
type NodeSchema struct {
NodeID int `json:"node_id"`
NodeName string `json:"node_name,omitempty"`
NodeFeatures []string `json:"node_features,omitempty"`
Cache *CacheConfigSchema `json:"cache,omitempty"`
Directory *DirectoryConfigSchema `json:"directory,omitempty"`
CoherenceDomainID *int `json:"coherence_domain_id,omitempty"`
InPorts []PortSchema `json:"in_ports,omitempty"`
OutPorts []PortSchema `json:"out_ports,omitempty"`
}
NodeSchema represents a node in the OpenAPI schema.