Skip to content

Commit 22d596c

Browse files
PatrykWrobelDevigcbot
authored andcommitted
Add support for exclusion of IR from zebin output
This change introduces the new internal option: -exclude-ir-from-zebin, as well as the new entry in register of flags: ExcludeIRFromZEBinary. The purpose of this option is to exclude SPIR-V section from files generated in ZEBIN format.
1 parent 143b1e2 commit 22d596c

File tree

6 files changed

+13
-1
lines changed

6 files changed

+13
-1
lines changed

IGC/AdaptorOCL/UnifyIROCL.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,9 @@ static void CommonOCLBasedPasses(
273273
CompilerOpts.EnableZEBinary =
274274
pContext->m_InternalOptions.EnableZEBinary;
275275

276+
CompilerOpts.ExcludeIRFromZEBinary =
277+
pContext->m_InternalOptions.ExcludeIRFromZEBinary;
278+
276279
IGCPassManager mpmSPIR(pContext, "Unify");
277280
#ifdef IGC_SCALAR_USE_KHRONOS_SPIRV_TRANSLATOR
278281
mpmSPIR.add(new PreprocessSPVIR());

IGC/AdaptorOCL/dllInterfaceCompute.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1294,9 +1294,10 @@ bool TranslateBuildSPMD(const STB_TranslateInputArgs *pInputArgs,
12941294
// ze binary foramt
12951295
llvm::SmallVector<char, 64> buf;
12961296
llvm::raw_svector_ostream llvm_os(buf);
1297+
const bool excludeIRFromZEBinary = IGC_IS_FLAG_ENABLED(ExcludeIRFromZEBinary) || oclContext.getModuleMetaData()->compOpt.ExcludeIRFromZEBinary;
12971298
const char* spv_data = nullptr;
12981299
uint32_t spv_size = 0;
1299-
if (inputDataFormatTemp == TB_DATA_FORMAT_SPIR_V) {
1300+
if (inputDataFormatTemp == TB_DATA_FORMAT_SPIR_V && !excludeIRFromZEBinary) {
13001301
spv_data = pInputArgs->pInput;
13011302
spv_size = pInputArgs->InputSize;
13021303
}

IGC/Compiler/CodeGenContext.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -838,6 +838,11 @@ namespace IGC
838838
{
839839
EnableZEBinary = true;
840840
}
841+
// -cl-intel-exclude-ir-from-zebin
842+
else if (suffix.equals("-exclude-ir-from-zebin"))
843+
{
844+
ExcludeIRFromZEBinary = true;
845+
}
841846
// -cl-intel-no-spill
842847
else if (suffix.equals("-no-spill"))
843848
{

IGC/Compiler/CodeGenPublic.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1340,6 +1340,7 @@ namespace IGC
13401340
bool UseBindlessPrintf = false;
13411341
bool UseBindlessLegacyMode = true;
13421342
bool EnableZEBinary = false;
1343+
bool ExcludeIRFromZEBinary = false;
13431344
bool NoSpill = false;
13441345
bool DisableNoMaskWA = false;
13451346
bool IgnoreBFRounding = false; // If true, ignore BFloat rounding when folding bf operations

IGC/common/MDFrameWork.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -287,6 +287,7 @@ namespace IGC
287287
// patch-token based binary if the input contains features those
288288
// are not supported by ZEBinary
289289
bool EnableZEBinary = false;
290+
bool ExcludeIRFromZEBinary = false;
290291
};
291292

292293
enum class ThreadIDLayout

IGC/common/igc_flags.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -506,6 +506,7 @@ DECLARE_IGC_REGKEY(bool, HybridRAWithSpill, false, "Did Hybrid RA with Spill", f
506506
DECLARE_IGC_REGKEY(bool, StripDebugInfo, false, "Strip debug info from llvm IR lowered from input to IGC", false)
507507
DECLARE_IGC_REGKEY(bool, EmitPreDefinedForAllFunctions, false, "When enabled, pre-defined variables for gid, grid, lid are emitted for all functions. This causes those functions to be inlined even when stack calls is enabled.", true)
508508
DECLARE_IGC_REGKEY(bool, EnableZEBinary, false, "Enable output in ZE binary format", true)
509+
DECLARE_IGC_REGKEY(bool, ExcludeIRFromZEBinary, false, "Exclude IR sections from ZE binary", true)
509510
DECLARE_IGC_REGKEY(bool, AllocateZeroInitializedVarsInBss, false, "Allocate zero initialized global variables in .bss section in ZEBinary", true)
510511
DECLARE_IGC_REGKEY(DWORD, OverrideOCLMaxParamSize, 0, "Override the value imposed on the kernel by CL_DEVICE_MAX_PARAMETER_SIZE. Value in bytes, if value==0 no override happens.", true)
511512

0 commit comments

Comments
 (0)