mirror of
https://github.com/intel/compute-runtime.git
synced 2025-12-24 12:23:05 +08:00
feature: use llvm bc for ir-level linking as alternative to spirv
This forces clCompile outputs (clLink inputs) to use llvm bc format unless underlying compiler's preferred IR is spirV. Related-To: NEO-16362 Signed-off-by: Chodor, Jaroslaw <jaroslaw.chodor@intel.com>
This commit is contained in:
committed by
Compute-Runtime-Automation
parent
8e60b53415
commit
6a280a4790
@@ -211,6 +211,9 @@ TranslationOutput::ErrorCode CompilerInterface::compile(
|
|||||||
|
|
||||||
if (outType == IGC::CodeType::undefined) {
|
if (outType == IGC::CodeType::undefined) {
|
||||||
outType = getPreferredIntermediateRepresentation(device);
|
outType = getPreferredIntermediateRepresentation(device);
|
||||||
|
if (outType != IGC::CodeType::spirV) {
|
||||||
|
outType = IGC::CodeType::llvmBc;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
CIF::CIFMain *fclMain = nullptr;
|
CIF::CIFMain *fclMain = nullptr;
|
||||||
|
|||||||
@@ -169,6 +169,13 @@ class MockCompilerInterface : public CompilerInterface {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
IGC::CodeType::CodeType_t getPreferredIntermediateRepresentation(const Device &device) override {
|
||||||
|
if (preferredIr != IGC::CodeType::undefined) {
|
||||||
|
return preferredIr;
|
||||||
|
}
|
||||||
|
return CompilerInterface::getPreferredIntermediateRepresentation(device);
|
||||||
|
}
|
||||||
|
|
||||||
static std::vector<char> getDummyGenBinary();
|
static std::vector<char> getDummyGenBinary();
|
||||||
static void releaseDummyGenBinary();
|
static void releaseDummyGenBinary();
|
||||||
|
|
||||||
@@ -190,6 +197,7 @@ class MockCompilerInterface : public CompilerInterface {
|
|||||||
SipKernelType requestedSipKernel = SipKernelType::count;
|
SipKernelType requestedSipKernel = SipKernelType::count;
|
||||||
|
|
||||||
IGC::IgcOclDeviceCtxTagOCL *peekIgcDeviceCtx(Device *device) { return igcDeviceContexts[device].get(); }
|
IGC::IgcOclDeviceCtxTagOCL *peekIgcDeviceCtx(Device *device) { return igcDeviceContexts[device].get(); }
|
||||||
|
IGC::CodeType::CodeType_t preferredIr = IGC::CodeType::undefined;
|
||||||
};
|
};
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
|
|||||||
@@ -173,6 +173,21 @@ TEST_F(CompilerInterfaceTest, WhenPreferredIntermediateRepresentationSpecifiedTh
|
|||||||
EXPECT_EQ(TranslationOutput::ErrorCode::success, err);
|
EXPECT_EQ(TranslationOutput::ErrorCode::success, err);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST_F(CompilerInterfaceTest, GivenCompileCommandWhenPreferredIntermediateNotSpirvThenUseLlvmBc) {
|
||||||
|
USE_REAL_FILE_SYSTEM();
|
||||||
|
|
||||||
|
CompilerCacheConfig config = {};
|
||||||
|
config.enabled = false;
|
||||||
|
auto tempCompilerCache = std::make_unique<CompilerCache>(config);
|
||||||
|
pCompilerInterface->cache.reset(tempCompilerCache.release());
|
||||||
|
inputArgs.outType = IGC::CodeType::undefined;
|
||||||
|
pCompilerInterface->preferredIr = IGC::CodeType::oclC;
|
||||||
|
TranslationOutput translationOutput;
|
||||||
|
auto err = pCompilerInterface->compile(*pDevice, inputArgs, translationOutput);
|
||||||
|
EXPECT_EQ(IGC::CodeType::llvmBc, translationOutput.intermediateCodeType);
|
||||||
|
EXPECT_EQ(TranslationOutput::ErrorCode::success, err);
|
||||||
|
}
|
||||||
|
|
||||||
TEST_F(CompilerInterfaceTest, whenCompilerIsNotAvailableThenBuildFailsGracefully) {
|
TEST_F(CompilerInterfaceTest, whenCompilerIsNotAvailableThenBuildFailsGracefully) {
|
||||||
pCompilerInterface->defaultIgc.entryPoint.reset(nullptr);
|
pCompilerInterface->defaultIgc.entryPoint.reset(nullptr);
|
||||||
pCompilerInterface->failLoadIgc = true;
|
pCompilerInterface->failLoadIgc = true;
|
||||||
|
|||||||
Reference in New Issue
Block a user