From 3d4a78bec0d7c013e699c10eb56de15f85c82430 Mon Sep 17 00:00:00 2001 From: Nikos Nikoleris Date: Thu, 30 Aug 2018 10:26:31 +0100 Subject: [PATCH] configs: Use the same address ranges for dir and mem_ctrls In Ruby, for every directory we create one memory controller for every range in the memory ranges. Previously the memory controllers and the directories created their address ranges independently and as a result a mismatch was possible. In fact, we assinged an interleaved address range with hasing for the memory controllers while the corresponding directories would be assigned the same interleaved address range without hashing. This change uses the address range of the memory controllers to populate the list of address ranges for the corresponding directory and avoid bugs due to code duplication. Change-Id: I1e321c81a254199e5aaa9f3b81f4a4642c60a67a Reviewed-on: https://gem5-review.googlesource.com/12318 Reviewed-by: Jason Lowe-Power Maintainer: Jason Lowe-Power --- configs/ruby/Garnet_standalone.py | 2 +- configs/ruby/MESI_Three_Level.py | 2 +- configs/ruby/MESI_Two_Level.py | 2 +- configs/ruby/MI_example.py | 2 +- configs/ruby/MOESI_CMP_directory.py | 2 +- configs/ruby/MOESI_CMP_token.py | 2 +- configs/ruby/MOESI_hammer.py | 2 +- configs/ruby/Ruby.py | 35 +++++++++++------------------ 8 files changed, 20 insertions(+), 29 deletions(-) diff --git a/configs/ruby/Garnet_standalone.py b/configs/ruby/Garnet_standalone.py index 168f84dd4..a70780bf7 100644 --- a/configs/ruby/Garnet_standalone.py +++ b/configs/ruby/Garnet_standalone.py @@ -101,7 +101,7 @@ def create_system(options, full_system, system, dma_ports, bootmem, l1_cntrl.forwardFromCache = MessageBuffer() mem_dir_cntrl_nodes, rom_dir_cntrl_node = create_directories( - options, system.mem_ranges, bootmem, ruby_system, system) + options, bootmem, ruby_system, system) dir_cntrl_nodes = mem_dir_cntrl_nodes[:] if rom_dir_cntrl_node is not None: dir_cntrl_nodes.append(rom_dir_cntrl_node) diff --git a/configs/ruby/MESI_Three_Level.py b/configs/ruby/MESI_Three_Level.py index 7c80e48ad..f38b7cfa6 100644 --- a/configs/ruby/MESI_Three_Level.py +++ b/configs/ruby/MESI_Three_Level.py @@ -201,7 +201,7 @@ def create_system(options, full_system, system, dma_ports, bootmem, clk_domain = ruby_system.clk_domain, clk_divider = 3) mem_dir_cntrl_nodes, rom_dir_cntrl_node = create_directories( - options, system.mem_ranges, bootmem, ruby_system, system) + options, bootmem, ruby_system, system) dir_cntrl_nodes = mem_dir_cntrl_nodes[:] if rom_dir_cntrl_node is not None: dir_cntrl_nodes.append(rom_dir_cntrl_node) diff --git a/configs/ruby/MESI_Two_Level.py b/configs/ruby/MESI_Two_Level.py index b488b9d51..52976e6bb 100644 --- a/configs/ruby/MESI_Two_Level.py +++ b/configs/ruby/MESI_Two_Level.py @@ -175,7 +175,7 @@ def create_system(options, full_system, system, dma_ports, bootmem, clk_divider = 3) mem_dir_cntrl_nodes, rom_dir_cntrl_node = create_directories( - options, system.mem_ranges, bootmem, ruby_system, system) + options, bootmem, ruby_system, system) dir_cntrl_nodes = mem_dir_cntrl_nodes[:] if rom_dir_cntrl_node is not None: dir_cntrl_nodes.append(rom_dir_cntrl_node) diff --git a/configs/ruby/MI_example.py b/configs/ruby/MI_example.py index c92bb2036..222d084a8 100644 --- a/configs/ruby/MI_example.py +++ b/configs/ruby/MI_example.py @@ -127,7 +127,7 @@ def create_system(options, full_system, system, dma_ports, bootmem, clk_divider=3) mem_dir_cntrl_nodes, rom_dir_cntrl_node = create_directories( - options, system.mem_ranges, bootmem, ruby_system, system) + options, bootmem, ruby_system, system) dir_cntrl_nodes = mem_dir_cntrl_nodes[:] if rom_dir_cntrl_node is not None: dir_cntrl_nodes.append(rom_dir_cntrl_node) diff --git a/configs/ruby/MOESI_CMP_directory.py b/configs/ruby/MOESI_CMP_directory.py index 80d0bc106..3fef48b3b 100644 --- a/configs/ruby/MOESI_CMP_directory.py +++ b/configs/ruby/MOESI_CMP_directory.py @@ -167,7 +167,7 @@ def create_system(options, full_system, system, dma_ports, bootmem, mem_dir_cntrl_nodes, rom_dir_cntrl_node = create_directories( - options, system.mem_ranges, bootmem, ruby_system, system) + options, bootmem, ruby_system, system) dir_cntrl_nodes = mem_dir_cntrl_nodes[:] if rom_dir_cntrl_node is not None: dir_cntrl_nodes.append(rom_dir_cntrl_node) diff --git a/configs/ruby/MOESI_CMP_token.py b/configs/ruby/MOESI_CMP_token.py index 25b18a0b8..94a518b2a 100644 --- a/configs/ruby/MOESI_CMP_token.py +++ b/configs/ruby/MOESI_CMP_token.py @@ -192,7 +192,7 @@ def create_system(options, full_system, system, dma_ports, bootmem, clk_divider=3) mem_dir_cntrl_nodes, rom_dir_cntrl_node = create_directories( - options, system.mem_ranges, bootmem, ruby_system, system) + options, bootmem, ruby_system, system) dir_cntrl_nodes = mem_dir_cntrl_nodes[:] if rom_dir_cntrl_node is not None: dir_cntrl_nodes.append(rom_dir_cntrl_node) diff --git a/configs/ruby/MOESI_hammer.py b/configs/ruby/MOESI_hammer.py index a2e902df3..7c31ca201 100644 --- a/configs/ruby/MOESI_hammer.py +++ b/configs/ruby/MOESI_hammer.py @@ -174,7 +174,7 @@ def create_system(options, full_system, system, dma_ports, bootmem, clk_divider=3) mem_dir_cntrl_nodes, rom_dir_cntrl_node = create_directories( - options, system.mem_ranges, bootmem, ruby_system, system) + options, bootmem, ruby_system, system) dir_cntrl_nodes = mem_dir_cntrl_nodes[:] if rom_dir_cntrl_node is not None: dir_cntrl_nodes.append(rom_dir_cntrl_node) diff --git a/configs/ruby/Ruby.py b/configs/ruby/Ruby.py index f1415b062..2fb174061 100644 --- a/configs/ruby/Ruby.py +++ b/configs/ruby/Ruby.py @@ -91,6 +91,14 @@ def setup_memory_controllers(system, ruby, dir_cntrls, options): mem_ctrls = [] crossbars = [] + if options.numa_high_bit: + dir_bits = int(math.log(options.num_dirs, 2)) + intlv_size = 2 ** (options.numa_high_bit - dir_bits + 1) + else: + # if the numa_bit is not specified, set the directory bits as the + # lowest bits above the block offset bits + intlv_size = options.cacheline_size + # Sets bits to be used for interleaving. Creates memory controllers # attached to a directory controller. A separate controller is created # for each address range as the abstract memory can handle only one @@ -102,15 +110,17 @@ def setup_memory_controllers(system, ruby, dir_cntrls, options): crossbars.append(crossbar) dir_cntrl.memory = crossbar.slave + dir_ranges = [] for r in system.mem_ranges: mem_ctrl = MemConfig.create_mem_ctrl( MemConfig.get(options.mem_type), r, index, options.num_dirs, - int(math.log(options.num_dirs, 2)), options.cacheline_size) + int(math.log(options.num_dirs, 2)), intlv_size) if options.access_backing_store: mem_ctrl.kvm_map=False mem_ctrls.append(mem_ctrl) + dir_ranges.append(mem_ctrl.range) if crossbar != None: mem_ctrl.port = crossbar.master @@ -118,6 +128,7 @@ def setup_memory_controllers(system, ruby, dir_cntrls, options): mem_ctrl.port = dir_cntrl.memory index += 1 + dir_cntrl.addr_ranges = dir_ranges system.mem_ctrls = mem_ctrls @@ -199,33 +210,13 @@ def create_system(options, full_system, system, piobus = None, dma_ports = [], ruby.phys_mem = SimpleMemory(range=system.mem_ranges[0], in_addr_map=False) -def create_directories(options, mem_ranges, bootmem, ruby_system, - system): +def create_directories(options, bootmem, ruby_system, system): dir_cntrl_nodes = [] - if options.numa_high_bit: - numa_bit = options.numa_high_bit - else: - # if the numa_bit is not specified, set the directory bits as the - # lowest bits above the block offset bits, and the numa_bit as the - # highest of those directory bits - dir_bits = int(math.log(options.num_dirs, 2)) - block_size_bits = int(math.log(options.cacheline_size, 2)) - numa_bit = block_size_bits + dir_bits - 1 - for i in xrange(options.num_dirs): - dir_ranges = [] - for r in mem_ranges: - addr_range = m5.objects.AddrRange(r.start, size = r.size(), - intlvHighBit = numa_bit, - intlvBits = dir_bits, - intlvMatch = i) - dir_ranges.append(addr_range) - dir_cntrl = Directory_Controller() dir_cntrl.version = i dir_cntrl.directory = RubyDirectoryMemory() dir_cntrl.ruby_system = ruby_system - dir_cntrl.addr_ranges = dir_ranges exec("ruby_system.dir_cntrl%d = dir_cntrl" % i) dir_cntrl_nodes.append(dir_cntrl) -- 2.30.2