Skip to content

Commit

Permalink
incorporate review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
makslevental committed Jun 24, 2024
1 parent ac58e66 commit d4a34e1
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 21 deletions.
4 changes: 2 additions & 2 deletions build_tools/ci/print_ir_aie2xclbin/buffers_xclbin.mlir
Original file line number Diff line number Diff line change
Expand Up @@ -66,13 +66,13 @@
// CHECK: }
// CHECK: ],
// CHECK: "extended-data": {
// CHECK: "dpu_kernel_id": "0x101",
// CHECK: "dpu_kernel_id": "0x0",
// CHECK: "functional": "0",
// CHECK: "subtype": "DPU"
// CHECK: },
// CHECK: "instances": [
// CHECK: {
// CHECK: "name": "FOO"
// CHECK: "name": "dummy2_0"
// CHECK: }
// CHECK: ],
// CHECK: "name": "dummy2_0",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2024 The IREE Authors
// Copyright 2023 The IREE Authors
//
// Licensed under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ static xilinx::AIE::DeviceOp getDeviceOpFromEntryPoint(ModuleOp moduleOp,

class AIETargetDirectDevice final : public IREE::HAL::TargetDevice {
public:
AIETargetDirectDevice(const AMDAIEOptions &options) : options(options) {}
AIETargetDirectDevice(const AMDAIEOptions &options) {}

IREE::HAL::DeviceTargetAttr getDefaultDeviceTarget(
MLIRContext *context,
Expand All @@ -113,9 +113,6 @@ class AIETargetDirectDevice final : public IREE::HAL::TargetDevice {
b.getStringAttr("amd-aie-direct"),
configAttr, executableTargetAttrs);
}

private:
AMDAIEOptions options;
};

class AIETargetDirectBackend final : public IREE::HAL::TargetBackend {
Expand Down Expand Up @@ -186,9 +183,10 @@ class AIETargetDirectBackend final : public IREE::HAL::TargetBackend {
buildAMDAIELinkingPassPipeline(passManager);
}

LogicalResult serializeExecutable(const SerializationOptions &serOptions,
IREE::HAL::ExecutableVariantOp variantOp,
OpBuilder &executableBuilder) override;
LogicalResult serializeExecutable(
const SerializationOptions &serializationOptions,
IREE::HAL::ExecutableVariantOp variantOp,
OpBuilder &executableBuilder) override;

const AMDAIEOptions &getOptions() const { return options; }

Expand All @@ -197,20 +195,20 @@ class AIETargetDirectBackend final : public IREE::HAL::TargetBackend {
};

LogicalResult AIETargetDirectBackend::serializeExecutable(
const SerializationOptions &serOptions,
const SerializationOptions &serializationOptions,
IREE::HAL::ExecutableVariantOp variantOp, OpBuilder &executableBuilder) {
ModuleOp moduleOp = variantOp.getInnerModule();

auto basename =
llvm::join_items("_", serOptions.dumpBaseName, variantOp.getName());
auto basename = llvm::join_items("_", serializationOptions.dumpBaseName,
variantOp.getName());

auto maybeWorkDir = [&]() -> FailureOr<SmallString<128>> {
// If a path for intermediates has been specified, assume it is common for
// all executables compiling in parallel, and so create an
// executable-specific subdir to keep this executable's intermediates
// separate.
if (!serOptions.dumpIntermediatesPath.empty()) {
SmallString<128> workDir{serOptions.dumpIntermediatesPath};
if (!serializationOptions.dumpIntermediatesPath.empty()) {
SmallString<128> workDir{serializationOptions.dumpIntermediatesPath};
llvm::sys::path::append(workDir, basename);
auto ecode = llvm::sys::fs::create_directories(workDir);
if (ecode) {
Expand Down Expand Up @@ -280,7 +278,6 @@ LogicalResult AIETargetDirectBackend::serializeExecutable(
}
uint64_t ordinalCount = entryPointOrdinals.size();

std::vector<uint32_t> npuInstrs;
std::unique_ptr<llvm::MemoryBuffer> xclbinIn;

FlatbufferBuilder builder;
Expand Down Expand Up @@ -336,8 +333,12 @@ LogicalResult AIETargetDirectBackend::serializeExecutable(
TK.TempDir = entryPointWorkDir.str();
TK.UseChess = options.useChess;
TK.Verbose = options.showInvokedCommands;
TK.XCLBinInstanceName = "FOO";
TK.XCLBinKernelID = "0x101";
TK.XCLBinInstanceName = entryPointNamesFb[ordinal];

// Convert ordinal to hexadecimal string for xclbin kernel id.
std::stringstream ordinalHex;
ordinalHex << "0x" << std::hex << ordinal;
TK.XCLBinKernelID = ordinalHex.str();
TK.XCLBinKernelName = entryPointNamesFb[ordinal];

SmallString<64> aieToolsDir(options.vitisInstallDir);
Expand All @@ -350,6 +351,7 @@ LogicalResult AIETargetDirectBackend::serializeExecutable(
xclbinPath)))
return failure();

std::vector<uint32_t> npuInstrs;
std::ifstream instrFile(static_cast<std::string>(npuInstPath));
std::string line;
while (std::getline(instrFile, line)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,4 @@ mlir::LogicalResult aie2xclbin(mlir::MLIRContext *ctx, mlir::ModuleOp moduleOp,
mlir::StringRef OutputXCLBin,
mlir::StringRef InputXCLBin = "");

} // namespace xilinx
} // namespace xilinx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2024 The IREE Authors
// Copyright 2023 The IREE Authors
//
// Licensed under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2024 The IREE Authors
// Copyright 2023 The IREE Authors
//
// Licensed under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
Expand Down

0 comments on commit d4a34e1

Please sign in to comment.