Add aie-insert-trace-flows pass#19
Conversation
|
depends on Xilinx#2705 |
| std::unique_ptr<mlir::OperationPass<DeviceOp>> | ||
| createAIEInsertTraceFlowsPass(); |
There was a problem hiding this comment.
[clang-format] reported by reviewdog 🐶
| std::unique_ptr<mlir::OperationPass<DeviceOp>> | |
| createAIEInsertTraceFlowsPass(); | |
| std::unique_ptr<mlir::OperationPass<DeviceOp>> createAIEInsertTraceFlowsPass(); |
| if (eventNum) { | ||
| startEvent = *eventNum; | ||
| } else { | ||
| startOp.emitError("unknown broadcast event '") << eventName << "'"; |
There was a problem hiding this comment.
[clang-format] reported by reviewdog 🐶
| startOp.emitError("unknown broadcast event '") << eventName << "'"; | |
| startOp.emitError("unknown broadcast event '") | |
| << eventName << "'"; |
There was a problem hiding this comment.
Remaining comments which cannot be posted as a review comment to avoid GitHub Rate Limit
black
[black] reported by reviewdog 🐶
[black] reported by reviewdog 🐶
mlir-aie/mlir_autotrace_example/visualize_trace.py
Lines 131 to 133 in 86ff619
[black] reported by reviewdog 🐶
mlir-aie/mlir_autotrace_example/visualize_trace.py
Lines 135 to 136 in 86ff619
[black] reported by reviewdog 🐶
[black] reported by reviewdog 🐶
[black] reported by reviewdog 🐶
[black] reported by reviewdog 🐶
mlir-aie/mlir_autotrace_example/visualize_trace.py
Lines 151 to 154 in 86ff619
[black] reported by reviewdog 🐶
mlir-aie/mlir_autotrace_example/visualize_trace.py
Lines 158 to 159 in 86ff619
[black] reported by reviewdog 🐶
[black] reported by reviewdog 🐶
[black] reported by reviewdog 🐶
[black] reported by reviewdog 🐶
[black] reported by reviewdog 🐶
[black] reported by reviewdog 🐶
[black] reported by reviewdog 🐶
[black] reported by reviewdog 🐶
mlir-aie/mlir_autotrace_example/visualize_trace.py
Lines 188 to 190 in 86ff619
[black] reported by reviewdog 🐶
[black] reported by reviewdog 🐶
[black] reported by reviewdog 🐶
mlir-aie/mlir_autotrace_example/visualize_trace.py
Lines 200 to 202 in 86ff619
[black] reported by reviewdog 🐶
mlir-aie/mlir_autotrace_example/visualize_trace.py
Lines 205 to 207 in 86ff619
[black] reported by reviewdog 🐶
mlir-aie/mlir_autotrace_example/visualize_trace.py
Lines 210 to 212 in 86ff619
[black] reported by reviewdog 🐶
[black] reported by reviewdog 🐶
[black] reported by reviewdog 🐶
mlir-aie/mlir_autotrace_example/visualize_trace.py
Lines 219 to 221 in 86ff619
[black] reported by reviewdog 🐶
| @@ -0,0 +1,225 @@ | |||
| #!/usr/bin/env python3 | |||
| ##===- visualize_trace.py -----------------------------------------------===## | |||
| # | |||
There was a problem hiding this comment.
[black] reported by reviewdog 🐶
| # | |
| # |
| # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| # | ||
| # Copyright (C) 2025, Advanced Micro Devices, Inc. | ||
| # |
There was a problem hiding this comment.
[black] reported by reviewdog 🐶
| # | |
| # |
| import matplotlib.patches as mpatches | ||
| from collections import defaultdict | ||
|
|
||
| def parse_trace_json(trace_file): |
There was a problem hiding this comment.
[black] reported by reviewdog 🐶
| def parse_trace_json(trace_file): | |
| def parse_trace_json(trace_file): |
|
|
||
| def parse_trace_json(trace_file): | ||
| """Parse the trace JSON file and extract events.""" | ||
| with open(trace_file, 'r') as f: |
There was a problem hiding this comment.
[black] reported by reviewdog 🐶
| with open(trace_file, 'r') as f: | |
| with open(trace_file, "r") as f: |
| """Parse the trace JSON file and extract events.""" | ||
| with open(trace_file, 'r') as f: | ||
| data = json.load(f) | ||
|
|
There was a problem hiding this comment.
[black] reported by reviewdog 🐶
| (interval['start'], lane - 0.4), | ||
| interval['duration'], |
There was a problem hiding this comment.
[black] reported by reviewdog 🐶
| (interval['start'], lane - 0.4), | |
| interval['duration'], | |
| (interval["start"], lane - 0.4), | |
| interval["duration"], |
| interval['duration'], | ||
| 0.8, | ||
| facecolor=color, | ||
| edgecolor='black', |
There was a problem hiding this comment.
[black] reported by reviewdog 🐶
| edgecolor='black', | |
| edgecolor="black", |
| facecolor=color, | ||
| edgecolor='black', | ||
| linewidth=0.5, | ||
| alpha=0.7 |
There was a problem hiding this comment.
[black] reported by reviewdog 🐶
| alpha=0.7 | |
| alpha=0.7, |
| alpha=0.7 | ||
| ) | ||
| ax.add_patch(rect) | ||
|
|
There was a problem hiding this comment.
[black] reported by reviewdog 🐶
|
|
||
| # Add text label if duration is large enough (relative to visible range) | ||
| label_threshold = time_range / 100 # Show label if event is > 1% of total time | ||
| if interval['duration'] > label_threshold: |
There was a problem hiding this comment.
[black] reported by reviewdog 🐶
| if interval['duration'] > label_threshold: | |
| if interval["duration"] > label_threshold: |
| label_threshold = time_range / 100 # Show label if event is > 1% of total time | ||
| if interval['duration'] > label_threshold: | ||
| ax.text( | ||
| interval['start'] + interval['duration'] / 2, |
There was a problem hiding this comment.
[black] reported by reviewdog 🐶
| interval['start'] + interval['duration'] / 2, | |
| interval["start"] + interval["duration"] / 2, |
| event_name.replace('INSTR_', '').replace('DMA_', '').replace('_', ' '), | ||
| ha='center', | ||
| va='center', |
There was a problem hiding this comment.
[black] reported by reviewdog 🐶
| event_name.replace('INSTR_', '').replace('DMA_', '').replace('_', ' '), | |
| ha='center', | |
| va='center', | |
| event_name.replace("INSTR_", "").replace("DMA_", "").replace("_", " "), | |
| ha="center", | |
| va="center", |
| weight='bold', | ||
| clip_on=True |
There was a problem hiding this comment.
[black] reported by reviewdog 🐶
| weight='bold', | |
| clip_on=True | |
| weight="bold", | |
| clip_on=True, |
| weight='bold', | ||
| clip_on=True | ||
| ) | ||
|
|
There was a problem hiding this comment.
[black] reported by reviewdog 🐶
| # Set up axes | ||
| ax.set_ylim(-0.5, lane_idx - 0.5) | ||
| ax.set_yticks(range(lane_idx)) | ||
|
|
There was a problem hiding this comment.
[black] reported by reviewdog 🐶
| '-t', '--title', | ||
| default='MLIR Trace Timeline', | ||
| help='Chart title (default: MLIR Trace Timeline)' |
There was a problem hiding this comment.
[black] reported by reviewdog 🐶
| '-t', '--title', | |
| default='MLIR Trace Timeline', | |
| help='Chart title (default: MLIR Trace Timeline)' | |
| "-t", | |
| "--title", | |
| default="MLIR Trace Timeline", | |
| help="Chart title (default: MLIR Trace Timeline)", |
| default='MLIR Trace Timeline', | ||
| help='Chart title (default: MLIR Trace Timeline)' | ||
| ) | ||
|
|
There was a problem hiding this comment.
[black] reported by reviewdog 🐶
| ) | ||
|
|
||
| args = parser.parse_args() | ||
|
|
There was a problem hiding this comment.
[black] reported by reviewdog 🐶
|
|
||
| print(f"Found {len(processes)} processes, {len(threads)} threads, {len(events)} events") | ||
|
|
There was a problem hiding this comment.
[black] reported by reviewdog 🐶
| print(f"Found {len(processes)} processes, {len(threads)} threads, {len(events)} events") | |
| print( | |
| f"Found {len(processes)} processes, {len(threads)} threads, {len(events)} events" | |
| ) | |
|
|
||
| create_timeline(processes, threads, events, args.output, args.title) | ||
|
|
||
| if __name__ == '__main__': |
There was a problem hiding this comment.
[black] reported by reviewdog 🐶
| if __name__ == '__main__': | |
| if __name__ == "__main__": |
7fcea46 to
d580aba
Compare
Implement new MLIR pass to automatically insert trace packet flows and runtime sequence configuration for AIE trace operations. Features: - Creates packet flows from trace ports to shim DMA channels - Supports core and mem trace types with correct port assignment - Minimizes shim tile usage by routing multiple traces to same shim - Allocates packet IDs automatically if not specified - Inserts runtime sequence operations for trace setup (timer control, BD config, DMA setup, broadcast generation) - Configurable options for shim channel, BD ID, packet ID, buffer size Tests: - test_insert_trace_flows_simple.mlir: Single core trace - test_insert_trace_flows_multiple.mlir: Multiple traces (core + mem) from different tiles routing to one shim
d580aba to
a2748ea
Compare
Add aie-insert-trace-flows pass
Implement new MLIR pass to automatically insert trace packet flows and runtime sequence configuration for AIE trace operations.