48#include "debug/RubyNetwork.hh"
64 m_switch_id(sid), m_switch(
sw)
86 for (
int i = 0;
i < in.size(); ++
i) {
87 if (in[
i] !=
nullptr) {
88 in[
i]->setConsumer(
this);
89 in[
i]->setIncomingLink(port);
112 int cur_prio =
m_in_prio[vnet].front()->routingPriority();
115 if (buf->routingPriority() != cur_prio)
123 const NetDest& routing_table_entry,
125 Tick routing_latency,
134 m_out.push_back({routing_latency, out});
144 if (
m_in[in_port].size() <= vnet) {
148 return m_in[in_port][vnet];
160 unsigned start_in_port = 0;
162 for (
int i = 0;
i < in.size(); ++
i) {
166 if (ready_time < lowest_tick){
167 lowest_tick = ready_time;
172 DPRINTF(RubyNetwork,
"vnet %d: %d pending msgs. "
173 "Checking port %d first\n",
176 for (
int i = 0;
i < in.size(); ++
i) {
177 int in_port = (
i + start_in_port) % in.size();
196 while (buffer->
isReady(current_time)) {
201 net_msg_ptr = msg_ptr.get();
202 DPRINTF(RubyNetwork,
"Message: %s\n", (*net_msg_ptr));
205 output_links.clear();
212 for (
int i = 0;
i < output_links.size();
i++) {
213 int outgoing = output_links[
i].m_link_id;
216 if (!out_port.
buffers[vnet]->areNSlotsAvailable(1, current_time))
219 DPRINTF(RubyNetwork,
"Checking if node is blocked ..."
220 "outgoing: %d, vnet: %d, enough: %d\n",
221 outgoing, vnet, enough);
227 DPRINTF(RubyNetwork,
"Can't deliver message since a node "
229 DPRINTF(RubyNetwork,
"Message: %s\n", (*net_msg_ptr));
233 MsgPtr unmodified_msg_ptr;
235 if (output_links.size() > 1) {
243 unmodified_msg_ptr = msg_ptr->clone();
251 for (
int i=0;
i<output_links.size();
i++) {
252 int outgoing = output_links[
i].m_link_id;
257 msg_ptr = unmodified_msg_ptr->clone();
262 net_msg_ptr = msg_ptr.get();
266 DPRINTF(RubyNetwork,
"Enqueuing net msg from "
267 "inport[%d][%d] to outport [%d][%d].\n",
270 out_port.
buffers[vnet]->enqueue(msg_ptr, current_time,
282 int lowest_prio_vnet = 0;
288 highest_prio_vnet = 0;
294 for (
int vnet = highest_prio_vnet;
295 (vnet * decrementer) >= (decrementer * lowest_prio_vnet);
296 vnet -= decrementer) {
Tick clockEdge(Cycles cycles=Cycles(0)) const
Determine the tick when a cycle begins, by default the current one, but the argument also enables the...
Cycles is a wrapper class for representing cycle counts, i.e.
virtual void addOutPort(LinkID link_id, const std::vector< MessageBuffer * > &m_out_buffer, const NetDest &routing_table_entry, const PortDirection &direction, int link_weight)=0
virtual void route(const Message &msg, int vnet, bool deterministic, std::vector< RouteInfo > &out_links)=0
void scheduleEvent(Cycles timeDelta)
bool isReady(Tick current_time) const
int getIncomingLink() const
int routingPriority() const
Tick dequeue(Tick current_time, bool decrement_messages=true)
Updates the delay cycles of the message at the head of the queue, removes it from the queue and retur...
const MsgPtr & peekMsgPtr() const
virtual const NetDest & getDestination() const
void init(SimpleNetwork *)
void addOutPort(const std::vector< MessageBuffer * > &out, const NetDest &routing_table_entry, const PortDirection &dst_inport, Tick routing_latency, int link_weight)
std::vector< std::vector< MessageBuffer * > > m_in_prio
std::vector< std::vector< MessageBuffer * > > m_in
void storeEventInfo(int info)
std::vector< int > m_pending_message_count
const SwitchID m_switch_id
std::vector< OutputPort > m_out
void operateVnet(int vnet)
std::vector< std::vector< std::vector< MessageBuffer * > > > m_in_prio_groups
uint32_t m_virtual_networks
SimpleNetwork * m_network_ptr
PerfectSwitch(SwitchID sid, Switch *, uint32_t)
void print(std::ostream &out) const
MessageBuffer * inBuffer(int in_port, int vnet) const
void updatePriorityGroups(int vnet, MessageBuffer *buf)
void addInPort(const std::vector< MessageBuffer * > &in)
void operateMessageBuffer(MessageBuffer *b, int vnet)
bool isVNetOrdered(int vnet) const
BaseRoutingUnit & getRoutingUnit()
SignedBitfield< 31, 0 > sw
std::shared_ptr< Message > MsgPtr
std::string PortDirection
const int PRIORITY_SWITCH_LIMIT
Copyright (c) 2024 - Pranith Kumar Copyright (c) 2020 Inria All rights reserved.
uint64_t Tick
Tick count type.
std::vector< MessageBuffer * > buffers