forked from nod-ai/iree-amd-aie
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move most of LLVM lowering out of aie2xclbin (nod-ai#838)
Is a continuation of nod-ai@be42d19 -- it that PR we moved vector->aievec into the main pipeline, this PR moves aievec->llvm into the main pipeline (and a few other dialect lowerings to llvm). Moving the lowering of func to llvm is tricky, because of the position of the pass `AMDAIECoreToStandardFunc` which lowers from CoreOp to func. TBC.
- Loading branch information
Showing
8 changed files
with
162 additions
and
98 deletions.
There are no files selected for viewing
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
72 changes: 72 additions & 0 deletions
72
compiler/plugins/target/AMD-AIE/iree-amd-aie/Transforms/AMDAIELoadAlignmentReset.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,72 @@ | ||
// 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 "mlir/Dialect/LLVMIR/LLVMDialect.h" | ||
#include "iree-amd-aie/IR/AMDAIEDialect.h" | ||
#include "iree-amd-aie/Transforms/Passes.h" | ||
#include "mlir/Pass/Pass.h" | ||
#include "mlir/Dialect/SCF/Transforms/Transforms.h" | ||
#include "mlir/Dialect/SCF/Utils/Utils.h" | ||
#include "mlir/Pass/Pass.h" | ||
#define DEBUG_TYPE "iree-amdaie-acquire-release-to-use-lock" | ||
|
||
namespace mlir::iree_compiler::AMDAIE { | ||
|
||
using namespace mlir; | ||
|
||
namespace { | ||
|
||
// A pass which removes the alignment attribute from llvm load operations, | ||
// if the alignment is less than 4 (2 or 1). | ||
// | ||
// Example. The pass replaces: | ||
// | ||
// ``` | ||
// %113 = llvm.load %112 {alignment = 2 : i64} | ||
// : !llvm.ptr -> vector<32xbf16> | ||
// ``` | ||
// | ||
// with | ||
// | ||
// ``` | ||
// %113 = llvm.load %112 | ||
// : !llvm.ptr -> vector<32xbf16> | ||
// ``` | ||
// | ||
// If this pass is not included in the matmul pipeline, there is an OOM error | ||
// later in the compilation. This is a temporary workaround while a better | ||
// solution is found: propagation of memref.assume_alignment is one option. | ||
// See also https://jira.xilinx.com/projects/AIECC/issues/AIECC-589 | ||
|
||
class AMDAIELoadAlignmentReset | ||
: public impl::AMDAIELoadAlignmentResetBase< | ||
AMDAIELoadAlignmentReset> { | ||
void getDependentDialects(DialectRegistry ®istry) const override { | ||
registry.insert<AMDAIEDialect>(); | ||
} | ||
|
||
void runOnOperation() override { | ||
getOperation()->walk([](Operation *op) { | ||
if (auto loadOp = dyn_cast<LLVM::LoadOp>(op)) { | ||
auto alignmentAttr = loadOp.getAlignmentAttr(); | ||
if (alignmentAttr) { | ||
int alignmentVal = alignmentAttr.getValue().getSExtValue(); | ||
if (alignmentVal == 2 || alignmentVal == 1) { | ||
loadOp.setAlignment(std::optional<uint64_t>()); | ||
} | ||
} | ||
} | ||
}); | ||
} | ||
}; | ||
|
||
} // namespace | ||
|
||
std::unique_ptr<Pass> createAMDAIELoadAlignmentResetPass() { | ||
return std::make_unique<AMDAIELoadAlignmentReset>(); | ||
} | ||
|
||
} // 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