Skip to content

Commit

Permalink
Change Indexed to Tagged
Browse files Browse the repository at this point in the history
  • Loading branch information
tilk committed Apr 1, 2024
1 parent 110d596 commit a318903
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 12 deletions.
4 changes: 2 additions & 2 deletions coreblocks/core_structs/rf.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from transactron import Method, Transaction, def_method, TModule
from coreblocks.interface.layouts import RFLayouts
from coreblocks.params import GenParams
from transactron.lib.metrics import HwExpHistogram, IndexedLatencyMeasurer
from transactron.lib.metrics import HwExpHistogram, TaggedLatencyMeasurer
from transactron.utils.amaranth_ext.functions import popcount
from transactron.utils.transactron_helpers import make_layout

Expand All @@ -22,7 +22,7 @@ def __init__(self, *, gen_params: GenParams):
self.write = Method(i=layouts.rf_write)
self.free = Method(i=layouts.rf_free)

self.perf_rf_valid_time = IndexedLatencyMeasurer(
self.perf_rf_valid_time = TaggedLatencyMeasurer(
"struct.rf.valid_time",
description="Distribution of time registers are valid in RF",
slots_number=2**gen_params.phys_regs_bits,
Expand Down
4 changes: 2 additions & 2 deletions coreblocks/func_blocks/fu/common/rs.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from coreblocks.params import GenParams
from coreblocks.frontend.decoder import OpType
from coreblocks.interface.layouts import RSLayouts
from transactron.lib.metrics import HwExpHistogram, IndexedLatencyMeasurer
from transactron.lib.metrics import HwExpHistogram, TaggedLatencyMeasurer
from transactron.utils import RecordDict
from transactron.utils.amaranth_ext.functions import popcount
from transactron.utils.transactron_helpers import make_layout
Expand Down Expand Up @@ -44,7 +44,7 @@ def __init__(
self.data = Array(Signal(self.internal_layout) for _ in range(self.rs_entries))
self.data_ready = Signal(self.rs_entries)

self.perf_rs_wait_time = IndexedLatencyMeasurer(
self.perf_rs_wait_time = TaggedLatencyMeasurer(
f"fu.block_{rs_number}.rs.valid_time",
description=f"Distribution of time instructions wait in RS {rs_number}",
slots_number=2**self.rs_entries_bits,
Expand Down
2 changes: 1 addition & 1 deletion test/transactron/test_metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,7 @@ class TestIndexedLatencyMeasurer(TestLatencyMeasurerBase):
def test_latency_measurer(self):
random.seed(42)

m = SimpleTestCircuit(IndexedLatencyMeasurer("latency", slots_number=self.slots_number, max_latency=300))
m = SimpleTestCircuit(TaggedLatencyMeasurer("latency", slots_number=self.slots_number, max_latency=300))
DependencyContext.get().add_dependency(HwMetricsEnabledKey(), True)

latencies: list[int] = []
Expand Down
14 changes: 7 additions & 7 deletions transactron/lib/metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"HwCounter",
"HwExpHistogram",
"FIFOLatencyMeasurer",
"IndexedLatencyMeasurer",
"TaggedLatencyMeasurer",
"HardwareMetricsManager",
"HwMetricsEnabledKey",
]
Expand Down Expand Up @@ -474,12 +474,12 @@ def metrics_enabled(self) -> bool:
return DependencyContext.get().get_dependency(HwMetricsEnabledKey())


class IndexedLatencyMeasurer(Elaboratable):
class TaggedLatencyMeasurer(Elaboratable):
"""
Measures duration between two events, e.g. request processing latency.
It can track multiple events at the same time, i.e. the second event can
be registered as started, before the first finishes. However, each event
needs to have an unique slot index.
needs to have an unique slot tag.
The module exposes an exponential histogram of the measured latencies.
"""
Expand Down Expand Up @@ -571,7 +571,7 @@ def _(slot: Value):

def start(self, m: TModule, *, slot: ValueLike):
"""
Registers the start of an event for a given slot index.
Registers the start of an event for a given slot tag.
Should be called in the body of either a transaction or a method.
Expand All @@ -580,7 +580,7 @@ def start(self, m: TModule, *, slot: ValueLike):
m: TModule
Transactron module
slot: ValueLike
The slot index of the event.
The slot tag of the event.
"""

if not self.metrics_enabled():
Expand All @@ -590,7 +590,7 @@ def start(self, m: TModule, *, slot: ValueLike):

def stop(self, m: TModule, *, slot: ValueLike):
"""
Registers the end of the event for a given slot index.
Registers the end of the event for a given slot tag.
Should be called in the body of either a transaction or a method.
Expand All @@ -599,7 +599,7 @@ def stop(self, m: TModule, *, slot: ValueLike):
m: TModule
Transactron module
slot: ValueLike
The slot index of the event.
The slot tag of the event.
"""

if not self.metrics_enabled():
Expand Down

0 comments on commit a318903

Please sign in to comment.