ruby: fixed DirectoryMemory's numa_high_bit configuration
authorBrad Beckmann <Brad.Beckmann@amd.com>
Fri, 20 Aug 2010 18:46:13 +0000 (11:46 -0700)
committerBrad Beckmann <Brad.Beckmann@amd.com>
Fri, 20 Aug 2010 18:46:13 +0000 (11:46 -0700)
This fix includes the off-by-one bit selection bug for numa mapping.

configs/ruby/Ruby.py
src/mem/ruby/common/Address.hh
src/mem/ruby/system/DirectoryMemory.cc

index 07a6632dd02f60154d970acfe4ed5b743c54b88c..71add4b61d7e727bcf7fa3361c20bdc88fad56d4 100644 (file)
@@ -27,6 +27,7 @@
 #
 # Authors: Brad Beckmann
 
+import math
 import m5
 from m5.objects import *
 from m5.defines import buildEnv
@@ -42,7 +43,8 @@ def define_options(parser):
 
     # ruby mapping options
     parser.add_option("--numa-high-bit", type="int", default=none,
-                      help="high order address bit to use for numa mapping")
+                      help="high order address bit to use for numa mapping. " \
+                           "0 = highest bit, not specified = lowest bit")
 
     # ruby sparse memory options
     parser.add_option("--use-map", action="store_true", default=False)
@@ -88,14 +90,32 @@ def create_system(options, system, piobus = None, dma_devices = []):
         network = SimpleNetwork(topology = net_topology)
 
     #
+    # Loop through the directory controlers.
     # Determine the total memory size of the ruby system and verify it is equal
     # to physmem.  However, if Ruby memory is using sparse memory in SE 
     # mode, then the system should not back-up the memory state with
     # the Memory Vector and thus the memory size bytes should stay at 0.
+    # Also set the numa bits to the appropriate values.
     #
     total_mem_size = MemorySize('0B')
+
+    dir_bits = int(math.log(options.num_dirs, 2))
+
+    if options.numa_high_bit:
+        numa_bit = options.numa_high_bit
+    else:
+        # if not specified, use the lowest bits above the block offest
+        if options.numa_high_bit == 0:
+            if dir_bits > 0:
+                # add 5 because bits 0-5 are the block offset
+                numa_bit = dir_bits + 5
+            else:
+                numa_bit = 6
+        
     for dir_cntrl in dir_cntrls:
         total_mem_size.value += dir_cntrl.directory.size.value
+        dir_cntrl.directory.numa_high_bit = numa_bit
+        
     physmem_size = long(system.physmem.range.second) - \
                      long(system.physmem.range.first) + 1
     assert(total_mem_size.value == physmem_size)
index dc58d012f036b1170cee721d32d8c83460384ffb..23b683d6902466f8c474935420bf9e78e537bcdf 100644 (file)
@@ -187,7 +187,7 @@ Address::bitRemove(int small, int big) const
         physical_address_t higher_bits = m_address & mask;
 
         // Shift the valid high bits over the removed section
-        higher_bits = higher_bits >> (big - small);
+        higher_bits = higher_bits >> (big - small + 1);
         return (higher_bits | lower_bits);
     }
 }
index 65b61c935dac921bdaa3043517fab735702e7ffa..fbb48d7f50a82ae5bd4a9cc3efd4595f7bb0cc1f 100644 (file)
@@ -71,7 +71,7 @@ DirectoryMemory::init()
     m_total_size_bytes += m_size_bytes;
 
     if (m_numa_high_bit == 0) {
-        m_numa_high_bit = RubySystem::getMemorySizeBits();
+        m_numa_high_bit = RubySystem::getMemorySizeBits() - 1;
     }
     assert(m_numa_high_bit != 0);
 }
@@ -125,7 +125,7 @@ DirectoryMemory::mapAddressToDirectoryVersion(PhysAddress address)
     if (m_num_directories_bits == 0)
         return 0;
 
-    uint64 ret = address.bitSelect(m_numa_high_bit - m_num_directories_bits,
+    uint64 ret = address.bitSelect(m_numa_high_bit - m_num_directories_bits + 1,
                                    m_numa_high_bit);
     return ret;
 }
@@ -140,10 +140,15 @@ DirectoryMemory::isPresent(PhysAddress address)
 uint64
 DirectoryMemory::mapAddressToLocalIdx(PhysAddress address)
 {
-    uint64 ret = address.bitRemove(m_numa_high_bit - m_num_directories_bits,
-                                   m_numa_high_bit)
-        >> (RubySystem::getBlockSizeBits());
-    return ret;
+    uint64 ret;
+    if (m_num_directories_bits > 0) {
+        ret = address.bitRemove(m_numa_high_bit - m_num_directories_bits + 1,
+                                m_numa_high_bit);
+    } else {
+        ret = address.getAddress();
+    }
+
+    return ret >> (RubySystem::getBlockSizeBits());
 }
 
 Directory_Entry&