GPU_VIPER_Baseline.py revision 13731
110298Salexandru.dutu@amd.com# Copyright (c) 2015 Advanced Micro Devices, Inc.
210298Salexandru.dutu@amd.com# All rights reserved.
310298Salexandru.dutu@amd.com#
410298Salexandru.dutu@amd.com# For use for simulation and test purposes only
510298Salexandru.dutu@amd.com#
610298Salexandru.dutu@amd.com# Redistribution and use in source and binary forms, with or without
710298Salexandru.dutu@amd.com# modification, are permitted provided that the following conditions are met:
810298Salexandru.dutu@amd.com#
910298Salexandru.dutu@amd.com# 1. Redistributions of source code must retain the above copyright notice,
1010298Salexandru.dutu@amd.com# this list of conditions and the following disclaimer.
1110298Salexandru.dutu@amd.com#
1210298Salexandru.dutu@amd.com# 2. Redistributions in binary form must reproduce the above copyright notice,
1310298Salexandru.dutu@amd.com# this list of conditions and the following disclaimer in the documentation
1410298Salexandru.dutu@amd.com# and/or other materials provided with the distribution.
1510298Salexandru.dutu@amd.com#
1610298Salexandru.dutu@amd.com# 3. Neither the name of the copyright holder nor the names of its
1710298Salexandru.dutu@amd.com# contributors may be used to endorse or promote products derived from this
1810298Salexandru.dutu@amd.com# software without specific prior written permission.
1910298Salexandru.dutu@amd.com#
2010298Salexandru.dutu@amd.com# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
2110298Salexandru.dutu@amd.com# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
2210298Salexandru.dutu@amd.com# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
2310298Salexandru.dutu@amd.com# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
2410298Salexandru.dutu@amd.com# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
2510298Salexandru.dutu@amd.com# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
2610298Salexandru.dutu@amd.com# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
2710298Salexandru.dutu@amd.com# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
2810298Salexandru.dutu@amd.com# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
2910298Salexandru.dutu@amd.com# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
3010298Salexandru.dutu@amd.com# POSSIBILITY OF SUCH DAMAGE.
3110298Salexandru.dutu@amd.com#
3210298Salexandru.dutu@amd.com# Authors: Sooraj Puthoor
3310298Salexandru.dutu@amd.com
3410298Salexandru.dutu@amd.comimport math
3510298Salexandru.dutu@amd.comimport m5
3610298Salexandru.dutu@amd.comfrom m5.objects import *
3710298Salexandru.dutu@amd.comfrom m5.defines import buildEnv
3810298Salexandru.dutu@amd.comfrom m5.util import addToPath
3910298Salexandru.dutu@amd.comfrom Ruby import create_topology
4010298Salexandru.dutu@amd.comfrom Ruby import send_evicts
4110298Salexandru.dutu@amd.com
4210298Salexandru.dutu@amd.comaddToPath('../')
4310298Salexandru.dutu@amd.com
4410298Salexandru.dutu@amd.comfrom topologies.Cluster import Cluster
4510298Salexandru.dutu@amd.comfrom topologies.Crossbar import Crossbar
4610298Salexandru.dutu@amd.com
4710298Salexandru.dutu@amd.comclass CntrlBase:
4810298Salexandru.dutu@amd.com    _seqs = 0
4910298Salexandru.dutu@amd.com    @classmethod
5010298Salexandru.dutu@amd.com    def seqCount(cls):
5110298Salexandru.dutu@amd.com        # Use SeqCount not class since we need global count
5210298Salexandru.dutu@amd.com        CntrlBase._seqs += 1
5310298Salexandru.dutu@amd.com        return CntrlBase._seqs - 1
5410298Salexandru.dutu@amd.com
5510298Salexandru.dutu@amd.com    _cntrls = 0
5610298Salexandru.dutu@amd.com    @classmethod
5710298Salexandru.dutu@amd.com    def cntrlCount(cls):
5810298Salexandru.dutu@amd.com        # Use CntlCount not class since we need global count
5910298Salexandru.dutu@amd.com        CntrlBase._cntrls += 1
6010298Salexandru.dutu@amd.com        return CntrlBase._cntrls - 1
6110298Salexandru.dutu@amd.com
6210298Salexandru.dutu@amd.com    _version = 0
6310298Salexandru.dutu@amd.com    @classmethod
6410298Salexandru.dutu@amd.com    def versionCount(cls):
6510298Salexandru.dutu@amd.com        cls._version += 1 # Use count for this particular type
6610298Salexandru.dutu@amd.com        return cls._version - 1
6710298Salexandru.dutu@amd.com
6810298Salexandru.dutu@amd.comclass L1Cache(RubyCache):
6910298Salexandru.dutu@amd.com    resourceStalls = False
7010298Salexandru.dutu@amd.com    dataArrayBanks = 2
7110298Salexandru.dutu@amd.com    tagArrayBanks = 2
7210298Salexandru.dutu@amd.com    dataAccessLatency = 1
7310298Salexandru.dutu@amd.com    tagAccessLatency = 1
7410298Salexandru.dutu@amd.com    def create(self, size, assoc, options):
7510298Salexandru.dutu@amd.com        self.size = MemorySize(size)
7610298Salexandru.dutu@amd.com        self.assoc = assoc
7710298Salexandru.dutu@amd.com        self.replacement_policy = PseudoLRUReplacementPolicy()
7810298Salexandru.dutu@amd.com
7910298Salexandru.dutu@amd.comclass L2Cache(RubyCache):
8010298Salexandru.dutu@amd.com    resourceStalls = False
8110298Salexandru.dutu@amd.com    assoc = 16
8210298Salexandru.dutu@amd.com    dataArrayBanks = 16
8310298Salexandru.dutu@amd.com    tagArrayBanks = 16
8410298Salexandru.dutu@amd.com    def create(self, size, assoc, options):
8510298Salexandru.dutu@amd.com        self.size = MemorySize(size)
8610298Salexandru.dutu@amd.com        self.assoc = assoc
8710298Salexandru.dutu@amd.com        self.replacement_policy = PseudoLRUReplacementPolicy()
8810298Salexandru.dutu@amd.com
8910298Salexandru.dutu@amd.comclass CPCntrl(CorePair_Controller, CntrlBase):
9010298Salexandru.dutu@amd.com
9110298Salexandru.dutu@amd.com    def create(self, options, ruby_system, system):
9210298Salexandru.dutu@amd.com        self.version = self.versionCount()
9310298Salexandru.dutu@amd.com
9410298Salexandru.dutu@amd.com        self.L1Icache = L1Cache()
9510298Salexandru.dutu@amd.com        self.L1Icache.create(options.l1i_size, options.l1i_assoc, options)
9610298Salexandru.dutu@amd.com        self.L1D0cache = L1Cache()
9710298Salexandru.dutu@amd.com        self.L1D0cache.create(options.l1d_size, options.l1d_assoc, options)
9810298Salexandru.dutu@amd.com        self.L1D1cache = L1Cache()
9910298Salexandru.dutu@amd.com        self.L1D1cache.create(options.l1d_size, options.l1d_assoc, options)
10010298Salexandru.dutu@amd.com        self.L2cache = L2Cache()
10110298Salexandru.dutu@amd.com        self.L2cache.create(options.l2_size, options.l2_assoc, options)
10210298Salexandru.dutu@amd.com
10310298Salexandru.dutu@amd.com        self.sequencer = RubySequencer()
10410298Salexandru.dutu@amd.com        self.sequencer.version = self.seqCount()
10510298Salexandru.dutu@amd.com        self.sequencer.icache = self.L1Icache
10610298Salexandru.dutu@amd.com        self.sequencer.dcache = self.L1D0cache
10710298Salexandru.dutu@amd.com        self.sequencer.ruby_system = ruby_system
10810298Salexandru.dutu@amd.com        self.sequencer.coreid = 0
10910298Salexandru.dutu@amd.com        self.sequencer.is_cpu_sequencer = True
11010298Salexandru.dutu@amd.com
11110298Salexandru.dutu@amd.com        self.sequencer1 = RubySequencer()
11210298Salexandru.dutu@amd.com        self.sequencer1.version = self.seqCount()
11310298Salexandru.dutu@amd.com        self.sequencer1.icache = self.L1Icache
11410298Salexandru.dutu@amd.com        self.sequencer1.dcache = self.L1D1cache
11510298Salexandru.dutu@amd.com        self.sequencer1.ruby_system = ruby_system
11610298Salexandru.dutu@amd.com        self.sequencer1.coreid = 1
11710298Salexandru.dutu@amd.com        self.sequencer1.is_cpu_sequencer = True
11810298Salexandru.dutu@amd.com
11910298Salexandru.dutu@amd.com        self.issue_latency = options.cpu_to_dir_latency
12010298Salexandru.dutu@amd.com        self.send_evictions = send_evicts(options)
12110298Salexandru.dutu@amd.com
12210298Salexandru.dutu@amd.com        self.ruby_system = ruby_system
12310298Salexandru.dutu@amd.com
12410298Salexandru.dutu@amd.com        if options.recycle_latency:
12510298Salexandru.dutu@amd.com            self.recycle_latency = options.recycle_latency
12610298Salexandru.dutu@amd.com
12710298Salexandru.dutu@amd.comclass TCPCache(RubyCache):
12810298Salexandru.dutu@amd.com    size = "16kB"
12910298Salexandru.dutu@amd.com    assoc = 16
13010298Salexandru.dutu@amd.com    dataArrayBanks = 16
13110298Salexandru.dutu@amd.com    tagArrayBanks = 16
13210298Salexandru.dutu@amd.com    dataAccessLatency = 4
13310298Salexandru.dutu@amd.com    tagAccessLatency = 1
13410298Salexandru.dutu@amd.com    def create(self, options):
13510298Salexandru.dutu@amd.com        self.size = MemorySize(options.tcp_size)
13610298Salexandru.dutu@amd.com        self.dataArrayBanks = 16
13710298Salexandru.dutu@amd.com        self.tagArrayBanks = 16
13810298Salexandru.dutu@amd.com        self.dataAccessLatency = 4
13910298Salexandru.dutu@amd.com        self.tagAccessLatency = 1
14010298Salexandru.dutu@amd.com        self.resourceStalls = options.no_tcc_resource_stalls
14110298Salexandru.dutu@amd.com        self.replacement_policy = PseudoLRUReplacementPolicy()
14210298Salexandru.dutu@amd.com
14310298Salexandru.dutu@amd.comclass TCPCntrl(TCP_Controller, CntrlBase):
14410556Salexandru.dutu@amd.com
14510556Salexandru.dutu@amd.com    def create(self, options, ruby_system, system):
14610298Salexandru.dutu@amd.com        self.version = self.versionCount()
14710298Salexandru.dutu@amd.com        self.L1cache = TCPCache()
14810298Salexandru.dutu@amd.com        self.L1cache.create(options)
14910298Salexandru.dutu@amd.com        self.issue_latency = 1
15010558Salexandru.dutu@amd.com
15110558Salexandru.dutu@amd.com        self.coalescer = VIPERCoalescer()
15210298Salexandru.dutu@amd.com        self.coalescer.version = self.seqCount()
15310298Salexandru.dutu@amd.com        self.coalescer.icache = self.L1cache
15410298Salexandru.dutu@amd.com        self.coalescer.dcache = self.L1cache
15510298Salexandru.dutu@amd.com        self.coalescer.ruby_system = ruby_system
15610298Salexandru.dutu@amd.com        self.coalescer.support_inst_reqs = False
15710298Salexandru.dutu@amd.com        self.coalescer.is_cpu_sequencer = False
15810298Salexandru.dutu@amd.com
15910298Salexandru.dutu@amd.com        self.sequencer = RubySequencer()
160        self.sequencer.version = self.seqCount()
161        self.sequencer.icache = self.L1cache
162        self.sequencer.dcache = self.L1cache
163        self.sequencer.ruby_system = ruby_system
164        self.sequencer.is_cpu_sequencer = True
165
166        self.use_seq_not_coal = False
167
168        self.ruby_system = ruby_system
169        if options.recycle_latency:
170            self.recycle_latency = options.recycle_latency
171
172class SQCCache(RubyCache):
173    dataArrayBanks = 8
174    tagArrayBanks = 8
175    dataAccessLatency = 1
176    tagAccessLatency = 1
177
178    def create(self, options):
179        self.size = MemorySize(options.sqc_size)
180        self.assoc = options.sqc_assoc
181        self.replacement_policy = PseudoLRUReplacementPolicy()
182
183class SQCCntrl(SQC_Controller, CntrlBase):
184
185    def create(self, options, ruby_system, system):
186        self.version = self.versionCount()
187        self.L1cache = SQCCache()
188        self.L1cache.create(options)
189        self.L1cache.resourceStalls = False
190        self.sequencer = RubySequencer()
191        self.sequencer.version = self.seqCount()
192        self.sequencer.icache = self.L1cache
193        self.sequencer.dcache = self.L1cache
194        self.sequencer.ruby_system = ruby_system
195        self.sequencer.support_data_reqs = False
196        self.sequencer.is_cpu_sequencer = False
197        self.ruby_system = ruby_system
198        if options.recycle_latency:
199            self.recycle_latency = options.recycle_latency
200
201class TCC(RubyCache):
202    size = MemorySize("256kB")
203    assoc = 16
204    dataAccessLatency = 8
205    tagAccessLatency = 2
206    resourceStalls = True
207    def create(self, options):
208        self.assoc = options.tcc_assoc
209        if hasattr(options, 'bw_scalor') and options.bw_scalor > 0:
210          s = options.num_compute_units
211          tcc_size = s * 128
212          tcc_size = str(tcc_size)+'kB'
213          self.size = MemorySize(tcc_size)
214          self.dataArrayBanks = 64
215          self.tagArrayBanks = 64
216        else:
217          self.size = MemorySize(options.tcc_size)
218          self.dataArrayBanks = 256 / options.num_tccs #number of data banks
219          self.tagArrayBanks = 256 / options.num_tccs #number of tag banks
220        self.size.value = self.size.value / options.num_tccs
221        if ((self.size.value / long(self.assoc)) < 128):
222            self.size.value = long(128 * self.assoc)
223        self.start_index_bit = math.log(options.cacheline_size, 2) + \
224                               math.log(options.num_tccs, 2)
225        self.replacement_policy = PseudoLRUReplacementPolicy()
226
227class TCCCntrl(TCC_Controller, CntrlBase):
228    def create(self, options, ruby_system, system):
229        self.version = self.versionCount()
230        self.L2cache = TCC()
231        self.L2cache.create(options)
232        self.ruby_system = ruby_system
233        self.L2cache.resourceStalls = options.no_tcc_resource_stalls
234
235        if options.recycle_latency:
236            self.recycle_latency = options.recycle_latency
237
238class L3Cache(RubyCache):
239    dataArrayBanks = 16
240    tagArrayBanks = 16
241
242    def create(self, options, ruby_system, system):
243        self.size = MemorySize(options.l3_size)
244        self.size.value /= options.num_dirs
245        self.assoc = options.l3_assoc
246        self.dataArrayBanks /= options.num_dirs
247        self.tagArrayBanks /= options.num_dirs
248        self.dataArrayBanks /= options.num_dirs
249        self.tagArrayBanks /= options.num_dirs
250        self.dataAccessLatency = options.l3_data_latency
251        self.tagAccessLatency = options.l3_tag_latency
252        self.resourceStalls = False
253        self.replacement_policy = PseudoLRUReplacementPolicy()
254
255class ProbeFilter(RubyCache):
256    size = "4MB"
257    assoc = 16
258    dataArrayBanks = 256
259    tagArrayBanks = 256
260
261    def create(self, options, ruby_system, system):
262        self.block_size = "%dB" % (64 * options.blocks_per_region)
263        self.size = options.region_dir_entries * \
264            self.block_size * options.num_compute_units
265        self.assoc = 8
266        self.tagArrayBanks = 8
267        self.tagAccessLatency = options.dir_tag_latency
268        self.dataAccessLatency = 1
269        self.resourceStalls = options.no_resource_stalls
270        self.start_index_bit = 6 + int(math.log(options.blocks_per_region, 2))
271        self.replacement_policy = PseudoLRUReplacementPolicy()
272
273class L3Cntrl(L3Cache_Controller, CntrlBase):
274    def create(self, options, ruby_system, system):
275        self.version = self.versionCount()
276        self.L3cache = L3Cache()
277        self.L3cache.create(options, ruby_system, system)
278        self.l3_response_latency = \
279            max(self.L3cache.dataAccessLatency, self.L3cache.tagAccessLatency)
280        self.ruby_system = ruby_system
281        if options.recycle_latency:
282            self.recycle_latency = options.recycle_latency
283
284    def connectWireBuffers(self, req_to_dir, resp_to_dir, l3_unblock_to_dir,
285                           req_to_l3, probe_to_l3, resp_to_l3):
286        self.reqToDir = req_to_dir
287        self.respToDir = resp_to_dir
288        self.l3UnblockToDir = l3_unblock_to_dir
289        self.reqToL3 = req_to_l3
290        self.probeToL3 = probe_to_l3
291        self.respToL3 = resp_to_l3
292
293class DirMem(RubyDirectoryMemory, CntrlBase):
294    def create(self, options, ruby_system, system):
295        self.version = self.versionCount()
296
297        phys_mem_size = AddrRange(options.mem_size).size()
298        mem_module_size = phys_mem_size / options.num_dirs
299        dir_size = MemorySize('0B')
300        dir_size.value = mem_module_size
301        self.size = dir_size
302
303class DirCntrl(Directory_Controller, CntrlBase):
304    def create(self, options, ruby_system, system):
305        self.version = self.versionCount()
306        self.response_latency = 30
307        self.directory = DirMem()
308        self.directory.create(options, ruby_system, system)
309        self.L3CacheMemory = L3Cache()
310        self.L3CacheMemory.create(options, ruby_system, system)
311        self.ProbeFilterMemory = ProbeFilter()
312        self.ProbeFilterMemory.create(options, ruby_system, system)
313        self.l3_hit_latency = \
314            max(self.L3CacheMemory.dataAccessLatency,
315            self.L3CacheMemory.tagAccessLatency)
316
317        self.ruby_system = ruby_system
318        if options.recycle_latency:
319            self.recycle_latency = options.recycle_latency
320
321    def connectWireBuffers(self, req_to_dir, resp_to_dir, l3_unblock_to_dir,
322                           req_to_l3, probe_to_l3, resp_to_l3):
323        self.reqToDir = req_to_dir
324        self.respToDir = resp_to_dir
325        self.l3UnblockToDir = l3_unblock_to_dir
326        self.reqToL3 = req_to_l3
327        self.probeToL3 = probe_to_l3
328        self.respToL3 = resp_to_l3
329
330def define_options(parser):
331    parser.add_option("--num-subcaches", type = "int", default = 4)
332    parser.add_option("--l3-data-latency", type = "int", default = 20)
333    parser.add_option("--l3-tag-latency", type = "int", default = 15)
334    parser.add_option("--cpu-to-dir-latency", type = "int", default = 120)
335    parser.add_option("--gpu-to-dir-latency", type = "int", default = 120)
336    parser.add_option("--no-resource-stalls", action = "store_false",
337                      default = True)
338    parser.add_option("--no-tcc-resource-stalls", action = "store_false",
339                      default = True)
340    parser.add_option("--num-tbes", type = "int", default = 2560)
341    parser.add_option("--l2-latency", type = "int", default = 50)  # load to use
342    parser.add_option("--num-tccs", type = "int", default = 1,
343                      help = "number of TCC banks in the GPU")
344    parser.add_option("--sqc-size", type = 'string', default = '32kB',
345                      help = "SQC cache size")
346    parser.add_option("--sqc-assoc", type = 'int', default = 8,
347                      help = "SQC cache assoc")
348    parser.add_option("--region-dir-entries", type = "int", default = 8192)
349    parser.add_option("--dir-tag-latency", type = "int", default = 8)
350    parser.add_option("--dir-tag-banks", type = "int", default = 4)
351    parser.add_option("--blocks-per-region", type = "int", default = 1)
352    parser.add_option("--use-L3-on-WT", action = "store_true", default = False)
353    parser.add_option("--nonInclusiveDir", action = "store_true",
354                      default = False)
355    parser.add_option("--WB_L1", action = "store_true",
356        default = False, help = "writeback L2")
357    parser.add_option("--WB_L2", action = "store_true",
358        default = False, help = "writeback L2")
359    parser.add_option("--TCP_latency", type = "int",
360        default = 4, help = "TCP latency")
361    parser.add_option("--TCC_latency", type = "int",
362        default = 16, help = "TCC latency")
363    parser.add_option("--tcc-size", type = 'string', default = '2MB',
364                      help = "agregate tcc size")
365    parser.add_option("--tcc-assoc", type = 'int', default = 16,
366                      help = "tcc assoc")
367    parser.add_option("--tcp-size", type = 'string', default = '16kB',
368                      help = "tcp size")
369    parser.add_option("--sampler-sets", type = "int", default = 1024)
370    parser.add_option("--sampler-assoc", type = "int", default = 16)
371    parser.add_option("--sampler-counter", type = "int", default = 512)
372    parser.add_option("--noL1", action = "store_true", default = False,
373                      help = "bypassL1")
374    parser.add_option("--noL2", action = "store_true", default = False,
375                      help = "bypassL2")
376
377def create_system(options, full_system, system, dma_devices, bootmem,
378                  ruby_system):
379    if buildEnv['PROTOCOL'] != 'GPU_VIPER_Baseline':
380        panic("This script requires the" \
381        "GPU_VIPER_Baseline protocol to be built.")
382
383    cpu_sequencers = []
384
385    #
386    # The ruby network creation expects the list of nodes in the system to be
387    # consistent with the NetDest list.  Therefore the l1 controller nodes
388    # must be listed before the directory nodes and directory nodes before
389    # dma nodes, etc.
390    #
391    cp_cntrl_nodes = []
392    tcp_cntrl_nodes = []
393    sqc_cntrl_nodes = []
394    tcc_cntrl_nodes = []
395    dir_cntrl_nodes = []
396    l3_cntrl_nodes = []
397
398    #
399    # Must create the individual controllers before the network to ensure the
400    # controller constructors are called before the network constructor
401    #
402
403    # For an odd number of CPUs, still create the right number of controllers
404    TCC_bits = int(math.log(options.num_tccs, 2))
405
406    # This is the base crossbar that connects the L3s, Dirs, and cpu/gpu
407    # Clusters
408    crossbar_bw = 16 * options.num_compute_units #Assuming a 2GHz clock
409    mainCluster = Cluster(intBW = crossbar_bw)
410    for i in range(options.num_dirs):
411
412        dir_cntrl = DirCntrl(noTCCdir=True,TCC_select_num_bits = TCC_bits)
413        dir_cntrl.create(options, ruby_system, system)
414        dir_cntrl.number_of_TBEs = options.num_tbes
415        dir_cntrl.useL3OnWT = options.use_L3_on_WT
416        dir_cntrl.inclusiveDir = not options.nonInclusiveDir
417
418        # Connect the Directory controller to the ruby network
419        dir_cntrl.requestFromCores = MessageBuffer(ordered = True)
420        dir_cntrl.requestFromCores.slave = ruby_system.network.master
421
422        dir_cntrl.responseFromCores = MessageBuffer()
423        dir_cntrl.responseFromCores.slave = ruby_system.network.master
424
425        dir_cntrl.unblockFromCores = MessageBuffer()
426        dir_cntrl.unblockFromCores.slave = ruby_system.network.master
427
428        dir_cntrl.probeToCore = MessageBuffer()
429        dir_cntrl.probeToCore.master = ruby_system.network.slave
430
431        dir_cntrl.responseToCore = MessageBuffer()
432        dir_cntrl.responseToCore.master = ruby_system.network.slave
433
434        dir_cntrl.triggerQueue = MessageBuffer(ordered = True)
435        dir_cntrl.L3triggerQueue = MessageBuffer(ordered = True)
436        dir_cntrl.responseFromMemory = MessageBuffer()
437
438        exec("system.dir_cntrl%d = dir_cntrl" % i)
439        dir_cntrl_nodes.append(dir_cntrl)
440        mainCluster.add(dir_cntrl)
441
442    cpuCluster = Cluster(extBW = crossbar_bw, intBW=crossbar_bw)
443    for i in range((options.num_cpus + 1) // 2):
444
445        cp_cntrl = CPCntrl()
446        cp_cntrl.create(options, ruby_system, system)
447
448        exec("system.cp_cntrl%d = cp_cntrl" % i)
449        #
450        # Add controllers and sequencers to the appropriate lists
451        #
452        cpu_sequencers.extend([cp_cntrl.sequencer, cp_cntrl.sequencer1])
453
454        # Connect the CP controllers and the network
455        cp_cntrl.requestFromCore = MessageBuffer()
456        cp_cntrl.requestFromCore.master = ruby_system.network.slave
457
458        cp_cntrl.responseFromCore = MessageBuffer()
459        cp_cntrl.responseFromCore.master = ruby_system.network.slave
460
461        cp_cntrl.unblockFromCore = MessageBuffer()
462        cp_cntrl.unblockFromCore.master = ruby_system.network.slave
463
464        cp_cntrl.probeToCore = MessageBuffer()
465        cp_cntrl.probeToCore.slave = ruby_system.network.master
466
467        cp_cntrl.responseToCore = MessageBuffer()
468        cp_cntrl.responseToCore.slave = ruby_system.network.master
469
470        cp_cntrl.mandatoryQueue = MessageBuffer()
471        cp_cntrl.triggerQueue = MessageBuffer(ordered = True)
472
473        cpuCluster.add(cp_cntrl)
474
475    gpuCluster = Cluster(extBW = crossbar_bw, intBW = crossbar_bw)
476    for i in range(options.num_compute_units):
477
478        tcp_cntrl = TCPCntrl(TCC_select_num_bits = TCC_bits,
479                             issue_latency = 1,
480                             number_of_TBEs = 2560)
481        # TBEs set to max outstanding requests
482        tcp_cntrl.create(options, ruby_system, system)
483        tcp_cntrl.WB = options.WB_L1
484        tcp_cntrl.disableL1 = options.noL1
485
486        exec("system.tcp_cntrl%d = tcp_cntrl" % i)
487        #
488        # Add controllers and sequencers to the appropriate lists
489        #
490        cpu_sequencers.append(tcp_cntrl.coalescer)
491        tcp_cntrl_nodes.append(tcp_cntrl)
492
493        # Connect the CP (TCP) controllers to the ruby network
494        tcp_cntrl.requestFromTCP = MessageBuffer(ordered = True)
495        tcp_cntrl.requestFromTCP.master = ruby_system.network.slave
496
497        tcp_cntrl.responseFromTCP = MessageBuffer(ordered = True)
498        tcp_cntrl.responseFromTCP.master = ruby_system.network.slave
499
500        tcp_cntrl.unblockFromCore = MessageBuffer()
501        tcp_cntrl.unblockFromCore.master = ruby_system.network.slave
502
503        tcp_cntrl.probeToTCP = MessageBuffer(ordered = True)
504        tcp_cntrl.probeToTCP.slave = ruby_system.network.master
505
506        tcp_cntrl.responseToTCP = MessageBuffer(ordered = True)
507        tcp_cntrl.responseToTCP.slave = ruby_system.network.master
508
509        tcp_cntrl.mandatoryQueue = MessageBuffer()
510
511        gpuCluster.add(tcp_cntrl)
512
513    for i in range(options.num_sqc):
514
515        sqc_cntrl = SQCCntrl(TCC_select_num_bits = TCC_bits)
516        sqc_cntrl.create(options, ruby_system, system)
517
518        exec("system.sqc_cntrl%d = sqc_cntrl" % i)
519        #
520        # Add controllers and sequencers to the appropriate lists
521        #
522        cpu_sequencers.append(sqc_cntrl.sequencer)
523
524        # Connect the SQC controller to the ruby network
525        sqc_cntrl.requestFromSQC = MessageBuffer(ordered = True)
526        sqc_cntrl.requestFromSQC.master = ruby_system.network.slave
527
528        sqc_cntrl.probeToSQC = MessageBuffer(ordered = True)
529        sqc_cntrl.probeToSQC.slave = ruby_system.network.master
530
531        sqc_cntrl.responseToSQC = MessageBuffer(ordered = True)
532        sqc_cntrl.responseToSQC.slave = ruby_system.network.master
533
534        sqc_cntrl.mandatoryQueue = MessageBuffer()
535
536        # SQC also in GPU cluster
537        gpuCluster.add(sqc_cntrl)
538
539    # Because of wire buffers, num_tccs must equal num_tccdirs
540    numa_bit = 6
541
542    for i in range(options.num_tccs):
543
544        tcc_cntrl = TCCCntrl()
545        tcc_cntrl.create(options, ruby_system, system)
546        tcc_cntrl.l2_request_latency = options.gpu_to_dir_latency
547        tcc_cntrl.l2_response_latency = options.TCC_latency
548        tcc_cntrl_nodes.append(tcc_cntrl)
549        tcc_cntrl.WB = options.WB_L2
550        tcc_cntrl.number_of_TBEs = 2560 * options.num_compute_units
551
552        # Connect the TCC controllers to the ruby network
553        tcc_cntrl.requestFromTCP = MessageBuffer(ordered = True)
554        tcc_cntrl.requestFromTCP.slave = ruby_system.network.master
555
556        tcc_cntrl.responseToCore = MessageBuffer(ordered = True)
557        tcc_cntrl.responseToCore.master = ruby_system.network.slave
558
559        tcc_cntrl.probeFromNB = MessageBuffer()
560        tcc_cntrl.probeFromNB.slave = ruby_system.network.master
561
562        tcc_cntrl.responseFromNB = MessageBuffer()
563        tcc_cntrl.responseFromNB.slave = ruby_system.network.master
564
565        tcc_cntrl.requestToNB = MessageBuffer(ordered = True)
566        tcc_cntrl.requestToNB.master = ruby_system.network.slave
567
568        tcc_cntrl.responseToNB = MessageBuffer()
569        tcc_cntrl.responseToNB.master = ruby_system.network.slave
570
571        tcc_cntrl.unblockToNB = MessageBuffer()
572        tcc_cntrl.unblockToNB.master = ruby_system.network.slave
573
574        tcc_cntrl.triggerQueue = MessageBuffer(ordered = True)
575
576        exec("system.tcc_cntrl%d = tcc_cntrl" % i)
577        # connect all of the wire buffers between L3 and dirs up
578        # TCC cntrls added to the GPU cluster
579        gpuCluster.add(tcc_cntrl)
580
581    # Assuming no DMA devices
582    assert(len(dma_devices) == 0)
583
584    # Add cpu/gpu clusters to main cluster
585    mainCluster.add(cpuCluster)
586    mainCluster.add(gpuCluster)
587
588    ruby_system.network.number_of_virtual_networks = 10
589
590    return (cpu_sequencers, dir_cntrl_nodes, mainCluster)
591