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
Move trace NPU passes to AIEX dialect (fixes AIEX loading issue)
PROBLEM: AIEX dialect couldn't be loaded during AIE pass executionSOLUTION: Move NPU-generating passes to AIEX dialect where they belong- Moved AIEInlineTraceConfig.cpp to lib/Dialect/AIEX/Transforms/- Moved AIEConfigToNPU.cpp to lib/Dialect/AIEX/Transforms/- Updated pass definitions in AIEXPasses.td- Removed from AIEPasses.td- Updated CMakeLists for both dialects- Updated pass registration headers- Fixed namespaces (AIEX, not AIE)RESULT: npu.write32 generation now works!- Pass renamed: aie-inline-trace-config → aiex-inline-trace-config- Pass renamed: aie-config-to-npu → aiex-config-to-npu- Col/row preserved in npu.write32 operations- RegisterDatabase integration functional- Bitfield merging workingExample output:aiex.npu.write32 {address=0xB40D0, column=0, row=2, value=0x1E2E0001}This is the correct architectural placement: AIEX depends on AIE.
  • Loading branch information
@fifield
fifield committedNov 14, 2025
commit248af1c01c3a0c713503985e901242379e0f4723
2 changes: 0 additions & 2 deletionsinclude/aie/Dialect/AIE/Transforms/AIEPasses.h
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -57,8 +57,6 @@ std::unique_ptr<mlir::OperationPass<DeviceOp>>
createAIEGenerateColumnControlOverlayPass();
std::unique_ptr<mlir::OperationPass<DeviceOp>> createAIEAssignTileCtrlIDsPass();
std::unique_ptr<mlir::OperationPass<DeviceOp>> createAIETraceToConfigPass();
std::unique_ptr<mlir::OperationPass<DeviceOp>> createAIEInlineTraceConfigPass();
std::unique_ptr<mlir::OperationPass<DeviceOp>> createAIEConfigToNPUPass();

/// Generate the code for registering passes.
#define GEN_PASS_REGISTRATION
Expand Down
33 changes: 3 additions & 30 deletionsinclude/aie/Dialect/AIE/Transforms/AIEPasses.td
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -382,39 +382,12 @@ def AIETraceToConfig : Pass<"aie-trace-to-config", "DeviceOp"> {

This pass transforms declarative trace configurations into register-level
specifications that can be further lowered to NPU register writes.
}];

let constructor = "xilinx::AIE::createAIETraceToConfigPass()";
let dependentDialects = [
"xilinx::AIE::AIEDialect",
];
}

def AIEInlineTraceConfig : Pass<"aie-inline-trace-config", "DeviceOp"> {
let summary = "Inline trace configuration symbols into runtime sequence";
let description = [{
Replaces aie.trace.start_config operations with the actual aie.trace.reg
operations from the referenced trace configuration symbol.

This inlining happens within the runtime sequence context.
Note: This pass only does semantic lowering. NPU write generation
happens in aiex-inline-trace-config (AIEX dialect).
}];

let constructor = "xilinx::AIE::createAIEInlineTraceConfigPass()";
let dependentDialects = [
"xilinx::AIE::AIEDialect",
];
}

def AIEConfigToNPU : Pass<"aie-config-to-npu", "DeviceOp"> {
let summary = "Lower trace register ops to NPU write operations";
let description = [{
Converts aie.trace.reg operations to aiex.npu.write32 operations.

This pass resolves logical register/field names to absolute addresses
and encoded bitfield values, then generates the final NPU register writes.
}];

let constructor = "xilinx::AIE::createAIEConfigToNPUPass()";
let constructor = "xilinx::AIE::createAIETraceToConfigPass()";
let dependentDialects = [
"xilinx::AIE::AIEDialect",
];
Expand Down
4 changes: 4 additions & 0 deletionsinclude/aie/Dialect/AIEX/Transforms/AIEXPasses.h
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -50,6 +50,10 @@ std::unique_ptr<mlir::OperationPass<AIE::DeviceOp>>
createAIETxnToControlPacketPass();
std::unique_ptr<mlir::OperationPass<AIE::DeviceOp>>
createAIELegalizeControlPacketPass();
std::unique_ptr<mlir::OperationPass<AIE::DeviceOp>>
createAIEXInlineTraceConfigPass();
std::unique_ptr<mlir::OperationPass<AIE::DeviceOp>>
createAIEXConfigToNPUPass();

/// Generate the code for registering passes.
#define GEN_PASS_REGISTRATION
Expand Down
37 changes: 37 additions & 0 deletionsinclude/aie/Dialect/AIEX/Transforms/AIEXPasses.td
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -254,4 +254,41 @@ def AIELegalizeControlPacket : Pass<"aie-legalize-ctrl-packet", "AIE::DeviceOp">
"xilinx::AIEX::AIEXDialect",
];
}

