fix: ocloc fatbinary handle -out_dir without -output

Currently if we pass `-out_dir` in ocloc fatbinary cmdline, e.g.:
./ocloc compile -file vector.cl ... -out_dir ../exampler_dir
ocloc sets the name for the output file from the `-output` parameter.
But as the `-output` parameter is not provided,
the file name will be empty and won't be written to disk.

This patch adds support for a scenario
where you pass `-out_dir` without `-output`.
In this case, the file will have default name - input file's base name.

Related-To: NEO-10603
Signed-off-by: Fabian Zwolinski <fabian.zwolinski@intel.com>
This commit is contained in:
Fabian Zwolinski
2024-04-15 13:11:36 +00:00
committed by Compute-Runtime-Automation
parent b3b72d0e37
commit e7420de011
2 changed files with 83 additions and 5 deletions

View File

@@ -401,13 +401,21 @@ int buildFatBinary(const std::vector<std::string> &args, OclocArgHelper *argHelp
}
auto fatbinaryData = fatbinary.encode();
std::string fatbinaryFileName = outputFileName;
if (outputFileName.empty() && (false == inputFileName.empty())) {
fatbinaryFileName = OfflineCompiler::getFileNameTrunk(inputFileName) + ".ar";
}
std::string fatbinaryFileName = "";
if (false == outputDirectory.empty()) {
fatbinaryFileName = outputDirectory + "/" + outputFileName;
fatbinaryFileName = outputDirectory + "/";
}
if (false == outputFileName.empty()) {
fatbinaryFileName += outputFileName;
} else {
if (false == inputFileName.empty()) {
fatbinaryFileName += OfflineCompiler::getFileNameTrunk(inputFileName) + ".ar";
}
}
argHelper->saveOutput(fatbinaryFileName, fatbinaryData.data(), fatbinaryData.size());
return 0;