stdlib, python: Add warning message and clarify binary vs metric units (#1479)

This PR changes memory and cache sizes in various parts of the gem5
codebase to use binary units (e.g. KiB) instead of metric units (e.g.
kB). This makes the codebase more consistent, as gem5 automatically
converts memory and cache sizes that are in metric units to binary
units.

This PR also adds a warning message to let users know when an
auto-conversion from base 10 to base 2 units occurs.

There were a few places in configs and in the comments of various files
where I didn't change the metric units, as I couldn't figure out where
the parameters with those units were being used.
This commit is contained in:
Bobby R. Bruce
2024-09-17 17:32:27 +00:00
committed by GitHub
106 changed files with 390 additions and 308 deletions

View File

@@ -1189,8 +1189,8 @@ class VExpress_GEM5_Base(RealView):
Memory map:
0x00000000-0x03ffffff: Boot memory (CS0)
0x04000000-0x07ffffff: Trusted Memory/Reserved
0x04000000-0x0403FFFF: 256kB Trusted SRAM
0x06000000-0x07ffffff: 32MB Trusted DRAM
0x04000000-0x0403FFFF: 256KiB Trusted SRAM
0x06000000-0x07ffffff: 32MiB Trusted DRAM
0x08000000-0x0bffffff: NOR FLASH0 (CS0 alias)
0x0c000000-0x0fffffff: NOR FLASH1 (Off-chip, CS4)
0x10000000-0x13ffffff: gem5-specific peripherals (Off-chip, CS5)
@@ -1316,7 +1316,7 @@ class VExpress_GEM5_Base(RealView):
# Trusted DRAM
# TODO: preventing access from unsecure world to the trusted RAM
trusted_dram = SimpleMemory(
range=AddrRange(0x06000000, size="32MB"), conf_table_reported=False
range=AddrRange(0x06000000, size="32MiB"), conf_table_reported=False
)
# Non-Trusted SRAM
non_trusted_sram = MmioSRAM(
@@ -1454,7 +1454,7 @@ class VExpress_GEM5_Base(RealView):
# VRAM
vram = SimpleMemory(
range=AddrRange(0x18000000, size="32MB"), conf_table_reported=False
range=AddrRange(0x18000000, size="32MiB"), conf_table_reported=False
)
def _off_chip_devices(self):

View File

@@ -183,7 +183,7 @@ class HiFive(HiFiveBase):
# PCI
pci_host = GenericRiscvPciHost(
conf_base=0x30000000,
conf_size="256MB",
conf_size="256MiB",
conf_device_bits=12,
pci_pio_base=0x2F000000,
pci_mem_base=0x40000000,

View File

@@ -47,8 +47,8 @@ class GoodbyeObject(SimObject):
cxx_class = "gem5::GoodbyeObject"
buffer_size = Param.MemorySize(
"1kB", "Size of buffer to fill with goodbye"
"1KiB", "Size of buffer to fill with goodbye"
)
write_bandwidth = Param.MemoryBandwidth(
"100MB/s", "Bandwidth to fill the buffer"
"100MiB/s", "Bandwidth to fill the buffer"
)

View File

@@ -41,6 +41,6 @@ class SimpleCache(ClockedObject):
latency = Param.Cycles(1, "Cycles taken on a hit or to resolve a miss")
size = Param.MemorySize("16kB", "The size of the cache")
size = Param.MemorySize("16KiB", "The size of the cache")
system = Param.System(Parent.any, "The system this cache is part of")

View File

@@ -53,10 +53,10 @@ class CfiMemory(AbstractMemory):
latency = Param.Latency("30ns", "Request to response latency")
latency_var = Param.Latency("0ns", "Request to response latency variance")
# The memory bandwidth limit default is set to 12.8GB/s which is
# The memory bandwidth limit default is set to 12.8GiB/s which is
# representative of a x64 DDR3-1600 channel.
bandwidth = Param.MemoryBandwidth(
"12.8GB/s", "Combined read and write bandwidth"
"12.8GiB/s", "Combined read and write bandwidth"
)
vendor_id = Param.UInt16(0, "vendor ID")

View File

@@ -294,7 +294,7 @@ class DDR3_1600_8x8(DRAMInterface):
# DDR3 is a BL8 device
burst_length = 8
# Each device has a page (row buffer) size of 1 Kbyte (1K columns x8)
# Each device has a page (row buffer) size of 1 Kibibyte (1KiB columns x8)
device_rowbuffer_size = "1KiB"
# 8x8 configuration, so 8 devices
@@ -700,7 +700,7 @@ class LPDDR2_S4_1066_1x32(DRAMInterface):
# LPDDR2_S4 is a BL4 and BL8 device
burst_length = 8
# Each device has a page (row buffer) size of 1KB
# Each device has a page (row buffer) size of 1KiB
# (this depends on the memory density)
device_rowbuffer_size = "1KiB"
@@ -1276,7 +1276,7 @@ class DDR5_4400_4x8(DRAMInterface):
burst_length = 16
# Each device has a page (row buffer) size of 256B
# Four devices lead to a page size of 1KB
# Four devices lead to a page size of 1KiB
device_rowbuffer_size = "256B"
# 4Gbx8 configuration
@@ -1312,10 +1312,10 @@ class DDR5_4400_4x8(DRAMInterface):
# RRD_S (different bank group) : 8nCK
tRRD = "3.632ns"
# RRD_L (same bank group) is MAX(8nCK, 5ns) for 1KB page
# RRD_L (same bank group) is MAX(8nCK, 5ns) for 1KiB page
tRRD_L = "5ns"
# tFAW for 1KB page is MAX(32nCK, 14.545ns)
# tFAW for 1KiB page is MAX(32nCK, 14.545ns)
tXAW = "14.545ns"
activation_limit = 4
@@ -1420,10 +1420,10 @@ class DDR5_6400_4x8(DDR5_4400_4x8):
# RRD_S (different bank group) : 8nCK
tRRD = "2.496ns"
# RRD_L (same bank group) is MAX(8nCK, 5ns) for 1KB page
# RRD_L (same bank group) is MAX(8nCK, 5ns) for 1KiB page
tRRD_L = "5ns"
# tFAW for 1KB page is MAX(32 CK, 10.00ns)
# tFAW for 1KiB page is MAX(32 CK, 10.00ns)
tXAW = "10ns"
# Rd/Wr turnaround timings
@@ -1480,7 +1480,7 @@ class DDR5_8400_4x8(DDR5_4400_4x8):
# RRD_S (different bank group) : 8nCK
tRRD = "1.904ns"
# tFAW for 1KB page is MAX(32 CK, 10.00ns)
# tFAW for 1KiB page is MAX(32 CK, 10.00ns)
tXAW = "10ns"
# Rd/Wr turnaround timings

View File

@@ -174,9 +174,9 @@ class RiscvBoard(AbstractSystemBoard, KernelDiskWorkload):
]
# PCI
self.bridge.ranges.append(AddrRange(0x2F000000, size="16MB"))
self.bridge.ranges.append(AddrRange(0x30000000, size="256MB"))
self.bridge.ranges.append(AddrRange(0x40000000, size="512MB"))
self.bridge.ranges.append(AddrRange(0x2F000000, size="16MiB"))
self.bridge.ranges.append(AddrRange(0x30000000, size="256MiB"))
self.bridge.ranges.append(AddrRange(0x40000000, size="512MiB"))
def _setup_pma(self) -> None:
"""Set the PMA devices on each core."""
@@ -187,9 +187,9 @@ class RiscvBoard(AbstractSystemBoard, KernelDiskWorkload):
]
# PCI
uncacheable_range.append(AddrRange(0x2F000000, size="16MB"))
uncacheable_range.append(AddrRange(0x30000000, size="256MB"))
uncacheable_range.append(AddrRange(0x40000000, size="512MB"))
uncacheable_range.append(AddrRange(0x2F000000, size="16MiB"))
uncacheable_range.append(AddrRange(0x30000000, size="256MiB"))
uncacheable_range.append(AddrRange(0x40000000, size="512MiB"))
# TODO: Not sure if this should be done per-core like in the example
for cpu in self.get_processor().get_cores():

View File

@@ -67,7 +67,7 @@ class X86Board(AbstractSystemBoard, KernelDiskWorkload):
A board capable of full system simulation for X86.
**Limitations**
* Currently, this board's memory is hardcoded to 3GB.
* Currently, this board's memory is hardcoded to 3GiB.
* Much of the I/O subsystem is hard coded.
"""
@@ -238,8 +238,8 @@ class X86Board(AbstractSystemBoard, KernelDiskWorkload):
entries = [
# Mark the first megabyte of memory as reserved
X86E820Entry(addr=0, size="639kB", range_type=1),
X86E820Entry(addr=0x9FC00, size="385kB", range_type=2),
X86E820Entry(addr=0, size="639KiB", range_type=1),
X86E820Entry(addr=0x9FC00, size="385KiB", range_type=2),
# Mark the rest of physical memory as available
X86E820Entry(
addr=0x100000,
@@ -248,9 +248,9 @@ class X86Board(AbstractSystemBoard, KernelDiskWorkload):
),
]
# Reserve the last 16kB of the 32-bit address space for m5ops
# Reserve the last 16KiB of the 32-bit address space for m5ops
entries.append(
X86E820Entry(addr=0xFFFF0000, size="64kB", range_type=2)
X86E820Entry(addr=0xFFFF0000, size="64KiB", range_type=2)
)
self.workload.e820_table.entries = entries
@@ -283,10 +283,10 @@ class X86Board(AbstractSystemBoard, KernelDiskWorkload):
def _setup_memory_ranges(self):
memory = self.get_memory()
if memory.get_size() > toMemorySize("3GB"):
if memory.get_size() > toMemorySize("3GiB"):
raise Exception(
"X86Board currently only supports memory sizes up "
"to 3GB because of the I/O hole."
"to 3GiB because of the I/O hole."
)
data_range = AddrRange(memory.get_size())
memory.set_memory_range([data_range])

View File

@@ -41,15 +41,15 @@ class AbstractTwoLevelCacheHierarchy:
l2_assoc: int,
):
"""
:param l1i_size: The size of the L1 Instruction cache (e.g. "32kB").
:param l1i_size: The size of the L1 Instruction cache (e.g. "32KiB").
:param l1i_assoc:
:param l1d_size: The size of the L1 Data cache (e.g. "32kB").
:param l1d_size: The size of the L1 Data cache (e.g. "32KiB").
:param l1d_assoc:
:param l2_size: The size of the L2 cache (e.g., "256kB").
:param l2_size: The size of the L2 cache (e.g., "256KiB").
:param l2_assoc:
"""

View File

@@ -69,9 +69,9 @@ class PrivateL1CacheHierarchy(AbstractClassicCacheHierarchy):
membus: Optional[BaseXBar] = None,
) -> None:
"""
:param l1d_size: The size of the L1 Data Cache (e.g., "32kB").
:param l1d_size: The size of the L1 Data Cache (e.g., "32KiB").
:param l1i_size: The size of the L1 Instruction Cache (e.g., "32kB").
:param l1i_size: The size of the L1 Instruction Cache (e.g., "32KiB").
:param membus: The memory bus. This parameter is optional parameter and
will default to a 64 bit width SystemXBar is not
@@ -151,7 +151,7 @@ class PrivateL1CacheHierarchy(AbstractClassicCacheHierarchy):
data_latency=50,
response_latency=50,
mshrs=20,
size="1kB",
size="1KiB",
tgts_per_mshr=12,
addr_ranges=board.mem_ranges,
)