def AIEXInlineTraceConfig : Pass<"aiex-inline-trace-config", "AIE::DeviceOp"> {
let summary = "Inline trace configuration and generate NPU writes";
let description = [{
Replaces aie.trace.start_config operations by:
1. Looking up the referenced trace.config symbol
2. Resolving register/field names using RegisterDatabase
3. Encoding bitfield values
4. Merging multiple field writes to same register
5. Generating aiex.npu.write32 operations with col/row preserved

This pass integrates RegisterDatabase and generates NPU writes directly,
preserving col/row information from the tile operation.
}];

let constructor = "xilinx::AIEX::createAIEXInlineTraceConfigPass()";
let dependentDialects = [
"xilinx::AIE::AIEDialect",
"xilinx::AIEX::AIEXDialect",
];
}

def AIEXConfigToNPU : Pass<"aiex-config-to-npu", "AIE::DeviceOp"> {
let summary = "Lower trace register ops to NPU write operations (stub)";
let description = [{
This pass is currently a no-op stub.
NPU write generation for trace configuration happens in AIEXInlineTraceConfig.
Kept for future extensibility.
}];

let constructor = "xilinx::AIEX::createAIEXConfigToNPUPass()";
let dependentDialects = [
"xilinx::AIE::AIEDialect",
"xilinx::AIEX::AIEXDialect",
];
}

