feat(zebin): add support for build options section

This change:
* Adds support for build options section in zebinary - using
build options in binary when rebuilding.
* Appends "-cl-intel-allow-zebin" flag to build options when zebin is
used.

Resolves: NEO-6916

Signed-off-by: Krystian Chmielewski <krystian.chmielewski@intel.com>
This commit is contained in:
Krystian Chmielewski
2022-04-25 12:12:15 +00:00
committed by Compute-Runtime-Automation
parent 0d82216f43
commit e007ba499f
10 changed files with 159 additions and 15 deletions

View File

@ -180,6 +180,9 @@ cl_int Program::createProgramFromBinary(
this->irBinarySize = singleDeviceBinary.intermediateRepresentation.size();
this->isSpirV = NEO::isSpirVBitcode(ArrayRef<const uint8_t>(reinterpret_cast<const uint8_t *>(this->irBinary.get()), this->irBinarySize));
this->options = singleDeviceBinary.buildOptions.str();
if (singleDeviceBinary.format == NEO::DeviceBinaryFormat::Zebin) {
this->options += " " + NEO::CompilerOptions::allowZebin.str();
}
if (false == singleDeviceBinary.debugData.empty()) {
this->buildInfos[rootDeviceIndex].debugData = makeCopy(reinterpret_cast<const char *>(singleDeviceBinary.debugData.begin()), singleDeviceBinary.debugData.size());

View File

@ -1984,6 +1984,23 @@ kernels:
}
}
TEST_F(ProgramTests, whenCreatingFromZebinThenAppendAllowZebinFlagToBuildOptions) {
if (sizeof(void *) != 8U) {
GTEST_SKIP();
}
ZebinTestData::ValidEmptyProgram zebin;
zebin.elfHeader->machine = defaultHwInfo->platform.eProductFamily;
auto device = std::make_unique<MockClDevice>(MockDevice::createWithNewExecutionEnvironment<MockDevice>(nullptr, mockRootDeviceIndex));
auto program = std::make_unique<MockProgram>(toClDeviceVector(*device));
cl_int retVal = program->createProgramFromBinary(zebin.storage.data(), zebin.storage.size(), *device);
EXPECT_EQ(CL_SUCCESS, retVal);
auto expectedOptions = " " + NEO::CompilerOptions::allowZebin.str();
EXPECT_STREQ(expectedOptions.c_str(), program->options.c_str());
}
TEST_F(ProgramTests, givenProgramFromGenBinaryWhenSLMSizeIsBiggerThenDeviceLimitThenReturnError) {
PatchTokensTestData::ValidProgramWithKernelUsingSlm patchtokensProgram;
patchtokensProgram.slmMutable->TotalInlineLocalMemorySize = static_cast<uint32_t>(pDevice->getDeviceInfo().localMemSize * 2);