View File

@@ -89,11 +89,11 @@ class PrivateL1PrivateL2CacheHierarchy(
membus: Optional[BaseXBar] = None,
) -> None:
"""
:param l1d_size: The size of the L1 Data Cache (e.g., "32kB").
:param l1d_size: The size of the L1 Data Cache (e.g., "32KiB").
:param l1i_size: The size of the L1 Instruction Cache (e.g., "32kB").
:param l1i_size: The size of the L1 Instruction Cache (e.g., "32KiB").
:param l2_size: The size of the L2 Cache (e.g., "256kB").
:param l2_size: The size of the L2 Cache (e.g., "256KiB").
:param membus: The memory bus. This parameter is optional parameter and
will default to a 64 bit width SystemXBar is not
@@ -178,7 +178,7 @@ class PrivateL1PrivateL2CacheHierarchy(
data_latency=50,
response_latency=50,
mshrs=20,
size="1kB",
size="1KiB",
tgts_per_mshr=12,
addr_ranges=board.mem_ranges,
)

View File

@@ -82,9 +82,9 @@ class PrivateL1SharedL2CacheHierarchy(
membus: Optional[BaseXBar] = None,
) -> None:
"""
:param l1d_size: The size of the L1 Data Cache (e.g., "32kB").
:param l1i_size: The size of the L1 Instruction Cache (e.g., "32kB").
:param l2_size: The size of the L2 Cache (e.g., "256kB").
:param l1d_size: The size of the L1 Data Cache (e.g., "32KiB").
:param l1i_size: The size of the L1 Instruction Cache (e.g., "32KiB").
:param l2_size: The size of the L2 Cache (e.g., "256KiB").
:param l1d_assoc: The associativity of the L1 Data Cache.
:param l1i_assoc: The associativity of the L1 Instruction Cache.
:param l2_assoc: The associativity of the L2 Cache.
@@ -181,7 +181,7 @@ class PrivateL1SharedL2CacheHierarchy(
data_latency=50,
response_latency=50,
mshrs=20,
size="1kB",
size="1KiB",
tgts_per_mshr=12,
addr_ranges=board.mem_ranges,
)

