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