ruby: perfect switch: refactor code
Refactored the code in operateVnet(), moved partly to a new function operateMessageBuffer(). This is required since a later patch moves to having a wakeup event per MessageBuffer instead of one event for the entire Switch.
This commit is contained in:
parent
25cd13dbf1
commit
8b199b775e
2 changed files with 136 additions and 129 deletions
|
@ -103,9 +103,6 @@ PerfectSwitch::~PerfectSwitch()
|
||||||
void
|
void
|
||||||
PerfectSwitch::operateVnet(int vnet)
|
PerfectSwitch::operateVnet(int vnet)
|
||||||
{
|
{
|
||||||
MsgPtr msg_ptr;
|
|
||||||
Message *net_msg_ptr = NULL;
|
|
||||||
|
|
||||||
// This is for round-robin scheduling
|
// This is for round-robin scheduling
|
||||||
int incoming = m_round_robin_start;
|
int incoming = m_round_robin_start;
|
||||||
m_round_robin_start++;
|
m_round_robin_start++;
|
||||||
|
@ -122,10 +119,6 @@ PerfectSwitch::operateVnet(int vnet)
|
||||||
incoming = 0;
|
incoming = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// temporary vectors to store the routing results
|
|
||||||
vector<LinkID> output_links;
|
|
||||||
vector<NetDest> output_link_destinations;
|
|
||||||
|
|
||||||
// Is there a message waiting?
|
// Is there a message waiting?
|
||||||
if (m_in[incoming].size() <= vnet) {
|
if (m_in[incoming].size() <= vnet) {
|
||||||
continue;
|
continue;
|
||||||
|
@ -136,6 +129,22 @@ PerfectSwitch::operateVnet(int vnet)
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
operateMessageBuffer(buffer, incoming, vnet);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
PerfectSwitch::operateMessageBuffer(MessageBuffer *buffer, int incoming,
|
||||||
|
int vnet)
|
||||||
|
{
|
||||||
|
MsgPtr msg_ptr;
|
||||||
|
Message *net_msg_ptr = NULL;
|
||||||
|
|
||||||
|
// temporary vectors to store the routing results
|
||||||
|
vector<LinkID> output_links;
|
||||||
|
vector<NetDest> output_link_destinations;
|
||||||
|
|
||||||
while (buffer->isReady()) {
|
while (buffer->isReady()) {
|
||||||
DPRINTF(RubyNetwork, "incoming: %d\n", incoming);
|
DPRINTF(RubyNetwork, "incoming: %d\n", incoming);
|
||||||
|
|
||||||
|
@ -257,8 +266,7 @@ PerfectSwitch::operateVnet(int vnet)
|
||||||
// Change the internal destination set of the message so it
|
// Change the internal destination set of the message so it
|
||||||
// knows which destinations this link is responsible for.
|
// knows which destinations this link is responsible for.
|
||||||
net_msg_ptr = msg_ptr.get();
|
net_msg_ptr = msg_ptr.get();
|
||||||
net_msg_ptr->getDestination() =
|
net_msg_ptr->getDestination() = output_link_destinations[i];
|
||||||
output_link_destinations[i];
|
|
||||||
|
|
||||||
// Enqeue msg
|
// Enqeue msg
|
||||||
DPRINTF(RubyNetwork, "Enqueuing net msg from "
|
DPRINTF(RubyNetwork, "Enqueuing net msg from "
|
||||||
|
@ -269,8 +277,6 @@ PerfectSwitch::operateVnet(int vnet)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void
|
||||||
PerfectSwitch::wakeup()
|
PerfectSwitch::wakeup()
|
||||||
|
|
|
@ -85,6 +85,7 @@ class PerfectSwitch : public Consumer
|
||||||
PerfectSwitch& operator=(const PerfectSwitch& obj);
|
PerfectSwitch& operator=(const PerfectSwitch& obj);
|
||||||
|
|
||||||
void operateVnet(int vnet);
|
void operateVnet(int vnet);
|
||||||
|
void operateMessageBuffer(MessageBuffer *b, int incoming, int vnet);
|
||||||
|
|
||||||
const SwitchID m_switch_id;
|
const SwitchID m_switch_id;
|
||||||
Switch * const m_switch;
|
Switch * const m_switch;
|
||||||
|
|
Loading…
Reference in a new issue