@@ -2583,7 +2583,8 @@ class AIRToAIEPass : public air::impl::AIRToAIEBase<AIRToAIEPass> {
2583
2583
std::unordered_set<Operation *> &allocs_to_remap,
2584
2584
const AIE::AIETargetModel &targetModel,
2585
2585
TileDMAAllocator &tileDmaAlloc, int x, int y) {
2586
- bool isAIE2 = isa<AIE::AIE2TargetModel>(targetModel);
2586
+ bool UsesSemaphoreLocks =
2587
+ targetModel.hasProperty (AIE::AIETargetModel::UsesSemaphoreLocks);
2587
2588
AIE::DMAChannel tile_channel =
2588
2589
tileDmaAlloc.lookupDMAAllocation (x, y, memcpyOpIf).dma_channel ;
2589
2590
AIE::BufferOp bufferOp = tileDmaAlloc.getBuffer (BufferId, x, y, memcpyOpIf);
@@ -2596,12 +2597,12 @@ class AIRToAIEPass : public air::impl::AIRToAIEBase<AIRToAIEPass> {
2596
2597
Value alloc = nullptr ;
2597
2598
auto tileInbound = isTileInbound (memcpyOpIf, (int )air::MemorySpace::L1);
2598
2599
if (tileInbound) {
2599
- lockAqValue = isAIE2 ? 1 : 1 ;
2600
- lockRelValue = isAIE2 ? 1 : 0 ;
2600
+ lockAqValue = UsesSemaphoreLocks ? 1 : 1 ;
2601
+ lockRelValue = UsesSemaphoreLocks ? 1 : 0 ;
2601
2602
alloc = memcpyOpIf.getDstMemref ();
2602
2603
} else {
2603
- lockAqValue = isAIE2 ? 1 : 0 ;
2604
- lockRelValue = isAIE2 ? 1 : 1 ;
2604
+ lockAqValue = UsesSemaphoreLocks ? 1 : 0 ;
2605
+ lockRelValue = UsesSemaphoreLocks ? 1 : 1 ;
2605
2606
alloc = memcpyOpIf.getSrcMemref ();
2606
2607
}
2607
2608
@@ -2619,8 +2620,9 @@ class AIRToAIEPass : public air::impl::AIRToAIEBase<AIRToAIEPass> {
2619
2620
builder.setInsertionPoint (memcpyOpIf);
2620
2621
2621
2622
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,
2624
2626
lockAqValue);
2625
2627
// try to find a place to put the unlock. If there are deallocs,
2626
2628
// replace them with unlock. Otherwise, put them at the end.
@@ -2715,7 +2717,8 @@ class AIRToAIEPass : public air::impl::AIRToAIEBase<AIRToAIEPass> {
2715
2717
const AIE::AIETargetModel &targetModel, Block *bd,
2716
2718
air::MemcpyInterface memcpyOp, bufferOpTy bufferOp,
2717
2719
int chan) {
2718
- bool isAIE2 = isa<AIE::AIE2TargetModel>(targetModel);
2720
+ bool UsesSemaphoreLocks =
2721
+ targetModel.hasProperty (AIE::AIETargetModel::UsesSemaphoreLocks);
2719
2722
bool isMM2S = (dir == AIE::DMAChannelDir::MM2S);
2720
2723
2721
2724
auto b = OpBuilder::atBlockEnd (bd);
@@ -2726,11 +2729,11 @@ class AIRToAIEPass : public air::impl::AIRToAIEBase<AIRToAIEPass> {
2726
2729
int64_t lockRelValue = -1 ;
2727
2730
auto aie2LockVal = getLockValuePair (targetModel, bufferOp->getResult (0 ));
2728
2731
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 ;
2731
2734
} 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 ;
2734
2737
}
2735
2738
auto ndcpy = cast<air::MemcpyInterface>(memcpyOp);
2736
2739
@@ -2763,8 +2766,9 @@ class AIRToAIEPass : public air::impl::AIRToAIEBase<AIRToAIEPass> {
2763
2766
Value length =
2764
2767
b.create <arith::ConstantIndexOp>(memcpyOp.getLoc (), len)->getResult (0 );
2765
2768
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,
2768
2772
lockAqValue);
2769
2773
2770
2774
// Packet flow routing: get packet flow id.
@@ -2783,7 +2787,8 @@ class AIRToAIEPass : public air::impl::AIRToAIEBase<AIRToAIEPass> {
2783
2787
auto wraps_and_strides =
2784
2788
AIE::BDDimLayoutArrayAttr::get (ndcpy->getContext (), ArrayRef (dims));
2785
2789
bool useDefaultDataAccessPattern =
2786
- isAIE2 ? isDefaultDataAccessPattern (sizes, strides, memref) : true ;
2790
+ UsesSemaphoreLocks ? isDefaultDataAccessPattern (sizes, strides, memref)
2791
+ : true ;
2787
2792
AIE::DMABDOp aieDmaBdOp = nullptr ;
2788
2793
if (wraps_and_strides.getValue ().empty () || useDefaultDataAccessPattern)
2789
2794
aieDmaBdOp = b.create <AIE::DMABDOp>(
@@ -3318,7 +3323,7 @@ class AIRToAIEPass : public air::impl::AIRToAIEBase<AIRToAIEPass> {
3318
3323
3319
3324
for (auto herd : herds) {
3320
3325
std::vector<Attribute> dma_allocations;
3321
- if (!device.getTargetModel ().isNPU ( )) {
3326
+ if (!device.getTargetModel ().hasProperty (AIE::AIETargetModel::IsNPU )) {
3322
3327
// AIE1 dma metadata format
3323
3328
getDmaAllocationMetadata (builder, ctx, herd, shimDmaAlloc.s2mm_allocs ,
3324
3329
AIE::DMAChannelDir::S2MM,
@@ -3354,7 +3359,7 @@ class AIRToAIEPass : public air::impl::AIRToAIEBase<AIRToAIEPass> {
3354
3359
}
3355
3360
for (auto seg : segs) {
3356
3361
std::vector<Attribute> dma_allocations;
3357
- if (!device.getTargetModel ().isNPU ( )) {
3362
+ if (!device.getTargetModel ().hasProperty (AIE::AIETargetModel::IsNPU )) {
3358
3363
// AIE1 memtile dma metadata format
3359
3364
getDmaAllocationMetadata (builder, ctx, seg, shimDmaAlloc.mm2s_allocs ,
3360
3365
AIE::DMAChannelDir::MM2S,
0 commit comments