-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Split L2 input and output objectFifos for memTile/shimTile distribution
- Loading branch information
Showing
10 changed files
with
594 additions
and
74 deletions.
There are no files selected for viewing
364 changes: 300 additions & 64 deletions
364
...ler/plugins/target/AMD-AIE/iree-amd-aie/Transforms/AMDAIELogicalObjFifoSplittingUtils.cpp
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
78 changes: 78 additions & 0 deletions
78
compiler/plugins/target/AMD-AIE/iree-amd-aie/Transforms/AMDAIESplitLogicalObjFifos.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
// Copyright 2024 The IREE Authors | ||
// | ||
// 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 | ||
#include "iree-amd-aie/IR/AMDAIEOps.h" | ||
#include "iree-amd-aie/Transforms/AMDAIELogicalObjFifoSplittingUtils.h" | ||
#include "iree-amd-aie/Transforms/Passes.h" | ||
#include "mlir/IR/Iterators.h" | ||
#include "mlir/Pass/Pass.h" | ||
|
||
#define DEBUG_TYPE "iree-amdaie-split-logical-objectfifos" | ||
|
||
namespace mlir::iree_compiler::AMDAIE { | ||
|
||
namespace { | ||
|
||
class AMDAIESplitLogicalObjFifosPass | ||
: public impl::AMDAIESplitLogicalObjFifosBase< | ||
AMDAIESplitLogicalObjFifosPass> { | ||
public: | ||
using AMDAIESplitLogicalObjFifosBase::AMDAIESplitLogicalObjFifosBase; | ||
|
||
void getDependentDialects(DialectRegistry ®istry) const override { | ||
registry.insert<AMDAIEDialect>(); | ||
} | ||
void runOnOperation() override; | ||
}; | ||
|
||
void AMDAIESplitLogicalObjFifosPass::runOnOperation() { | ||
ModuleOp moduleOp = getOperation(); | ||
MLIRContext *context = &getContext(); | ||
IRRewriter rewriter(context); | ||
|
||
// Walk and collect all dma ops between L3 and L2. | ||
SmallVector<AMDAIE::DmaCpyNdOp> l3L2DmaOps; | ||
WalkResult res = moduleOp->walk([&](AMDAIE::DmaCpyNdOp op) { | ||
std::optional<uint8_t> sourceMemSpace = op.getSourceMemorySpaceAsUInt(); | ||
std::optional<uint8_t> targetMemSpace = op.getTargetMemorySpaceAsUInt(); | ||
if (!sourceMemSpace || !targetMemSpace) { | ||
op.emitOpError() << "expected a source and target memory space"; | ||
return WalkResult::interrupt(); | ||
} | ||
if ((sourceMemSpace.value() == 1 && targetMemSpace.value() == 0) || | ||
(sourceMemSpace.value() == 0 && targetMemSpace.value() == 1)) { | ||
l3L2DmaOps.push_back(op); | ||
} | ||
return WalkResult::advance(); | ||
}); | ||
if (res.wasInterrupted()) return signalPassFailure(); | ||
|
||
// Split the dma ops of L3->L2 / L2->L3. | ||
for (AMDAIE::DmaCpyNdOp dmaOp : l3L2DmaOps) { | ||
if (failed(splitDoublyStridedOp(rewriter, dmaOp))) { | ||
LLVM_DEBUG(llvm::dbgs() | ||
<< "Failed to perform splitting of doubly strided op"); | ||
return signalPassFailure(); | ||
} | ||
} | ||
|
||
// Walk and split input and output objectfifos in L2 memory space. | ||
res = moduleOp->walk([&](AMDAIE::LogicalObjectFifoFromMemrefOp op) { | ||
if (op.getMemorySpaceAsUInt() != 1) return WalkResult::skip(); | ||
if (failed(splitLogicalObjectFifo(rewriter, op))) { | ||
return WalkResult::interrupt(); | ||
} | ||
return WalkResult::advance(); | ||
}); | ||
if (res.wasInterrupted()) return signalPassFailure(); | ||
} | ||
|
||
} // namespace | ||
|
||
std::unique_ptr<Pass> createAMDAIESplitLogicalObjFifosPass() { | ||
return std::make_unique<AMDAIESplitLogicalObjFifosPass>(); | ||
} | ||
|
||
} // namespace mlir::iree_compiler::AMDAIE |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.