Skip to content

Commit

Permalink
simplify, simplify, simplify
Browse files Browse the repository at this point in the history
  • Loading branch information
newling committed Aug 19, 2024
1 parent 5cefc27 commit efc9461
Show file tree
Hide file tree
Showing 15 changed files with 130 additions and 267 deletions.
1 change: 0 additions & 1 deletion compiler/plugins/target/AMD-AIE/aie/AIEOps.td
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ class AIE_Op<string mnemonic, list<Trait> traits = []> :
Op<AIE_Dialect, mnemonic, traits>;

def AIE_DeviceOp: AIE_Op<"device", [
HasParent<"mlir::ModuleOp">,
SymbolTable, SingleBlock, NoTerminator, IsolatedFromAbove
]> {
let summary = "Define an AIE design targetting a complete device";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,12 @@

#include <algorithm>
#include <cassert>
#include <list>
#include <set>

#include "AIEDialect.h"
#include "Passes.h"
#include "iree-amd-aie/aie_runtime/iree_aie_router.h"
#include "iree-amd-aie/aie_runtime/iree_aie_runtime.h"
#include "llvm/ADT/DenseMapInfo.h"
#include "llvm/Support/raw_os_ostream.h"
#include "mlir/Pass/Pass.h"
#include "mlir/Transforms/DialectConversion.h"

Expand Down
89 changes: 0 additions & 89 deletions compiler/plugins/target/AMD-AIE/aie/AMDAIEXToStandard.cpp

This file was deleted.

1 change: 0 additions & 1 deletion compiler/plugins/target/AMD-AIE/aie/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,6 @@ iree_cc_library(
AMDAIELocalizeLocks.cpp
AMDAIENormalizeAddressSpaces.cpp
AMDAIEObjectFifoStatefulTransform.cpp
AMDAIEXToStandard.cpp
DEPS
iree-amd-aie::aie_runtime::iree_aie_runtime_static
::AIEDialectIR
Expand Down
4 changes: 1 addition & 3 deletions compiler/plugins/target/AMD-AIE/aie/Passes.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ createAMDAIEPathfinderPass();
std::unique_ptr<OperationPass<ModuleOp>> createAMDAIECoreToStandardPass();
std::unique_ptr<OperationPass<xilinx::AIE::DeviceOp>>
createAMDAIEDmaToNpuPass();
std::unique_ptr<OperationPass<ModuleOp>> createAMDAIEXToStandardPass();

void registerAMDAIEAssignBufferAddressesBasic();
void registerAMDAIEAssignBufferDescriptorIDs();
Expand All @@ -44,9 +43,8 @@ void registerAMDAIELocalizeLocks();
void registerAMDAIENormalizeAddressSpaces();
void registerAMDAIEObjectFifoStatefulTransform();
void registerAMDAIERoutePathfinderFlows();

void registerAMDAIEDmaToNpu();
void registerAMDAIEXToStandardPass();

} // namespace mlir::iree_compiler::AMDAIE

#endif // AMDAIE_PASSES_H_

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ struct AMDAIESession
AMDAIE::registerAMDAIEObjectFifoStatefulTransform();
AMDAIE::registerAMDAIERoutePathfinderFlows();
AMDAIE::registerAMDAIEDmaToNpu();
AMDAIE::registerAMDAIEXToStandardPass();
AMDAIE::registerAIRConversionPasses();
AMDAIE::registerAIRTransformPasses();
aievec::registerConvertAIEVecToLLVMPass();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -349,18 +349,8 @@ LogicalResult AIETargetBackend::serializeExecutable(
ParserConfig pcfg(variantOp->getContext());
llvm::SourceMgr srcMgr;

// TODO(newling) check if we just just pass DeviceOp around directly,
// is is really necessary to wrap it in a module?
ModuleOp moduleWithOneDevice;
{
OpBuilder opBuilder(moduleOp.getContext());
moduleWithOneDevice = opBuilder.create<ModuleOp>(moduleOp.getLoc());
opBuilder.setInsertionPointToStart(moduleWithOneDevice.getBody());
opBuilder.clone(*deviceOps[i].getOperation());
}

if (failed(aie2xclbin(
/*ctx=*/variantOp->getContext(), moduleWithOneDevice,
/*ctx=*/variantOp->getContext(), deviceOps[i],
/*outputNPU=*/npuInstPath.str().str(),
/*outputXCLBin=*/xclbinPath.str().str(),
/*printIRBeforeAll=*/options.aie2xclbinPrintIrBeforeAll,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
#include "AMDAIETargets.h"
#include "aie/AIEDialect.h"
#include "llvm/ADT/StringExtras.h"
#include "llvm/IR/Module.h"

using namespace mlir;
using namespace xilinx;
Expand All @@ -17,15 +16,11 @@ std::string utohexstr(uint32_t u) { return "0x" + llvm::utohexstr(u); }

namespace mlir::iree_compiler::AMDAIE {

LogicalResult AIETranslateToBCF(ModuleOp module, raw_ostream &output,
LogicalResult AIETranslateToBCF(DeviceOp deviceOp, raw_ostream &output,
int tileCol, int tileRow) {
DenseMap<TileLoc, Operation *> tiles;
DenseMap<Operation *, SmallVector<BufferOp, 4>> buffers;

if (module.getOps<DeviceOp>().empty())
module.emitOpError("expected aie.device operation at toplevel");
DeviceOp deviceOp = *(module.getOps<DeviceOp>().begin());

collectTiles(deviceOp, tiles);
collectBuffers(deviceOp, buffers);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception

#include <cassert>
#include <cstdint> // uint
#include <cstdint>
#include <filesystem>
#include <optional>
#include <string>
Expand All @@ -17,12 +17,9 @@
#include "iree-amd-aie/aie_runtime/iree_aie_runtime.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/Twine.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/ErrorHandling.h"
#include "mlir/IR/Block.h"
#include "mlir/IR/BuiltinOps.h"
#include "mlir/IR/BuiltinTypeInterfaces.h"
#include "mlir/Support/LLVM.h"
#include "mlir/Support/LogicalResult.h"

Expand Down Expand Up @@ -341,14 +338,11 @@ LogicalResult generateCDOBinariesSeparately(
return success();
}

LogicalResult AIETranslateToCDODirect(ModuleOp m, llvm::StringRef workDirPath,
LogicalResult AIETranslateToCDODirect(xilinx::AIE::DeviceOp device,
llvm::StringRef workDirPath,
bool bigEndian, bool emitUnified,
bool cdoDebug, bool aieSim,
bool enableCores) {
auto devOps = m.getOps<DeviceOp>();
assert(llvm::range_size(devOps) == 1 &&
"only exactly 1 device op supported.");
DeviceOp device = *devOps.begin();
AMDAIEDeviceModel deviceModel = getDeviceModel(device.getDevice());
byte_ordering endianness =
bigEndian ? byte_ordering::Big_Endian : byte_ordering::Little_Endian;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,14 +50,10 @@ static void writeLDScriptMap(raw_ostream &output, BufferOp buf, int offset) {
// .bss : { *(.bss) } > data
// }
LogicalResult mlir::iree_compiler::AMDAIE::AIETranslateToLdScript(
ModuleOp module, raw_ostream &output, int tileCol, int tileRow) {
DeviceOp deviceOp, raw_ostream &output, int tileCol, int tileRow) {
DenseMap<TileLoc, Operation *> tiles;
DenseMap<Operation *, SmallVector<BufferOp, 4>> buffers;

if (module.getOps<DeviceOp>().empty()) {
module.emitOpError("expected AIE.device operation at toplevel");
}
DeviceOp deviceOp = *(module.getOps<DeviceOp>().begin());

collectTiles(deviceOp, tiles);
::collectBuffers(deviceOp, buffers);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,16 @@
namespace mlir::iree_compiler::AMDAIE {
std::vector<uint32_t> AIETranslateToNPU(mlir::ModuleOp);

mlir::LogicalResult AIETranslateToLdScript(mlir::ModuleOp module,
mlir::LogicalResult AIETranslateToLdScript(xilinx::AIE::DeviceOp,
llvm::raw_ostream &output,
int tileCol, int tileRow);

mlir::LogicalResult AIETranslateToBCF(mlir::ModuleOp module,
mlir::LogicalResult AIETranslateToBCF(xilinx::AIE::DeviceOp,
llvm::raw_ostream &output, int tileCol,
int tileRow);

mlir::LogicalResult AIETranslateToCDODirect(
mlir::ModuleOp m, llvm::StringRef workDirPath, bool bigEndian = false,
xilinx::AIE::DeviceOp, llvm::StringRef workDirPath, bool bigEndian = false,
bool emitUnified = false, bool cdoDebug = false, bool aieSim = false,
bool enableCores = true);
} // namespace mlir::iree_compiler::AMDAIE
Expand Down
Loading

0 comments on commit efc9461

Please sign in to comment.