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

[proposal][wip] Add event trace configuration to mlir-aie#2705

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Draft
fifield wants to merge41 commits intoXilinx:main
base:main
Choose a base branch
Loading
fromfifield:events_proposal
Draft
Show file tree
Hide file tree
Changes from1 commit
Commits
Show all changes
41 commits
Select commitHold shift + click to select a range
80a48e3
Add a callable library function to parse_trace.py
fifieldNov 13, 2025
733652a
Apply suggestions from code review
fifieldNov 13, 2025
edee5a6
Generate trace_events package with CMake instead of checking into git
fifieldNov 10, 2025
7a7e694
Apply suggestions from code review
fifieldNov 11, 2025
a1cb4cf
Make duplicate event number detection fail the build (#2697)
CopilotNov 11, 2025
e1bfbde
Generate and include tablegen event enums in AIE dialect
fifieldNov 14, 2025
543bedb
Commit 1: Add TableGen definitions for trace operations
fifieldNov 8, 2025
c5e52d5
Commit 2: Add verification tests for trace operations
fifieldNov 8, 2025
7034d74
Commit 3: Implement standalone JSON register database loader
fifieldNov 8, 2025
6c506c6
Commit 4: Implement AIETraceToConfigPass
fifieldNov 8, 2025
c7c734c
Commit 5: Implement AIEInlineTraceConfigPass
fifieldNov 8, 2025
c4c8b5e
Commit 6: Add AIEConfigToNPUPass stub implementation
fifieldNov 8, 2025
a25c6fe
Commit 7: Add end-to-end trace pipeline test
fifieldNov 8, 2025
b4f5660
Complete Pass 3 implementation with RegisterDatabase integration
fifieldNov 8, 2025
b611636
Refactor: Fix design issue with col/row preservation
fifieldNov 8, 2025
248af1c
Move trace NPU passes to AIEX dialect (fixes AIEX loading issue)
fifieldNov 8, 2025
9a4ff28
Move and update trace tests to AIEX dialect
fifieldNov 8, 2025
184c25d
Update AIEX tests to use runtime_sequence
fifieldNov 8, 2025
10449f3
checkpoint
fifieldNov 10, 2025
4a4e41f
start a test
fifieldNov 11, 2025
300908f
format
fifieldNov 11, 2025
6b591cc
checkpoint
fifieldNov 11, 2025
97007eb
updates, fixes, formatting
fifieldNov 12, 2025
caaf7f4
clang-format
fifieldNov 12, 2025
b58edf2
remove aie-config-to-npu placeholder
fifieldNov 12, 2025
6556d01
fixes for core mem events
fifieldNov 12, 2025
1635816
fix test location
fifieldNov 12, 2025
aa79764
Add stream switch port event monitoring to AIE trace infrastructure
fifieldNov 13, 2025
41ba2c7
update example to use aie.trace.port
fifieldNov 13, 2025
bb18de2
Replace BoolAttr with DMAChannelDir for trace port direction
fifieldNov 13, 2025
ebfab0d
Add test.py for trace example
fifieldNov 13, 2025
6095f3a
implement trace and combo event op tablegen
fifieldNov 14, 2025
7907894
Update lower pass for combo and edge events
fifieldNov 14, 2025
01c9a32
Update dialect to use generated enums for events
fifieldNov 15, 2025
a2433db
fix aie1 suffix
fifieldNov 15, 2025
e6a6457
checkpoint
fifieldNov 15, 2025
2532c8a
fixes, format, refactor, cleanup
fifieldNov 15, 2025
2e0fc12
checkpoint
fifieldNov 15, 2025
ef6c53e
wip
fifieldNov 16, 2025
cc56b4d
cleanup, fixes, refactor
fifieldNov 17, 2025
fc99d49
implement AIETargetModel getStreamSwitchPortIndex
fifieldNov 17, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
PrevPrevious commit
NextNext commit
checkpoint
  • Loading branch information
@fifield
fifield committedNov 15, 2025
commit2e0fc12065b97ce627a542563942a778d43148db
269 changes: 136 additions & 133 deletionslib/Dialect/AIE/IR/AIETraceOps.cpp
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -26,25 +26,30 @@ using namespace xilinx::AIE;
//===----------------------------------------------------------------------===//

std::string TraceEventAttr::getEventName() const {
// If it's a string attribute, return the string directly
if (auto strAttr = llvm::dyn_cast<StringAttr>(getValue())) {
// If the string is fully qualified (contains '::'), extract just the name
StringRef strValue = strAttr.getValue();
size_t pos = strValue.find("::");
if (pos != StringRef::npos) {
return strValue.substr(pos + 2).str();
}
return strAttr.getValue().str();
}

// Check for typed enum attributes and use stringify functions
Attribute value = getValue();
if (auto coreEvt = llvm::dyn_cast<CoreEventAIE2Attr>(value)) {
return stringifyCoreEventAIE2(coreEvt.getValue()).str();
}
if (auto memEvt = llvm::dyn_cast<MemEventAIE2Attr>(value)) {
return stringifyMemEventAIE2(memEvt.getValue()).str();
}
if (auto shimEvt = llvm::dyn_cast<ShimTileEventAIE2Attr>(value)) {
return stringifyShimTileEventAIE2(shimEvt.getValue()).str();
}
if (auto memTileEvt = llvm::dyn_cast<MemTileEventAIE2Attr>(value)) {
return stringifyMemTileEventAIE2(memTileEvt.getValue()).str();
}
////Check for typed enum attributes and use stringify functions
//Attribute value = getValue();
//if (auto coreEvt = llvm::dyn_cast<CoreEventAIE2Attr>(value)) {
// return stringifyCoreEventAIE2(coreEvt.getValue()).str();
//}
//if (auto memEvt = llvm::dyn_cast<MemEventAIE2Attr>(value)) {
// return stringifyMemEventAIE2(memEvt.getValue()).str();
//}
//if (auto shimEvt = llvm::dyn_cast<ShimTileEventAIE2Attr>(value)) {
// return stringifyShimTileEventAIE2(shimEvt.getValue()).str();
//}
//if (auto memTileEvt = llvm::dyn_cast<MemTileEventAIE2Attr>(value)) {
// return stringifyMemTileEventAIE2(memTileEvt.getValue()).str();
//}

// Fallback: shouldn't reach here for well-formed IR
return "";
Expand DownExpand Up@@ -201,93 +206,82 @@ ParseResult xilinx::AIE::parseTraceEvent(AsmParser &parser, Attribute &result) {
return parser.emitError(parser.getCurrentLocation(),
"expected enum case name");
}
// Validate the enum and convert to string to avoid ambiguity between
// AIE2 and AIE2P enums which have identical integer values

// AIE2 event enums
if (enumTypeName == "CoreEventAIE2") {
auto enumVal = symbolizeCoreEventAIE2(caseName);
if (!enumVal)
return parser.emitError(loc, "unknown CoreEventAIE2 value: ") << caseName;
result = CoreEventAIE2Attr::get(ctx, *enumVal);
return success();
}
if (enumTypeName == "MemEventAIE2") {
auto enumVal = symbolizeMemEventAIE2(caseName);
if (!enumVal)
return parser.emitError(loc, "unknown MemEventAIE2 value: ") << caseName;
result = MemEventAIE2Attr::get(ctx, *enumVal);
return success();
}
if (enumTypeName == "MemTileEventAIE2") {
auto enumVal = symbolizeMemTileEventAIE2(caseName);
if (!enumVal)
return parser.emitError(loc, "unknown MemTileEventAIE2 value: ")
<< caseName;
result = MemTileEventAIE2Attr::get(ctx, *enumVal);
return success();
}
if (enumTypeName == "ShimTileEventAIE2") {
auto enumVal = symbolizeShimTileEventAIE2(caseName);
if (!enumVal)
return parser.emitError(loc, "unknown ShimTileEventAIE2 value: ")
<< caseName;
result = ShimTileEventAIE2Attr::get(ctx, *enumVal);
return success();
}
// Define a helper struct for enum validation
struct EnumValidator {
StringRef name;
std::function<std::optional<uint32_t>(StringRef)> symbolizer;
};

// AIE event enums
if (enumTypeName == "CoreEventAIE") {
auto enumVal = symbolizeCoreEventAIE(caseName);
if (!enumVal)
return parser.emitError(loc, "unknown CoreEventAIE value: ") << caseName;
result = CoreEventAIEAttr::get(ctx, *enumVal);
return success();
}
if (enumTypeName == "MemEventAIE") {
auto enumVal = symbolizeMemEventAIE(caseName);
if (!enumVal)
return parser.emitError(loc, "unknown MemEventAIE value: ") << caseName;
result = MemEventAIEAttr::get(ctx, *enumVal);
return success();
}
if (enumTypeName == "ShimTileEventAIE") {
auto enumVal = symbolizeShimTileEventAIE(caseName);
if (!enumVal)
return parser.emitError(loc, "unknown ShimTileEventAIE value: ")
<< caseName;
result = ShimTileEventAIEAttr::get(ctx, *enumVal);
return success();
}
// Table of supported enum types and their symbolizer functions
static const EnumValidator validators[] = {
// AIE2 event enums
{"CoreEventAIE2",
[](StringRef s) { return symbolizeCoreEventAIE2(s).has_value(); }},
{"MemEventAIE2",
[](StringRef s) {
auto result = symbolizeMemEventAIE2(s);
return result.has_value();
}},
{"MemTileEventAIE2",
[](StringRef s) {
auto result = symbolizeMemTileEventAIE2(s);
return result.has_value();
}},
{"ShimTileEventAIE2",
[](StringRef s) {
auto result = symbolizeShimTileEventAIE2(s);
return result.has_value();
}},
// AIE event enums
{"CoreEventAIE",
[](StringRef s) {
auto result = symbolizeCoreEventAIE(s);
return result.has_value();
}},
{"MemEventAIE",
[](StringRef s) {
auto result = symbolizeMemEventAIE(s);
return result.has_value();
}},
{"ShimTileEventAIE",
[](StringRef s) {
auto result = symbolizeShimTileEventAIE(s);
return result.has_value();
}},
// AIE2P event enums
{"CoreEventAIE2P",
[](StringRef s) {
auto result = symbolizeCoreEventAIE2P(s);
return result.has_value();
}},
{"MemEventAIE2P",
[](StringRef s) {
auto result = symbolizeMemEventAIE2P(s);
return result.has_value();
}},
{"MemTileEventAIE2P",
[](StringRef s) {
auto result = symbolizeMemTileEventAIE2P(s);
return result.has_value();
}},
{"ShimTileEventAIE2P",
[](StringRef s) {
auto result = symbolizeShimTileEventAIE2P(s);
return result.has_value();
}},
};

// AIE2P event enums
if (enumTypeName == "CoreEventAIE2P") {
auto enumVal = symbolizeCoreEventAIE2P(caseName);
if (!enumVal)
return parser.emitError(loc, "unknown CoreEventAIE2P value: ")
<< caseName;
result = CoreEventAIE2PAttr::get(ctx, *enumVal);
return success();
}
if (enumTypeName == "MemEventAIE2P") {
auto enumVal = symbolizeMemEventAIE2P(caseName);
if (!enumVal)
return parser.emitError(loc, "unknown MemEventAIE2P value: ") << caseName;
result = MemEventAIE2PAttr::get(ctx, *enumVal);
return success();
}
if (enumTypeName == "MemTileEventAIE2P") {
auto enumVal = symbolizeMemTileEventAIE2P(caseName);
if (!enumVal)
return parser.emitError(loc, "unknown MemTileEventAIE2P value: ")
<< caseName;
result = MemTileEventAIE2PAttr::get(ctx, *enumVal);
return success();
}
if (enumTypeName == "ShimTileEventAIE2P") {
auto enumVal = symbolizeShimTileEventAIE2P(caseName);
if (!enumVal)
return parser.emitError(loc, "unknown ShimTileEventAIE2P value: ")
<< caseName;
result = ShimTileEventAIE2PAttr::get(ctx, *enumVal);
// Look up and validate the enum type
for (const auto &validator : validators) {
if (enumTypeName != validator.name)
continue;
if (!validator.symbolizer(caseName))
return parser.emitError(loc, "unknown ")
<< enumTypeName << " value: " << caseName;
result = StringAttr::get(ctx, enumTypeName + "::" + caseName);
return success();
}

Expand All@@ -296,42 +290,51 @@ ParseResult xilinx::AIE::parseTraceEvent(AsmParser &parser, Attribute &result) {

void xilinx::AIE::printTraceEventEnum(AsmPrinter &printer, Attribute attr) {
if (auto strAttr = llvm::dyn_cast<StringAttr>(attr)) {
// If string contains "::" (enum format), print without quotes
if (strAttr.getValue().contains("::")) {
printer << strAttr.getValue();
return;
}
printer << "\"" << strAttr.getValue() << "\"";
}
// AIE2 event enums
else if (auto coreEvt = llvm::dyn_cast<CoreEventAIE2Attr>(attr)) {
printer << "CoreEventAIE2::" << stringifyCoreEventAIE2(coreEvt.getValue());
} else if (auto memEvt = llvm::dyn_cast<MemEventAIE2Attr>(attr)) {
printer << "MemEventAIE2::" << stringifyMemEventAIE2(memEvt.getValue());
} else if (auto memTileEvt = llvm::dyn_cast<MemTileEventAIE2Attr>(attr)) {
printer << "MemTileEventAIE2::"
<< stringifyMemTileEventAIE2(memTileEvt.getValue());
} else if (auto shimTileEvt = llvm::dyn_cast<ShimTileEventAIE2Attr>(attr)) {
printer << "ShimTileEventAIE2::"
<< stringifyShimTileEventAIE2(shimTileEvt.getValue());
}
// AIE event enums
else if (auto coreEvt = llvm::dyn_cast<CoreEventAIEAttr>(attr)) {
printer << "CoreEventAIE::" << stringifyCoreEventAIE(coreEvt.getValue());
} else if (auto memEvt = llvm::dyn_cast<MemEventAIEAttr>(attr)) {
printer << "MemEventAIE::" << stringifyMemEventAIE(memEvt.getValue());
} else if (auto shimTileEvt = llvm::dyn_cast<ShimTileEventAIEAttr>(attr)) {
printer << "ShimTileEventAIE::"
<< stringifyShimTileEventAIE(shimTileEvt.getValue());
}
// AIE2P event enums
else if (auto coreEvt = llvm::dyn_cast<CoreEventAIE2PAttr>(attr)) {
printer << "CoreEventAIE2P::"
<< stringifyCoreEventAIE2P(coreEvt.getValue());
} else if (auto memEvt = llvm::dyn_cast<MemEventAIE2PAttr>(attr)) {
printer << "MemEventAIE2P::" << stringifyMemEventAIE2P(memEvt.getValue());
} else if (auto memTileEvt = llvm::dyn_cast<MemTileEventAIE2PAttr>(attr)) {
printer << "MemTileEventAIE2P::"
<< stringifyMemTileEventAIE2P(memTileEvt.getValue());
} else if (auto shimTileEvt = llvm::dyn_cast<ShimTileEventAIE2PAttr>(attr)) {
printer << "ShimTileEventAIE2P::"
<< stringifyShimTileEventAIE2P(shimTileEvt.getValue());
}
// // AIE2 event enums
// else if (auto coreEvt = llvm::dyn_cast<CoreEventAIE2Attr>(attr)) {
// printer << "CoreEventAIE2::" <<
// stringifyCoreEventAIE2(coreEvt.getValue());
// } else if (auto memEvt = llvm::dyn_cast<MemEventAIE2Attr>(attr)) {
// printer << "MemEventAIE2::" << stringifyMemEventAIE2(memEvt.getValue());
// } else if (auto memTileEvt = llvm::dyn_cast<MemTileEventAIE2Attr>(attr)) {
// printer << "MemTileEventAIE2::"
// << stringifyMemTileEventAIE2(memTileEvt.getValue());
// } else if (auto shimTileEvt = llvm::dyn_cast<ShimTileEventAIE2Attr>(attr))
// {
// printer << "ShimTileEventAIE2::"
// << stringifyShimTileEventAIE2(shimTileEvt.getValue());
// }
// // AIE event enums
// else if (auto coreEvt = llvm::dyn_cast<CoreEventAIEAttr>(attr)) {
// printer << "CoreEventAIE::" << stringifyCoreEventAIE(coreEvt.getValue());
// } else if (auto memEvt = llvm::dyn_cast<MemEventAIEAttr>(attr)) {
// printer << "MemEventAIE::" << stringifyMemEventAIE(memEvt.getValue());
// } else if (auto shimTileEvt = llvm::dyn_cast<ShimTileEventAIEAttr>(attr)) {
// printer << "ShimTileEventAIE::"
// << stringifyShimTileEventAIE(shimTileEvt.getValue());
// }
// // AIE2P event enums
// else if (auto coreEvt = llvm::dyn_cast<CoreEventAIE2PAttr>(attr)) {
// printer << "CoreEventAIE2P::"
// << stringifyCoreEventAIE2P(coreEvt.getValue());
// } else if (auto memEvt = llvm::dyn_cast<MemEventAIE2PAttr>(attr)) {
// printer << "MemEventAIE2P::" <<
// stringifyMemEventAIE2P(memEvt.getValue());
// } else if (auto memTileEvt = llvm::dyn_cast<MemTileEventAIE2PAttr>(attr)) {
// printer << "MemTileEventAIE2P::"
// << stringifyMemTileEventAIE2P(memTileEvt.getValue());
// } else if (auto shimTileEvt = llvm::dyn_cast<ShimTileEventAIE2PAttr>(attr))
// {
// printer << "ShimTileEventAIE2P::"
// << stringifyShimTileEventAIE2P(shimTileEvt.getValue());
// }
}

//===----------------------------------------------------------------------===//
Expand Down
16 changes: 13 additions & 3 deletionstest/dialect/AIE/trace/test_trace_parse.mlir
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,13 @@
//===- test_trace_parse.mlir -----------------------------------*- MLIR -*-===//
//
// This file is licensed under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
// (c) Copyright 2025 Advanced Micro Devices, Inc.
//
//===----------------------------------------------------------------------===//

// RUN: aie-opt %s | FileCheck %s

// CHECK-LABEL: module {
Expand All@@ -15,13 +25,13 @@ module {
// CHECK: aie.trace.packet id = 1 type = core
aie.trace.packet id=1 type="core"

// CHECK: aie.trace.event <INSTR_EVENT_0>
// CHECK: aie.trace.event<"INSTR_EVENT_0">
aie.trace.event<"INSTR_EVENT_0">

// CHECK: aie.trace.event <INSTR_VECTOR> label ="vector_op"
// CHECK: aie.trace.event<"INSTR_VECTOR"> label = vector_op
aie.trace.event<"INSTR_VECTOR"> label="vector_op"

// CHECK: aie.trace.event <LOCK_STALL>
// CHECK: aie.trace.event<"LOCK_STALL">
aie.trace.event<"LOCK_STALL">

// CHECK: aie.trace.start broadcast = 15
Expand Down
15 changes: 12 additions & 3 deletionstest/dialect/AIE/trace/test_trace_to_config.mlir
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,20 @@
//===- test_trace_to_config.mlir -------------------------------*- MLIR -*-===//
//
// This file is licensed under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
// (c) Copyright 2025 Advanced Micro Devices, Inc.
//
//===----------------------------------------------------------------------===//

// RUN: aie-opt %s -aie-trace-to-config | FileCheck %s

// CHECK-LABEL: module {
module {
aie.device(npu1_1col) {
%tile02 = aie.tile(0, 2)

// CHECK: aie.trace.config @test_trace_config(%tile_0_2) {

aie.trace @test_trace(%tile02) {
aie.trace.mode "Event-Time"
aie.trace.packet id=1 type="core"
Expand All@@ -15,7 +24,7 @@ module {
aie.trace.start broadcast=15
aie.trace.stop broadcast=14
}

// CHECK-DAG: aie.trace.reg register = "Trace_Control0" field = "Mode" value = 0 : i32
// CHECK-DAG: aie.trace.reg register = "Trace_Control1" field = "ID" value = 1 : i32
// CHECK-DAG: aie.trace.reg register = "Trace_Control1" field = "Packet_Type" value = 0 : i32
Expand Down
10 changes: 10 additions & 0 deletionstest/dialect/AIE/trace/test_trace_verify.mlir
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,13 @@
//===- test_trace_verify.mlir ----------------------------------*- MLIR -*-===//
//
// This file is licensed under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
// (c) Copyright 2025 Advanced Micro Devices, Inc.
//
//===----------------------------------------------------------------------===//

// RUN: aie-opt %s -split-input-file -verify-diagnostics

// Test: Too many events (max 8)
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp