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

2
Jenkinsfile vendored
View File

@ -1,5 +1,5 @@
#!groovy
dependenciesRevision='682c4e3d433c6796acebfcbc8f0e2a5135f58412-1330'
strategy='EQUAL'
allowedCD=259
allowedCD=258
allowedF=7

View File

@ -693,7 +693,7 @@ struct LockListener {
: device(device) {
}
static void Listener(MockCompilerInterface &compInt) {
static void listener(MockCompilerInterface &compInt) {
auto data = (LockListener *)compInt.lockListenerData;
auto deviceCtx = CIF::RAII::UPtr(new MockDeviceCtx);
EXPECT_TRUE(compInt.getDeviceContexts<DeviceCtx>().empty());
@ -733,7 +733,7 @@ TEST_F(CompilerInterfaceTest, GivenSimultaneousRequestForNewFclTranslationContex
using ListenerT = LockListener<IGC::FclOclDeviceCtxTagOCL, MockFclOclDeviceCtx>;
ListenerT listenerData(device);
this->pCompilerInterface->lockListenerData = &listenerData;
this->pCompilerInterface->lockListener = ListenerT::Listener;
this->pCompilerInterface->lockListener = ListenerT::listener;
auto ret = this->pCompilerInterface->createFclTranslationCtx(*device, IGC::CodeType::oclC, IGC::CodeType::spirV);
EXPECT_NE(nullptr, ret.get());
@ -790,7 +790,7 @@ TEST_F(CompilerInterfaceTest, GivenSimultaneousRequestForNewIgcTranslationContex
using ListenerT = LockListener<IGC::IgcOclDeviceCtxTagOCL, MockIgcOclDeviceCtx>;
ListenerT listenerData{device};
this->pCompilerInterface->lockListenerData = &listenerData;
this->pCompilerInterface->lockListener = ListenerT::Listener;
this->pCompilerInterface->lockListener = ListenerT::listener;
auto ret = this->pCompilerInterface->createIgcTranslationCtx(*device, IGC::CodeType::spirV, IGC::CodeType::oclGenBin);
EXPECT_NE(nullptr, ret.get());
@ -900,7 +900,7 @@ TEST_F(CompilerInterfaceTest, IsCompilerAvailable) {
EXPECT_TRUE(this->pCompilerInterface->isCompilerAvailable(IGC::CodeType::llvmLl, IGC::CodeType::oclGenBin));
EXPECT_TRUE(this->pCompilerInterface->isCompilerAvailable(IGC::CodeType::elf, IGC::CodeType::llvmBc));
EXPECT_TRUE(this->pCompilerInterface->isCompilerAvailable(IGC::CodeType::elf, IGC::CodeType::oclGenBin));
this->pCompilerInterface->fclMain = std::move(befIgcImain);
this->pCompilerInterface->fclMain = std::move(befFclImain);
befIgcImain = std::move(this->pCompilerInterface->igcMain);
befFclImain = std::move(this->pCompilerInterface->fclMain);
@ -916,7 +916,7 @@ TEST_F(CompilerInterfaceTest, IsCompilerAvailable) {
EXPECT_FALSE(this->pCompilerInterface->isCompilerAvailable(IGC::CodeType::elf, IGC::CodeType::llvmBc));
EXPECT_FALSE(this->pCompilerInterface->isCompilerAvailable(IGC::CodeType::elf, IGC::CodeType::oclGenBin));
this->pCompilerInterface->igcMain = std::move(befIgcImain);
this->pCompilerInterface->fclMain = std::move(befIgcImain);
this->pCompilerInterface->fclMain = std::move(befFclImain);
}
TEST_F(CompilerInterfaceTest, whenCompilerIsNotAvailableThenGetSipKernelBinaryFailsGracefully) {

View File

@ -188,12 +188,19 @@ cl_int Program::rebuildProgramFromIr() {
inputArgs.apiOptions = ArrayRef<const char>(options);
inputArgs.internalOptions = ArrayRef<const char>(internalOptions);
TranslationOutput output = {};
auto err = pCompilerInterface->link(*this->pDevice, inputArgs, output);
TranslationOutput compilerOuput = {};
auto err = pCompilerInterface->link(*this->pDevice, inputArgs, compilerOuput);
this->updateBuildLog(this->pDevice, compilerOuput.frontendCompilerLog.c_str(), compilerOuput.frontendCompilerLog.size());
this->updateBuildLog(this->pDevice, compilerOuput.backendCompilerLog.c_str(), compilerOuput.backendCompilerLog.size());
if (TranslationOutput::ErrorCode::Success != err) {
return asClError(err);
}
this->genBinary = std::move(compilerOuput.deviceBinary.mem);
this->genBinarySize = compilerOuput.deviceBinary.size;
this->debugData = std::move(compilerOuput.debugData.mem);
this->debugDataSize = compilerOuput.debugData.size;
auto retVal = processGenBinary();
if (retVal != CL_SUCCESS) {
return retVal;

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);