View File

@@ -67,7 +67,7 @@ class DDR3_1600_8x8(DRAMInterface):
# DDR3 is a BL8 device
burst_length = 8
# Each device has a page (row buffer) size of 1 Kbyte (1K columns x8)
# Each device has a page (row buffer) size of 1 Kibibyte (1Ki columns x8)
device_rowbuffer_size = "1KiB"
# 8x8 configuration, so 8 devices

View File

@@ -181,7 +181,7 @@ class DDR4_2400_8x8(DDR4_2400_16x4):
# 8x8 configuration, 8 devices each with an 8-bit interface
device_bus_width = 8
# Each device has a page (row buffer) size of 1 Kbyte (1K columns x8)
# Each device has a page (row buffer) size of 1 Kibibyte (1K columns x8)
device_rowbuffer_size = "1KiB"
# 8x8 configuration, so 8 devices
@@ -214,7 +214,7 @@ class DDR4_2400_4x16(DDR4_2400_16x4):
# 4x16 configuration, 4 devices each with an 16-bit interface
device_bus_width = 16
# Each device has a page (row buffer) size of 2 Kbyte (1K columns x16)
# Each device has a page (row buffer) size of 2 Kibibyte (1K columns x16)
device_rowbuffer_size = "2KiB"
# 4x16 configuration, so 4 devices

