mirror of
https://github.com/intel/compute-runtime.git
synced 2026-01-07 21:27:04 +08:00
fix(zebin): disable zebin when vme extension is enabled in source code
Signed-off-by: Kamil Kopryk <kamil.kopryk@intel.com>
This commit is contained in:
committed by
Compute-Runtime-Automation
parent
3c5b3d4bac
commit
a97a2839aa
@@ -74,7 +74,7 @@ cl_int Program::build(
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
disableZebinIfVmeEnabled(options, internalOptions);
|
disableZebinIfVmeEnabled(options, internalOptions, sourceCode);
|
||||||
|
|
||||||
TranslationInput inputArgs = {IGC::CodeType::oclC, IGC::CodeType::oclGenBin};
|
TranslationInput inputArgs = {IGC::CodeType::oclC, IGC::CodeType::oclGenBin};
|
||||||
if (createdFrom != CreatedFrom::SOURCE) {
|
if (createdFrom != CreatedFrom::SOURCE) {
|
||||||
|
|||||||
@@ -448,19 +448,31 @@ bool Program::containsVmeUsage(const std::vector<KernelInfo *> &kernelInfos) con
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Program::disableZebinIfVmeEnabled(std::string &options, std::string &internalOptions) {
|
void Program::disableZebinIfVmeEnabled(std::string &options, std::string &internalOptions, const std::string &sourceCode) {
|
||||||
auto isVme = false;
|
|
||||||
const char *vmeOptions[] = {"cl_intel_device_side_advanced_vme_enable",
|
const char *vmeOptions[] = {"cl_intel_device_side_advanced_vme_enable",
|
||||||
"cl_intel_device_side_avc_vme_enable",
|
"cl_intel_device_side_avc_vme_enable",
|
||||||
"cl_intel_device_side_vme_enable"};
|
"cl_intel_device_side_vme_enable"};
|
||||||
for (auto vmeOption : vmeOptions) {
|
|
||||||
auto pos = options.find(vmeOption);
|
const char *vmeEnabledExtensions[] = {"cl_intel_motion_estimation : enable",
|
||||||
if (pos != std::string::npos) {
|
"cl_intel_device_side_avc_motion_estimation : enable",
|
||||||
isVme = true;
|
"cl_intel_advanced_motion_estimation : enable"};
|
||||||
break;
|
|
||||||
|
auto containsVme = [](const auto &data, const auto &patterns) {
|
||||||
|
for (const auto &pattern : patterns) {
|
||||||
|
auto pos = data.find(pattern);
|
||||||
|
if (pos != std::string::npos) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
return false;
|
||||||
|
};
|
||||||
|
|
||||||
|
if (DebugManager.flags.DontDisableZebinIfVmeUsed.get() == true) {
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
if (isVme) {
|
|
||||||
|
if (containsVme(options, vmeOptions) || containsVme(sourceCode, vmeEnabledExtensions)) {
|
||||||
auto pos = options.find(CompilerOptions::allowZebin.str());
|
auto pos = options.find(CompilerOptions::allowZebin.str());
|
||||||
if (pos != std::string::npos) {
|
if (pos != std::string::npos) {
|
||||||
options.erase(pos, pos + CompilerOptions::allowZebin.length());
|
options.erase(pos, pos + CompilerOptions::allowZebin.length());
|
||||||
|
|||||||
@@ -307,7 +307,7 @@ class Program : public BaseObject<_cl_program> {
|
|||||||
void setBuildStatusSuccess(const ClDeviceVector &deviceVector, cl_program_binary_type binaryType);
|
void setBuildStatusSuccess(const ClDeviceVector &deviceVector, cl_program_binary_type binaryType);
|
||||||
|
|
||||||
bool containsVmeUsage(const std::vector<KernelInfo *> &kernelInfos) const;
|
bool containsVmeUsage(const std::vector<KernelInfo *> &kernelInfos) const;
|
||||||
void disableZebinIfVmeEnabled(std::string &options, std::string &internalOptions);
|
void disableZebinIfVmeEnabled(std::string &options, std::string &internalOptions, const std::string &sourceCode);
|
||||||
|
|
||||||
bool isSpirV = false;
|
bool isSpirV = false;
|
||||||
|
|
||||||
|
|||||||
@@ -3380,13 +3380,14 @@ TEST(ProgramVmeUsage, givenVmeUsageWhenContainsVmeUsageIsCalledThenReturnTrue) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
TEST(ProgramVmeUsage, givenVmeOptionsWhenDisableZebinIfVmeEnabledIsCalledThenZebinIsDisabled) {
|
TEST(ProgramVmeUsage, givenVmeOptionsWhenDisableZebinIfVmeEnabledIsCalledThenZebinIsDisabled) {
|
||||||
|
DebugManagerStateRestore debugManagerStateRestore{};
|
||||||
MockClDevice device{new MockDevice()};
|
MockClDevice device{new MockDevice()};
|
||||||
MockProgram program(toClDeviceVector(device));
|
MockProgram program(toClDeviceVector(device));
|
||||||
|
|
||||||
{
|
{
|
||||||
std::string options = CompilerOptions::allowZebin.str();
|
std::string options = CompilerOptions::allowZebin.str();
|
||||||
std::string internalOptions = "";
|
std::string internalOptions = "";
|
||||||
program.disableZebinIfVmeEnabled(options, internalOptions);
|
program.disableZebinIfVmeEnabled(options, internalOptions, "");
|
||||||
EXPECT_TRUE(CompilerOptions::contains(options, CompilerOptions::allowZebin));
|
EXPECT_TRUE(CompilerOptions::contains(options, CompilerOptions::allowZebin));
|
||||||
EXPECT_FALSE(CompilerOptions::contains(internalOptions, CompilerOptions::disableZebin));
|
EXPECT_FALSE(CompilerOptions::contains(internalOptions, CompilerOptions::disableZebin));
|
||||||
}
|
}
|
||||||
@@ -3394,16 +3395,86 @@ TEST(ProgramVmeUsage, givenVmeOptionsWhenDisableZebinIfVmeEnabledIsCalledThenZeb
|
|||||||
{
|
{
|
||||||
std::string options = CompilerOptions::allowZebin.str() + " cl_intel_device_side_vme_enable";
|
std::string options = CompilerOptions::allowZebin.str() + " cl_intel_device_side_vme_enable";
|
||||||
std::string internalOptions = "";
|
std::string internalOptions = "";
|
||||||
program.disableZebinIfVmeEnabled(options, internalOptions);
|
DebugManager.flags.DontDisableZebinIfVmeUsed = false;
|
||||||
|
program.disableZebinIfVmeEnabled(options, internalOptions, "");
|
||||||
|
EXPECT_FALSE(CompilerOptions::contains(options, CompilerOptions::allowZebin));
|
||||||
|
EXPECT_TRUE(CompilerOptions::contains(internalOptions, CompilerOptions::disableZebin));
|
||||||
|
}
|
||||||
|
{
|
||||||
|
|
||||||
|
std::string options = CompilerOptions::allowZebin.str() + " cl_intel_device_side_vme_enable";
|
||||||
|
std::string internalOptions = "";
|
||||||
|
DebugManager.flags.DontDisableZebinIfVmeUsed = true;
|
||||||
|
program.disableZebinIfVmeEnabled(options, internalOptions, "");
|
||||||
|
EXPECT_TRUE(CompilerOptions::contains(options, CompilerOptions::allowZebin));
|
||||||
|
EXPECT_FALSE(CompilerOptions::contains(internalOptions, CompilerOptions::disableZebin));
|
||||||
|
}
|
||||||
|
{
|
||||||
|
std::string options = "cl_intel_device_side_vme_enable";
|
||||||
|
std::string internalOptions = "";
|
||||||
|
DebugManager.flags.DontDisableZebinIfVmeUsed = false;
|
||||||
|
program.disableZebinIfVmeEnabled(options, internalOptions, "");
|
||||||
EXPECT_FALSE(CompilerOptions::contains(options, CompilerOptions::allowZebin));
|
EXPECT_FALSE(CompilerOptions::contains(options, CompilerOptions::allowZebin));
|
||||||
EXPECT_TRUE(CompilerOptions::contains(internalOptions, CompilerOptions::disableZebin));
|
EXPECT_TRUE(CompilerOptions::contains(internalOptions, CompilerOptions::disableZebin));
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
std::string options = "cl_intel_device_side_vme_enable";
|
std::string options = "cl_intel_device_side_vme_enable";
|
||||||
std::string internalOptions = "";
|
std::string internalOptions = "";
|
||||||
program.disableZebinIfVmeEnabled(options, internalOptions);
|
DebugManager.flags.DontDisableZebinIfVmeUsed = true;
|
||||||
|
program.disableZebinIfVmeEnabled(options, internalOptions, "");
|
||||||
EXPECT_FALSE(CompilerOptions::contains(options, CompilerOptions::allowZebin));
|
EXPECT_FALSE(CompilerOptions::contains(options, CompilerOptions::allowZebin));
|
||||||
EXPECT_TRUE(CompilerOptions::contains(internalOptions, CompilerOptions::disableZebin));
|
EXPECT_FALSE(CompilerOptions::contains(internalOptions, CompilerOptions::disableZebin));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST(ProgramVmeUsage, givenVmeExtensionsEnabledInSourceCodeWhenDisableZebinIfVmeEnabledIsCalledThenZebinIsDisabled) {
|
||||||
|
DebugManagerStateRestore debugManagerStateRestore{};
|
||||||
|
MockClDevice device{new MockDevice()};
|
||||||
|
MockProgram program(toClDeviceVector(device));
|
||||||
|
|
||||||
|
{
|
||||||
|
std::string options = CompilerOptions::allowZebin.str();
|
||||||
|
std::string internalOptions = "";
|
||||||
|
std::string sourceCode = "cl_intel_motion_estimation";
|
||||||
|
program.disableZebinIfVmeEnabled(options, internalOptions, sourceCode);
|
||||||
|
EXPECT_TRUE(CompilerOptions::contains(options, CompilerOptions::allowZebin));
|
||||||
|
EXPECT_FALSE(CompilerOptions::contains(internalOptions, CompilerOptions::disableZebin));
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
std::string options = CompilerOptions::allowZebin.str();
|
||||||
|
std::string internalOptions = "";
|
||||||
|
std::string sourceCode = "cl_intel_motion_estimation : disable";
|
||||||
|
program.disableZebinIfVmeEnabled(options, internalOptions, sourceCode);
|
||||||
|
EXPECT_TRUE(CompilerOptions::contains(options, CompilerOptions::allowZebin));
|
||||||
|
EXPECT_FALSE(CompilerOptions::contains(internalOptions, CompilerOptions::disableZebin));
|
||||||
|
}
|
||||||
|
|
||||||
|
const char *vmeEnabledExtensions[] = {"cl_intel_motion_estimation : enable",
|
||||||
|
"cl_intel_device_side_avc_motion_estimation : enable",
|
||||||
|
"cl_intel_advanced_motion_estimation : enable"};
|
||||||
|
|
||||||
|
for (auto extension : vmeEnabledExtensions) {
|
||||||
|
|
||||||
|
std::string sourceCode = extension;
|
||||||
|
|
||||||
|
{
|
||||||
|
std::string options = CompilerOptions::allowZebin.str();
|
||||||
|
std::string internalOptions = "";
|
||||||
|
DebugManager.flags.DontDisableZebinIfVmeUsed = false;
|
||||||
|
program.disableZebinIfVmeEnabled(options, internalOptions, sourceCode);
|
||||||
|
EXPECT_FALSE(CompilerOptions::contains(options, CompilerOptions::allowZebin));
|
||||||
|
EXPECT_TRUE(CompilerOptions::contains(internalOptions, CompilerOptions::disableZebin));
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
std::string options = CompilerOptions::allowZebin.str();
|
||||||
|
std::string internalOptions = "";
|
||||||
|
DebugManager.flags.DontDisableZebinIfVmeUsed = true;
|
||||||
|
program.disableZebinIfVmeEnabled(options, internalOptions, sourceCode);
|
||||||
|
EXPECT_TRUE(CompilerOptions::contains(options, CompilerOptions::allowZebin));
|
||||||
|
EXPECT_FALSE(CompilerOptions::contains(internalOptions, CompilerOptions::disableZebin));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -78,6 +78,7 @@ DECLARE_DEBUG_VARIABLE(bool, DisableGpuHangDetection, false, "Disable GPU hang d
|
|||||||
DECLARE_DEBUG_VARIABLE(bool, DisableForceToStateless, false, "Do not force stateless for buffers")
|
DECLARE_DEBUG_VARIABLE(bool, DisableForceToStateless, false, "Do not force stateless for buffers")
|
||||||
DECLARE_DEBUG_VARIABLE(bool, ForceTheoreticalMaxWorkGroupCount, false, "Do not apply any limitation to max cooperative/concurrent work-group count queries")
|
DECLARE_DEBUG_VARIABLE(bool, ForceTheoreticalMaxWorkGroupCount, false, "Do not apply any limitation to max cooperative/concurrent work-group count queries")
|
||||||
DECLARE_DEBUG_VARIABLE(bool, DisableScratchPages, false, "Disable scratch pages during VM creations")
|
DECLARE_DEBUG_VARIABLE(bool, DisableScratchPages, false, "Disable scratch pages during VM creations")
|
||||||
|
DECLARE_DEBUG_VARIABLE(bool, DontDisableZebinIfVmeUsed, false, "When enabled, driver will not add -cl-intel-disable-zebin internal option when vme is used")
|
||||||
DECLARE_DEBUG_VARIABLE(std::string, ForceDeviceId, std::string("unk"), "Override device id in AUB/TBX mode")
|
DECLARE_DEBUG_VARIABLE(std::string, ForceDeviceId, std::string("unk"), "Override device id in AUB/TBX mode")
|
||||||
DECLARE_DEBUG_VARIABLE(std::string, FilterDeviceId, std::string("unk"), "Device id filter, adapter matching device id will be opened; ignored when unk")
|
DECLARE_DEBUG_VARIABLE(std::string, FilterDeviceId, std::string("unk"), "Device id filter, adapter matching device id will be opened; ignored when unk")
|
||||||
DECLARE_DEBUG_VARIABLE(std::string, FilterBdfPath, std::string("unk"), "Linux-only, BDF path filter, only matching paths will be opened; ignored when unk")
|
DECLARE_DEBUG_VARIABLE(std::string, FilterBdfPath, std::string("unk"), "Linux-only, BDF path filter, only matching paths will be opened; ignored when unk")
|
||||||
|
|||||||
@@ -52,6 +52,7 @@ ForceAuxTranslationMode = -1
|
|||||||
OverrideGpuAddressSpace = -1
|
OverrideGpuAddressSpace = -1
|
||||||
OverrideMaxWorkgroupSize = -1
|
OverrideMaxWorkgroupSize = -1
|
||||||
EnableFlushTaskSubmission = -1
|
EnableFlushTaskSubmission = -1
|
||||||
|
DontDisableZebinIfVmeUsed = 0
|
||||||
DoCpuCopyOnReadBuffer = -1
|
DoCpuCopyOnReadBuffer = -1
|
||||||
DoCpuCopyOnWriteBuffer = -1
|
DoCpuCopyOnWriteBuffer = -1
|
||||||
PauseOnEnqueue = -1
|
PauseOnEnqueue = -1
|
||||||
|
|||||||
Reference in New Issue
Block a user