ruby: perfect switch: refactor code
Refactored the code in operateVnet(), moved partly to a new function operateMessageBuffer().
This commit is contained in:
parent
a706b6259a
commit
5f1d1ce5d4
2 changed files with 136 additions and 129 deletions
|
@ -104,9 +104,6 @@ PerfectSwitch::~PerfectSwitch()
|
|||
void
|
||||
PerfectSwitch::operateVnet(int vnet)
|
||||
{
|
||||
MsgPtr msg_ptr;
|
||||
Message *net_msg_ptr = NULL;
|
||||
|
||||
// This is for round-robin scheduling
|
||||
int incoming = m_round_robin_start;
|
||||
m_round_robin_start++;
|
||||
|
@ -123,10 +120,6 @@ PerfectSwitch::operateVnet(int vnet)
|
|||
incoming = 0;
|
||||
}
|
||||
|
||||
// temporary vectors to store the routing results
|
||||
vector<LinkID> output_links;
|
||||
vector<NetDest> output_link_destinations;
|
||||
|
||||
// Is there a message waiting?
|
||||
if (m_in[incoming].size() <= vnet) {
|
||||
continue;
|
||||
|
@ -137,6 +130,22 @@ PerfectSwitch::operateVnet(int vnet)
|
|||
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()) {
|
||||
DPRINTF(RubyNetwork, "incoming: %d\n", incoming);
|
||||
|
||||
|
@ -258,8 +267,7 @@ PerfectSwitch::operateVnet(int vnet)
|
|||
// Change the internal destination set of the message so it
|
||||
// knows which destinations this link is responsible for.
|
||||
net_msg_ptr = msg_ptr.get();
|
||||
net_msg_ptr->getDestination() =
|
||||
output_link_destinations[i];
|
||||
net_msg_ptr->getDestination() = output_link_destinations[i];
|
||||
|
||||
// Enqeue msg
|
||||
DPRINTF(RubyNetwork, "Enqueuing net msg from "
|
||||
|
@ -270,8 +278,6 @@ PerfectSwitch::operateVnet(int vnet)
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
PerfectSwitch::wakeup()
|
||||
|
|
|
@ -85,6 +85,7 @@ class PerfectSwitch : public Consumer
|
|||
PerfectSwitch& operator=(const PerfectSwitch& obj);
|
||||
|
||||
void operateVnet(int vnet);
|
||||
void operateMessageBuffer(MessageBuffer *b, int incoming, int vnet);
|
||||
|
||||
SwitchID m_switch_id;
|
||||
|
||||
|
|
Loading…
Reference in a new issue