Generate trace events enum package with CMake instead of manual generation#2696
Generate trace events enum package with CMake instead of manual generation#2696
Conversation
There's only one minor difference between aie2 and aie2p, so the differences don't matter in practice. The main goal here is to enable aie1 and aie2ps/aie4 in future. |
|
@fifield Can you do a diff between the generated events and the previous list of events in |
You're right there were gaps. I didn't check vs. the original file. Fixed in 113327f |
andrej
left a comment
There was a problem hiding this comment.
Nice improvement to the trace infrastructure
There was a problem hiding this comment.
Pull Request Overview
This PR automates the generation of trace event enumerations during the CMake build process and extends support from AIE2-only to multiple AIE architectures (AIE1, AIE2/AIEML, AIE2P).
Key changes:
- Refactored generator script to support multiple architectures and output both Python enums and a unified JSON database
- Restructured trace_events from a single file to a package with per-architecture modules (aie.py, aie2.py, aie2p.py)
- Integrated generation into CMake build with automatic copying and installation of generated files
Reviewed Changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| utils/generate_events_enum.py | Extended to process multiple architecture headers, generate JSON database, and output per-architecture Python modules with configurable naming |
| python/utils/trace_events/init.py | New package initialization file documenting available architecture modules |
| python/utils/trace.py | Updated import to use new package structure (aie.utils.trace_events.aie2) |
| python/utils/parse_trace.py | Updated import to use new package structure and renamed PLEvent to ShimTileEvent |
| python/utils/parse_eventIR.py | Updated import to use new package structure and renamed PLEvent to ShimTileEvent |
| python/CMakeLists.txt | Added CMake custom commands to generate trace event files, copy to build directory, and install them as a package |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
acb18cc to
ee47a25
Compare
9d79c16 to
353e830
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 13 out of 13 changed files in this pull request and generated 2 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Renamed trace_events_enum.py to trace_events package with per-architecture modules
- Changed from single file to package: aie.utils.trace_events.{aie,aie2,aie2p}
- Renamed PLEvent to ShimTileEvent to match expected usage
- Generate files during build into build/regdb/ directory instead of manually generating
- Copy generated files to Python package directory during build
- Install generated files along with checked-in __init__.py
- Update all imports to use new package structure
- Conditionally emit UCEvent enum only when events are defined (e.g. aie2ps in future)
- Emit unified events.json into build/regdb for compiler ingest (for future work)
- Map aieml architecture to aie2 for Python module naming
Fill enum value gaps with reserved placeholders
The generator now fills gaps in enum values with rsvd_XX placeholders
to ensure continuous numbering from min to max value. This matches the
behavior of the original manually-generated file and ensures that all
hardware event codes are represented in the enum, even if they are
reserved or undefined.
Example: If events 0-53 and 55-127 are defined, value 54 gets
placeholder rsvd_54 to maintain continuity.
Fixes comparison with original trace_events_enum.py file.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: fifield <800843+fifield@users.noreply.github.com> Co-authored-by: Jeff Fifield <jeff.fifield@amd.com> Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
- Add generate_events_tablegen.py to create TableGen enum definitions from aie-rt event headers - Update AIE dialect CMakeLists to generate AIEEvents*.td.inc files during build process - Include generated event enums in AIEAttrs.td - Add proper CMake dependencies to ensure enums are generated before they are needed by tablegen This allows the AIE dialect to emit C++ enum classes for all event types (CoreEvent, MemEvent, ShimTileEvent, MemTileEvent) across all AIE architectures (AIE, AIE2, AIE2P).
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Summary
Automates the generation of trace event enumerations during the build process and adds support for multiple AIE architectures (AIE1, AIE2/AIEML, AIE2P) instead of only AIE2.
Changes
trace_events_enum.pytotrace_eventspackage with per-architecture modules (aie,aie2,aie2p)from aie.utils.trace_events_enum import ...tofrom aie.utils.trace_events.aie2 import ...for explicit architecture selectionPLEventtoShimTileEventto match expected usage in trace utilitiesbuild/regdb/directory__init__.pyaiemlarchitecture toaie2Python module nameUCEventenum only when events are definedevents.jsondatabase for future compiler integrationtrace.py,parse_trace.py, andparse_eventIR.pyto use new package structureBenefits
Testing