Skip to content

Commit

Permalink
Fixes for aie2xclbin on Windows (#1129)
Browse files Browse the repository at this point in the history
This deals with some issues that appear when you try to run the windows build of aie2xclbin. Some of these are workarounds for problems with the peano build on windows that ought to get removed later.
  • Loading branch information
erieaton-amd authored Mar 15, 2024
1 parent 90397ad commit fed78cd
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 3 deletions.
2 changes: 1 addition & 1 deletion runtime_lib/xaiengine/aie-rt
14 changes: 13 additions & 1 deletion tools/aie2xclbin/XCLBinGen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -299,17 +299,25 @@ static LogicalResult generateCoreElfFiles(ModuleOp moduleOp,
std::string targetLower = StringRef(TK.TargetArch).lower();
SmallVector<std::string, 10> flags;
flags.push_back("-O2");
#ifdef _WIN32
// TODO: Windows tries to load the wrong builtins path.
std::string targetFlag = "--target=" + targetLower;
#else
std::string targetFlag = "--target=" + targetLower + "-none-elf";
#endif
flags.push_back(targetFlag);
flags.emplace_back(objFile);
SmallString<64> meBasicPath(TK.InstallDir);
sys::path::append(meBasicPath, "aie_runtime_lib", TK.TargetArch,
"me_basic.o");
flags.emplace_back(meBasicPath);
#ifndef _WIN32
// TODO: No libc build on windows
SmallString<64> libcPath(TK.PeanoDir);
sys::path::append(libcPath, "lib", targetLower + "-none-unknown-elf",
"libc.a");
flags.emplace_back(libcPath);
#endif
flags.push_back("-Wl,--gc-sections");
std::string ldScriptFlag = "-Wl,-T," + std::string(ldscript_path);
flags.push_back(ldScriptFlag);
Expand Down Expand Up @@ -619,6 +627,10 @@ struct RemoveAlignment2FromLLVMLoadPass
}
});
}

public:
MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(
RemoveAlignment2FromLLVMLoadPass);
};
} // namespace

Expand Down Expand Up @@ -785,7 +797,7 @@ static LogicalResult generateUnifiedObject(MLIRContext *context,
sys::path::append(OptLLVMIRFile, "input.opt.ll");
if (runTool(peanoOptBin,
{"-O2", "--inline-threshold=10", "-S", std::string(LLVMIRFile),
"-o", std::string(OptLLVMIRFile)},
"--disable-builtin=memset", "-o", std::string(OptLLVMIRFile)},
TK.Verbose) != 0)
return moduleOp.emitOpError("Failed to optimize");

Expand Down
3 changes: 2 additions & 1 deletion tools/aie2xclbin/aie2xclbin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,8 @@ int main(int argc, char *argv[]) {
TK.PrintIRBeforeAll = PrintIRBeforeAll;
TK.PrintIRModuleScope = PrintIRModuleScope;

findVitis(TK);
if (TK.UseChess)
findVitis(TK);

if (Verbose)
llvm::dbgs() << "\nCompiling " << FileName << "\n";
Expand Down

0 comments on commit fed78cd

Please sign in to comment.