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

[XCLBinGen] Fix chess core elf generation #728

Merged
merged 1 commit into from
Aug 30, 2024
Merged
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
12 changes: 12 additions & 0 deletions build_tools/ci/run_matmul_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -759,6 +759,18 @@ if [ -d "$VITIS" ]; then
--num_repeat_runs "10" \
--use_ukernel "1"

run_matmul_test \
--name_prefix "chess_i32_matmul_multi_core" \
--lower_to_aie_pipeline "objectFifo" \
--tile_pipeline "pack-peel" \
--lhs_rhs_type "i32" \
--acc_type "i32" \
--m "32" \
--n "32" \
--k "32" \
--use_chess "1" \
--num_repeat_runs "10"

fi

echo "\n\n"
Expand Down
72 changes: 36 additions & 36 deletions compiler/plugins/target/AMD-AIE/iree-amd-aie/Target/XCLBinGen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -603,45 +603,46 @@ static LogicalResult generateCoreElfFiles(
chessArgs.emplace_back("-o");
chessArgs.emplace_back(elfFile.string());
std::vector<std::string> env = makeChessEnv(*vitisDir, npuVersion);
return runTool(xChessCCExe, chessArgs, verbose, env);
}
if (failed(runTool(xChessCCExe, chessArgs, verbose, env))) {
return deviceOp.emitOpError() << "failed to generate elf for core: ("
<< col << ", " << row << ")";
}
} else {
Path ldscriptPath = tempDir / (elfFileName + ".ld");
{
auto ldscriptOutput =
openOutputFile(ldscriptPath.string(), &errorMessage);
if (!ldscriptOutput) {
llvm::errs() << "Failed to open ldscript file because: "
<< errorMessage;
return failure();
}
if (failed(mlir::iree_compiler::AMDAIE::AIETranslateToLdScript(
deviceOp, ldscriptOutput->os(), col, row))) {
return failure();
}
ldscriptOutput->keep();
}

Path ldscriptPath = tempDir / (elfFileName + ".ld");
{
auto ldscriptOutput =
openOutputFile(ldscriptPath.string(), &errorMessage);
if (!ldscriptOutput) {
llvm::errs() << "Failed to open ldscript file because: "
<< errorMessage;
return failure();
std::string targetLower = StringRef(targetArch).lower();
std::vector<std::string> flags;
flags.emplace_back(objFile);
if (ukernel && (ukernel == "mm" || ukernel == "all")) {
flags.emplace_back(mmObjectFilePath->string());
}
if (failed(mlir::iree_compiler::AMDAIE::AIETranslateToLdScript(
deviceOp, ldscriptOutput->os(), col, row))) {
llvm::errs() << "failed to generate ld script for core (" << col << ","
<< row << ")\n";
flags.emplace_back("--target=" + targetLower + "-none-unknown-elf");
flags.emplace_back("-Wl,--gc-sections");
flags.emplace_back("-Wl,--orphan-handling=error");
flags.emplace_back("-Wl,-T," + ldscriptPath.string());
flags.emplace_back("-o");
flags.emplace_back(elfFile.string());
if (verbose) flags.emplace_back("-v");
// we run clang (ie cc) so that libc, libm, crt0/1 paths are injected
// automatically into the ld.lld invocation
if (failed(
runTool((peanoDir / "bin" / "clang").string(), flags, verbose))) {
return failure();
}
ldscriptOutput->keep();
}

std::string targetLower = StringRef(targetArch).lower();
std::vector<std::string> flags;
flags.emplace_back(objFile);
if (ukernel && (ukernel == "mm" || ukernel == "all")) {
flags.emplace_back(mmObjectFilePath->string());
}
flags.emplace_back("--target=" + targetLower + "-none-unknown-elf");
flags.emplace_back("-Wl,--gc-sections");
flags.emplace_back("-Wl,--orphan-handling=error");
flags.emplace_back("-Wl,-T," + ldscriptPath.string());
flags.emplace_back("-o");
flags.emplace_back(elfFile.string());
if (verbose) flags.emplace_back("-v");
// we run clang (ie cc) so that libc, libm, crt0/1 paths are injected
// automatically into the ld.lld invocation
if (failed(
runTool((peanoDir / "bin" / "clang").string(), flags, verbose))) {
return failure();
}
}
return success();
Expand Down Expand Up @@ -1149,7 +1150,6 @@ LogicalResult aie2xclbin(
const std::string &xclBinInstanceName, const std::string &amdAIEInstallDir,
const std::optional<std::string> &InputXCLBin,
const std::optional<std::string> &ukernel) {

FailureOr<ArrayRef<uint32_t>> maybeNpuInstructions =
getNpuInstructions(deviceOp);
if (failed(maybeNpuInstructions)) {
Expand Down
Loading