View File

@@ -50,7 +50,7 @@ class DDR5_4400_4x8(DRAMInterface):
burst_length = 16
# Each device has a page (row buffer) size of 256B
# Four devices lead to a page size of 1KB
# Four devices lead to a page size of 1KiB
device_rowbuffer_size = "256B"
# 4Gbx8 configuration
@@ -86,10 +86,10 @@ class DDR5_4400_4x8(DRAMInterface):
# RRD_S (different bank group) : 8nCK
tRRD = "3.632ns"
# RRD_L (same bank group) is MAX(8nCK, 5ns) for 1KB page
# RRD_L (same bank group) is MAX(8nCK, 5ns) for 1KiB page
tRRD_L = "5ns"
# tFAW for 1KB page is MAX(32nCK, 14.545ns)
# tFAW for 1KiB page is MAX(32nCK, 14.545ns)
tXAW = "14.545ns"
activation_limit = 4
@@ -194,10 +194,10 @@ class DDR5_6400_4x8(DDR5_4400_4x8):
# RRD_S (different bank group) : 8nCK
tRRD = "2.496ns"
# RRD_L (same bank group) is MAX(8nCK, 5ns) for 1KB page
# RRD_L (same bank group) is MAX(8nCK, 5ns) for 1KiB page
tRRD_L = "5ns"
# tFAW for 1KB page is MAX(32 CK, 10.00ns)
# tFAW for 1KiB page is MAX(32 CK, 10.00ns)
tXAW = "10ns"
# Rd/Wr turnaround timings
@@ -254,7 +254,7 @@ class DDR5_8400_4x8(DDR5_4400_4x8):
# RRD_S (different bank group) : 8nCK
tRRD = "1.904ns"
# tFAW for 1KB page is MAX(32 CK, 10.00ns)
# tFAW for 1KiB page is MAX(32 CK, 10.00ns)
tXAW = "10ns"
# Rd/Wr turnaround timings

