diff options
author | Nilay Vaish <nilay@cs.wisc.edu> | 2014-09-15 16:19:38 -0500 |
---|---|---|
committer | Nilay Vaish <nilay@cs.wisc.edu> | 2014-09-15 16:19:38 -0500 |
commit | 2ccdfc547d5b58bdc859e4497658e972d7af5c45 (patch) | |
tree | 4f1d75beb873b84f66612e250b774a149fe2e91e /src/mem/ruby/network/simple/PerfectSwitch.cc | |
parent | 8d18713d28854cef9beef20f22065a769d7a0396 (diff) | |
download | gem5-2ccdfc547d5b58bdc859e4497658e972d7af5c45.tar.xz |
ruby: network: revert some of the changes from ad9c042dce54
The changeset ad9c042dce54 made changes to the structures under the network
directory to use a map of buffers instead of vector of buffers.
The reasoning was that not all vnets that are created are used and we
needlessly allocate more buffers than required and then iterate over them
while processing network messages. But the move to map resulted in a slow
down which was pointed out by Andreas Hansson. This patch moves things
back to using vector of message buffers.
Diffstat (limited to 'src/mem/ruby/network/simple/PerfectSwitch.cc')
-rw-r--r-- | src/mem/ruby/network/simple/PerfectSwitch.cc | 34 |
1 files changed, 21 insertions, 13 deletions
diff --git a/src/mem/ruby/network/simple/PerfectSwitch.cc b/src/mem/ruby/network/simple/PerfectSwitch.cc index caf07b3cf..86cafbe15 100644 --- a/src/mem/ruby/network/simple/PerfectSwitch.cc +++ b/src/mem/ruby/network/simple/PerfectSwitch.cc @@ -68,26 +68,30 @@ PerfectSwitch::init(SimpleNetwork *network_ptr) } void -PerfectSwitch::addInPort(const map<int, MessageBuffer*>& in) +PerfectSwitch::addInPort(const vector<MessageBuffer*>& in) { NodeID port = m_in.size(); m_in.push_back(in); - for (auto& it : in) { - it.second->setConsumer(this); + for (int i = 0; i < in.size(); ++i) { + if (in[i] != nullptr) { + in[i]->setConsumer(this); - string desc = csprintf("[Queue from port %s %s %s to PerfectSwitch]", - to_string(m_switch_id), to_string(port), to_string(it.first)); + string desc = + csprintf("[Queue from port %s %s %s to PerfectSwitch]", + to_string(m_switch_id), to_string(port), + to_string(i)); - it.second->setDescription(desc); - it.second->setIncomingLink(port); - it.second->setVnet(it.first); + in[i]->setDescription(desc); + in[i]->setIncomingLink(port); + in[i]->setVnet(i); + } } } void -PerfectSwitch::addOutPort(const map<int, MessageBuffer*>& out, - const NetDest& routing_table_entry) +PerfectSwitch::addOutPort(const vector<MessageBuffer*>& out, + const NetDest& routing_table_entry) { // Setup link order LinkOrder l; @@ -131,10 +135,14 @@ PerfectSwitch::operateVnet(int vnet) vector<NetDest> output_link_destinations; // Is there a message waiting? - auto it = m_in[incoming].find(vnet); - if (it == m_in[incoming].end()) + if (m_in[incoming].size() <= vnet) { continue; - MessageBuffer *buffer = (*it).second; + } + + MessageBuffer *buffer = m_in[incoming][vnet]; + if (buffer == nullptr) { + continue; + } while (buffer->isReady()) { DPRINTF(RubyNetwork, "incoming: %d\n", incoming); |