Fixing regression in rebuildFromIr

Change-Id: If1604861180d935575cd06fb2978df114453a070
This commit is contained in:
Jaroslaw Chodor
2019-11-02 13:09:17 +01:00
parent ddd1bd21a3
commit cab8968e1a
5 changed files with 49 additions and 13 deletions

View File

@@ -11,15 +11,15 @@
#include "unit_tests/mocks/mock_program.h"
namespace NEO {
void ProgramFixture::CreateProgramWithSource(cl_context pContext,
cl_device_id *pDeviceList,
const std::string &SourceFileName) {
void ProgramFixture::CreateProgramWithSource(cl_context context,
cl_device_id *deviceList,
const std::string &sourceFileName) {
Cleanup();
cl_int retVal = CL_SUCCESS;
std::string testFile;
testFile.append(clFiles);
testFile.append(SourceFileName);
testFile.append(sourceFileName);
ASSERT_EQ(true, fileExists(testFile));
knownSource = loadDataFromFile(
@@ -31,7 +31,7 @@ void ProgramFixture::CreateProgramWithSource(cl_context pContext,
const char *sources[1] = {knownSource.get()};
pProgram = Program::create<MockProgram>(
pContext,
context,
1,
sources,
&knownSourceSize,

View File

@@ -2975,6 +2975,35 @@ TEST_F(ProgramTests, givenProgramWithSpirvWhenRebuildProgramIsCalledThenSpirvPat
EXPECT_EQ(0, memcmp(spirv, spvSectionData, spvSectionDataSize));
}
TEST_F(ProgramTests, whenRebuildingProgramThenStoreDeviceBinaryProperly) {
auto device = castToObject<Device>(pContext->getDevice(0));
auto compilerInterface = new MockCompilerInterface();
pDevice->getExecutionEnvironment()->compilerInterface.reset(compilerInterface);
auto compilerMain = new MockCIFMain();
compilerInterface->SetIgcMain(compilerMain);
compilerMain->setDefaultCreatorFunc<NEO::MockIgcOclDeviceCtx>(NEO::MockIgcOclDeviceCtx::Create);
MockCompilerDebugVars debugVars = {};
char binaryToReturn[] = "abcdfghijklmnop";
debugVars.binaryToReturn = binaryToReturn;
debugVars.binaryToReturnSize = sizeof(binaryToReturn);
gEnvironment->igcPushDebugVars(debugVars);
std::unique_ptr<void, void (*)(void *)> igcDebugVarsAutoPop{&gEnvironment, [](void *) { gEnvironment->igcPopDebugVars(); }};
auto program = clUniquePtr(new MockProgram(*pDevice->getExecutionEnvironment()));
program->setDevice(device);
uint32_t ir[16] = {0x03022307, 0x23471113, 0x17192329};
program->irBinary = makeCopy(ir, sizeof(ir));
program->irBinarySize = sizeof(ir);
EXPECT_EQ(nullptr, program->genBinary);
EXPECT_EQ(0U, program->genBinarySize);
program->rebuildProgramFromIr();
ASSERT_NE(nullptr, program->genBinary);
ASSERT_EQ(sizeof(binaryToReturn), program->genBinarySize);
EXPECT_EQ(0, memcmp(binaryToReturn, program->genBinary.get(), program->genBinarySize));
}
TEST_F(ProgramTests, givenProgramWhenInternalOptionsArePassedThenTheyAreRemovedFromBuildOptions) {
ExecutionEnvironment executionEnvironment;
MockProgram pProgram(executionEnvironment);