View File

@@ -65,7 +65,7 @@ class GDDR5_4000_2x32(DRAMInterface):
# GDDR5 is a BL8 device
burst_length = 8
# Each device has a page (row buffer) size of 2Kbits (256Bytes)
# Each device has a page (row buffer) size of 2Kibibits (256Bytes)
device_rowbuffer_size = "256B"
# 2x32 configuration, so 2 devices

View File

@@ -60,7 +60,7 @@ class HMC_2500_1x32(DDR3_1600_8x8):
[2] High performance AXI-4.0 based interconnect for extensible smart memory
cubes (E. Azarkhish et. al).
Assumed for the HMC model is a 30 nm technology node.
The modelled HMC consists of 4 Gbit layers which sum up to 2GiB of memory
The modelled HMC consists of 4 Gibibit layers which sum up to 2GiB of memory
(4 layers).
Each layer has 16 vaults and each vault consists of 2 banks per layer.
In order to be able to use the same controller used for 2D DRAM generations

View File

@@ -69,7 +69,7 @@ class LPDDR2_S4_1066_1x32(DRAMInterface):
# LPDDR2_S4 is a BL4 and BL8 device
burst_length = 8
# Each device has a page (row buffer) size of 1KB
# Each device has a page (row buffer) size of 1KiB
# (this depends on the memory density)
device_rowbuffer_size = "1KiB"

View File

@@ -69,7 +69,7 @@ class LPDDR3_1600_1x32(DRAMInterface):
# LPDDR3 is a BL8 device
burst_length = 8
# Each device has a page (row buffer) size of 4KB
# Each device has a page (row buffer) size of 4KiB
device_rowbuffer_size = "4KiB"
# 1x32 configuration, so 1 device

View File

@@ -68,7 +68,7 @@ class WideIO_200_1x128(DRAMInterface):
# This is a BL4 device
burst_length = 4
# Each device has a page (row buffer) size of 4KB
# Each device has a page (row buffer) size of 4KiB
# (this depends on the memory density)
device_rowbuffer_size = "4KiB"

View File

@@ -140,38 +140,38 @@ class SingleChannel(AbstractMemorySystem):
def SingleChannelDDR3_1600(
size: Optional[str] = "2048MB",
size: Optional[str] = "2048MiB",
) -> SingleChannel:
"""
A single channel DDR3_1600.
:param size: The size of the memory system. Default value of 2048MB.
:param size: The size of the memory system. Default value of 2048MiB.
"""
return SingleChannel("DDR3_8Gb_x8_1600", size)
def SingleChannelDDR4_2400(size: Optional[str] = "1024MB") -> SingleChannel:
def SingleChannelDDR4_2400(size: Optional[str] = "1024MiB") -> SingleChannel:
"""
A single channel DDR3_2400.
:param size: The size of the memory system. Default value of 1024MB.
:param size: The size of the memory system. Default value of 1024MiB.
"""
return SingleChannel("DDR4_4Gb_x8_2400", size)
def SingleChannelLPDDR3_1600(size: Optional[str] = "256MB") -> SingleChannel:
def SingleChannelLPDDR3_1600(size: Optional[str] = "256MiB") -> SingleChannel:
"""
A single channel LPDDR3_1600.
:param size: The size of the memory system. Default value of 256MB.
:param size: The size of the memory system. Default value of 256MiB.
"""
return SingleChannel("LPDDR3_8Gb_x32_1600", size)
def SingleChannelHBM(size: Optional[str] = "64MB") -> SingleChannel:
def SingleChannelHBM(size: Optional[str] = "64MiB") -> SingleChannel:
"""
A single channel HBM.
:param size: The size of the memory system. Default value of 64MB.
:param size: The size of the memory system. Default value of 64MiB.
"""
return SingleChannel("HBM1_4Gb_x128", size)

View File

