mirror of
https://github.com/intel/compute-runtime.git
synced 2025-12-20 08:53:55 +08:00
fix(zebin): Extend oneDNN WA for whole application context
When a dummy kernel "kernel void_(){}" is passed in sources - specific
for workloads with ngen backend - enforce fallback to CTNI for the whole
application context (mark the context as non-zebinary).
Related-To: NEO-7772
Signed-off-by: Kacper Nowak <kacper.nowak@intel.com>
This commit is contained in:
committed by
Compute-Runtime-Automation
parent
6c59953072
commit
efba242570
@@ -579,4 +579,12 @@ std::unique_lock<std::mutex> Context::obtainOwnershipForMultiRootDeviceAllocator
|
||||
return std::unique_lock<std::mutex>(multiRootDeviceAllocatorMtx);
|
||||
}
|
||||
|
||||
void Context::setContextAsNonZebin() {
|
||||
this->nonZebinContext = true;
|
||||
}
|
||||
|
||||
bool Context::checkIfContextIsNonZebin() const {
|
||||
return this->nonZebinContext;
|
||||
}
|
||||
|
||||
} // namespace NEO
|
||||
|
||||
@@ -226,6 +226,8 @@ class Context : public BaseObject<_cl_context> {
|
||||
TagAllocatorBase *getMultiRootDeviceTimestampPacketAllocator();
|
||||
std::unique_lock<std::mutex> obtainOwnershipForMultiRootDeviceAllocator();
|
||||
void setMultiRootDeviceTimestampPacketAllocator(std::unique_ptr<TagAllocatorBase> &allocator);
|
||||
void setContextAsNonZebin();
|
||||
bool checkIfContextIsNonZebin() const;
|
||||
|
||||
protected:
|
||||
struct BuiltInKernel {
|
||||
@@ -271,5 +273,6 @@ class Context : public BaseObject<_cl_context> {
|
||||
|
||||
bool interopUserSync = false;
|
||||
bool resolvesRequiredInKernels = false;
|
||||
bool nonZebinContext = false;
|
||||
};
|
||||
} // namespace NEO
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
#include "shared/source/utilities/logger.h"
|
||||
|
||||
#include "opencl/source/cl_device/cl_device.h"
|
||||
#include "opencl/source/context/context.h"
|
||||
#include "opencl/source/gtpin/gtpin_notify.h"
|
||||
#include "opencl/source/helpers/cl_validators.h"
|
||||
#include "opencl/source/platform/platform.h"
|
||||
@@ -116,9 +117,11 @@ cl_int Program::build(
|
||||
NEO::CompilerOptions::concatenateAppend(internalOptions, NEO::DebugManager.flags.InjectInternalBuildOptions.get());
|
||||
}
|
||||
|
||||
if (this->enforceFallbackToPatchtokens) {
|
||||
if (nullptr != this->getContextPtr()) {
|
||||
if (this->getContext().checkIfContextIsNonZebin()) {
|
||||
CompilerOptions::concatenateAppend(internalOptions, CompilerOptions::disableZebin);
|
||||
}
|
||||
}
|
||||
|
||||
inputArgs.apiOptions = ArrayRef<const char>(options.c_str(), options.length());
|
||||
inputArgs.internalOptions = ArrayRef<const char>(internalOptions.c_str(), internalOptions.length());
|
||||
|
||||
@@ -79,7 +79,9 @@ T *Program::create(
|
||||
|
||||
program = new T(pContext, false, pContext->getDevices());
|
||||
if (ail) {
|
||||
ail->forceFallbackToPatchtokensIfRequired(combinedString, program->enforceFallbackToPatchtokens);
|
||||
if (ail->isFallbackToPatchtokensRequired(combinedString)) {
|
||||
pContext->setContextAsNonZebin();
|
||||
}
|
||||
}
|
||||
program->sourceCode.swap(combinedString);
|
||||
program->createdFrom = CreatedFrom::SOURCE;
|
||||
|
||||
@@ -564,6 +564,14 @@ bool Program::isOptionValueValid(ConstStringRef option, ConstStringRef value) {
|
||||
return false;
|
||||
}
|
||||
|
||||
Context &Program::getContext() const {
|
||||
return *context;
|
||||
}
|
||||
|
||||
Context *Program::getContextPtr() const {
|
||||
return context;
|
||||
}
|
||||
|
||||
const ClDeviceVector &Program::getDevicesInProgram() const {
|
||||
if (clDevicesInProgram.empty()) {
|
||||
return clDevices;
|
||||
|
||||
@@ -161,13 +161,8 @@ class Program : public BaseObject<_cl_program> {
|
||||
return std::any_of(this->deviceBuildInfos.begin(), this->deviceBuildInfos.end(), [](auto deviceBuildInfo) { return deviceBuildInfo.second.buildStatus == CL_SUCCESS && deviceBuildInfo.second.programBinaryType == CL_PROGRAM_BINARY_TYPE_EXECUTABLE; });
|
||||
}
|
||||
|
||||
Context &getContext() const {
|
||||
return *context;
|
||||
}
|
||||
|
||||
Context *getContextPtr() const {
|
||||
return context;
|
||||
}
|
||||
Context &getContext() const;
|
||||
Context *getContextPtr() const;
|
||||
|
||||
ExecutionEnvironment &peekExecutionEnvironment() const {
|
||||
return executionEnvironment;
|
||||
@@ -385,7 +380,6 @@ class Program : public BaseObject<_cl_program> {
|
||||
|
||||
bool isBuiltIn = false;
|
||||
bool kernelDebugEnabled = false;
|
||||
bool enforceFallbackToPatchtokens = false;
|
||||
uint32_t maxRootDeviceIndex = std::numeric_limits<uint32_t>::max();
|
||||
std::mutex lockMutex;
|
||||
uint32_t exposedKernels = 0;
|
||||
|
||||
@@ -54,7 +54,6 @@ class MockProgram : public Program {
|
||||
using Program::debuggerInfos;
|
||||
using Program::deviceBuildInfos;
|
||||
using Program::disableZebinIfVmeEnabled;
|
||||
using Program::enforceFallbackToPatchtokens;
|
||||
using Program::extractInternalOptions;
|
||||
using Program::getKernelInfo;
|
||||
using Program::getModuleAllocations;
|
||||
|
||||
@@ -691,8 +691,7 @@ TEST_F(MinimumProgramFixture, givenEmptyAilWhenCreateProgramWithSourcesThenSourc
|
||||
pProgram->release();
|
||||
}
|
||||
|
||||
HWTEST_F(MinimumProgramFixture, givenEmptyAilWhenCreateProgramWithSourcesAndWithDummyKernelThenDoNotSetFallbackRequired) {
|
||||
|
||||
HWTEST_F(MinimumProgramFixture, givenEmptyAilWhenCreateProgramWithSourcesAndWithDummyKernelThenDoNotMarkApplicationContextAsNonZebin) {
|
||||
VariableBackup<AILConfiguration *> ailConfigurationBackup(&ailConfigurationTable[productFamily]);
|
||||
ailConfigurationTable[productFamily] = nullptr;
|
||||
const char *dummyKernelSources[] = {"kernel void _(){}"}; // if detected - should trigger fallback to CTNI
|
||||
@@ -708,11 +707,11 @@ HWTEST_F(MinimumProgramFixture, givenEmptyAilWhenCreateProgramWithSourcesAndWith
|
||||
ASSERT_NE(nullptr, pProgram);
|
||||
ASSERT_EQ(CL_SUCCESS, retVal);
|
||||
|
||||
EXPECT_FALSE(pProgram->enforceFallbackToPatchtokens);
|
||||
EXPECT_FALSE(pProgram->getContext().checkIfContextIsNonZebin());
|
||||
pProgram->release();
|
||||
}
|
||||
|
||||
TEST_F(MinimumProgramFixture, givenEnforceLegacyBinaryFormatFlagSetWhenBuildingProgramThenInternalOptionsShouldContainDisableZebinOption) {
|
||||
TEST_F(MinimumProgramFixture, givenApplicationContextMarkedAsNonZebinWhenBuildingProgramThenInternalOptionsShouldContainDisableZebinOption) {
|
||||
const char *kernelSources[] = {"some source code"};
|
||||
size_t knownSourceSize = strlen(kernelSources[0]);
|
||||
|
||||
@@ -720,7 +719,9 @@ TEST_F(MinimumProgramFixture, givenEnforceLegacyBinaryFormatFlagSetWhenBuildingP
|
||||
auto pDevice = pContext->getDevice(0);
|
||||
pDevice->getExecutionEnvironment()->rootDeviceEnvironments[pDevice->getRootDeviceIndex()]->compilerInterface.reset(cip);
|
||||
|
||||
auto pProgram = Program::create<SucceedingGenBinaryProgram>(
|
||||
MockProgram *pProgram = nullptr;
|
||||
pContext->setContextAsNonZebin();
|
||||
pProgram = Program::create<SucceedingGenBinaryProgram>(
|
||||
pContext,
|
||||
1,
|
||||
kernelSources,
|
||||
@@ -730,14 +731,44 @@ TEST_F(MinimumProgramFixture, givenEnforceLegacyBinaryFormatFlagSetWhenBuildingP
|
||||
ASSERT_NE(nullptr, pProgram);
|
||||
ASSERT_EQ(CL_SUCCESS, retVal);
|
||||
|
||||
pProgram->enforceFallbackToPatchtokens = true;
|
||||
retVal = pProgram->build(pProgram->getDevices(), "", false);
|
||||
EXPECT_EQ(CL_SUCCESS, retVal);
|
||||
|
||||
EXPECT_TRUE(CompilerOptions::contains(cip->buildInternalOptions, CompilerOptions::disableZebin));
|
||||
pProgram->release();
|
||||
}
|
||||
|
||||
HWTEST2_F(MinimumProgramFixture, givenAILReturningTrueForFallbackRequirementWhenBuildingProgramThenMarkContextAsNonZebin, IsAtLeastSkl) {
|
||||
class MockAIL : public AILConfigurationHw<productFamily> {
|
||||
public:
|
||||
bool isFallbackToPatchtokensRequired(const std::string &kernelSources) override {
|
||||
return true;
|
||||
}
|
||||
};
|
||||
VariableBackup<AILConfiguration *> ailConfiguration(&ailConfigurationTable[productFamily]);
|
||||
|
||||
MockAIL mockAIL;
|
||||
ailConfigurationTable[productFamily] = &mockAIL;
|
||||
ASSERT_FALSE(pContext->checkIfContextIsNonZebin());
|
||||
|
||||
const char *kernelSources[] = {"some source code"};
|
||||
size_t knownSourceSize = strlen(kernelSources[0]);
|
||||
MockProgram *pProgram = nullptr;
|
||||
pProgram = Program::create<SucceedingGenBinaryProgram>(
|
||||
pContext,
|
||||
1,
|
||||
kernelSources,
|
||||
&knownSourceSize,
|
||||
retVal);
|
||||
|
||||
ASSERT_NE(nullptr, pProgram);
|
||||
ASSERT_EQ(CL_SUCCESS, retVal);
|
||||
|
||||
retVal = pProgram->build(pProgram->getDevices(), "", false);
|
||||
EXPECT_EQ(CL_SUCCESS, retVal);
|
||||
EXPECT_TRUE(pContext->checkIfContextIsNonZebin());
|
||||
pProgram->release();
|
||||
}
|
||||
|
||||
TEST_F(ProgramFromSourceTest, GivenSpecificParamatersWhenBuildingProgramThenSuccessOrCorrectErrorCodeIsReturned) {
|
||||
KernelBinaryHelper kbHelper(binaryFileName, true);
|
||||
auto device = pPlatform->getClDevice(0);
|
||||
|
||||
@@ -50,7 +50,7 @@ class AILConfiguration {
|
||||
|
||||
virtual void modifyKernelIfRequired(std::string &kernel) = 0;
|
||||
|
||||
virtual void forceFallbackToPatchtokensIfRequired(const std::string &kernelSources, bool &requiresFallback) = 0;
|
||||
virtual bool isFallbackToPatchtokensRequired(const std::string &kernelSources) = 0;
|
||||
|
||||
protected:
|
||||
virtual void applyExt(RuntimeCapabilityTable &runtimeCapabilityTable) = 0;
|
||||
@@ -73,7 +73,7 @@ class AILConfigurationHw : public AILConfiguration {
|
||||
void applyExt(RuntimeCapabilityTable &runtimeCapabilityTable) override;
|
||||
|
||||
void modifyKernelIfRequired(std::string &kernel) override;
|
||||
void forceFallbackToPatchtokensIfRequired(const std::string &kernelSources, bool &requiresFallback) override;
|
||||
bool isFallbackToPatchtokensRequired(const std::string &kernelSources) override;
|
||||
};
|
||||
|
||||
template <PRODUCT_FAMILY product>
|
||||
|
||||
@@ -20,20 +20,20 @@ inline void AILConfigurationHw<Product>::modifyKernelIfRequired(std::string &ker
|
||||
// Only this specific kernel with that exact source code will be affected.
|
||||
|
||||
template <PRODUCT_FAMILY Product>
|
||||
inline void AILConfigurationHw<Product>::forceFallbackToPatchtokensIfRequired(const std::string &kernelSources, bool &requiresFallback) {
|
||||
inline bool AILConfigurationHw<Product>::isFallbackToPatchtokensRequired(const std::string &kernelSources) {
|
||||
std::string_view dummyKernelSource{"kernel void _(){}"};
|
||||
if (sourcesContain(kernelSources, dummyKernelSource)) {
|
||||
requiresFallback = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
for (const auto &name : {"Resolve",
|
||||
"ArcControlAssist",
|
||||
"ArcControl"}) {
|
||||
if (processName == name) {
|
||||
requiresFallback = true;
|
||||
break;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
template <PRODUCT_FAMILY Product>
|
||||
|
||||
@@ -70,10 +70,10 @@ void AILConfigurationHw<IGFX_DG2>::modifyKernelIfRequired(std::string &kernelsSo
|
||||
}
|
||||
|
||||
template <>
|
||||
inline void AILConfigurationHw<IGFX_DG2>::forceFallbackToPatchtokensIfRequired(const std::string &kernelSources, bool &requiresFallback) {
|
||||
inline bool AILConfigurationHw<IGFX_DG2>::isFallbackToPatchtokensRequired(const std::string &kernelSources) {
|
||||
std::string_view dummyKernelSource{"kernel void _(){}"};
|
||||
if (sourcesContain(kernelSources, dummyKernelSource)) {
|
||||
requiresFallback = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
for (const auto &name : {"Wondershare Filmora 11",
|
||||
@@ -84,10 +84,10 @@ inline void AILConfigurationHw<IGFX_DG2>::forceFallbackToPatchtokensIfRequired(c
|
||||
"ArcControlAssist",
|
||||
"ArcControl"}) {
|
||||
if (processName == name) {
|
||||
requiresFallback = true;
|
||||
break;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
template class AILConfigurationHw<IGFX_DG2>;
|
||||
|
||||
@@ -16,22 +16,14 @@ using AILBaseTests = ::testing::Test;
|
||||
|
||||
HWTEST2_F(AILBaseTests, whenKernelSourceIsANGenDummyKernelThenDoEnforcePatchtokensFormat, IsAtLeastSkl) {
|
||||
std::string dummyKernelSource{"kernel void _(){}"};
|
||||
bool enforceRebuildToCTNI = false;
|
||||
|
||||
AILConfigurationHw<productFamily> ail;
|
||||
ail.forceFallbackToPatchtokensIfRequired(dummyKernelSource, enforceRebuildToCTNI);
|
||||
|
||||
EXPECT_TRUE(enforceRebuildToCTNI);
|
||||
EXPECT_TRUE(ail.isFallbackToPatchtokensRequired(dummyKernelSource));
|
||||
}
|
||||
|
||||
HWTEST2_F(AILBaseTests, whenKernelSourceIsNotANGenDummyKernelThenDoNotEnforcePatchtokensFormat, IsAtLeastSkl) {
|
||||
std::string dummyKernelSource{"kernel void copybuffer(__global int* a, __global int* b){ //some code }"};
|
||||
bool enforceRebuildToCTNI = false;
|
||||
|
||||
AILConfigurationHw<productFamily> ail;
|
||||
ail.forceFallbackToPatchtokensIfRequired(dummyKernelSource, enforceRebuildToCTNI);
|
||||
|
||||
EXPECT_FALSE(enforceRebuildToCTNI);
|
||||
EXPECT_FALSE(ail.isFallbackToPatchtokensRequired(dummyKernelSource));
|
||||
}
|
||||
|
||||
HWTEST2_F(AILBaseTests, givenApplicationNamesThatRequirAILWhenCheckingIfPatchtokenFallbackIsRequiredThenIsCorrectResult, IsAtLeastSkl) {
|
||||
@@ -48,11 +40,7 @@ HWTEST2_F(AILBaseTests, givenApplicationNamesThatRequirAILWhenCheckingIfPatchtok
|
||||
"ArcControlAssist",
|
||||
"ArcControl"}) {
|
||||
ail.processName = name;
|
||||
|
||||
bool fallbackRequired;
|
||||
ail.forceFallbackToPatchtokensIfRequired("", fallbackRequired);
|
||||
|
||||
EXPECT_TRUE(fallbackRequired);
|
||||
EXPECT_TRUE(ail.isFallbackToPatchtokensRequired(""));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -54,11 +54,7 @@ HWTEST2_F(AILTestsDg2, givenApplicationNamesThatRequirAILWhenCheckingIfPatchtoke
|
||||
"ArcControlAssist",
|
||||
"ArcControl"}) {
|
||||
ail.processName = name;
|
||||
|
||||
bool fallbackRequired;
|
||||
ail.forceFallbackToPatchtokensIfRequired("", fallbackRequired);
|
||||
|
||||
EXPECT_TRUE(fallbackRequired);
|
||||
EXPECT_TRUE(ail.isFallbackToPatchtokensRequired(""));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user