Skip to content

Commit

Permalink
add skeleton of aie to txn pass
Browse files Browse the repository at this point in the history
  • Loading branch information
fifield committed Sep 11, 2024
1 parent 6f4c138 commit 9dbf4ce
Show file tree
Hide file tree
Showing 10 changed files with 93 additions and 2 deletions.
28 changes: 28 additions & 0 deletions include/aie/Conversion/AIEToTransaction/AIEToTransaction.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
//===- AIEToTransaction.h ---------------------------------------*- C++ -*-===//
//
// This file is 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
//
// Copyright (C) 2024, Advanced Micro Devices, Inc. All rights reserved.
//
//===----------------------------------------------------------------------===//

#ifndef AIE_CONVERSION_AIETOTRANSACTION_AIETOTRANSACTION_H
#define AIE_CONVERSION_AIETOTRANSACTION_AIETOTRANSACTION_H

#include "aie/Dialect/AIE/IR/AIEDialect.h"
#include "aie/Dialect/AIEX/IR/AIEXDialect.h"

#include "mlir/Pass/Pass.h"

#include <memory>

namespace xilinx::AIE {

std::unique_ptr<mlir::OperationPass<xilinx::AIE::DeviceOp>>
createConvertAIEToTransactionPass();

} // namespace xilinx::AIE

#endif // AIE_CONVERSION_AIETOTRANSACTION_AIETOTRANSACTION_H
1 change: 1 addition & 0 deletions include/aie/Conversion/Passes.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#ifndef AIE_CONVERSION_PASSES_H
#define AIE_CONVERSION_PASSES_H

#include "aie/Conversion/AIEToTransaction/AIEToTransaction.h"
#include "aie/Conversion/AIEVecToLLVM/AIEVecToLLVM.h"
#include "aie/Conversion/PassesEnums.h.inc"

Expand Down
20 changes: 20 additions & 0 deletions include/aie/Conversion/Passes.td
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,24 @@ def ConvertAIEVecToLLVM : Pass<"convert-aievec-to-llvm", "mlir::ModuleOp"> {
];
}

//===----------------------------------------------------------------------===//
// AIEToTransaction
//===----------------------------------------------------------------------===//

def ConvertAIEToTransaction : Pass<"convert-aie-to-transaction",
"xilinx::AIE::DeviceOp"> {
let summary = "Convert AIE dialect to npu transaction operations";
let description = [{
This pass converts aie.device operations to a sequence of transaction binary
operations (writes, masked writes, and block writes) that can be used to
to configure the npu device. The transaction operations are emitted as
`npu.write32`, `npu.maskwrite32`, and `npu.blockwrite` operations. A new
`aiex.runtime_sequence` operation is inserted into the `aie.device` to
contain the new transaction operations sequence.
}];
let constructor = "xilinx::AIE::createConvertAIEToTransactionPass()";
let dependentDialects = ["xilinx::AIE::AIEDialect",
"xilinx::AIEX::AIEXDialect"];
}

#endif // AIE_CONVERSION_PASSES
2 changes: 1 addition & 1 deletion include/aie/Dialect/AIEX/Transforms/AIEXPasses.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//===- AIEPasses.h ----------------------------------------------*- C++ -*-===//
//===- AIEXPasses.h ---------------------------------------------*- C++ -*-===//
//
// This file is licensed under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
Expand Down
1 change: 1 addition & 0 deletions lib/CAPI/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ add_mlir_public_c_api_library(AIECAPI
AIEX
AIEXTransforms
AIEXUtils
MLIRAIEToTransaction
MLIRAIEVecDialect
MLIRAIEVecAIE1Dialect
MLIRAIEVecToLLVM
Expand Down
23 changes: 23 additions & 0 deletions lib/Conversion/AIEToTransaction/AIEToTransaction.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@

#include "../PassDetail.h"

#include "aie/Conversion/AIEToTransaction/AIEToTransaction.h"

using namespace mlir;

namespace {

struct ConvertAIEToTransactionPass
: ConvertAIEToTransactionBase<ConvertAIEToTransactionPass> {
void runOnOperation() override {
auto device = getOperation();
device.dump();
}
};

} // end anonymous namespace

std::unique_ptr<mlir::OperationPass<xilinx::AIE::DeviceOp>>
xilinx::AIE::createConvertAIEToTransactionPass() {
return std::make_unique<ConvertAIEToTransactionPass>();
}
15 changes: 15 additions & 0 deletions lib/Conversion/AIEToTransaction/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
add_mlir_conversion_library(MLIRAIEToTransaction
AIEToTransaction.cpp

ADDITIONAL_HEADER_DIRS
$(CMAKE_CURRENT_SRC_DIR)/../../../../include/aie/Conversion/AIEToTransaction

DEPENDS
MLIRAIEConversionPassIncGen

LINK_COMPONENTS
Core

LINK_LIBS PUBLIC
AIERTX
)
3 changes: 2 additions & 1 deletion lib/Conversion/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
add_subdirectory(AIEVecToLLVM)
add_subdirectory(AIEToTransaction)
add_subdirectory(AIEVecToLLVM)
1 change: 1 addition & 0 deletions lib/Conversion/PassDetail.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#define AIE_CONVERSION_PASSDETAIL_H_

#include "aie/Conversion/Passes.h"

#include "mlir/Dialect/Arith/IR/Arith.h"
#include "mlir/Dialect/Vector/IR/VectorOps.h"
#include "mlir/IR/BuiltinOps.h"
Expand Down
1 change: 1 addition & 0 deletions tools/aie-opt/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ set(LIBS
AIEX
AIEXTransforms
AIEXUtils
MLIRAIEToTransaction
MLIRAIEVecDialect
MLIRAIEVecAIE1Dialect
MLIRAIEVecTransformOps
Expand Down

0 comments on commit 9dbf4ce

Please sign in to comment.