@@ -133,7 +133,7 @@ class DRAMSysDDR4_1866(DRAMSysMem):
configuration=(
DEFAULT_DRAMSYS_DIRECTORY / "configs/ddr4-example.json"
).as_posix(),
size="4GB",
size="4GiB",
recordable=recordable,
)
@@ -151,7 +151,7 @@ class DRAMSysDDR3_1600(DRAMSysMem):
configuration=(
DEFAULT_DRAMSYS_DIRECTORY / "configs/ddr3-gem5-se.json"
).as_posix(),
size="1GB",
size="1GiB",
recordable=recordable,
)
@@ -169,7 +169,7 @@ class DRAMSysLPDDR4_3200(DRAMSysMem):
configuration=(
DEFAULT_DRAMSYS_DIRECTORY / "configs/lpddr4-example.json"
).as_posix(),
size="1GB",
size="1GiB",
recordable=recordable,
)
@@ -187,6 +187,6 @@ class DRAMSysHBM2(DRAMSysMem):
configuration=(
DEFAULT_DRAMSYS_DIRECTORY / "configs/hbm2-example.json"
).as_posix(),
size="1GB",
size="1GiB",
recordable=recordable,
)

View File

@@ -58,7 +58,7 @@ class ComplexGenerator(AbstractGenerator):
def add_linear(
self,
duration: str = "1ms",
rate: str = "100GB/s",
rate: str = "100GiB/s",
block_size: int = 64,
min_addr: int = 0,
max_addr: int = 32768,
@@ -99,7 +99,7 @@ class ComplexGenerator(AbstractGenerator):
def add_random(
self,
duration: str = "1ms",
rate: str = "100GB/s",
rate: str = "100GiB/s",
block_size: int = 64,
min_addr: int = 0,
max_addr: int = 32768,

View File

@@ -39,7 +39,7 @@ class LinearGenerator(AbstractGenerator):
self,
num_cores: int = 1,
duration: str = "1ms",
rate: str = "100GB/s",
rate: str = "100GiB/s",
block_size: int = 64,
min_addr: int = 0,
max_addr: int = 32768,

View File

@@ -38,7 +38,7 @@ class RandomGenerator(AbstractGenerator):
self,
num_cores: int = 1,
duration: str = "1ms",
rate: str = "100GB/s",
rate: str = "100GiB/s",
block_size: int = 64,
min_addr: int = 0,
max_addr: int = 32768,

View File

@@ -40,7 +40,7 @@ class StridedGenerator(AbstractGenerator):
self,
num_cores: int = 1,
duration: str = "1ms",
rate: str = "100GB/s",
rate: str = "100GiB/s",
block_size: int = 64,
superblock_size: int = 64,
stride_size: Optional[int] = None,

View File

@@ -41,10 +41,10 @@ from ...utils.requires import requires
class X86DemoBoard(X86Board):
"""
This prebuilt X86 board is used for demonstration purposes. It simulates
an X86 3GHz quad-core system with a 2GB DDR3_1600 memory system. A
an X86 3GHz quad-core system with a 2GiB DDR3_1600 memory system. A
MESI_Two_Level cache hierarchy is set with an l1 data and instruction
cache, each 32kB with an associativity of 8, and a single bank l2 cache of
1MB with an associativity of 16.
cache, each 32KiB with an associativity of 8, and a single bank l2 cache of
1MiB with an associativity of 16.
**DISCLAIMER**: This board is solely for demonstration purposes. This board
is not known to be representative of any real-world system or produce
@@ -77,16 +77,16 @@ class X86DemoBoard(X86Board):
"real-world system. Use with caution."
)
memory = SingleChannelDDR3_1600(size="2GB")
memory = SingleChannelDDR3_1600(size="2GiB")
processor = SimpleProcessor(
cpu_type=CPUTypes.TIMING, isa=ISA.X86, num_cores=4
)
cache_hierarchy = MESITwoLevelCacheHierarchy(
l1d_size="32kB",
l1d_size="32KiB",
l1d_assoc=8,
l1i_size="32kB",
l1i_size="32KiB",
l1i_assoc=8,
l2_size="1MB",
l2_size="1MiB",
l2_assoc=16,
num_l2_banks=1,
)

View File

@@ -77,7 +77,7 @@ def U74Memory():
"""
Memory for the U74 board.
DDR4 Subsystem with 16GB of memory.
DDR4 Subsystem with 16GiB of memory.
Starts at 0x80000000.
@@ -85,7 +85,7 @@ def U74Memory():
:return: ChanneledMemory
"""
memory = SingleChannelDDR4_2400("16GB")
memory = SingleChannelDDR4_2400("16GiB")
memory.set_memory_range(
[AddrRange(start=0x80000000, size=memory.get_size())]
)
@@ -121,7 +121,7 @@ class RISCVMatchedBoard(
:param clk_freq: The clock frequency of the system,
default: 1.2GHz
:param l2_size: The size of the L2 cache,
default: 2MB
default: 2MiB
:param is_fs: Whether the system is a full system or not,
default: False (SE Mode)
@@ -230,9 +230,9 @@ class RISCVMatchedBoard(
]
# PCI
self.bridge.ranges.append(AddrRange(0x2F000000, size="16MB"))
self.bridge.ranges.append(AddrRange(0x30000000, size="256MB"))
self.bridge.ranges.append(AddrRange(0x40000000, size="512MB"))
self.bridge.ranges.append(AddrRange(0x2F000000, size="16MiB"))
self.bridge.ranges.append(AddrRange(0x30000000, size="256MiB"))
self.bridge.ranges.append(AddrRange(0x40000000, size="512MiB"))
def _setup_pma(self) -> None:
"""Set the PMA devices on each core"""
@@ -243,9 +243,9 @@ class RISCVMatchedBoard(
]
# PCI
uncacheable_range.append(AddrRange(0x2F000000, size="16MB"))
uncacheable_range.append(AddrRange(0x30000000, size="256MB"))
uncacheable_range.append(AddrRange(0x40000000, size="512MB"))
uncacheable_range.append(AddrRange(0x2F000000, size="16MiB"))
uncacheable_range.append(AddrRange(0x30000000, size="256MiB"))
uncacheable_range.append(AddrRange(0x40000000, size="512MiB"))
# TODO: Not sure if this should be done per-core like in the example
for cpu in self.get_processor().get_cores():

View File

@@ -79,7 +79,7 @@ class RISCVMatchedCacheHierarchy(
l2_size: str,
) -> None:
"""
:param l2_size: The size of the L2 Cache (e.g., "256kB").
:param l2_size: The size of the L2 Cache (e.g., "256KiB").
"""
AbstractClassicCacheHierarchy.__init__(self=self)
AbstractTwoLevelCacheHierarchy.__init__(
@@ -173,7 +173,7 @@ class RISCVMatchedCacheHierarchy(
data_latency=50,
response_latency=50,
mshrs=20,
size="1kB",
size="1KiB",
tgts_per_mshr=12,
addr_ranges=board.mem_ranges,
)

View File

@@ -92,7 +92,7 @@ from m5.util.pybind import *
# object, either using keyword assignment in the constructor or in
# separate assignment statements. For example:
#
# cache = BaseCache(size='64KB')
# cache = BaseCache(size='64KiB')
# cache.hit_latency = 3
# cache.assoc = 8
#

View File

@@ -38,6 +38,8 @@
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
# metric prefixes
from typing import Optional
atto = 1.0e-18
femto = 1.0e-15
pico = 1.0e-12
@@ -96,6 +98,15 @@ binary_prefixes = {
"k": kibi,
}
base_10_to_2 = {
"k": "Ki",
"M": "Mi",
"G": "Gi",
"T": "Ti",
"P": "Pi",
"E": "Ei",
}
def assertStr(value):
if not isinstance(value, str):
@@ -254,10 +265,38 @@ def toNetworkBandwidth(value):
def toMemoryBandwidth(value):
checkBaseConversion(value, "B/s")
return toBinaryFloat(value, "memory bandwidth", "B/s")
def _base_10_to_2(value: str, unit: str) -> Optional[str]:
"""Convert a base 10 memory/cache size SI prefix strings to base 2. Used
in `checkBaseConversion` to provide a warning message to the user. Will
return None if no conversion is required.
This function is intentionally separate from `checkBaseConversion` to aid
in testing."""
size_and_prefix, _ = _split_suffix(value, [unit])
size, prefix = _split_suffix(size_and_prefix, binary_prefixes)
if prefix in base_10_to_2.keys():
return f"{size}{base_10_to_2[prefix]}"
return None
def checkBaseConversion(value, unit):
if type(value) is str:
new_value = _base_10_to_2(value, unit)
if new_value:
from m5.util import warn
warn(
f"Base 10 memory/cache size {value} will be cast to base 2"
+ f" size {new_value}{unit}."
)
def toMemorySize(value):
checkBaseConversion(value, "B")
return toBinaryInteger(value, "memory size", "B")