GPU_RfO.py revision 12065:e3e51756dfef
1#
2#  Copyright (c) 2011-2015 Advanced Micro Devices, Inc.
3#  All rights reserved.
4#
5#  For use for simulation and test purposes only
6#
7#  Redistribution and use in source and binary forms, with or without
8#  modification, are permitted provided that the following conditions are met:
9#
10#  1. Redistributions of source code must retain the above copyright notice,
11#  this list of conditions and the following disclaimer.
12#
13#  2. Redistributions in binary form must reproduce the above copyright notice,
14#  this list of conditions and the following disclaimer in the documentation
15#  and/or other materials provided with the distribution.
16#
17#  3. Neither the name of the copyright holder nor the names of its contributors
18#  may be used to endorse or promote products derived from this software
19#  without specific prior written permission.
20#
21#  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
22#  AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23#  IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24#  ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
25#  LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
26#  CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
27#  SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
28#  INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
29#  CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
30#  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31#  POSSIBILITY OF SUCH DAMAGE.
32#
33#  Author: Lisa Hsu
34#
35
36import math
37import m5
38from m5.objects import *
39from m5.defines import buildEnv
40from Ruby import create_topology
41from Ruby import send_evicts
42
43from topologies.Cluster import Cluster
44from topologies.Crossbar import Crossbar
45
46class CntrlBase:
47    _seqs = 0
48    @classmethod
49    def seqCount(cls):
50        # Use SeqCount not class since we need global count
51        CntrlBase._seqs += 1
52        return CntrlBase._seqs - 1
53
54    _cntrls = 0
55    @classmethod
56    def cntrlCount(cls):
57        # Use CntlCount not class since we need global count
58        CntrlBase._cntrls += 1
59        return CntrlBase._cntrls - 1
60
61    _version = 0
62    @classmethod
63    def versionCount(cls):
64        cls._version += 1 # Use count for this particular type
65        return cls._version - 1
66
67class TccDirCache(RubyCache):
68    size = "512kB"
69    assoc = 16
70    resourceStalls = False
71    def create(self, options):
72        self.size = MemorySize(options.tcc_size)
73        self.size.value += (options.num_compute_units *
74                            (MemorySize(options.tcp_size).value) *
75                            options.tcc_dir_factor) / long(options.num_tccs)
76        self.start_index_bit = math.log(options.cacheline_size, 2) + \
77                               math.log(options.num_tccs, 2)
78        self.replacement_policy = PseudoLRUReplacementPolicy()
79
80class L1DCache(RubyCache):
81    resourceStalls = False
82    def create(self, options):
83        self.size = MemorySize(options.l1d_size)
84        self.assoc = options.l1d_assoc
85        self.replacement_policy = PseudoLRUReplacementPolicy()
86
87class L1ICache(RubyCache):
88    resourceStalls = False
89    def create(self, options):
90        self.size = MemorySize(options.l1i_size)
91        self.assoc = options.l1i_assoc
92        self.replacement_policy = PseudoLRUReplacementPolicy()
93
94class L2Cache(RubyCache):
95    resourceStalls = False
96    def create(self, options):
97        self.size = MemorySize(options.l2_size)
98        self.assoc = options.l2_assoc
99        self.replacement_policy = PseudoLRUReplacementPolicy()
100
101
102class CPCntrl(CorePair_Controller, CntrlBase):
103
104    def create(self, options, ruby_system, system):
105        self.version = self.versionCount()
106
107        self.L1Icache = L1ICache()
108        self.L1Icache.create(options)
109        self.L1D0cache = L1DCache()
110        self.L1D0cache.create(options)
111        self.L1D1cache = L1DCache()
112        self.L1D1cache.create(options)
113        self.L2cache = L2Cache()
114        self.L2cache.create(options)
115
116        self.sequencer = RubySequencer()
117        self.sequencer.icache_hit_latency = 2
118        self.sequencer.dcache_hit_latency = 2
119        self.sequencer.version = self.seqCount()
120        self.sequencer.icache = self.L1Icache
121        self.sequencer.dcache = self.L1D0cache
122        self.sequencer.ruby_system = ruby_system
123        self.sequencer.coreid = 0
124        self.sequencer.is_cpu_sequencer = True
125
126        self.sequencer1 = RubySequencer()
127        self.sequencer1.version = self.seqCount()
128        self.sequencer1.icache = self.L1Icache
129        self.sequencer1.dcache = self.L1D1cache
130        self.sequencer1.icache_hit_latency = 2
131        self.sequencer1.dcache_hit_latency = 2
132        self.sequencer1.ruby_system = ruby_system
133        self.sequencer1.coreid = 1
134        self.sequencer1.is_cpu_sequencer = True
135
136        self.issue_latency = options.cpu_to_dir_latency
137        self.send_evictions = send_evicts(options)
138
139        self.ruby_system = ruby_system
140
141        if options.recycle_latency:
142            self.recycle_latency = options.recycle_latency
143
144class TCPCache(RubyCache):
145    assoc = 8
146    dataArrayBanks = 16
147    tagArrayBanks = 4
148    dataAccessLatency = 4
149    tagAccessLatency = 1
150    def create(self, options):
151        self.size = MemorySize(options.tcp_size)
152        self.replacement_policy = PseudoLRUReplacementPolicy()
153
154class TCPCntrl(TCP_Controller, CntrlBase):
155
156    def create(self, options, ruby_system, system):
157        self.version = self.versionCount()
158
159        self.L1cache = TCPCache(tagAccessLatency = options.TCP_latency)
160        self.L1cache.resourceStalls = options.no_resource_stalls
161        self.L1cache.create(options)
162
163        self.coalescer = RubyGPUCoalescer()
164        self.coalescer.version = self.seqCount()
165        self.coalescer.icache = self.L1cache
166        self.coalescer.dcache = self.L1cache
167        self.coalescer.ruby_system = ruby_system
168        self.coalescer.support_inst_reqs = False
169        self.coalescer.is_cpu_sequencer = False
170        self.coalescer.max_outstanding_requests = options.simds_per_cu * \
171                                                  options.wfs_per_simd * \
172                                                  options.wf_size
173
174        self.sequencer = RubySequencer()
175        self.sequencer.version = self.seqCount()
176        self.sequencer.icache = self.L1cache
177        self.sequencer.dcache = self.L1cache
178        self.sequencer.ruby_system = ruby_system
179        self.sequencer.is_cpu_sequencer = True
180
181        self.use_seq_not_coal = False
182
183        self.ruby_system = ruby_system
184
185        if options.recycle_latency:
186            self.recycle_latency = options.recycle_latency
187
188    def createCP(self, options, ruby_system, system):
189        self.version = self.versionCount()
190
191        self.L1cache = TCPCache(tagAccessLatency = options.TCP_latency)
192        self.L1cache.resourceStalls = options.no_resource_stalls
193        self.L1cache.create(options)
194
195        self.coalescer = RubyGPUCoalescer()
196        self.coalescer.version = self.seqCount()
197        self.coalescer.icache = self.L1cache
198        self.coalescer.dcache = self.L1cache
199        self.coalescer.ruby_system = ruby_system
200        self.coalescer.support_inst_reqs = False
201        self.coalescer.is_cpu_sequencer = False
202
203        self.sequencer = RubySequencer()
204        self.sequencer.version = self.seqCount()
205        self.sequencer.icache = self.L1cache
206        self.sequencer.dcache = self.L1cache
207        self.sequencer.ruby_system = ruby_system
208        self.sequencer.is_cpu_sequencer = True
209
210        self.use_seq_not_coal = True
211
212        self.ruby_system = ruby_system
213
214        if options.recycle_latency:
215            self.recycle_latency = options.recycle_latency
216
217class SQCCache(RubyCache):
218    size = "32kB"
219    assoc = 8
220    dataArrayBanks = 16
221    tagArrayBanks = 4
222    dataAccessLatency = 4
223    tagAccessLatency = 1
224    def create(self, options):
225        self.replacement_policy = PseudoLRUReplacementPolicy()
226
227class SQCCntrl(SQC_Controller, CntrlBase):
228
229    def create(self, options, ruby_system, system):
230        self.version = self.versionCount()
231
232        self.L1cache = SQCCache()
233        self.L1cache.create(options)
234        self.L1cache.resourceStalls = options.no_resource_stalls
235
236        self.sequencer = RubySequencer()
237
238        self.sequencer.version = self.seqCount()
239        self.sequencer.icache = self.L1cache
240        self.sequencer.dcache = self.L1cache
241        self.sequencer.ruby_system = ruby_system
242        self.sequencer.support_data_reqs = False
243        self.sequencer.is_cpu_sequencer = False
244
245        self.ruby_system = ruby_system
246
247        if options.recycle_latency:
248            self.recycle_latency = options.recycle_latency
249
250    def createCP(self, options, ruby_system, system):
251        self.version = self.versionCount()
252
253        self.L1cache = SQCCache()
254        self.L1cache.create(options)
255        self.L1cache.resourceStalls = options.no_resource_stalls
256
257        self.sequencer = RubySequencer()
258
259        self.sequencer.version = self.seqCount()
260        self.sequencer.icache = self.L1cache
261        self.sequencer.dcache = self.L1cache
262        self.sequencer.ruby_system = ruby_system
263        self.sequencer.support_data_reqs = False
264
265        self.ruby_system = ruby_system
266
267        if options.recycle_latency:
268            self.recycle_latency = options.recycle_latency
269
270
271class TCC(RubyCache):
272    assoc = 16
273    dataAccessLatency = 8
274    tagAccessLatency = 2
275    resourceStalls = True
276    def create(self, options):
277        self.size = MemorySize(options.tcc_size)
278        self.size = self.size / options.num_tccs
279        self.dataArrayBanks = 256 / options.num_tccs #number of data banks
280        self.tagArrayBanks = 256 / options.num_tccs #number of tag banks
281        if ((self.size.value / long(self.assoc)) < 128):
282            self.size.value = long(128 * self.assoc)
283        self.start_index_bit = math.log(options.cacheline_size, 2) + \
284                               math.log(options.num_tccs, 2)
285        self.replacement_policy = PseudoLRUReplacementPolicy()
286
287class TCCCntrl(TCC_Controller, CntrlBase):
288    def create(self, options, ruby_system, system):
289        self.version = self.versionCount()
290        self.L2cache = TCC()
291        self.L2cache.create(options)
292        self.l2_response_latency = options.TCC_latency
293
294        self.number_of_TBEs = 2048
295
296        self.ruby_system = ruby_system
297
298        if options.recycle_latency:
299            self.recycle_latency = options.recycle_latency
300
301    def connectWireBuffers(self, req_to_tccdir, resp_to_tccdir,
302                           tcc_unblock_to_tccdir, req_to_tcc,
303                           probe_to_tcc, resp_to_tcc):
304        self.w_reqToTCCDir = req_to_tccdir
305        self.w_respToTCCDir = resp_to_tccdir
306        self.w_TCCUnblockToTCCDir = tcc_unblock_to_tccdir
307        self.w_reqToTCC = req_to_tcc
308        self.w_probeToTCC = probe_to_tcc
309        self.w_respToTCC = resp_to_tcc
310
311class TCCDirCntrl(TCCdir_Controller, CntrlBase):
312    def create(self, options, ruby_system, system):
313        self.version = self.versionCount()
314
315        self.directory = TccDirCache()
316        self.directory.create(options)
317
318        self.number_of_TBEs = 1024
319
320        self.ruby_system = ruby_system
321
322        if options.recycle_latency:
323            self.recycle_latency = options.recycle_latency
324
325    def connectWireBuffers(self, req_to_tccdir, resp_to_tccdir,
326                           tcc_unblock_to_tccdir, req_to_tcc,
327                           probe_to_tcc, resp_to_tcc):
328        self.w_reqToTCCDir = req_to_tccdir
329        self.w_respToTCCDir = resp_to_tccdir
330        self.w_TCCUnblockToTCCDir = tcc_unblock_to_tccdir
331        self.w_reqToTCC = req_to_tcc
332        self.w_probeToTCC = probe_to_tcc
333        self.w_respToTCC = resp_to_tcc
334
335class L3Cache(RubyCache):
336    assoc = 8
337    dataArrayBanks = 256
338    tagArrayBanks = 256
339
340    def create(self, options, ruby_system, system):
341        self.size = MemorySize(options.l3_size)
342        self.size.value /= options.num_dirs
343        self.dataArrayBanks /= options.num_dirs
344        self.tagArrayBanks /= options.num_dirs
345        self.dataArrayBanks /= options.num_dirs
346        self.tagArrayBanks /= options.num_dirs
347        self.dataAccessLatency = options.l3_data_latency
348        self.tagAccessLatency = options.l3_tag_latency
349        self.resourceStalls = options.no_resource_stalls
350        self.replacement_policy = PseudoLRUReplacementPolicy()
351
352class L3Cntrl(L3Cache_Controller, CntrlBase):
353    def create(self, options, ruby_system, system):
354        self.version = self.versionCount()
355        self.L3cache = L3Cache()
356        self.L3cache.create(options, ruby_system, system)
357
358        self.l3_response_latency = max(self.L3cache.dataAccessLatency,
359                                       self.L3cache.tagAccessLatency)
360        self.ruby_system = ruby_system
361
362        if options.recycle_latency:
363            self.recycle_latency = options.recycle_latency
364
365    def connectWireBuffers(self, req_to_dir, resp_to_dir, l3_unblock_to_dir,
366                           req_to_l3, probe_to_l3, resp_to_l3):
367        self.reqToDir = req_to_dir
368        self.respToDir = resp_to_dir
369        self.l3UnblockToDir = l3_unblock_to_dir
370        self.reqToL3 = req_to_l3
371        self.probeToL3 = probe_to_l3
372        self.respToL3 = resp_to_l3
373
374class DirCntrl(Directory_Controller, CntrlBase):
375    def create(self, options, dir_ranges, ruby_system, system):
376        self.version = self.versionCount()
377
378        self.response_latency = 30
379
380        self.addr_ranges = dir_ranges
381        self.directory = RubyDirectoryMemory()
382
383        self.L3CacheMemory = L3Cache()
384        self.L3CacheMemory.create(options, ruby_system, system)
385
386        self.l3_hit_latency = max(self.L3CacheMemory.dataAccessLatency,
387                                  self.L3CacheMemory.tagAccessLatency)
388
389        self.number_of_TBEs = options.num_tbes
390
391        self.ruby_system = ruby_system
392
393        if options.recycle_latency:
394            self.recycle_latency = options.recycle_latency
395
396    def connectWireBuffers(self, req_to_dir, resp_to_dir, l3_unblock_to_dir,
397                           req_to_l3, probe_to_l3, resp_to_l3):
398        self.reqToDir = req_to_dir
399        self.respToDir = resp_to_dir
400        self.l3UnblockToDir = l3_unblock_to_dir
401        self.reqToL3 = req_to_l3
402        self.probeToL3 = probe_to_l3
403        self.respToL3 = resp_to_l3
404
405
406
407def define_options(parser):
408    parser.add_option("--num-subcaches", type="int", default=4)
409    parser.add_option("--l3-data-latency", type="int", default=20)
410    parser.add_option("--l3-tag-latency", type="int", default=15)
411    parser.add_option("--cpu-to-dir-latency", type="int", default=15)
412    parser.add_option("--gpu-to-dir-latency", type="int", default=160)
413    parser.add_option("--no-resource-stalls", action="store_false",
414                      default=True)
415    parser.add_option("--num-tbes", type="int", default=256)
416    parser.add_option("--l2-latency", type="int", default=50) # load to use
417    parser.add_option("--num-tccs", type="int", default=1,
418                      help="number of TCC directories and banks in the GPU")
419    parser.add_option("--TCP_latency", type="int", default=4,
420                      help="TCP latency")
421    parser.add_option("--TCC_latency", type="int", default=16,
422                      help="TCC latency")
423    parser.add_option("--tcc-size", type='string', default='256kB',
424                      help="agregate tcc size")
425    parser.add_option("--tcp-size", type='string', default='16kB',
426                      help="tcp size")
427    parser.add_option("--tcc-dir-factor", type='int', default=4,
428                      help="TCCdir size = factor *(TCPs + TCC)")
429
430def create_system(options, full_system, system, dma_devices, ruby_system):
431    if buildEnv['PROTOCOL'] != 'GPU_RfO':
432        panic("This script requires the GPU_RfO protocol to be built.")
433
434    cpu_sequencers = []
435
436    #
437    # The ruby network creation expects the list of nodes in the system to be
438    # consistent with the NetDest list.  Therefore the l1 controller nodes
439    # must be listed before the directory nodes and directory nodes before
440    # dma nodes, etc.
441    #
442    cp_cntrl_nodes = []
443    tcp_cntrl_nodes = []
444    sqc_cntrl_nodes = []
445    tcc_cntrl_nodes = []
446    tccdir_cntrl_nodes = []
447    dir_cntrl_nodes = []
448    l3_cntrl_nodes = []
449
450    #
451    # Must create the individual controllers before the network to ensure the
452    # controller constructors are called before the network constructor
453    #
454
455    TCC_bits = int(math.log(options.num_tccs, 2))
456
457    # This is the base crossbar that connects the L3s, Dirs, and cpu/gpu
458    # Clusters
459    mainCluster = Cluster(extBW = 512, intBW = 512) # 1 TB/s
460
461    if options.numa_high_bit:
462        numa_bit = options.numa_high_bit
463    else:
464        # if the numa_bit is not specified, set the directory bits as the
465        # lowest bits above the block offset bits, and the numa_bit as the
466        # highest of those directory bits
467        dir_bits = int(math.log(options.num_dirs, 2))
468        block_size_bits = int(math.log(options.cacheline_size, 2))
469        numa_bit = block_size_bits + dir_bits - 1
470
471    for i in xrange(options.num_dirs):
472        dir_ranges = []
473        for r in system.mem_ranges:
474            addr_range = m5.objects.AddrRange(r.start, size = r.size(),
475                                              intlvHighBit = numa_bit,
476                                              intlvBits = dir_bits,
477                                              intlvMatch = i)
478            dir_ranges.append(addr_range)
479
480        dir_cntrl = DirCntrl(TCC_select_num_bits = TCC_bits)
481        dir_cntrl.create(options, dir_ranges, ruby_system, system)
482        dir_cntrl.number_of_TBEs = 2560 * options.num_compute_units
483        #Enough TBEs for all TCP TBEs
484
485        # Connect the Directory controller to the ruby network
486        dir_cntrl.requestFromCores = MessageBuffer(ordered = True)
487        dir_cntrl.requestFromCores.slave = ruby_system.network.master
488
489        dir_cntrl.responseFromCores = MessageBuffer()
490        dir_cntrl.responseFromCores.slave = ruby_system.network.master
491
492        dir_cntrl.unblockFromCores = MessageBuffer()
493        dir_cntrl.unblockFromCores.slave = ruby_system.network.master
494
495        dir_cntrl.probeToCore = MessageBuffer()
496        dir_cntrl.probeToCore.master = ruby_system.network.slave
497
498        dir_cntrl.responseToCore = MessageBuffer()
499        dir_cntrl.responseToCore.master = ruby_system.network.slave
500
501        dir_cntrl.triggerQueue = MessageBuffer(ordered = True)
502        dir_cntrl.L3triggerQueue = MessageBuffer(ordered = True)
503        dir_cntrl.responseFromMemory = MessageBuffer()
504
505        exec("system.dir_cntrl%d = dir_cntrl" % i)
506        dir_cntrl_nodes.append(dir_cntrl)
507
508        mainCluster.add(dir_cntrl)
509
510    # For an odd number of CPUs, still create the right number of controllers
511    cpuCluster = Cluster(extBW = 512, intBW = 512)  # 1 TB/s
512    for i in xrange((options.num_cpus + 1) / 2):
513
514        cp_cntrl = CPCntrl()
515        cp_cntrl.create(options, ruby_system, system)
516
517        exec("system.cp_cntrl%d = cp_cntrl" % i)
518        #
519        # Add controllers and sequencers to the appropriate lists
520        #
521        cpu_sequencers.extend([cp_cntrl.sequencer, cp_cntrl.sequencer1])
522
523        # Connect the CP controllers and the network
524        cp_cntrl.requestFromCore = MessageBuffer()
525        cp_cntrl.requestFromCore.master = ruby_system.network.slave
526
527        cp_cntrl.responseFromCore = MessageBuffer()
528        cp_cntrl.responseFromCore.master = ruby_system.network.slave
529
530        cp_cntrl.unblockFromCore = MessageBuffer()
531        cp_cntrl.unblockFromCore.master = ruby_system.network.slave
532
533        cp_cntrl.probeToCore = MessageBuffer()
534        cp_cntrl.probeToCore.slave = ruby_system.network.master
535
536        cp_cntrl.responseToCore = MessageBuffer()
537        cp_cntrl.responseToCore.slave = ruby_system.network.master
538
539        cp_cntrl.mandatoryQueue = MessageBuffer()
540        cp_cntrl.triggerQueue = MessageBuffer(ordered = True)
541
542        cpuCluster.add(cp_cntrl)
543
544    gpuCluster = Cluster(extBW = 512, intBW = 512)  # 1 TB/s
545
546    for i in xrange(options.num_compute_units):
547
548        tcp_cntrl = TCPCntrl(TCC_select_num_bits = TCC_bits,
549                             number_of_TBEs = 2560) # max outstanding requests
550        tcp_cntrl.create(options, ruby_system, system)
551
552        exec("system.tcp_cntrl%d = tcp_cntrl" % i)
553        #
554        # Add controllers and sequencers to the appropriate lists
555        #
556        cpu_sequencers.append(tcp_cntrl.coalescer)
557        tcp_cntrl_nodes.append(tcp_cntrl)
558
559        # Connect the TCP controller to the ruby network
560        tcp_cntrl.requestFromTCP = MessageBuffer(ordered = True)
561        tcp_cntrl.requestFromTCP.master = ruby_system.network.slave
562
563        tcp_cntrl.responseFromTCP = MessageBuffer(ordered = True)
564        tcp_cntrl.responseFromTCP.master = ruby_system.network.slave
565
566        tcp_cntrl.unblockFromCore = MessageBuffer(ordered = True)
567        tcp_cntrl.unblockFromCore.master = ruby_system.network.slave
568
569        tcp_cntrl.probeToTCP = MessageBuffer(ordered = True)
570        tcp_cntrl.probeToTCP.slave = ruby_system.network.master
571
572        tcp_cntrl.responseToTCP = MessageBuffer(ordered = True)
573        tcp_cntrl.responseToTCP.slave = ruby_system.network.master
574
575        tcp_cntrl.mandatoryQueue = MessageBuffer()
576
577        gpuCluster.add(tcp_cntrl)
578
579    for i in xrange(options.num_sqc):
580
581        sqc_cntrl = SQCCntrl(TCC_select_num_bits = TCC_bits)
582        sqc_cntrl.create(options, ruby_system, system)
583
584        exec("system.sqc_cntrl%d = sqc_cntrl" % i)
585        #
586        # Add controllers and sequencers to the appropriate lists
587        #
588        cpu_sequencers.append(sqc_cntrl.sequencer)
589
590        # Connect the SQC controller to the ruby network
591        sqc_cntrl.requestFromSQC = MessageBuffer(ordered = True)
592        sqc_cntrl.requestFromSQC.master = ruby_system.network.slave
593
594        sqc_cntrl.responseFromSQC = MessageBuffer(ordered = True)
595        sqc_cntrl.responseFromSQC.master = ruby_system.network.slave
596
597        sqc_cntrl.unblockFromCore = MessageBuffer(ordered = True)
598        sqc_cntrl.unblockFromCore.master = ruby_system.network.slave
599
600        sqc_cntrl.probeToSQC = MessageBuffer(ordered = True)
601        sqc_cntrl.probeToSQC.slave = ruby_system.network.master
602
603        sqc_cntrl.responseToSQC = MessageBuffer(ordered = True)
604        sqc_cntrl.responseToSQC.slave = ruby_system.network.master
605
606        sqc_cntrl.mandatoryQueue = MessageBuffer()
607
608        # SQC also in GPU cluster
609        gpuCluster.add(sqc_cntrl)
610
611    for i in xrange(options.num_cp):
612
613        tcp_cntrl = TCPCntrl(TCC_select_num_bits = TCC_bits,
614                             number_of_TBEs = 2560) # max outstanding requests
615        tcp_cntrl.createCP(options, ruby_system, system)
616
617        exec("system.tcp_cntrl%d = tcp_cntrl" % (options.num_compute_units + i))
618        #
619        # Add controllers and sequencers to the appropriate lists
620        #
621        cpu_sequencers.append(tcp_cntrl.sequencer)
622        tcp_cntrl_nodes.append(tcp_cntrl)
623
624        # Connect the TCP controller to the ruby network
625        tcp_cntrl.requestFromTCP = MessageBuffer(ordered = True)
626        tcp_cntrl.requestFromTCP.master = ruby_system.network.slave
627
628        tcp_cntrl.responseFromTCP = MessageBuffer(ordered = True)
629        tcp_cntrl.responseFromTCP.master = ruby_system.network.slave
630
631        tcp_cntrl.unblockFromCore = MessageBuffer(ordered = True)
632        tcp_cntrl.unblockFromCore.master = ruby_system.network.slave
633
634        tcp_cntrl.probeToTCP = MessageBuffer(ordered = True)
635        tcp_cntrl.probeToTCP.slave = ruby_system.network.master
636
637        tcp_cntrl.responseToTCP = MessageBuffer(ordered = True)
638        tcp_cntrl.responseToTCP.slave = ruby_system.network.master
639
640        tcp_cntrl.mandatoryQueue = MessageBuffer()
641
642        gpuCluster.add(tcp_cntrl)
643
644        sqc_cntrl = SQCCntrl(TCC_select_num_bits = TCC_bits)
645        sqc_cntrl.createCP(options, ruby_system, system)
646
647        exec("system.sqc_cntrl%d = sqc_cntrl" % (options.num_compute_units + i))
648        #
649        # Add controllers and sequencers to the appropriate lists
650        #
651        cpu_sequencers.append(sqc_cntrl.sequencer)
652
653        # Connect the SQC controller to the ruby network
654        sqc_cntrl.requestFromSQC = MessageBuffer(ordered = True)
655        sqc_cntrl.requestFromSQC.master = ruby_system.network.slave
656
657        sqc_cntrl.responseFromSQC = MessageBuffer(ordered = True)
658        sqc_cntrl.responseFromSQC.master = ruby_system.network.slave
659
660        sqc_cntrl.unblockFromCore = MessageBuffer(ordered = True)
661        sqc_cntrl.unblockFromCore.master = ruby_system.network.slave
662
663        sqc_cntrl.probeToSQC = MessageBuffer(ordered = True)
664        sqc_cntrl.probeToSQC.slave = ruby_system.network.master
665
666        sqc_cntrl.responseToSQC = MessageBuffer(ordered = True)
667        sqc_cntrl.responseToSQC.slave = ruby_system.network.master
668
669        sqc_cntrl.mandatoryQueue = MessageBuffer()
670
671        # SQC also in GPU cluster
672        gpuCluster.add(sqc_cntrl)
673
674    for i in xrange(options.num_tccs):
675
676        tcc_cntrl = TCCCntrl(TCC_select_num_bits = TCC_bits,
677                             number_of_TBEs = options.num_compute_units * 2560)
678        #Enough TBEs for all TCP TBEs
679        tcc_cntrl.create(options, ruby_system, system)
680        tcc_cntrl_nodes.append(tcc_cntrl)
681
682        tccdir_cntrl = TCCDirCntrl(TCC_select_num_bits = TCC_bits,
683                              number_of_TBEs = options.num_compute_units * 2560)
684        #Enough TBEs for all TCP TBEs
685        tccdir_cntrl.create(options, ruby_system, system)
686        tccdir_cntrl_nodes.append(tccdir_cntrl)
687
688        exec("system.tcc_cntrl%d = tcc_cntrl" % i)
689        exec("system.tccdir_cntrl%d = tccdir_cntrl" % i)
690
691        # connect all of the wire buffers between L3 and dirs up
692        req_to_tccdir = RubyWireBuffer()
693        resp_to_tccdir = RubyWireBuffer()
694        tcc_unblock_to_tccdir = RubyWireBuffer()
695        req_to_tcc = RubyWireBuffer()
696        probe_to_tcc = RubyWireBuffer()
697        resp_to_tcc = RubyWireBuffer()
698
699        tcc_cntrl.connectWireBuffers(req_to_tccdir, resp_to_tccdir,
700                                     tcc_unblock_to_tccdir, req_to_tcc,
701                                     probe_to_tcc, resp_to_tcc)
702        tccdir_cntrl.connectWireBuffers(req_to_tccdir, resp_to_tccdir,
703                                        tcc_unblock_to_tccdir, req_to_tcc,
704                                        probe_to_tcc, resp_to_tcc)
705
706        # Connect the TCC controller to the ruby network
707        tcc_cntrl.responseFromTCC = MessageBuffer(ordered = True)
708        tcc_cntrl.responseFromTCC.master = ruby_system.network.slave
709
710        tcc_cntrl.responseToTCC = MessageBuffer(ordered = True)
711        tcc_cntrl.responseToTCC.slave = ruby_system.network.master
712
713        # Connect the TCC Dir controller to the ruby network
714        tccdir_cntrl.requestFromTCP = MessageBuffer(ordered = True)
715        tccdir_cntrl.requestFromTCP.slave = ruby_system.network.master
716
717        tccdir_cntrl.responseFromTCP = MessageBuffer(ordered = True)
718        tccdir_cntrl.responseFromTCP.slave = ruby_system.network.master
719
720        tccdir_cntrl.unblockFromTCP = MessageBuffer(ordered = True)
721        tccdir_cntrl.unblockFromTCP.slave = ruby_system.network.master
722
723        tccdir_cntrl.probeToCore = MessageBuffer(ordered = True)
724        tccdir_cntrl.probeToCore.master = ruby_system.network.slave
725
726        tccdir_cntrl.responseToCore = MessageBuffer(ordered = True)
727        tccdir_cntrl.responseToCore.master = ruby_system.network.slave
728
729        tccdir_cntrl.probeFromNB = MessageBuffer()
730        tccdir_cntrl.probeFromNB.slave = ruby_system.network.master
731
732        tccdir_cntrl.responseFromNB = MessageBuffer()
733        tccdir_cntrl.responseFromNB.slave = ruby_system.network.master
734
735        tccdir_cntrl.requestToNB = MessageBuffer()
736        tccdir_cntrl.requestToNB.master = ruby_system.network.slave
737
738        tccdir_cntrl.responseToNB = MessageBuffer()
739        tccdir_cntrl.responseToNB.master = ruby_system.network.slave
740
741        tccdir_cntrl.unblockToNB = MessageBuffer()
742        tccdir_cntrl.unblockToNB.master = ruby_system.network.slave
743
744        tccdir_cntrl.triggerQueue = MessageBuffer(ordered = True)
745
746        # TCC cntrls added to the GPU cluster
747        gpuCluster.add(tcc_cntrl)
748        gpuCluster.add(tccdir_cntrl)
749
750    # Assuming no DMA devices
751    assert(len(dma_devices) == 0)
752
753    # Add cpu/gpu clusters to main cluster
754    mainCluster.add(cpuCluster)
755    mainCluster.add(gpuCluster)
756
757    ruby_system.network.number_of_virtual_networks = 10
758
759    return (cpu_sequencers, dir_cntrl_nodes, mainCluster)
760