-
Notifications
You must be signed in to change notification settings - Fork 189
Use tablegen Python bindings for trace events instead of separate generation #3038
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,27 +6,41 @@ | |
| # | ||
| """Trace events enumerations for AIE architectures. | ||
|
|
||
| Available modules: | ||
| - aie: AIE1 architecture events | ||
| - aie2: AIE2/AIEML architecture events | ||
| - aie2p: AIE2P architecture events | ||
| Event enums are sourced from the TableGen-generated Python bindings | ||
| (aie.dialects._aie_enum_gen), which are produced from the same aie-rt | ||
| headers that define the hardware event numbers. | ||
|
|
||
| Architecture-specific enums (CoreEventAIE2, etc.) are re-exported here | ||
| under architecture-agnostic names (CoreEvent, etc.) for convenience. | ||
| Use get_events_for_device() to select the correct architecture. | ||
| """ | ||
|
|
||
| from enum import IntEnum | ||
| from types import SimpleNamespace | ||
| import typing | ||
|
|
||
| from . import aie | ||
| from . import aie2 | ||
| from . import aie2p | ||
|
|
||
| from .aie2 import ( | ||
| CoreEvent, | ||
| MemEvent, | ||
| ShimTileEvent, | ||
| MemTileEvent, | ||
| from aie.dialects._aie_enum_gen import ( | ||
| CoreEventAIE, | ||
| MemEventAIE, | ||
| ShimTileEventAIE, | ||
| CoreEventAIE2, | ||
| MemEventAIE2, | ||
| ShimTileEventAIE2, | ||
| MemTileEventAIE2, | ||
| CoreEventAIE2P, | ||
| MemEventAIE2P, | ||
| ShimTileEventAIE2P, | ||
| MemTileEventAIE2P, | ||
| ) | ||
|
|
||
| from aie.dialects.aie import WireBundle, DMAChannelDir | ||
|
|
||
| # Default to AIE2 for backwards compatibility | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm a little confused abut why we set defaults when there's a function below that does more correct conditional sets? Can you clarify a bit?
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes this is a part where I don't have a clear solution. The issue is the tablegen events suffixes the event names with the architecture (CoreEventAIE2.), but I still wanted to keep the aliases CoreEvent etc to paper over this name. The backwards compatibility comment is not very correct. The get_events_for_device is more correct but it will require changing all examples to first acquire events with it. |
||
| CoreEvent = CoreEventAIE2 | ||
| MemEvent = MemEventAIE2 | ||
| ShimTileEvent = ShimTileEventAIE2 | ||
| MemTileEvent = MemTileEventAIE2 | ||
|
|
||
|
|
||
| # We use the packet type field in the packet header to help differentiate the tile | ||
| # that the packet came from. Since packet types don't inherently have meaning, we | ||
|
|
@@ -44,11 +58,26 @@ class PacketType(IntEnum): | |
|
|
||
| def get_events_for_device(device: str): | ||
| if "xcvc1902" in device: | ||
| return aie | ||
| return SimpleNamespace( | ||
| CoreEvent=CoreEventAIE, | ||
| MemEvent=MemEventAIE, | ||
| ShimTileEvent=ShimTileEventAIE, | ||
| MemTileEvent=None, # AIE1 has no mem tiles | ||
| ) | ||
| elif "npu2p" in device: | ||
| return aie2p | ||
| return SimpleNamespace( | ||
| CoreEvent=CoreEventAIE2P, | ||
| MemEvent=MemEventAIE2P, | ||
| ShimTileEvent=ShimTileEventAIE2P, | ||
| MemTileEvent=MemTileEventAIE2P, | ||
| ) | ||
| else: | ||
| return aie2 | ||
| return SimpleNamespace( | ||
| CoreEvent=CoreEventAIE2, | ||
| MemEvent=MemEventAIE2, | ||
| ShimTileEvent=ShimTileEventAIE2, | ||
| MemTileEvent=MemTileEventAIE2, | ||
| ) | ||
|
|
||
|
|
||
| def _get_port_events(enum_class): | ||
|
|
@@ -68,9 +97,6 @@ class GenericEvent: | |
| def __init__( | ||
| self, code: typing.Union[CoreEvent, MemEvent, ShimTileEvent, MemTileEvent] | ||
| ): | ||
| # For backwards compatibility, allow integer as event | ||
| if isinstance(code, int): | ||
| code = CoreEvent(code) | ||
| self.code: typing.Union[CoreEvent, MemEvent, ShimTileEvent, MemTileEvent] = code | ||
|
|
||
| def get_register_writes(self): | ||
|
|
@@ -118,9 +144,6 @@ def __init__( | |
| enum_class=None, | ||
| valid_codes=None, | ||
| ): | ||
| # For backwards compatibility, allow integer as event | ||
| if isinstance(code, int) and enum_class: | ||
| code = enum_class(code) | ||
| if valid_codes: | ||
| assert code in valid_codes | ||
|
|
||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.