Skip to content

Commit

Permalink
Update with comment as well as add two more amdaie.core ops
Browse files Browse the repository at this point in the history
  • Loading branch information
Abhishek-Varma committed Aug 27, 2024
1 parent 3a05316 commit c33d9a4
Show file tree
Hide file tree
Showing 2 changed files with 121 additions and 34 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ void AMDAIESplitLogicalObjectFifosPass::runOnOperation() {

SmallVector<OpFoldResult> baseSourceOffsets =
l2ToL1DmaOps[0].getSourceMixedOffsets();
// We will now capture those dimensions where L2 memory was split. The way we
// do this is by checking all L2->L1 DmaOps' source offset and marking those
// dimensions which are not equal to at least one of the source offsets.
DenseSet<unsigned> splitDimensionsSet;
for (unsigned i = 1, n = l2ToL1DmaOps.size(); i < n; i++) {
SmallVector<OpFoldResult> sourceOffsets =
Expand Down Expand Up @@ -102,6 +105,17 @@ void AMDAIESplitLogicalObjectFifosPass::runOnOperation() {
cast<MemRefType>(
l3ToL2DmaOp.getTargetObjectFifo().getMemref().getType())
.getShape());
// We traverse through the split dimensions we captured earlier and for each
// such dimension we perform the following updates :-
// 1. Maintain a map: DIM -> CONST_OFFSET_TO_ADD. This is done with the
// assumption that L3<->L2 is 4D and L2<->L1 is 6D. `DIM` here is split
// dimension + 2. `CONST_OFFSET_TO_ADD` is the constant we get by
// multiplying L2 as source's offset at split dimension with L2 as
// target's size at split dimension + 2. We are maintaining this to later
// update the extraction offset of L3 -> L2.
// 2. Update L2 as source/target offset => 0.
// 3. Update L2 as source/target size => 1.
// 4. Compute the shape of L2 buffer after split.
DenseMap<int64_t, int64_t> dimToOffsetMapForL3AsSource;
for (unsigned dim : splitDimensionsSet) {
std::optional<int64_t> constantOffset =
Expand All @@ -114,7 +128,6 @@ void AMDAIESplitLogicalObjectFifosPass::runOnOperation() {
{dim + 2,
constantOffset.value() *
(getConstantIntValue(staticL2AsTargetSizes[dim + 2]).value())});
// splitDimensions.push_back(dim);
staticL2AsSourceOffsets[dim] = zeroVal;
staticL2AsSourceSizes[dim] = oneVal;
staticL2AsTargetOffsets[dim] = zeroVal;
Expand Down Expand Up @@ -144,6 +157,8 @@ void AMDAIESplitLogicalObjectFifosPass::runOnOperation() {

SmallVector<OpFoldResult, 4> staticL3AsSourceOffsets =
l3ToL2DmaOp.getSourceMixedOffsets();
// We now traverse the map : DIM -> CONST_OFFSET_TO_ADD we created earlier
// to update extraction offsets while splitting L3->L2.
for (auto [dim, offsetToAdd] : dimToOffsetMapForL3AsSource) {
auto applyOp = cast<affine::AffineApplyOp>(
cast<Value>(staticL3AsSourceOffsets[dim]).getDefiningOp());
Expand Down
Loading

0 comments on commit c33d9a4

Please sign in to comment.