Skip to content

Commit

Permalink
Have AIECtrlPacketToDmaPass figure out the ctrl packet stream size, i…
Browse files Browse the repository at this point in the history
…nstead of hard coding
  • Loading branch information
erwei-xilinx committed Sep 18, 2024
1 parent e90b275 commit 6232f02
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions lib/Dialect/AIEX/Transforms/AIECtrlPacketToDma.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,20 @@ struct AIECtrlPacketToDmaPass : AIECtrlPacketToDmaBase<AIECtrlPacketToDmaPass> {
auto newSeq =
builder.create<AIEX::RuntimeSequenceOp>(loc, f.getSymNameAttr());
newSeq.getBody().push_back(new Block);
auto ctrlPktMemrefType = MemRefType::get(
SmallVector<int64_t>{1024}, IntegerType::get(ctx, 32), nullptr, 0);

// Get total size of all control packets (in i32 words)
int64_t totalCtrlPktSizeInI32 = 0;
llvm::for_each(controlPacketOps, [&](AIEX::NpuControlPacketOp ctrlPktOp) {
if (ctrlPktOp.getData())
totalCtrlPktSizeInI32 += ctrlPktOp.getData()->size();
else if (ctrlPktOp.getLength())
totalCtrlPktSizeInI32 += *ctrlPktOp.getLength();
totalCtrlPktSizeInI32++; // Plus one control packet info word
});

auto ctrlPktMemrefType =
MemRefType::get(SmallVector<int64_t>{totalCtrlPktSizeInI32},
IntegerType::get(ctx, 32), nullptr, 0);
auto newBlockArg = newSeq.getBody().addArgument(ctrlPktMemrefType, loc);
builder.setInsertionPointToStart(&newSeq.getBody().front());

Expand Down

0 comments on commit 6232f02

Please sign in to comment.