Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit6539334

Browse files
committed
Update lower pass for combo and edge events
1 parent7d0ea0e commit6539334

File tree

4 files changed

+210
-0
lines changed

4 files changed

+210
-0
lines changed

‎lib/Dialect/AIE/Transforms/AIETraceToConfig.cpp‎

Lines changed: 133 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,139 @@ struct AIETraceToConfigPass : AIETraceToConfigBase<AIETraceToConfigPass> {
6464

6565
bool isMem = (packetType == TracePacketType::Mem);
6666

67+
// Process combo/edge events FIRST (before other trace config)
68+
// This ensures COMBO_EVENT_*/EDGE_DETECTION_EVENT_* are configured
69+
// before they can be referenced in trace.event operations
70+
71+
// 0a. Emit combo event configurations
72+
for (auto &op : trace.getBody().getOps()) {
73+
if (auto comboOp = dyn_cast<TraceComboEventOp>(op)) {
74+
uint32_t slot = comboOp.getSlot();
75+
76+
// Get input events
77+
std::string eventAName = comboOp.getEventA().getName().str();
78+
std::string eventBName = comboOp.getEventB().getName().str();
79+
ComboLogic logic = comboOp.getLogic();
80+
81+
// Lookup event numbers
82+
auto eventANum = regDB->lookupEvent(eventAName, tile, isMem);
83+
auto eventBNum = regDB->lookupEvent(eventBName, tile, isMem);
84+
85+
if (!eventANum) {
86+
comboOp.emitError("unknown event:") << eventAName;
87+
returnsignalPassFailure();
88+
}
89+
if (!eventBNum) {
90+
comboOp.emitError("unknown event:") << eventBName;
91+
returnsignalPassFailure();
92+
}
93+
94+
// Map slot to input event fields
95+
StringRef eventAField, eventBField, controlField;
96+
if (slot ==0) {
97+
eventAField ="eventA";
98+
eventBField ="eventB";
99+
controlField ="combo0";
100+
}elseif (slot ==1) {
101+
eventAField ="eventC";
102+
eventBField ="eventD";
103+
controlField ="combo1";
104+
}elseif (slot ==2) {
105+
// Combo2 is hierarchical - reuses eventA/B fields but represents
106+
// combo0/combo1
107+
eventAField ="eventA";
108+
eventBField ="eventB";
109+
controlField ="combo2";
110+
}
111+
112+
// Emit Combo_event_inputs register fields
113+
configBuilder.create<TraceRegOp>(
114+
comboOp.getLoc(), builder.getStringAttr("Combo_event_inputs"),
115+
builder.getStringAttr(eventAField),
116+
builder.getI32IntegerAttr(*eventANum),
117+
/*mask=*/nullptr,
118+
builder.getStringAttr("combo" +std::to_string(slot) +
119+
" eventA"));
120+
121+
configBuilder.create<TraceRegOp>(
122+
comboOp.getLoc(), builder.getStringAttr("Combo_event_inputs"),
123+
builder.getStringAttr(eventBField),
124+
builder.getI32IntegerAttr(*eventBNum),
125+
/*mask=*/nullptr,
126+
builder.getStringAttr("combo" +std::to_string(slot) +
127+
" eventB"));
128+
129+
// Emit Combo_event_control register field
130+
configBuilder.create<TraceRegOp>(
131+
comboOp.getLoc(), builder.getStringAttr("Combo_event_control"),
132+
builder.getStringAttr(controlField),
133+
builder.getI32IntegerAttr(static_cast<uint32_t>(logic)),
134+
/*mask=*/nullptr,
135+
builder.getStringAttr("combo" +std::to_string(slot) +
136+
" logic"));
137+
}
138+
}
139+
140+
// 0b. Emit edge detection configurations
141+
for (auto &op : trace.getBody().getOps()) {
142+
if (auto edgeOp = dyn_cast<TraceEdgeEventOp>(op)) {
143+
uint32_t slot = edgeOp.getSlot();
144+
std::string eventName = edgeOp.getEvent().getName().str();
145+
EdgeTrigger trigger = edgeOp.getTrigger();
146+
147+
// Lookup event number
148+
auto eventNum = regDB->lookupEvent(eventName, tile, isMem);
149+
if (!eventNum) {
150+
edgeOp.emitError("unknown event:") << eventName;
151+
returnsignalPassFailure();
152+
}
153+
154+
// Map slot to field names
155+
StringRef eventField = (slot ==0) ?"Edge_Detection_Event_0"
156+
:"Edge_Detection_Event_1";
157+
StringRef risingField = (slot ==0)
158+
?"Edge_Detection_0_Trigger_Rising"
159+
:"Edge_Detection_1_Trigger_Rising";
160+
StringRef fallingField = (slot ==0)
161+
?"Edge_Detection_0_Trigger_Falling"
162+
:"Edge_Detection_1_Trigger_Falling";
163+
164+
// Source event
165+
configBuilder.create<TraceRegOp>(
166+
edgeOp.getLoc(),
167+
builder.getStringAttr("Edge_Detection_event_control"),
168+
builder.getStringAttr(eventField),
169+
builder.getI32IntegerAttr(*eventNum),
170+
/*mask=*/nullptr,
171+
builder.getStringAttr("edge" +std::to_string(slot) +
172+
" source"));
173+
174+
// Trigger mode
175+
bool rising = (trigger == EdgeTrigger::RISING ||
176+
trigger == EdgeTrigger::BOTH);
177+
bool falling = (trigger == EdgeTrigger::FALLING ||
178+
trigger == EdgeTrigger::BOTH);
179+
180+
configBuilder.create<TraceRegOp>(
181+
edgeOp.getLoc(),
182+
builder.getStringAttr("Edge_Detection_event_control"),
183+
builder.getStringAttr(risingField),
184+
builder.getI32IntegerAttr(rising ?1 :0),
185+
/*mask=*/nullptr,
186+
builder.getStringAttr("edge" +std::to_string(slot) +
187+
" rising"));
188+
189+
configBuilder.create<TraceRegOp>(
190+
edgeOp.getLoc(),
191+
builder.getStringAttr("Edge_Detection_event_control"),
192+
builder.getStringAttr(fallingField),
193+
builder.getI32IntegerAttr(falling ?1 :0),
194+
/*mask=*/nullptr,
195+
builder.getStringAttr("edge" +std::to_string(slot) +
196+
" falling"));
197+
}
198+
}
199+
67200
// 1. Emit Trace_Control0 fields
68201
// Check for start/stop events
69202
for (auto &op : trace.getBody().getOps()) {
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
// RUN: aie-opt %s -aie-trace-to-config | FileCheck %s
2+
3+
aie.device(npu1_1col) {
4+
%tile02 =aie.tile(0,2)
5+
6+
// CHECK-LABEL: @test_combo_and_edge
7+
aie.trace@test_combo_and_edge(%tile02) {
8+
aie.trace.mode"Event-Time"
9+
aie.trace.packetid=1type=core
10+
11+
// Combo event (using events we know exist from previous tests)
12+
aie.trace.combo_event<0> <"INSTR_EVENT_0">AND_NOT <"INSTR_VECTOR">
13+
14+
// Edge detection
15+
aie.trace.edge_event<0>event=<"LOCK_STALL">trigger=BOTH
16+
17+
// Trace the derived events
18+
aie.trace.event<"COMBO_EVENT_0">
19+
aie.trace.event<"EDGE_DETECTION_EVENT_0">
20+
aie.trace.event<"INSTR_EVENT_0">
21+
22+
aie.trace.startbroadcast=15
23+
aie.trace.stopbroadcast=14
24+
}
25+
26+
// Check combo event configuration
27+
// CHECK: aie.trace.reg register = "Combo_event_inputs" field = "eventA"
28+
// CHECK: aie.trace.reg register = "Combo_event_inputs" field = "eventB"
29+
// CHECK: aie.trace.reg register = "Combo_event_control" field = "combo0" value = 1
30+
// Check edge detection configuration
31+
// CHECK: aie.trace.reg register = "Edge_Detection_event_control" field = "Edge_Detection_Event_0"
32+
// CHECK: aie.trace.reg register = "Edge_Detection_event_control" field = "Edge_Detection_0_Trigger_Rising" value = 1
33+
// CHECK: aie.trace.reg register = "Edge_Detection_event_control" field = "Edge_Detection_0_Trigger_Falling" value = 1
34+
// Check trace control
35+
// CHECK: aie.trace.reg register = "Trace_Control0" field = "Mode" value = 0
36+
// CHECK: aie.trace.reg register = "Trace_Control1" field = "ID" value = 1
37+
// CHECK: aie.trace.reg register = "Trace_Control0" field = "Trace_Start_Event" value = 15
38+
// CHECK: aie.trace.reg register = "Trace_Control0" field = "Trace_Stop_Event" value = 14
39+
// Check event slots
40+
// CHECK: aie.trace.reg register = "Trace_Event0" field = "Trace_Event0"
41+
// CHECK: aie.trace.reg register = "Trace_Event0" field = "Trace_Event1"
42+
// CHECK: aie.trace.reg register = "Trace_Event0" field = "Trace_Event2"
43+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// RUN: aie-opt %s -aie-trace-to-config | FileCheck %s
2+
3+
aie.device(npu1_1col) {
4+
%tile02 =aie.tile(0,2)
5+
6+
// CHECK-LABEL: @test_combo_lowering
7+
aie.trace@test_combo_lowering(%tile02) {
8+
aie.trace.combo_event<0> <"INSTR_EVENT_0">AND <"INSTR_VECTOR">
9+
aie.trace.event<"COMBO_EVENT_0">
10+
}
11+
12+
// CHECK: aie.trace.config @test_combo_lowering_config(%tile02)
13+
// CHECK: aie.trace.reg register = "Combo_event_inputs" field = "eventA"
14+
// CHECK: aie.trace.reg register = "Combo_event_inputs" field = "eventB"
15+
// CHECK: aie.trace.reg register = "Combo_event_control" field = "combo0" value = 0
16+
// CHECK: aie.trace.reg register = "Trace_Event0" field = "Trace_Event0"
17+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// RUN: aie-opt %s -aie-trace-to-config | FileCheck %s
2+
3+
aie.device(npu1_1col) {
4+
%tile02 =aie.tile(0,2)
5+
6+
// CHECK-LABEL: @test_edge_lowering
7+
aie.trace@test_edge_lowering(%tile02) {
8+
aie.trace.edge_event<0>event=<"LOCK_STALL">trigger=RISING
9+
aie.trace.event<"EDGE_DETECTION_EVENT_0">
10+
}
11+
12+
// CHECK: aie.trace.config @test_edge_lowering_config(%tile02)
13+
// CHECK: aie.trace.reg register = "Edge_Detection_event_control" field = "Edge_Detection_Event_0"
14+
// CHECK: aie.trace.reg register = "Edge_Detection_event_control" field = "Edge_Detection_0_Trigger_Rising" value = 1
15+
// CHECK: aie.trace.reg register = "Edge_Detection_event_control" field = "Edge_Detection_0_Trigger_Falling" value = 0
16+
// CHECK: aie.trace.reg register = "Trace_Event0" field = "Trace_Event0"
17+
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp