Force binary programs rebuild with debug variable RebuildPrecompiledKernels

Related-To: NEO-1865

Change-Id: Ib20e3ae3d7a40c61a52803049576bbd3ddac3b76
Signed-off-by: Pawel Wilma <pawel.wilma@intel.com>
This commit is contained in:
Pawel Wilma
2019-05-28 10:54:53 +02:00
committed by sys_ocldev
parent 17f9cc006d
commit fc02d57f65
3 changed files with 77 additions and 3 deletions

View File

@@ -2944,3 +2944,72 @@ TEST_F(ProgramTests, givenProgramWhenBuiltThenAdditionalOptionsAreApplied) {
program.build(1, &device, nullptr, nullptr, nullptr, false);
EXPECT_EQ(1u, program.applyAdditionalOptionsCalled);
}
struct RebuildProgram : public Program {
using Program::createProgramFromBinary;
RebuildProgram(ExecutionEnvironment &executionEnvironment, Context *context, bool isBuiltIn = false) : Program(executionEnvironment, context, isBuiltIn) {}
cl_int rebuildProgramFromIr() override {
rebuildProgramFromIrCalled = true;
return CL_SUCCESS;
}
cl_int processElfBinary(const void *pBinary, size_t binarySize, uint32_t &binaryVersion) override {
processElfBinaryCalled = true;
return CL_SUCCESS;
}
bool rebuildProgramFromIrCalled = false;
bool processElfBinaryCalled = false;
};
TEST(RebuildProgramFromIrTests, givenBinaryProgramWhenKernelRebulildIsForcedThenRebuildProgramFromIrCalled) {
DebugManagerStateRestore dbgRestorer;
DebugManager.flags.RebuildPrecompiledKernels.set(true);
cl_int retVal = CL_INVALID_BINARY;
SProgramBinaryHeader binHeader;
memset(&binHeader, 0, sizeof(binHeader));
binHeader.Magic = iOpenCL::MAGIC_CL;
binHeader.Version = iOpenCL::CURRENT_ICBE_VERSION;
binHeader.Device = platformDevices[0]->platform.eRenderCoreFamily;
binHeader.GPUPointerSizeInBytes = 8;
binHeader.NumberOfKernels = 0;
binHeader.SteppingId = 0;
binHeader.PatchListSize = 0;
size_t binSize = sizeof(SProgramBinaryHeader);
ExecutionEnvironment executionEnvironment;
std::unique_ptr<RebuildProgram> pProgram(RebuildProgram::createFromGenBinary<RebuildProgram>(executionEnvironment, nullptr, &binHeader, binSize, false, &retVal));
ASSERT_NE(nullptr, pProgram.get());
EXPECT_EQ(CL_SUCCESS, retVal);
binHeader.Version = iOpenCL::CURRENT_ICBE_VERSION;
retVal = pProgram->createProgramFromBinary(&binHeader, binSize);
EXPECT_EQ(CL_SUCCESS, retVal);
EXPECT_TRUE(pProgram->processElfBinaryCalled);
EXPECT_TRUE(pProgram->rebuildProgramFromIrCalled);
}
TEST(RebuildProgramFromIrTests, givenBinaryProgramWhenKernelRebulildIsNotForcedThenRebuildProgramFromIrNotCalled) {
cl_int retVal = CL_INVALID_BINARY;
SProgramBinaryHeader binHeader;
memset(&binHeader, 0, sizeof(binHeader));
binHeader.Magic = iOpenCL::MAGIC_CL;
binHeader.Version = iOpenCL::CURRENT_ICBE_VERSION;
binHeader.Device = platformDevices[0]->platform.eRenderCoreFamily;
binHeader.GPUPointerSizeInBytes = 8;
binHeader.NumberOfKernels = 0;
binHeader.SteppingId = 0;
binHeader.PatchListSize = 0;
size_t binSize = sizeof(SProgramBinaryHeader);
ExecutionEnvironment executionEnvironment;
std::unique_ptr<RebuildProgram> pProgram(RebuildProgram::createFromGenBinary<RebuildProgram>(executionEnvironment, nullptr, &binHeader, binSize, false, &retVal));
ASSERT_NE(nullptr, pProgram.get());
EXPECT_EQ(CL_SUCCESS, retVal);
binHeader.Version = iOpenCL::CURRENT_ICBE_VERSION;
retVal = pProgram->createProgramFromBinary(&binHeader, binSize);
EXPECT_EQ(CL_SUCCESS, retVal);
EXPECT_TRUE(pProgram->processElfBinaryCalled);
EXPECT_FALSE(pProgram->rebuildProgramFromIrCalled);
}