stdlib,ruby: Enable resetting version numbers (#1649)

Ruby requires each machine type to have a continuous set of version
numbers starting at 0. We were hiding this from users/developers by
using a Python class variable in the stdlib. Unfortunately, with
multiple ruby systems this doesn't work anymore.

As a stop-gap this change adds "resetting" these versions to the
beginning of `incorporate_caches`. It would be better to fix this in the
C++ code (and assign these numbers in C++ probably via the RubySystem),
but that's a bigger change than is needed right now.

---------

Signed-off-by: Jason Lowe-Power <jason@lowepower.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
This commit is contained in:
Jason Lowe-Power
2024-10-10 09:53:40 -07:00
committed by GitHub
parent 50f652a2ee
commit 3f42ab4ca9
6 changed files with 61 additions and 0 deletions

View File

@@ -82,6 +82,7 @@ class PrivateL1CacheHierarchy(AbstractRubyCacheHierarchy):
@overrides(AbstractCacheHierarchy)
def incorporate_cache(self, board: AbstractBoard) -> None:
super().incorporate_cache(board)
self.ruby_system = RubySystem()
# Ruby's global network.
@@ -244,3 +245,10 @@ class PrivateL1CacheHierarchy(AbstractRubyCacheHierarchy):
dma_controllers.append(ctrl)
return dma_controllers
@overrides(AbstractRubyCacheHierarchy)
def _reset_version_numbers(self):
from .nodes.abstract_node import AbstractNode
AbstractNode._version = 0
MemoryController._version = 0

View File

@@ -37,6 +37,18 @@ class AbstractRubyCacheHierarchy(AbstractCacheHierarchy):
def __init__(self):
super().__init__()
def _reset_version_numbers(self):
"""Needed for multiple ruby systems so that each system starts at 0.
Note: This needs to be overridden by the protocol since we don't know
the machine classes at this point.
"""
raise NotImplementedError
@overrides(AbstractCacheHierarchy)
def incorporate_cache(self, board):
self._reset_version_numbers()
@overrides(AbstractCacheHierarchy)
def is_ruby(self) -> bool:
return True

View File

@@ -38,6 +38,7 @@ from ......components.cachehierarchies.ruby.caches.mesi_three_level.directory im
from ......components.cachehierarchies.ruby.caches.mesi_three_level.dma_controller import (
DMAController,
)
from ......utils.override import overrides
from ......utils.requires import requires
from ....abstract_three_level_cache_hierarchy import (
AbstractThreeLevelCacheHierarchy,
@@ -95,6 +96,7 @@ class OctopiCache(
requires(
coherence_protocol_required=CoherenceProtocol.MESI_THREE_LEVEL
)
super().incorporate_cache(board)
cache_line_size = board.get_cache_line_size()
@@ -267,3 +269,15 @@ class OctopiCache(
]
for link in self.dma_int_links:
self.ruby_system.network._add_int_link(link)
@overrides(AbstractRubyCacheHierarchy)
def _reset_version_numbers(self):
from ....caches.mesi_three_level.l1_cache import L1Cache
from ....caches.mesi_three_level.l2_cache import L2Cache
from ....caches.mesi_three_level.l3_cache import L3Cache
Directory._version = 0
L1Cache._version = 0
L2Cache._version = 0
L3Cache._version = 0
DMAController._version = 0

View File

@@ -33,6 +33,7 @@ from m5.objects import (
)
from ....coherence_protocol import CoherenceProtocol
from ....utils.override import overrides
from ....utils.requires import requires
requires(coherence_protocol_required=CoherenceProtocol.MESI_THREE_LEVEL)
@@ -87,6 +88,7 @@ class MESIThreeLevelCacheHierarchy(
self._num_l3_banks = num_l3_banks
def incorporate_cache(self, board: AbstractBoard) -> None:
super().incorporate_cache(board)
cache_line_size = board.get_cache_line_size()
self.ruby_system = RubySystem()
@@ -233,3 +235,11 @@ class MESIThreeLevelCacheHierarchy(
ruby_system=self.ruby_system
)
board.connect_system_port(self.ruby_system.sys_port_proxy.in_ports)
@overrides(AbstractRubyCacheHierarchy)
def _reset_version_numbers(self):
Directory._version = 0
L1Cache._version = 0
L2Cache._version = 0
L3Cache._version = 0
DMAController._version = 0

View File

@@ -33,6 +33,7 @@ from m5.objects import (
)
from ....coherence_protocol import CoherenceProtocol
from ....utils.override import overrides
from ....utils.requires import requires
requires(coherence_protocol_required=CoherenceProtocol.MESI_TWO_LEVEL)
@@ -83,6 +84,7 @@ class MESITwoLevelCacheHierarchy(
self._num_l2_banks = num_l2_banks
def incorporate_cache(self, board: AbstractBoard) -> None:
super().incorporate_cache(board)
cache_line_size = board.get_cache_line_size()
self.ruby_system = RubySystem()
@@ -199,3 +201,10 @@ class MESITwoLevelCacheHierarchy(
ruby_system=self.ruby_system
)
board.connect_system_port(self.ruby_system.sys_port_proxy.in_ports)
@overrides(AbstractRubyCacheHierarchy)
def _reset_version_numbers(self):
Directory._version = 0
L1Cache._version = 0
L2Cache._version = 0
DMAController._version = 0

View File

@@ -32,6 +32,7 @@ from m5.objects import (
)
from ....coherence_protocol import CoherenceProtocol
from ....utils.override import overrides
from ....utils.requires import requires
requires(coherence_protocol_required=CoherenceProtocol.MI_EXAMPLE)
@@ -65,6 +66,7 @@ class MIExampleCacheHierarchy(AbstractRubyCacheHierarchy):
@overrides(AbstractCacheHierarchy)
def incorporate_cache(self, board: AbstractBoard) -> None:
super().incorporate_cache(board)
self.ruby_system = RubySystem()
# Ruby's global network.
@@ -176,3 +178,9 @@ class MIExampleCacheHierarchy(AbstractRubyCacheHierarchy):
ruby_system=self.ruby_system
)
board.connect_system_port(self.ruby_system.sys_port_proxy.in_ports)
@overrides(AbstractRubyCacheHierarchy)
def _reset_version_numbers(self):
Directory._version = 0
L1Cache._version = 0
DMAController._version = 0