Meatboy 106 has uploaded this change for review. ( https://gem5-review.googlesource.com/c/public/gem5/+/55723 )

Change subject: mem-ruby: Fix switch storage in SimpleNetwork
......................................................................

mem-ruby: Fix switch storage in SimpleNetwork

In SimpleNetwork, switches were assigned an index depending on their position
in params().routers. But switches are also referenced by their router_id
parameter in other locations of the ruby network system (e.g., src and dst node
parameter in links). If the router_id does not match the position in
SimpleNetwork::m_switches, the network initialization might fail or implement a different topology from what the user intended. This patch fixes this issue by
storing switch N at position N in SimpleNetwork::m_switches.

Change-Id: I398f950ad404efbf9516ea9bbced598970a2bc24
---
M src/mem/ruby/network/simple/SimpleNetwork.cc
1 file changed, 21 insertions(+), 2 deletions(-)



diff --git a/src/mem/ruby/network/simple/SimpleNetwork.cc b/src/mem/ruby/network/simple/SimpleNetwork.cc
index 38d9f79..4d1650d 100644
--- a/src/mem/ruby/network/simple/SimpleNetwork.cc
+++ b/src/mem/ruby/network/simple/SimpleNetwork.cc
@@ -67,8 +67,10 @@
     // record the routers
     for (std::vector<BasicRouter*>::const_iterator i = p.routers.begin();
          i != p.routers.end(); ++i) {
-        Switch* s = safe_cast<Switch*>(*i);
-        m_switches.push_back(s);
+        auto* s = safe_cast<Switch*>(*i);
+        auto id = static_cast<size_t>(s->params().router_id);
+        m_switches.resize(std::max(m_switches.size(), id+1), nullptr);
+        m_switches[id] = s;
         s->init_net_ptr(this);
     }


--
To view, visit https://gem5-review.googlesource.com/c/public/gem5/+/55723
To unsubscribe, or for help writing mail filters, visit https://gem5-review.googlesource.com/settings

Gerrit-Project: public/gem5
Gerrit-Branch: develop
Gerrit-Change-Id: I398f950ad404efbf9516ea9bbced598970a2bc24
Gerrit-Change-Number: 55723
Gerrit-PatchSet: 1
Gerrit-Owner: Meatboy 106 <garbage2collec...@gmail.com>
Gerrit-MessageType: newchange
_______________________________________________
gem5-dev mailing list -- gem5-dev@gem5.org
To unsubscribe send an email to gem5-dev-le...@gem5.org
%(web_page_url)slistinfo%(cgiext)s/%(_internal_name)s

Reply via email to