mirror of
https://github.com/intel/compute-runtime.git
synced 2025-09-15 13:01:45 +08:00
Reuse old build options if new ones are NULL
Change-Id: I435e7ec8554b0429dcf4f6f8d9d4fd80e70b68c6
This commit is contained in:

committed by
sys_ocldev

parent
cd85bcffdb
commit
746cf7fd33
@ -68,7 +68,9 @@ bool ModuleTranslationUnit::buildFromSpirV(const char *input, uint32_t inputSize
|
||||
UNRECOVERABLE_IF(nullptr == compilerInterface);
|
||||
UNRECOVERABLE_IF((nullptr == device) || (nullptr == device->getNEODevice()));
|
||||
|
||||
std::string options = buildOptions;
|
||||
if (nullptr != buildOptions) {
|
||||
options = buildOptions;
|
||||
}
|
||||
std::string internalOptions = NEO::CompilerOptions::concatenate(internalBuildOptions, BuildOptions::hasBufferOffsetArg);
|
||||
|
||||
if (device->getNEODevice()->getDeviceInfo().debuggerActive) {
|
||||
|
@ -491,6 +491,26 @@ HWTEST_F(ModuleTranslationUnitTest, WhenCreatingFromNativeBinaryThenSetsUpRequir
|
||||
EXPECT_FALSE(success);
|
||||
}
|
||||
|
||||
HWTEST_F(ModuleTranslationUnitTest, WhenBuildOptionsAreNullThenReuseExistingOptions) {
|
||||
struct MockCompilerInterface : CompilerInterface {
|
||||
TranslationOutput::ErrorCode build(const NEO::Device &device,
|
||||
const TranslationInput &input,
|
||||
TranslationOutput &output) override {
|
||||
receivedApiOptions = input.apiOptions.begin();
|
||||
return TranslationOutput::ErrorCode::BuildFailure;
|
||||
}
|
||||
std::string receivedApiOptions;
|
||||
} mockCompilerInterface;
|
||||
|
||||
L0::ModuleTranslationUnit moduleTu(this->device);
|
||||
moduleTu.options = "abcd";
|
||||
this->neoDevice->mockCompilerInterface = &mockCompilerInterface;
|
||||
auto ret = moduleTu.buildFromSpirV("", 0U, nullptr, "", nullptr);
|
||||
EXPECT_FALSE(ret);
|
||||
EXPECT_STREQ("abcd", moduleTu.options.c_str());
|
||||
EXPECT_STREQ("abcd", mockCompilerInterface.receivedApiOptions.c_str());
|
||||
}
|
||||
|
||||
TEST(BuildOptions, givenNoSrcOptionNameInSrcNamesWhenMovingBuildOptionsThenFalseIsReturned) {
|
||||
std::string srcNames = NEO::CompilerOptions::concatenate(NEO::CompilerOptions::fastRelaxedMath, NEO::CompilerOptions::finiteMathOnly);
|
||||
std::string dstNames;
|
||||
|
@ -66,7 +66,9 @@ cl_int Program::build(
|
||||
if (isCreatedFromBinary == false) {
|
||||
buildStatus = CL_BUILD_IN_PROGRESS;
|
||||
|
||||
options = (buildOptions) ? buildOptions : "";
|
||||
if (nullptr != buildOptions) {
|
||||
options = buildOptions;
|
||||
}
|
||||
extractInternalOptions(options);
|
||||
applyAdditionalOptions();
|
||||
|
||||
|
@ -970,8 +970,17 @@ TEST_P(ProgramFromSourceTest, GivenDifferentCommpilerOptionsWhenBuildingProgramT
|
||||
auto hash4 = pProgram->getCachedFileName();
|
||||
auto kernel4 = pProgram->getKernelInfo("CopyBuffer");
|
||||
EXPECT_NE(nullptr, kernel4);
|
||||
EXPECT_EQ(hash1, hash4);
|
||||
EXPECT_EQ(hash3, hash4);
|
||||
Callback::unwatch(kernel3);
|
||||
Callback::watch(kernel4);
|
||||
|
||||
retVal = pProgram->build(0, nullptr, "", nullptr, nullptr, true);
|
||||
EXPECT_EQ(CL_SUCCESS, retVal);
|
||||
auto hash5 = pProgram->getCachedFileName();
|
||||
auto kernel5 = pProgram->getKernelInfo("CopyBuffer");
|
||||
EXPECT_NE(nullptr, kernel5);
|
||||
EXPECT_EQ(hash1, hash5);
|
||||
Callback::unwatch(kernel4);
|
||||
}
|
||||
|
||||
TEST_P(ProgramFromSourceTest, GivenEmptyProgramWhenCreatingProgramThenInvalidValueErrorIsReturned) {
|
||||
|
@ -84,7 +84,7 @@ class Device : public ReferenceTrackedObject<Device> {
|
||||
SpecializedDeviceT *getSpecializedDevice() const {
|
||||
return reinterpret_cast<SpecializedDeviceT *>(specializedDevice);
|
||||
}
|
||||
CompilerInterface *getCompilerInterface() const;
|
||||
MOCKABLE_VIRTUAL CompilerInterface *getCompilerInterface() const;
|
||||
BuiltIns *getBuiltIns() const;
|
||||
|
||||
virtual uint32_t getRootDeviceIndex() const = 0;
|
||||
|
@ -126,6 +126,16 @@ class MockDevice : public RootDevice {
|
||||
|
||||
static decltype(&createCommandStream) createCommandStreamReceiverFunc;
|
||||
std::unique_ptr<MemoryManager> mockMemoryManager;
|
||||
|
||||
NEO::CompilerInterface *getCompilerInterface() const override {
|
||||
if (mockCompilerInterface != nullptr) {
|
||||
return mockCompilerInterface;
|
||||
} else {
|
||||
return Device::getCompilerInterface();
|
||||
}
|
||||
}
|
||||
|
||||
NEO::CompilerInterface *mockCompilerInterface = nullptr;
|
||||
};
|
||||
|
||||
template <>
|
||||
|
Reference in New Issue
Block a user