Skip to content

Commit 3e46233

Browse files
authored
Bump mlir-aie to f85a4a974fd59c82c878656d2b1536b4c2e74453 (Xilinx#789)
* Bump mlir-aie * Switch to using hasProperty() method on AIE target devices * Switch to using hasProperty() method on AIE target devices
1 parent 8ed48b9 commit 3e46233

File tree

4 files changed

+44
-38
lines changed

4 files changed

+44
-38
lines changed

mlir/lib/Conversion/AIRRtToNpuPass.cpp

+4-2
Original file line numberDiff line numberDiff line change
@@ -1557,12 +1557,14 @@ struct AIRRtToNpuPass : public impl::AIRRtToNpuBase<AIRRtToNpuPass> {
15571557
/*enable_packet*/ 1, /*out_of_order_id*/ 0,
15581558
/*packet_id*/ flowID, pkt_type,
15591559
/* d0_size */ 0, /* d0_stride */ 0, /* d1_size */ 0,
1560-
/* d1_stride */ 0, /* d2_stride */ 0,
1560+
/* d1_stride */ 0, /* d2_size */ 0, /* d2_stride */ 0,
15611561
/* iteration_current */ 0, /* iteration_size */ 0,
15621562
/* iteration_stride */ 0, /* next_bd */ 0, dstRowIndex,
15631563
/* use_next_bd */ 0,
15641564
/* valid_bd */ 1, /* lock_rel_val */ 0, /* lock_rel_id */ 0,
1565-
/* lock_acq_enable */ 0, /* lock_acq_val */ 0, /* lock_acq_id */ 0);
1565+
/* lock_acq_enable */ 0, /* lock_acq_val */ 0, /* lock_acq_id */ 0,
1566+
/* d0_zero_before*/ 0, /* d1_zero_before*/ 0, /* d2_zero_before*/ 0,
1567+
/* d0_zero_after*/ 0, /* d1_zero_after*/ 0, /* d2_zero_after*/ 0);
15661568
uint32_t addr = (dstColIndex << target_model.getColumnShift()) |
15671569
(0x1D004 + bdID * 0x20);
15681570
builder.create<AIEX::NpuAddressPatchOp>(builder.getUnknownLoc(), addr,

mlir/lib/Conversion/AIRToAIEPass.cpp

+22-17
Original file line numberDiff line numberDiff line change
@@ -2583,7 +2583,8 @@ class AIRToAIEPass : public air::impl::AIRToAIEBase<AIRToAIEPass> {
25832583
std::unordered_set<Operation *> &allocs_to_remap,
25842584
const AIE::AIETargetModel &targetModel,
25852585
TileDMAAllocator &tileDmaAlloc, int x, int y) {
2586-
bool isAIE2 = isa<AIE::AIE2TargetModel>(targetModel);
2586+
bool UsesSemaphoreLocks =
2587+
targetModel.hasProperty(AIE::AIETargetModel::UsesSemaphoreLocks);
25872588
AIE::DMAChannel tile_channel =
25882589
tileDmaAlloc.lookupDMAAllocation(x, y, memcpyOpIf).dma_channel;
25892590
AIE::BufferOp bufferOp = tileDmaAlloc.getBuffer(BufferId, x, y, memcpyOpIf);
@@ -2596,12 +2597,12 @@ class AIRToAIEPass : public air::impl::AIRToAIEBase<AIRToAIEPass> {
25962597
Value alloc = nullptr;
25972598
auto tileInbound = isTileInbound(memcpyOpIf, (int)air::MemorySpace::L1);
25982599
if (tileInbound) {
2599-
lockAqValue = isAIE2 ? 1 : 1;
2600-
lockRelValue = isAIE2 ? 1 : 0;
2600+
lockAqValue = UsesSemaphoreLocks ? 1 : 1;
2601+
lockRelValue = UsesSemaphoreLocks ? 1 : 0;
26012602
alloc = memcpyOpIf.getDstMemref();
26022603
} else {
2603-
lockAqValue = isAIE2 ? 1 : 0;
2604-
lockRelValue = isAIE2 ? 1 : 1;
2604+
lockAqValue = UsesSemaphoreLocks ? 1 : 0;
2605+
lockRelValue = UsesSemaphoreLocks ? 1 : 1;
26052606
alloc = memcpyOpIf.getSrcMemref();
26062607
}
26072608

@@ -2619,8 +2620,9 @@ class AIRToAIEPass : public air::impl::AIRToAIEBase<AIRToAIEPass> {
26192620
builder.setInsertionPoint(memcpyOpIf);
26202621

26212622
builder.create<AIE::UseLockOp>(memcpyOpIf->getLoc(), acqLockOp,
2622-
isAIE2 ? AIE::LockAction::AcquireGreaterEqual
2623-
: AIE::LockAction::Acquire,
2623+
UsesSemaphoreLocks
2624+
? AIE::LockAction::AcquireGreaterEqual
2625+
: AIE::LockAction::Acquire,
26242626
lockAqValue);
26252627
// try to find a place to put the unlock. If there are deallocs,
26262628
// replace them with unlock. Otherwise, put them at the end.
@@ -2715,7 +2717,8 @@ class AIRToAIEPass : public air::impl::AIRToAIEBase<AIRToAIEPass> {
27152717
const AIE::AIETargetModel &targetModel, Block *bd,
27162718
air::MemcpyInterface memcpyOp, bufferOpTy bufferOp,
27172719
int chan) {
2718-
bool isAIE2 = isa<AIE::AIE2TargetModel>(targetModel);
2720+
bool UsesSemaphoreLocks =
2721+
targetModel.hasProperty(AIE::AIETargetModel::UsesSemaphoreLocks);
27192722
bool isMM2S = (dir == AIE::DMAChannelDir::MM2S);
27202723

27212724
auto b = OpBuilder::atBlockEnd(bd);
@@ -2726,11 +2729,11 @@ class AIRToAIEPass : public air::impl::AIRToAIEBase<AIRToAIEPass> {
27262729
int64_t lockRelValue = -1;
27272730
auto aie2LockVal = getLockValuePair(targetModel, bufferOp->getResult(0));
27282731
if (!isMM2S) {
2729-
lockAqValue = isAIE2 ? aie2LockVal.first : 0;
2730-
lockRelValue = isAIE2 ? aie2LockVal.first : 1;
2732+
lockAqValue = UsesSemaphoreLocks ? aie2LockVal.first : 0;
2733+
lockRelValue = UsesSemaphoreLocks ? aie2LockVal.first : 1;
27312734
} else {
2732-
lockAqValue = isAIE2 ? aie2LockVal.second : 1;
2733-
lockRelValue = isAIE2 ? aie2LockVal.second : 0;
2735+
lockAqValue = UsesSemaphoreLocks ? aie2LockVal.second : 1;
2736+
lockRelValue = UsesSemaphoreLocks ? aie2LockVal.second : 0;
27342737
}
27352738
auto ndcpy = cast<air::MemcpyInterface>(memcpyOp);
27362739

@@ -2763,8 +2766,9 @@ class AIRToAIEPass : public air::impl::AIRToAIEBase<AIRToAIEPass> {
27632766
Value length =
27642767
b.create<arith::ConstantIndexOp>(memcpyOp.getLoc(), len)->getResult(0);
27652768
b.create<AIE::UseLockOp>(loc, acqLockOp,
2766-
isAIE2 ? AIE::LockAction::AcquireGreaterEqual
2767-
: AIE::LockAction::Acquire,
2769+
UsesSemaphoreLocks
2770+
? AIE::LockAction::AcquireGreaterEqual
2771+
: AIE::LockAction::Acquire,
27682772
lockAqValue);
27692773

27702774
// Packet flow routing: get packet flow id.
@@ -2783,7 +2787,8 @@ class AIRToAIEPass : public air::impl::AIRToAIEBase<AIRToAIEPass> {
27832787
auto wraps_and_strides =
27842788
AIE::BDDimLayoutArrayAttr::get(ndcpy->getContext(), ArrayRef(dims));
27852789
bool useDefaultDataAccessPattern =
2786-
isAIE2 ? isDefaultDataAccessPattern(sizes, strides, memref) : true;
2790+
UsesSemaphoreLocks ? isDefaultDataAccessPattern(sizes, strides, memref)
2791+
: true;
27872792
AIE::DMABDOp aieDmaBdOp = nullptr;
27882793
if (wraps_and_strides.getValue().empty() || useDefaultDataAccessPattern)
27892794
aieDmaBdOp = b.create<AIE::DMABDOp>(
@@ -3318,7 +3323,7 @@ class AIRToAIEPass : public air::impl::AIRToAIEBase<AIRToAIEPass> {
33183323

33193324
for (auto herd : herds) {
33203325
std::vector<Attribute> dma_allocations;
3321-
if (!device.getTargetModel().isNPU()) {
3326+
if (!device.getTargetModel().hasProperty(AIE::AIETargetModel::IsNPU)) {
33223327
// AIE1 dma metadata format
33233328
getDmaAllocationMetadata(builder, ctx, herd, shimDmaAlloc.s2mm_allocs,
33243329
AIE::DMAChannelDir::S2MM,
@@ -3354,7 +3359,7 @@ class AIRToAIEPass : public air::impl::AIRToAIEBase<AIRToAIEPass> {
33543359
}
33553360
for (auto seg : segs) {
33563361
std::vector<Attribute> dma_allocations;
3357-
if (!device.getTargetModel().isNPU()) {
3362+
if (!device.getTargetModel().hasProperty(AIE::AIETargetModel::IsNPU)) {
33583363
// AIE1 memtile dma metadata format
33593364
getDmaAllocationMetadata(builder, ctx, seg, shimDmaAlloc.mm2s_allocs,
33603365
AIE::DMAChannelDir::MM2S,

mlir/lib/Conversion/AIRToAIESchedulingUtils.cpp

+17-18
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ air::getWrapsAndStrides(SmallVector<Value> memcpy_sizes,
221221
std::pair<int64_t, int64_t>
222222
air::getLockValuePair(const AIE::AIETargetModel &targetModel,
223223
Value buffer_memref) {
224-
if (isa<AIE::AIE1TargetModel>(targetModel))
224+
if (!targetModel.hasProperty(AIE::AIETargetModel::UsesSemaphoreLocks))
225225
return std::make_pair(0, 0);
226226

227227
// Infer semaphore lock values using buffer op
@@ -264,7 +264,7 @@ air::getLockValuePair(const AIE::AIETargetModel &targetModel,
264264
std::pair<int64_t, int64_t>
265265
air::getLockValuePair(const AIE::AIETargetModel &targetModel,
266266
Value buffer_memref, air::ChannelOp air_chan) {
267-
if (isa<AIE::AIE1TargetModel>(targetModel))
267+
if (!targetModel.hasProperty(AIE::AIETargetModel::UsesSemaphoreLocks))
268268
return std::make_pair(0, 0);
269269

270270
if (!llvm::isa<MemRefType>(buffer_memref.getType()))
@@ -418,21 +418,10 @@ DMAAllocator::getLockForDMA(air::MemcpyInterface &memcpyOp, int col, int row,
418418
air_chan = getChannelDeclarationThroughSymbol(air_chan_op);
419419
}
420420
const auto &target_model = device.getTargetModel();
421-
bool isAIE2 = isa<AIE::AIE2TargetModel>(target_model);
422-
bool isAIE1 = isa<AIE::AIE1TargetModel>(target_model);
421+
bool UsesSemaphoreLocks =
422+
target_model.hasProperty(AIE::AIETargetModel::UsesSemaphoreLocks);
423423

424-
if (isAIE1) {
425-
for (size_t i = 0; i < lock_allocation_list.size(); i++) {
426-
// If multiple bds reference the same buffer and DMA channel
427-
if ((std::get<0>(lock_allocation_list[i]) == bufferOp) &&
428-
(std::get<2>(lock_allocation_list[i]) == channel)) {
429-
return {std::get<3>(lock_allocation_list[i]),
430-
std::get<4>(lock_allocation_list[i])};
431-
}
432-
}
433-
}
434-
435-
else if (isAIE2) {
424+
if (UsesSemaphoreLocks) {
436425
if (air_chan) {
437426
// AIE2's semaphore locks may share by air.channels
438427
for (size_t i = 0; i < lock_allocation_list.size(); i++) {
@@ -471,6 +460,15 @@ DMAAllocator::getLockForDMA(air::MemcpyInterface &memcpyOp, int col, int row,
471460
}
472461
}
473462
}
463+
} else {
464+
for (size_t i = 0; i < lock_allocation_list.size(); i++) {
465+
// If multiple bds reference the same buffer and DMA channel
466+
if ((std::get<0>(lock_allocation_list[i]) == bufferOp) &&
467+
(std::get<2>(lock_allocation_list[i]) == channel)) {
468+
return {std::get<3>(lock_allocation_list[i]),
469+
std::get<4>(lock_allocation_list[i])};
470+
}
471+
}
474472
}
475473
if (!bufferOp) {
476474
memcpyOp->emitOpError(
@@ -487,7 +485,7 @@ DMAAllocator::getLockForDMA(air::MemcpyInterface &memcpyOp, int col, int row,
487485

488486
OpBuilder builder(bufferOp);
489487
auto rlock = allocateLockOp(device, tile, 0);
490-
auto wlock = isAIE2 ? allocateLockOp(device, tile, init) : rlock;
488+
auto wlock = UsesSemaphoreLocks ? allocateLockOp(device, tile, init) : rlock;
491489
lock_allocation_list.push_back({bufferOp, air_chan, channel, rlock, wlock});
492490
return {rlock, wlock};
493491
}
@@ -1042,7 +1040,8 @@ void air::simpleDMAChannelAllocation(
10421040
}
10431041

10441042
// If found item in vector, return index; else return -1.
1045-
template <typename T> int air::foundInVector(T item, std::vector<T> vec) {
1043+
template <typename T>
1044+
int air::foundInVector(T item, std::vector<T> vec) {
10461045
auto it = std::find(vec.begin(), vec.end(), item);
10471046
int index = it - vec.begin();
10481047
return index;

utils/clone-mlir-aie.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
#
1515
##===----------------------------------------------------------------------===##
1616

17-
export HASH=779bbd147cd4c934aa0728afa52b1bda076e28f6
17+
export HASH=f85a4a974fd59c82c878656d2b1536b4c2e74453
1818
target_dir=mlir-aie
1919

2020
if [[ ! -d $target_dir ]]; then

0 commit comments

Comments
 (0)