Add support for exclusion of IR from binary generated by ocloc

Itroduces new parameter "-exclude_ir" to ocloc CLI.
This parameter can be used to reduce output binary size
when IR is not needed.

Related-To: NEO-6477

Signed-off-by: Patryk Wrobel <patryk.wrobel@intel.com>
This commit is contained in:
Patryk Wrobel
2021-12-08 13:40:26 +00:00
committed by Compute-Runtime-Automation
parent 2fd536104d
commit c324279bf5
3 changed files with 68 additions and 1 deletions

View File

@@ -667,6 +667,8 @@ int OfflineCompiler::parseCommandLine(size_t numArgs, const std::vector<std::str
} else if (("-revision_id" == currArg) && hasMoreArgs) {
revisionId = std::stoi(argv[argIndex + 1], nullptr, 0);
argIndex++;
} else if ("-exclude_ir" == currArg) {
excludeIr = true;
} else {
argHelper->printf("Invalid option (arg %d): %s\n", argIndex, argv[argIndex].c_str());
retVal = INVALID_COMMAND_LINE;
@@ -946,6 +948,8 @@ Usage: ocloc [compile] -file <filename> -device <device_type> [-output <filename
-revision_id <revision_id> Target stepping. Can be decimal or hexadecimal value.
-exclude_ir Excludes IR from the output binary file.
Examples :
Compile file to Intel Compute GPU device binary (out = source_file_Gen9core.bin)
ocloc -file source_file.cl -device skl
@@ -997,7 +1001,7 @@ bool OfflineCompiler::generateElfBinary() {
ArrayRef<const uint8_t>(reinterpret_cast<const uint8_t *>(binary.buildOptions.data()), binary.buildOptions.size()));
}
if (binary.intermediateRepresentation.empty() == false) {
if (!binary.intermediateRepresentation.empty() && !excludeIr) {
if (isSpirV) {
ElfEncoder.appendSection(SHT_OPENCL_SPIRV, SectionNamesOpenCl::spirvObject, binary.intermediateRepresentation);
} else {

View File

@@ -139,6 +139,7 @@ class OfflineCompiler {
bool forceStatelessToStatefulOptimization = false;
bool isSpirV = false;
bool showHelp = false;
bool excludeIr = false;
std::vector<uint8_t> elfBinary;
char *genBinary = nullptr;