Skip to content

Commit 44589b7

Browse files
jchodorCompute-Runtime-Automation
authored andcommitted
Fix for spirv regression - preserve IR type
Preserve IR type during Program::compile when program is created from IR Change-Id: I9ee12b27e52fa72a1abbfa070895caf0ac3e32fb
1 parent 2561ff6 commit 44589b7

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

runtime/compiler_interface/compiler_interface.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ cl_int CompilerInterface::compile(
222222
char *pOutput;
223223
uint32_t OutputSize;
224224
program.getSource(pOutput, OutputSize);
225-
program.storeIrBinary(pOutput, OutputSize, outType == IGC::CodeType::spirV);
225+
program.storeIrBinary(pOutput, OutputSize, program.getIsSpirV());
226226
}
227227
}
228228

unit_tests/compiler_interface/compiler_interface_tests.cpp

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -288,6 +288,26 @@ TEST_F(CompilerInterfaceTest, CompileClToIr) {
288288
gEnvironment->fclPopDebugVars();
289289
}
290290

291+
TEST_F(CompilerInterfaceTest, GivenProgramCreatedFromIrWhenCompileIsCalledThenIrFormatIsPreserved) {
292+
struct MockProgram : Program {
293+
using Program::isSpirV;
294+
using Program::pDevice;
295+
using Program::programBinaryType;
296+
};
297+
MockProgram prog;
298+
prog.programBinaryType = CL_PROGRAM_BINARY_TYPE_INTERMEDIATE;
299+
prog.pDevice = pContext->getDevice(0);
300+
prog.isSpirV = true;
301+
retVal = pCompilerInterface->compile(prog, inputArgs);
302+
EXPECT_EQ(CL_SUCCESS, retVal);
303+
EXPECT_TRUE(prog.isSpirV);
304+
305+
prog.isSpirV = false;
306+
retVal = pCompilerInterface->compile(prog, inputArgs);
307+
EXPECT_EQ(CL_SUCCESS, retVal);
308+
EXPECT_FALSE(prog.isSpirV);
309+
}
310+
291311
TEST_F(CompilerInterfaceTest, WhenCompileIsInvokedThenFclReceivesListOfExtensionsInInternalOptions) {
292312
std::string receivedInternalOptions;
293313

0 commit comments

Comments
 (0)