diff options
author | Nikos Nikoleris <nikos.nikoleris@arm.com> | 2017-03-13 18:19:08 +0000 |
---|---|---|
committer | Nikos Nikoleris <nikos.nikoleris@arm.com> | 2017-06-13 15:52:32 +0000 |
commit | 12db50c89584938839e035da47d206250cbfd7c2 (patch) | |
tree | 831a4151b29cdc14958b8dab2cce97fc3136d7b6 /src/mem/ruby/network | |
parent | dd3fc1f996679f4cfd29f980d43a0652542e6d9b (diff) | |
download | gem5-12db50c89584938839e035da47d206250cbfd7c2.tar.xz |
ruby: Add support for address ranges in the directory
Previously the directory covered a flat address range that always
started from address 0. This change adds a vector of address ranges
with interleaving and hashing that each directory keeps track of and
the necessary flexibility to support systems with non continuous
memory ranges.
Change-Id: I6ea1c629bdf4c5137b7d9c89dbaf6c826adfd977
Reviewed-by: Andreas Sandberg <andreas.sandberg@arm.com>
Reviewed-on: https://gem5-review.googlesource.com/2903
Reviewed-by: Bradford Beckmann <brad.beckmann@amd.com>
Reviewed-by: Jason Lowe-Power <jason@lowepower.com>
Maintainer: Jason Lowe-Power <jason@lowepower.com>
Diffstat (limited to 'src/mem/ruby/network')
-rw-r--r-- | src/mem/ruby/network/Network.cc | 40 | ||||
-rw-r--r-- | src/mem/ruby/network/Network.hh | 39 |
2 files changed, 78 insertions, 1 deletions
diff --git a/src/mem/ruby/network/Network.cc b/src/mem/ruby/network/Network.cc index e9b28a731..1761218b0 100644 --- a/src/mem/ruby/network/Network.cc +++ b/src/mem/ruby/network/Network.cc @@ -1,4 +1,16 @@ /* + * Copyright (c) 2017 ARM Limited + * All rights reserved. + * + * The license below extends only to copyright in the software and shall + * not be construed as granting a license to any other intellectual + * property including but not limited to intellectual property relating + * to a hardware implementation of the functionality of the software + * licensed hereunder. You may use the software subject to the license + * terms below provided that you ensure that this notice is replicated + * unmodified and in its entirety in all distributions of the software, + * modified or unmodified, in source code or in binary form. + * * Copyright (c) 1999-2008 Mark D. Hill and David A. Wood * All rights reserved. * @@ -29,6 +41,7 @@ #include "mem/ruby/network/Network.hh" #include "base/misc.hh" +#include "mem/ruby/common/MachineID.hh" #include "mem/ruby/network/BasicLink.hh" #include "mem/ruby/system/RubySystem.hh" @@ -73,6 +86,15 @@ Network::Network(const Params *p) BasicExtLink *ext_link = (*i); AbstractController *abs_cntrl = ext_link->params()->ext_node; abs_cntrl->initNetworkPtr(this); + const AddrRangeList &ranges = abs_cntrl->getAddrRanges(); + if (!ranges.empty()) { + MachineID mid = abs_cntrl->getMachineID(); + AddrMapNode addr_map_node = { + .id = mid.getNum(), + .ranges = ranges + }; + addrMap.emplace(mid.getType(), addr_map_node); + } } // Register a callback function for combining the statistics @@ -172,3 +194,21 @@ Network::setFromNetQueue(NodeID id, bool ordered, int network_num, } m_fromNetQueues[id][network_num] = b; } + +NodeID +Network::addressToNodeID(Addr addr, MachineType mtype) +{ + // Look through the address maps for entries with matching machine + // type to get the responsible node for this address. + const auto &matching_ranges = addrMap.equal_range(mtype); + for (auto it = matching_ranges.first; it != matching_ranges.second; it++) { + AddrMapNode &node = it->second; + auto &ranges = node.ranges; + for (AddrRange &range: ranges) { + if (range.contains(addr)) { + return node.id; + } + } + } + return MachineType_base_count(mtype); +} diff --git a/src/mem/ruby/network/Network.hh b/src/mem/ruby/network/Network.hh index 4c0d4edfc..7f5ed2aae 100644 --- a/src/mem/ruby/network/Network.hh +++ b/src/mem/ruby/network/Network.hh @@ -1,4 +1,16 @@ /* + * Copyright (c) 2017 ARM Limited + * All rights reserved. + * + * The license below extends only to copyright in the software and shall + * not be construed as granting a license to any other intellectual + * property including but not limited to intellectual property relating + * to a hardware implementation of the functionality of the software + * licensed hereunder. You may use the software subject to the license + * terms below provided that you ensure that this notice is replicated + * unmodified and in its entirety in all distributions of the software, + * modified or unmodified, in source code or in binary form. + * * Copyright (c) 1999-2008 Mark D. Hill and David A. Wood * All rights reserved. * @@ -42,13 +54,17 @@ #include <iostream> #include <string> +#include <unordered_map> #include <vector> +#include "base/addr_range.hh" +#include "base/types.hh" +#include "mem/packet.hh" #include "mem/protocol/LinkDirection.hh" #include "mem/protocol/MessageSizeType.hh" +#include "mem/ruby/common/MachineID.hh" #include "mem/ruby/common/TypeDefines.hh" #include "mem/ruby/network/Topology.hh" -#include "mem/packet.hh" #include "params/RubyNetwork.hh" #include "sim/clocked_object.hh" @@ -102,6 +118,20 @@ class Network : public ClockedObject virtual uint32_t functionalWrite(Packet *pkt) { fatal("Functional write not implemented.\n"); } + /** + * Map an address to the correct NodeID + * + * This function traverses the global address map to find the + * NodeID that corresponds to the given address and the type of + * the destination. For example for a request to a directory this + * function will return the NodeID of the right directory. + * + * @param the destination address + * @param the type of the destination + * @return the NodeID of the destination + */ + NodeID addressToNodeID(Addr addr, MachineType mtype); + protected: // Private copy constructor and assignment operator Network(const Network& obj); @@ -137,6 +167,13 @@ class Network : public ClockedObject void process() {ctr->collateStats();} }; + + // Global address map + struct AddrMapNode { + NodeID id; + AddrRangeList ranges; + }; + std::unordered_multimap<MachineType, AddrMapNode> addrMap; }; inline std::ostream& |