Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ObjectFifo] Add a pass to combine logical objFifos for connection reuse #760

Draft
wants to merge 7 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion build_tools/build_test_cpp.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ echo "Building IREE"

$CMAKE_ARGS = @(
"-GNinja"
"-DCMAKE_BUILD_TYPE=Release"
"-DCMAKE_BUILD_TYPE=Debug"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the reason test_transaction isn't generated on Windows...

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I.e., once you put this back to Release Windows will pass again.

"-DCMAKE_INSTALL_PREFIX=$install_dir"
"-DCMAKE_INSTALL_LIBDIR=lib"
"-DCMAKE_EXE_LINKER_FLAGS_INIT=-fuse-ld=lld"
Expand Down
2 changes: 1 addition & 1 deletion build_tools/build_test_cpp.sh
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ echo '{
cd $iree_dir
CMAKE_ARGS="\
-GNinja \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_BUILD_TYPE=Debug \
-DCMAKE_INSTALL_PREFIX=$install_dir \
-DCMAKE_INSTALL_LIBDIR=lib \
-DIREE_ERROR_ON_MISSING_SUBMODULES=OFF \
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
// 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-combine-logical-objectfifos-for-connection-reuse"

namespace mlir::iree_compiler::AMDAIE {

namespace {

class AMDAIECombineLogicalObjFifosForConnectionReusePass
: public impl::AMDAIECombineLogicalObjFifosForConnectionReuseBase<
AMDAIECombineLogicalObjFifosForConnectionReusePass> {
public:
using AMDAIECombineLogicalObjFifosForConnectionReuseBase::
AMDAIECombineLogicalObjFifosForConnectionReuseBase;

void getDependentDialects(DialectRegistry &registry) const override {
registry.insert<AMDAIEDialect>();
}
void runOnOperation() override;
};

void AMDAIECombineLogicalObjFifosForConnectionReusePass::runOnOperation() {
ModuleOp moduleOp = getOperation();
MLIRContext *context = &getContext();
IRRewriter rewriter(context);

SmallVector<AMDAIE::DmaCpyNdOp> l2ToL1DmaOps =
fetchDmaCpyNdOpsToSplitOrCombine(moduleOp);

if (failed(combineLogicalObjectFifos(rewriter, l2ToL1DmaOps, context))) {
return signalPassFailure();
}
}

} // namespace

std::unique_ptr<Pass>
createAMDAIECombineLogicalObjFifosForConnectionReusePass() {
return std::make_unique<AMDAIECombineLogicalObjFifosForConnectionReusePass>();
}

} // namespace mlir::iree_compiler::AMDAIE
Original file line number Diff line number Diff line change
Expand Up @@ -342,4 +342,17 @@ LogicalResult moveNpuDmaSyncUsersAfterAncestorInSameBlock(
return success();
}

/// Utility to fetch a unique CoreOp associated with a L2->L1 Dma op.
std::optional<CoreOp> fetchUniqueCoreOp(DmaCpyNdOp &l2ToL1DmaOp) {
SmallVector<CoreOp> coreOps;
for (Operation *userOp : l2ToL1DmaOp->getUsers()) {
if (auto coreOp = dyn_cast<CoreOp>(userOp)) {
coreOps.push_back(coreOp);
}
}
assert(coreOps.size() == 1 &&
"L2->L1 Dma op expected to have a unique Core op");
return coreOps[0];
}

} // namespace mlir::iree_compiler::AMDAIE
Original file line number Diff line number Diff line change
Expand Up @@ -370,6 +370,9 @@ struct DmaDimConfig {
LogicalResult moveNpuDmaSyncUsersAfterAncestorInSameBlock(
RewriterBase &rewriter, Operation *parentOp);

/// Utility to fetch a unique CoreOp associated with a L2->L1 Dma op.
std::optional<CoreOp> fetchUniqueCoreOp(DmaCpyNdOp &l2ToL1DmaOp);

} // namespace mlir::iree_compiler::AMDAIE

#endif
Loading
Loading