#endif
2 changes: 0 additions & 2 deletionslib/Dialect/AIE/Transforms/CMakeLists.txt
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -27,8 +27,6 @@ add_mlir_dialect_library(
AIELowerCascadeFlows.cpp
AIEGenerateColumnControlOverlay.cpp
AIETraceToConfig.cpp
AIEInlineTraceConfig.cpp
AIEConfigToNPU.cpp
ADDITIONAL_HEADER_DIRS
${AIE_BINARY_DIR}/include

Expand Down
35 changes: 35 additions & 0 deletionslib/Dialect/AIEX/Transforms/AIEConfigToNPU.cpp
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
//===- AIEConfigToNPU.cpp ---------------------------------------*- C++ -*-===//
//
// 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
//
// Copyright (C) 2025, Advanced Micro Devices, Inc.
//
//===----------------------------------------------------------------------===//
// Pass to lower trace.reg to aiex.npu.write32
// NOTE: This pass is now a stub. NPU generation moved to AIEInlineTraceConfig.
//===----------------------------------------------------------------------===//

#include "aie/Dialect/AIE/IR/AIEDialect.h"
#include "aie/Dialect/AIEX/Transforms/AIEXPasses.h"

#include "mlir/Pass/Pass.h"

using namespace mlir;
using namespace xilinx;
using namespace xilinx::AIEX;

struct AIEConfigToNPUPass : AIEXConfigToNPUBase<AIEConfigToNPUPass> {
void runOnOperation() override {
// This pass is now a no-op.
// NPU write generation happens in AIEInlineTraceConfig (Pass 2).
// Keeping this pass for future extensibility.
return;
}
};

std::unique_ptr<OperationPass<AIE::DeviceOp>>
xilinx::AIEX::createAIEXConfigToNPUPass() {
return std::make_unique<AIEConfigToNPUPass>();
}
147 changes: 147 additions & 0 deletionslib/Dialect/AIEX/Transforms/AIEInlineTraceConfig.cpp
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,147 @@
//===- AIEInlineTraceConfig.cpp ---------------------------------*- C++ -*-===//
//
// 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
//
// Copyright (C) 2025, Advanced Micro Devices, Inc.
//
//===----------------------------------------------------------------------===//
// Pass to inline trace.start_config and generate npu.write32
//===----------------------------------------------------------------------===//

#include "aie/Dialect/AIE/IR/AIEDialect.h"
#include "aie/Dialect/AIE/IR/AIERegisterDatabase.h"
#include "aie/Dialect/AIEX/IR/AIEXDialect.h"
#include "aie/Dialect/AIEX/Transforms/AIEXPasses.h"

#include "mlir/IR/Attributes.h"
#include "mlir/Pass/Pass.h"

using namespace mlir;
using namespace xilinx;
using namespace xilinx::AIE;
using namespace xilinx::AIEX;

struct AIEInlineTraceConfigPass : AIEXInlineTraceConfigBase<AIEInlineTraceConfigPass> {
void runOnOperation() override {
AIE::DeviceOp device = getOperation();

// Load RegisterDatabase for AIE2
auto regDb = RegisterDatabase::loadAIE2();
if (!regDb) {
device.emitError("Failed to load register database");
return signalPassFailure();
}

// // Load AIEX dialect (it's registered in aie-opt)
// device->getContext()->getOrLoadDialect<AIEX::AIEXDialect>();

// Collect all trace.start_config operations
SmallVector<TraceStartConfigOp> startConfigs;
device.walk([&](TraceStartConfigOp startConfig) {
startConfigs.push_back(startConfig);
});

for (auto startConfig : startConfigs) {
OpBuilder builder(startConfig);

// Lookup the trace config symbol
auto configSymbolName = startConfig.getTraceConfig();
auto configOp = dyn_cast_or_null<TraceConfigOp>(
SymbolTable::lookupNearestSymbolFrom(device,
builder.getStringAttr(configSymbolName))
);

if (!configOp) {
startConfig.emitError("trace config symbol '")
<< configSymbolName << "' not found";
return signalPassFailure();
}

// Get tile and extract col/row
auto tile = configOp.getTile();
auto tileOp = dyn_cast<TileOp>(tile.getDefiningOp());
if (!tileOp) {
startConfig.emitError("tile operand must be a TileOp");
return signalPassFailure();
}

int col = tileOp.getCol();
int row = tileOp.getRow();

// Determine module based on tile row
std::string module = "CORE_MODULE";
if (row == 0) module = "PL_MODULE";
else if (row == 1) module = "MEM_TILE_MODULE";

// Group register writes by offset for merging
std::map<uint32_t, uint32_t> mergedValues;
std::map<uint32_t, TraceRegOp> firstRegOp;

// Process all trace.reg operations in the config
for (auto &op : configOp.getBody().getOps()) {
auto regOp = dyn_cast<TraceRegOp>(op);
if (!regOp) continue;

// Look up register
auto regName = regOp.getRegName().str();
auto* regInfo = regDb->lookupRegister(regName, module);
if (!regInfo) {
regOp.emitWarning("Register '") << regName << "' not found in module " << module;
continue;
}

// Look up field
auto fieldName = regOp.getField().str();
auto* fieldInfo = regInfo->getField(fieldName);
if (!fieldInfo) {
regOp.emitWarning("Field '") << fieldName << "' not found in register " << regName;
continue;
}

// Encode value
uint32_t encodedValue = 0;
auto value = regOp.getValue();

if (auto intAttr = llvm::dyn_cast<IntegerAttr>(value)) {
// Integer value
encodedValue = regDb->encodeFieldValue(*fieldInfo, intAttr.getInt());
} else if (auto strAttr = llvm::dyn_cast<StringAttr>(value)) {
// String value - resolve as event
std::string strVal = strAttr.getValue().str();
auto eventCode = regDb->lookupEvent(strVal, "core");
if (eventCode) {
encodedValue = regDb->encodeFieldValue(*fieldInfo, *eventCode);
}
}

// Merge into accumulated value
mergedValues[regInfo->offset] |= encodedValue;
if (firstRegOp.find(regInfo->offset) == firstRegOp.end()) {
firstRegOp[regInfo->offset] = regOp;
}
}

// Generate aiex.npu.write32 operations with col/row
for (auto& [offset, value] : mergedValues) {
builder.create<AIEX::NpuWrite32Op>(
firstRegOp[offset].getLoc(),
builder.getUI32IntegerAttr(offset),
builder.getUI32IntegerAttr(value),
nullptr, // buffer
builder.getI32IntegerAttr(col), // column
builder.getI32IntegerAttr(row) // row
);
}

// Remove the start_config invocation
startConfig.erase();
}
}
};

std::unique_ptr<OperationPass<AIE::DeviceOp>>
xilinx::AIEX::createAIEXInlineTraceConfigPass() {
return std::make_unique<AIEInlineTraceConfigPass>();
}
2 changes: 2 additions & 0 deletionslib/Dialect/AIEX/Transforms/CMakeLists.txt
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -22,6 +22,8 @@ add_mlir_dialect_library(AIEXTransforms
AIELowerSetLock.cpp
AIETransformBfpTypes.cpp
AIETxnToControlPacket.cpp
AIEInlineTraceConfig.cpp
AIEConfigToNPU.cpp
ADDITIONAL_HEADER_DIRS
${AIE_BINARY_DIR}/include

Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp