Skip to content

Commit

Permalink
Do not run pathfinder pass twice (#726)
Browse files Browse the repository at this point in the history
Also in PR: remove an empty pass manager
  • Loading branch information
newling authored Aug 30, 2024
1 parent 9c4c167 commit e16dd26
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
#include "mlir/IR/IRMapping.h"
#include "mlir/IR/PatternMatch.h"
#include "mlir/Pass/Pass.h"
#include "mlir/Tools/mlir-translate/MlirTranslateMain.h"
#include "mlir/Transforms/DialectConversion.h"

#define DEBUG_TYPE "amdaie-standard-lowering"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -648,29 +648,14 @@ static LogicalResult generateCoreElfFiles(
}

static LogicalResult generateCDO(MLIRContext *context, AIE::DeviceOp deviceOp,
bool printIRBeforeAll, bool printIRAfterAll,
bool printIRModuleScope, bool timing,
const Path &tempDir) {
auto copy = cast<ModuleOp>(deviceOp.getParentOp()->clone());
deviceOp = *copy.getOps<AIE::DeviceOp>().begin();
std::string errorMessage;
PassManager passManager(context, AIE::DeviceOp::getOperationName());
applyConfigToPassManager(passManager, printIRBeforeAll, printIRAfterAll,
printIRModuleScope, timing);
passManager.addPass(
mlir::iree_compiler::AMDAIE::createAMDAIEPathfinderPass());

if (failed(passManager.run(deviceOp))) {
llvm::errs() << "failed to run passes to prepare for XCLBin generation";
return failure();
}

if (failed(mlir::iree_compiler::AMDAIE::AIETranslateToCDODirect(
deviceOp, tempDir.string()))) {
llvm::errs() << "failed to emit CDO";
return failure();
}

copy->erase();
return success();
}
Expand Down Expand Up @@ -1164,13 +1149,6 @@ LogicalResult aie2xclbin(
const std::string &xclBinInstanceName, const std::string &amdAIEInstallDir,
const std::optional<std::string> &InputXCLBin,
const std::optional<std::string> &ukernel) {
PassManager pm(ctx, AIE::DeviceOp::getOperationName());
applyConfigToPassManager(pm, printIRBeforeAll, printIRAfterAll,
printIRModuleScope, timing);
if (failed(pm.run(deviceOp))) {
llvm::errs() << ": NPU Instruction pipeline failed";
return failure();
}

FailureOr<ArrayRef<uint32_t>> maybeNpuInstructions =
getNpuInstructions(deviceOp);
Expand Down Expand Up @@ -1213,8 +1191,7 @@ LogicalResult aie2xclbin(
return failure();
}

if (failed(generateCDO(ctx, deviceOp, printIRBeforeAll, printIRAfterAll,
printIRModuleScope, timing, tempDirPath))) {
if (failed(generateCDO(ctx, deviceOp, tempDirPath))) {
llvm::errs() << "Failed to generate CDO\n";
return failure();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -824,6 +824,7 @@ void addMLIRAIELoweringPasses(OpPassManager &passManager) {
devicePM.addPass(createAMDAIENormalizeAddressSpacesPass());
devicePM.addPass(createCanonicalizerPass());
}

}

// NOTE: this runs on the top-level program module containing all hal.executable
Expand Down

0 comments on commit e16dd26

Please sign in to comment.