There are several parts to this PR to work towards #1349 . (1) Make RubySystem::getBlockSizeBytes non-static by providing ways to access the block size or passing the block size explicitly to classes. The main changes are: - DataBlocks must be explicitly allocated. A default ctor still exists to avoid needing to heavily modify SLICC. The size can be set using a realloc function, operator=, or copy ctor. This is handled completely transparently meaning no protocol or config changes are required. - WriteMask now requires block size to be set. This is also handled transparently by modifying the SLICC parser to identify WriteMask types and call setBlockSize(). - AbstractCacheEntry and TBE classes now require block size to be set. This is handled transparently by modifying the SLICC parser to identify these classes and call initBlockSize() which calls setBlockSize() for any DataBlock or WriteMask. - All AbstractControllers now have a pointer to RubySystem. This is assigned in SLICC generated code and requires no changes to protocol or configs. - The Ruby Message class now requires block size in all constructors. This is added to the argument list automatically by the SLICC parser. (2) Relax dependence on common functions in src/mem/ruby/common/Address.hh so that RubySystem::getBlockSizeBits is no longer static. Many classes already have a way to get block size from the previous commit, so they simply multiple by 8 to get the number of bits. For handling SLICC and reducing the number of changes, define makeCacheLine, getOffset, etc. in RubyPort and AbstractController. The only protocol changes required are to change any "RubySystem::foo()" calls with "m_ruby_system->foo()". For classes which do not have a way to get access to block size but still used makeLineAddress, getOffset, etc., the block size must be passed to that class. This requires some changes to the SimObject interface for two commonly used classes: DirectoryMemory and RubyPrefecther, resulting in user-facing API changes User-facing API changes: - DirectoryMemory and RubyPrefetcher now require the cache line size as a non-optional argument. - RubySequencer SimObjects now require RubySystem as a non-optional argument. - TesterThread in the GPU ruby tester now requires the cache line size as a non-optional argument. (3) Removes static member variables in RubySystem which control randomization, cooldown, and warmup. These are mostly used by the Ruby Network. The network classes are modified to take these former static variables as parameters which are passed to the corresponding method (e.g., enqueue, delayHead, etc.) rather than needing a RubySystem object at all. Change-Id: Ia63c2ad5cf0bf9d1cbdffba5d3a679bb4d3b1220 (4) There are two major SLICC generated static methods: getNumControllers() on each cache controller which returns the number of controllers created by the configs at run time and the functions which access this method, which are MachineType_base_count and MachineType_base_number. These need to be removed to create multiple RubySystem objects otherwise NetDest, version value, and other objects are incorrect. To remove the static requirement, MachineType_base_count and MachineType_base_number are moved to RubySystem. Any class which needs to call these methods must now have a pointer to a RubySystem. To enable that, several changes are made: - RubyRequest and Message now require a RubySystem pointer in the constructor. The pointer is passed to fields in the Message class which require a RubySystem pointer (e.g., NetDest). SLICC is modified to do this automatically. - SLICC structures may now optionally take an "implicit constructor" which can be used to call a non-default constructor for locally defined variables (e.g., temporary variables within SLICC actions). A statement such as "NetDest bcast_dest;" in SLICC will implicitly append a call to the NetDest constructor taking RubySystem, for example. - RubySystem gets passed to Ruby network objects (Network, Topology).
439 lines
14 KiB
Python
439 lines
14 KiB
Python
# Copyright (c) 2010-2015 Advanced Micro Devices, Inc.
|
|
# All rights reserved.
|
|
#
|
|
# Redistribution and use in source and binary forms, with or without
|
|
# modification, are permitted provided that the following conditions are met:
|
|
#
|
|
# 1. Redistributions of source code must retain the above copyright notice,
|
|
# this list of conditions and the following disclaimer.
|
|
#
|
|
# 2. Redistributions in binary form must reproduce the above copyright notice,
|
|
# this list of conditions and the following disclaimer in the documentation
|
|
# and/or other materials provided with the distribution.
|
|
#
|
|
# 3. Neither the name of the copyright holder nor the names of its
|
|
# contributors may be used to endorse or promote products derived from this
|
|
# software without specific prior written permission.
|
|
#
|
|
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
|
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
|
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
|
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
|
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
|
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
# POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
import math
|
|
|
|
from common import FileSystemConfig
|
|
|
|
import m5
|
|
from m5.defines import buildEnv
|
|
from m5.objects import *
|
|
from m5.util import addToPath
|
|
|
|
from .Ruby import (
|
|
create_topology,
|
|
send_evicts,
|
|
)
|
|
|
|
addToPath("../")
|
|
|
|
from topologies.Cluster import Cluster
|
|
from topologies.Crossbar import Crossbar
|
|
|
|
|
|
class CntrlBase:
|
|
_seqs = 0
|
|
|
|
@classmethod
|
|
def seqCount(cls):
|
|
# Use SeqCount not class since we need global count
|
|
CntrlBase._seqs += 1
|
|
return CntrlBase._seqs - 1
|
|
|
|
_cntrls = 0
|
|
|
|
@classmethod
|
|
def cntrlCount(cls):
|
|
# Use CntlCount not class since we need global count
|
|
CntrlBase._cntrls += 1
|
|
return CntrlBase._cntrls - 1
|
|
|
|
_version = 0
|
|
|
|
@classmethod
|
|
def versionCount(cls):
|
|
cls._version += 1 # Use count for this particular type
|
|
return cls._version - 1
|
|
|
|
|
|
class L1DCache(RubyCache):
|
|
resourceStalls = False
|
|
|
|
def create(self, options):
|
|
self.size = MemorySize(options.l1d_size)
|
|
self.assoc = options.l1d_assoc
|
|
self.replacement_policy = TreePLRURP()
|
|
|
|
|
|
class L1ICache(RubyCache):
|
|
resourceStalls = False
|
|
|
|
def create(self, options):
|
|
self.size = MemorySize(options.l1i_size)
|
|
self.assoc = options.l1i_assoc
|
|
self.replacement_policy = TreePLRURP()
|
|
|
|
|
|
class L2Cache(RubyCache):
|
|
resourceStalls = False
|
|
|
|
def create(self, options):
|
|
self.size = MemorySize(options.l2_size)
|
|
self.assoc = options.l2_assoc
|
|
self.replacement_policy = TreePLRURP()
|
|
|
|
|
|
class CPCntrl(CorePair_Controller, CntrlBase):
|
|
def create(self, options, ruby_system, system):
|
|
self.version = self.versionCount()
|
|
|
|
self.L1Icache = L1ICache()
|
|
self.L1Icache.create(options)
|
|
self.L1D0cache = L1DCache()
|
|
self.L1D0cache.create(options)
|
|
self.L1D1cache = L1DCache()
|
|
self.L1D1cache.create(options)
|
|
self.L2cache = L2Cache()
|
|
self.L2cache.create(options)
|
|
|
|
self.sequencer = RubySequencer(ruby_system=ruby_system)
|
|
self.sequencer.version = self.seqCount()
|
|
self.sequencer.dcache = self.L1D0cache
|
|
self.sequencer.ruby_system = ruby_system
|
|
self.sequencer.coreid = 0
|
|
self.sequencer.is_cpu_sequencer = True
|
|
|
|
self.sequencer1 = RubySequencer(ruby_system=ruby_system)
|
|
self.sequencer1.version = self.seqCount()
|
|
self.sequencer1.dcache = self.L1D1cache
|
|
self.sequencer1.ruby_system = ruby_system
|
|
self.sequencer1.coreid = 1
|
|
self.sequencer1.is_cpu_sequencer = True
|
|
|
|
# Defines icache/dcache hit latency
|
|
self.mandatory_queue_latency = 2
|
|
|
|
self.issue_latency = options.cpu_to_dir_latency
|
|
self.send_evictions = send_evicts(options)
|
|
|
|
self.ruby_system = ruby_system
|
|
|
|
if options.recycle_latency:
|
|
self.recycle_latency = options.recycle_latency
|
|
|
|
|
|
class L3Cache(RubyCache):
|
|
assoc = 8
|
|
dataArrayBanks = 256
|
|
tagArrayBanks = 256
|
|
|
|
def create(self, options, ruby_system, system):
|
|
self.size = MemorySize(options.l3_size)
|
|
self.size.value /= options.num_dirs
|
|
self.dataArrayBanks /= options.num_dirs
|
|
self.tagArrayBanks /= options.num_dirs
|
|
self.dataArrayBanks /= options.num_dirs
|
|
self.tagArrayBanks /= options.num_dirs
|
|
self.dataAccessLatency = options.l3_data_latency
|
|
self.tagAccessLatency = options.l3_tag_latency
|
|
self.resourceStalls = options.no_resource_stalls
|
|
self.replacement_policy = TreePLRURP()
|
|
|
|
|
|
class L3Cntrl(L3Cache_Controller, CntrlBase):
|
|
def create(self, options, ruby_system, system):
|
|
self.version = self.versionCount()
|
|
self.L3cache = L3Cache()
|
|
self.L3cache.create(options, ruby_system, system)
|
|
|
|
self.l3_response_latency = max(
|
|
self.L3cache.dataAccessLatency, self.L3cache.tagAccessLatency
|
|
)
|
|
self.ruby_system = ruby_system
|
|
|
|
if options.recycle_latency:
|
|
self.recycle_latency = options.recycle_latency
|
|
|
|
def connectWireBuffers(
|
|
self,
|
|
req_to_dir,
|
|
resp_to_dir,
|
|
l3_unblock_to_dir,
|
|
req_to_l3,
|
|
probe_to_l3,
|
|
resp_to_l3,
|
|
):
|
|
self.reqToDir = req_to_dir
|
|
self.respToDir = resp_to_dir
|
|
self.l3UnblockToDir = l3_unblock_to_dir
|
|
self.reqToL3 = req_to_l3
|
|
self.probeToL3 = probe_to_l3
|
|
self.respToL3 = resp_to_l3
|
|
|
|
|
|
class DirCntrl(Directory_Controller, CntrlBase):
|
|
def create(self, options, dir_ranges, ruby_system, system):
|
|
self.version = self.versionCount()
|
|
|
|
self.response_latency = 30
|
|
|
|
self.addr_ranges = dir_ranges
|
|
self.directory = RubyDirectoryMemory(
|
|
block_size=ruby_system.block_size_bytes
|
|
)
|
|
|
|
self.L3CacheMemory = L3Cache()
|
|
self.L3CacheMemory.create(options, ruby_system, system)
|
|
|
|
self.l3_hit_latency = max(
|
|
self.L3CacheMemory.dataAccessLatency,
|
|
self.L3CacheMemory.tagAccessLatency,
|
|
)
|
|
|
|
self.number_of_TBEs = options.num_tbes
|
|
|
|
self.ruby_system = ruby_system
|
|
|
|
if options.recycle_latency:
|
|
self.recycle_latency = options.recycle_latency
|
|
|
|
self.CPUonly = True
|
|
|
|
def connectWireBuffers(
|
|
self,
|
|
req_to_dir,
|
|
resp_to_dir,
|
|
l3_unblock_to_dir,
|
|
req_to_l3,
|
|
probe_to_l3,
|
|
resp_to_l3,
|
|
):
|
|
self.reqToDir = req_to_dir
|
|
self.respToDir = resp_to_dir
|
|
self.l3UnblockToDir = l3_unblock_to_dir
|
|
self.reqToL3 = req_to_l3
|
|
self.probeToL3 = probe_to_l3
|
|
self.respToL3 = resp_to_l3
|
|
|
|
|
|
def define_options(parser):
|
|
parser.add_argument("--num-subcaches", type=int, default=4)
|
|
parser.add_argument("--l3-data-latency", type=int, default=20)
|
|
parser.add_argument("--l3-tag-latency", type=int, default=15)
|
|
parser.add_argument("--cpu-to-dir-latency", type=int, default=15)
|
|
parser.add_argument(
|
|
"--no-resource-stalls", action="store_false", default=True
|
|
)
|
|
parser.add_argument("--num-tbes", type=int, default=256)
|
|
parser.add_argument("--l2-latency", type=int, default=50) # load to use
|
|
|
|
|
|
def create_system(
|
|
options, full_system, system, dma_devices, bootmem, ruby_system
|
|
):
|
|
if buildEnv["PROTOCOL"] != "MOESI_AMD_Base":
|
|
panic("This script requires the MOESI_AMD_Base protocol.")
|
|
|
|
cpu_sequencers = []
|
|
|
|
#
|
|
# The ruby network creation expects the list of nodes in the system to
|
|
# be consistent with the NetDest list. Therefore the l1 controller
|
|
# nodes must be listed before the directory nodes and directory nodes
|
|
# before dma nodes, etc.
|
|
#
|
|
l1_cntrl_nodes = []
|
|
l3_cntrl_nodes = []
|
|
dir_cntrl_nodes = []
|
|
|
|
control_count = 0
|
|
|
|
#
|
|
# Must create the individual controllers before the network to ensure
|
|
# the controller constructors are called before the network constructor
|
|
#
|
|
|
|
# This is the base crossbar that connects the L3s, Dirs, and cpu
|
|
# Cluster
|
|
mainCluster = Cluster(extBW=512, intBW=512) # 1 TB/s
|
|
|
|
if options.numa_high_bit:
|
|
numa_bit = options.numa_high_bit
|
|
else:
|
|
# if the numa_bit is not specified, set the directory bits as the
|
|
# lowest bits above the block offset bits, and the numa_bit as the
|
|
# highest of those directory bits
|
|
dir_bits = int(math.log(options.num_dirs, 2))
|
|
block_size_bits = int(math.log(options.cacheline_size, 2))
|
|
numa_bit = block_size_bits + dir_bits - 1
|
|
|
|
for i in range(options.num_dirs):
|
|
dir_ranges = []
|
|
for r in system.mem_ranges:
|
|
addr_range = m5.objects.AddrRange(
|
|
r.start,
|
|
size=r.size(),
|
|
intlvHighBit=numa_bit,
|
|
intlvBits=dir_bits,
|
|
intlvMatch=i,
|
|
)
|
|
dir_ranges.append(addr_range)
|
|
|
|
dir_cntrl = DirCntrl(TCC_select_num_bits=0)
|
|
dir_cntrl.create(options, dir_ranges, ruby_system, system)
|
|
|
|
# Connect the Directory controller to the ruby network
|
|
dir_cntrl.requestFromCores = MessageBuffer(ordered=True)
|
|
dir_cntrl.requestFromCores.in_port = ruby_system.network.out_port
|
|
|
|
dir_cntrl.responseFromCores = MessageBuffer()
|
|
dir_cntrl.responseFromCores.in_port = ruby_system.network.out_port
|
|
|
|
dir_cntrl.unblockFromCores = MessageBuffer()
|
|
dir_cntrl.unblockFromCores.in_port = ruby_system.network.out_port
|
|
|
|
dir_cntrl.probeToCore = MessageBuffer()
|
|
dir_cntrl.probeToCore.out_port = ruby_system.network.in_port
|
|
|
|
dir_cntrl.responseToCore = MessageBuffer()
|
|
dir_cntrl.responseToCore.out_port = ruby_system.network.in_port
|
|
|
|
dir_cntrl.triggerQueue = MessageBuffer(ordered=True)
|
|
dir_cntrl.L3triggerQueue = MessageBuffer(ordered=True)
|
|
|
|
dir_cntrl.requestToMemory = MessageBuffer()
|
|
dir_cntrl.responseFromMemory = MessageBuffer()
|
|
|
|
exec("system.dir_cntrl%d = dir_cntrl" % i)
|
|
dir_cntrl_nodes.append(dir_cntrl)
|
|
|
|
mainCluster.add(dir_cntrl)
|
|
|
|
# Technically this config can support an odd number of cpus, but the top
|
|
# level config files, such as the ruby_random_tester, will get confused if
|
|
# the number of cpus does not equal the number of sequencers. Thus make
|
|
# sure that an even number of cpus is specified.
|
|
assert (options.num_cpus % 2) == 0
|
|
|
|
# For an odd number of CPUs, still create the right number of controllers
|
|
cpuCluster = Cluster(extBW=512, intBW=512) # 1 TB/s
|
|
for i in range((options.num_cpus + 1) // 2):
|
|
cp_cntrl = CPCntrl()
|
|
cp_cntrl.create(options, ruby_system, system)
|
|
|
|
exec("system.cp_cntrl%d = cp_cntrl" % i)
|
|
#
|
|
# Add controllers and sequencers to the appropriate lists
|
|
#
|
|
cpu_sequencers.extend([cp_cntrl.sequencer, cp_cntrl.sequencer1])
|
|
|
|
# Connect the CP controllers and the network
|
|
cp_cntrl.requestFromCore = MessageBuffer()
|
|
cp_cntrl.requestFromCore.out_port = ruby_system.network.in_port
|
|
|
|
cp_cntrl.responseFromCore = MessageBuffer()
|
|
cp_cntrl.responseFromCore.out_port = ruby_system.network.in_port
|
|
|
|
cp_cntrl.unblockFromCore = MessageBuffer()
|
|
cp_cntrl.unblockFromCore.out_port = ruby_system.network.in_port
|
|
|
|
cp_cntrl.probeToCore = MessageBuffer()
|
|
cp_cntrl.probeToCore.in_port = ruby_system.network.out_port
|
|
|
|
cp_cntrl.responseToCore = MessageBuffer()
|
|
cp_cntrl.responseToCore.in_port = ruby_system.network.out_port
|
|
|
|
cp_cntrl.mandatoryQueue = MessageBuffer()
|
|
cp_cntrl.triggerQueue = MessageBuffer(ordered=True)
|
|
|
|
cpuCluster.add(cp_cntrl)
|
|
|
|
# Register CPUs and caches for each CorePair and directory (SE mode only)
|
|
if not full_system:
|
|
for i in range((options.num_cpus + 1) // 2):
|
|
FileSystemConfig.register_cpu(
|
|
physical_package_id=0,
|
|
core_siblings=range(options.num_cpus),
|
|
core_id=i * 2,
|
|
thread_siblings=[],
|
|
)
|
|
|
|
FileSystemConfig.register_cpu(
|
|
physical_package_id=0,
|
|
core_siblings=range(options.num_cpus),
|
|
core_id=i * 2 + 1,
|
|
thread_siblings=[],
|
|
)
|
|
|
|
FileSystemConfig.register_cache(
|
|
level=0,
|
|
idu_type="Instruction",
|
|
size=options.l1i_size,
|
|
line_size=options.cacheline_size,
|
|
assoc=options.l1i_assoc,
|
|
cpus=[i * 2, i * 2 + 1],
|
|
)
|
|
|
|
FileSystemConfig.register_cache(
|
|
level=0,
|
|
idu_type="Data",
|
|
size=options.l1d_size,
|
|
line_size=options.cacheline_size,
|
|
assoc=options.l1d_assoc,
|
|
cpus=[i * 2],
|
|
)
|
|
|
|
FileSystemConfig.register_cache(
|
|
level=0,
|
|
idu_type="Data",
|
|
size=options.l1d_size,
|
|
line_size=options.cacheline_size,
|
|
assoc=options.l1d_assoc,
|
|
cpus=[i * 2 + 1],
|
|
)
|
|
|
|
FileSystemConfig.register_cache(
|
|
level=1,
|
|
idu_type="Unified",
|
|
size=options.l2_size,
|
|
line_size=options.cacheline_size,
|
|
assoc=options.l2_assoc,
|
|
cpus=[i * 2, i * 2 + 1],
|
|
)
|
|
|
|
for i in range(options.num_dirs):
|
|
FileSystemConfig.register_cache(
|
|
level=2,
|
|
idu_type="Unified",
|
|
size=options.l3_size,
|
|
line_size=options.cacheline_size,
|
|
assoc=options.l3_assoc,
|
|
cpus=[n for n in range(options.num_cpus)],
|
|
)
|
|
|
|
# Assuming no DMA devices
|
|
assert len(dma_devices) == 0
|
|
|
|
# Add cpu/gpu clusters to main cluster
|
|
mainCluster.add(cpuCluster)
|
|
|
|
ruby_system.network.number_of_virtual_networks = 10
|
|
|
|
return (cpu_sequencers, dir_cntrl_nodes, mainCluster)
|