refactor: Store AIL in root device environment

Instead of storing AIL configurations in global table, store it
in root device environment.
This also prevents potential scenario with accessing deleted memory due
to symbol collision when application uses both OCL/L0 libraries.
- AIL is now stored in root device environment, and gets initialized
with other helpers
- Minor: corrected naming in ULTs

Signed-off-by: Kacper Nowak <kacper.nowak@intel.com>
Related-To: NEO-9240
This commit is contained in:
Kacper Nowak
2023-10-31 02:33:24 +00:00
committed by Compute-Runtime-Automation
parent 6562828095
commit c504b497d7
14 changed files with 96 additions and 180 deletions

View File

@@ -6,6 +6,7 @@
*/ */
#include "shared/source/ail/ail_configuration.h" #include "shared/source/ail/ail_configuration.h"
#include "shared/source/execution_environment/root_device_environment.h"
#include "shared/source/helpers/hw_info.h" #include "shared/source/helpers/hw_info.h"
#include "shared/source/helpers/string_helpers.h" #include "shared/source/helpers/string_helpers.h"
@@ -71,8 +72,7 @@ T *Program::create(
if (CL_SUCCESS == retVal) { if (CL_SUCCESS == retVal) {
auto &hwInfo = pContext->getDevice(0)->getHardwareInfo(); auto ail = pContext->getDevice(0)->getRootDeviceEnvironment().getAILConfigurationHelper();
auto ail = AILConfiguration::get(hwInfo.platform.eProductFamily);
if (ail) { if (ail) {
ail->modifyKernelIfRequired(combinedString); ail->modifyKernelIfRequired(combinedString);
} }

View File

@@ -680,10 +680,10 @@ void MinimumProgramFixture::TearDown() {
NEO::PlatformFixture::tearDown(); NEO::PlatformFixture::tearDown();
} }
TEST_F(MinimumProgramFixture, givenEmptyAilWhenCreateProgramWithSourcesThenSourcesDoNotChange) { HWTEST2_F(MinimumProgramFixture, givenEmptyAilWhenCreateProgramWithSourcesThenSourcesDoNotChange, IsDG2) {
auto pDevice = pContext->getDevice(0);
VariableBackup<AILConfiguration *> ailConfigurationBackup(&ailConfigurationTable[productFamily]); auto rootDeviceEnvironment = pDevice->getExecutionEnvironment()->rootDeviceEnvironments[rootDeviceIndex].get();
ailConfigurationTable[productFamily] = nullptr; rootDeviceEnvironment->ailConfiguration.reset(nullptr);
const char *sources[] = {"kernel() {}"}; const char *sources[] = {"kernel() {}"};
size_t knownSourceSize = strlen(sources[0]); size_t knownSourceSize = strlen(sources[0]);
@@ -701,9 +701,10 @@ TEST_F(MinimumProgramFixture, givenEmptyAilWhenCreateProgramWithSourcesThenSourc
pProgram->release(); pProgram->release();
} }
HWTEST_F(MinimumProgramFixture, givenEmptyAilWhenCreateProgramWithSourcesAndWithDummyKernelThenDoNotMarkApplicationContextAsNonZebin) { HWTEST2_F(MinimumProgramFixture, givenEmptyAilWhenCreateProgramWithSourcesAndWithDummyKernelThenDoNotMarkApplicationContextAsNonZebin, IsAtLeastSkl) {
VariableBackup<AILConfiguration *> ailConfigurationBackup(&ailConfigurationTable[productFamily]); auto pDevice = pContext->getDevice(0);
ailConfigurationTable[productFamily] = nullptr; auto rootDeviceEnvironment = pDevice->getExecutionEnvironment()->rootDeviceEnvironments[rootDeviceIndex].get();
rootDeviceEnvironment->ailConfiguration.reset(nullptr);
const char *dummyKernelSources[] = {"kernel void _(){}"}; // if detected - should trigger fallback to CTNI const char *dummyKernelSources[] = {"kernel void _(){}"}; // if detected - should trigger fallback to CTNI
size_t knownSourceSize = strlen(dummyKernelSources[0]); size_t knownSourceSize = strlen(dummyKernelSources[0]);
@@ -754,10 +755,10 @@ HWTEST2_F(MinimumProgramFixture, givenAILReturningTrueForFallbackRequirementWhen
return true; return true;
} }
}; };
VariableBackup<AILConfiguration *> ailConfiguration(&ailConfigurationTable[productFamily]); auto pDevice = pContext->getDevice(0);
auto rootDeviceEnvironment = pDevice->getExecutionEnvironment()->rootDeviceEnvironments[rootDeviceIndex].get();
rootDeviceEnvironment->ailConfiguration.reset(new MockAIL());
MockAIL mockAIL;
ailConfigurationTable[productFamily] = &mockAIL;
ASSERT_FALSE(pContext->checkIfContextIsNonZebin()); ASSERT_FALSE(pContext->checkIfContextIsNonZebin());
const char *kernelSources[] = {"some source code"}; const char *kernelSources[] = {"some source code"};

View File

@@ -10,6 +10,7 @@
#include "igfxfmid.h" #include "igfxfmid.h"
#include <cstdint> #include <cstdint>
#include <memory>
#include <set> #include <set>
#include <string> #include <string>
@@ -43,14 +44,24 @@ enum class AILEnumeration : uint32_t {
AIL_MAX_OPTIONS_COUNT AIL_MAX_OPTIONS_COUNT
}; };
class AILConfiguration;
using AILConfigurationCreateFunctionType = std::unique_ptr<AILConfiguration> (*)();
extern AILConfigurationCreateFunctionType ailConfigurationFactory[IGFX_MAX_PRODUCT];
class AILConfiguration { class AILConfiguration {
public: public:
static std::unique_ptr<AILConfiguration> create(PRODUCT_FAMILY product) {
auto ailConfigurationCreateFunction = ailConfigurationFactory[product];
if (ailConfigurationCreateFunction == nullptr) {
return nullptr;
}
auto ailConfiguration = ailConfigurationCreateFunction();
return ailConfiguration;
}
AILConfiguration() = default; AILConfiguration() = default;
MOCKABLE_VIRTUAL bool initProcessExecutableName(); MOCKABLE_VIRTUAL bool initProcessExecutableName();
static AILConfiguration *get(PRODUCT_FAMILY productFamily);
virtual void apply(RuntimeCapabilityTable &runtimeCapabilityTable); virtual void apply(RuntimeCapabilityTable &runtimeCapabilityTable);
virtual void modifyKernelIfRequired(std::string &kernel) = 0; virtual void modifyKernelIfRequired(std::string &kernel) = 0;
@@ -59,6 +70,8 @@ class AILConfiguration {
virtual bool isContextSyncFlagRequired() = 0; virtual bool isContextSyncFlagRequired() = 0;
virtual ~AILConfiguration() = default;
protected: protected:
virtual void applyExt(RuntimeCapabilityTable &runtimeCapabilityTable) = 0; virtual void applyExt(RuntimeCapabilityTable &runtimeCapabilityTable) = 0;
std::string processName; std::string processName;
@@ -67,15 +80,13 @@ class AILConfiguration {
MOCKABLE_VIRTUAL bool isKernelHashCorrect(const std::string &kernelSources, uint64_t expectedHash) const; MOCKABLE_VIRTUAL bool isKernelHashCorrect(const std::string &kernelSources, uint64_t expectedHash) const;
}; };
extern AILConfiguration *ailConfigurationTable[IGFX_MAX_PRODUCT];
extern const std::set<std::string_view> applicationsContextSyncFlag; extern const std::set<std::string_view> applicationsContextSyncFlag;
template <PRODUCT_FAMILY Product> template <PRODUCT_FAMILY Product>
class AILConfigurationHw : public AILConfiguration { class AILConfigurationHw : public AILConfiguration {
public: public:
static AILConfigurationHw<Product> &get() { static std::unique_ptr<AILConfiguration> create() {
static AILConfigurationHw<Product> ailConfiguration; auto ailConfiguration = std::unique_ptr<AILConfiguration>(new AILConfigurationHw());
return ailConfiguration; return ailConfiguration;
} }
@@ -89,7 +100,8 @@ class AILConfigurationHw : public AILConfiguration {
template <PRODUCT_FAMILY product> template <PRODUCT_FAMILY product>
struct EnableAIL { struct EnableAIL {
EnableAIL() { EnableAIL() {
ailConfigurationTable[product] = &AILConfigurationHw<product>::get(); auto ailConfigurationCreateFunction = AILConfigurationHw<product>::create;
ailConfigurationFactory[product] = ailConfigurationCreateFunction;
} }
}; };

View File

@@ -28,11 +28,7 @@ std::map<std::string_view, std::vector<AILEnumeration>> applicationMapMTL = {{"s
const std::set<std::string_view> applicationsContextSyncFlag = {}; const std::set<std::string_view> applicationsContextSyncFlag = {};
AILConfiguration *ailConfigurationTable[IGFX_MAX_PRODUCT] = {}; AILConfigurationCreateFunctionType ailConfigurationFactory[IGFX_MAX_PRODUCT];
AILConfiguration *AILConfiguration::get(PRODUCT_FAMILY productFamily) {
return ailConfigurationTable[productFamily];
}
void AILConfiguration::apply(RuntimeCapabilityTable &runtimeCapabilityTable) { void AILConfiguration::apply(RuntimeCapabilityTable &runtimeCapabilityTable) {
auto search = applicationMap.find(processName); auto search = applicationMap.find(processName);

View File

@@ -101,11 +101,6 @@ void RootDeviceEnvironment::prepareForCleanup() const {
} }
bool RootDeviceEnvironment::initAilConfiguration() { bool RootDeviceEnvironment::initAilConfiguration() {
if (!DebugManager.flags.EnableAIL.get()) {
return true;
}
auto ailConfiguration = AILConfiguration::get(hwInfo->platform.eProductFamily);
if (ailConfiguration == nullptr) { if (ailConfiguration == nullptr) {
return true; return true;
} }
@@ -161,6 +156,7 @@ void RootDeviceEnvironment::initHelpers() {
initApiGfxCoreHelper(); initApiGfxCoreHelper();
initCompilerProductHelper(); initCompilerProductHelper();
initReleaseHelper(); initReleaseHelper();
initAilConfigurationHelper();
} }
void RootDeviceEnvironment::initGfxCoreHelper() { void RootDeviceEnvironment::initGfxCoreHelper() {
@@ -186,10 +182,20 @@ void RootDeviceEnvironment::initReleaseHelper() {
} }
} }
void RootDeviceEnvironment::initAilConfigurationHelper() {
if (ailConfiguration == nullptr && DebugManager.flags.EnableAIL.get()) {
ailConfiguration = AILConfiguration::create(this->getHardwareInfo()->platform.eProductFamily);
}
}
ReleaseHelper *RootDeviceEnvironment::getReleaseHelper() const { ReleaseHelper *RootDeviceEnvironment::getReleaseHelper() const {
return releaseHelper.get(); return releaseHelper.get();
} }
AILConfiguration *RootDeviceEnvironment::getAILConfigurationHelper() const {
return ailConfiguration.get();
}
BuiltIns *RootDeviceEnvironment::getBuiltIns() { BuiltIns *RootDeviceEnvironment::getBuiltIns() {
if (this->builtins.get() == nullptr) { if (this->builtins.get() == nullptr) {
std::lock_guard<std::mutex> autolock(this->mtx); std::lock_guard<std::mutex> autolock(this->mtx);

View File

@@ -40,6 +40,7 @@ class ApiGfxCoreHelper;
class CompilerProductHelper; class CompilerProductHelper;
class GraphicsAllocation; class GraphicsAllocation;
class ReleaseHelper; class ReleaseHelper;
class AILConfiguration;
struct AllocationProperties; struct AllocationProperties;
struct HardwareInfo; struct HardwareInfo;
@@ -85,7 +86,9 @@ struct RootDeviceEnvironment : NonCopyableClass {
void initApiGfxCoreHelper(); void initApiGfxCoreHelper();
void initCompilerProductHelper(); void initCompilerProductHelper();
void initReleaseHelper(); void initReleaseHelper();
void initAilConfigurationHelper();
ReleaseHelper *getReleaseHelper() const; ReleaseHelper *getReleaseHelper() const;
AILConfiguration *getAILConfigurationHelper() const;
template <typename HelperType> template <typename HelperType>
HelperType &getHelper() const; HelperType &getHelper() const;
const ProductHelper &getProductHelper() const; const ProductHelper &getProductHelper() const;
@@ -108,6 +111,7 @@ struct RootDeviceEnvironment : NonCopyableClass {
std::unique_ptr<ProductHelper> productHelper; std::unique_ptr<ProductHelper> productHelper;
std::unique_ptr<CompilerProductHelper> compilerProductHelper; std::unique_ptr<CompilerProductHelper> compilerProductHelper;
std::unique_ptr<ReleaseHelper> releaseHelper; std::unique_ptr<ReleaseHelper> releaseHelper;
std::unique_ptr<AILConfiguration> ailConfiguration;
std::unique_ptr<AssertHandler> assertHandler; std::unique_ptr<AssertHandler> assertHandler;

View File

@@ -13,10 +13,8 @@ namespace NEO {
class MockAILConfiguration : public AILConfiguration { class MockAILConfiguration : public AILConfiguration {
public: public:
bool initProcessExecutableName() override { bool initProcessExecutableName() override {
initCalled = true;
return true; return true;
} }
bool initCalled = false;
void modifyKernelIfRequired(std::string &kernel) override {} void modifyKernelIfRequired(std::string &kernel) override {}
bool isFallbackToPatchtokensRequired(const std::string &kernelSources) override { bool isFallbackToPatchtokensRequired(const std::string &kernelSources) override {
@@ -33,7 +31,7 @@ class MockAILConfiguration : public AILConfiguration {
}; };
template <PRODUCT_FAMILY productFamily> template <PRODUCT_FAMILY productFamily>
class AILMock : public AILConfigurationHw<productFamily> { class AILWhitebox : public AILConfigurationHw<productFamily> {
public: public:
using AILConfiguration::apply; using AILConfiguration::apply;
using AILConfiguration::isKernelHashCorrect; using AILConfiguration::isKernelHashCorrect;

View File

@@ -19,54 +19,37 @@ using IsHostPtrTrackingDisabled = IsWithinGfxCore<IGFX_GEN9_CORE, IGFX_GEN11LP_C
using AILTests = ::testing::Test; using AILTests = ::testing::Test;
HWTEST2_F(AILTests, givenInitializedTemplateWhenGetAILConfigurationThenNullptrIsNotReturned, IsSKL) { TEST(AILTests, whenAILConfigurationCreateFunctionIsCalledWithUnknownGfxCoreThenNullptrIsReturned) {
auto ailConfiguration = AILConfiguration::get(productFamily); EXPECT_EQ(nullptr, AILConfiguration::create(IGFX_UNKNOWN));
EXPECT_NE(nullptr, ailConfiguration);
} }
HWTEST2_F(AILTests, givenInitilizedTemplateWhenApplyWithBlenderIsCalledThenFP64SupportIsEnabled, IsAtLeastGen12lp) { HWTEST2_F(AILTests, givenInitilizedTemplateWhenApplyWithBlenderIsCalledThenFP64SupportIsEnabled, IsAtLeastGen12lp) {
VariableBackup<AILConfiguration *> ailConfigurationBackup(&ailConfigurationTable[productFamily]); AILWhitebox<productFamily> ail;
ail.processName = "blender";
AILMock<productFamily> ailTemp;
ailTemp.processName = "blender";
ailConfigurationTable[productFamily] = &ailTemp;
auto ailConfiguration = AILConfiguration::get(productFamily);
ASSERT_NE(nullptr, ailConfiguration);
NEO::RuntimeCapabilityTable rtTable = {}; NEO::RuntimeCapabilityTable rtTable = {};
rtTable.ftrSupportsFP64 = false; rtTable.ftrSupportsFP64 = false;
ailConfiguration->apply(rtTable); ail.apply(rtTable);
EXPECT_EQ(rtTable.ftrSupportsFP64, true); EXPECT_EQ(rtTable.ftrSupportsFP64, true);
} }
HWTEST2_F(AILTests, givenInitilizedTemplateWhenApplyWithAdobePremiereProIsCalledThenPreferredPlatformNameIsSet, IsAtLeastGen9) { HWTEST2_F(AILTests, givenInitilizedTemplateWhenApplyWithAdobePremiereProIsCalledThenPreferredPlatformNameIsSet, IsAtLeastGen9) {
VariableBackup<AILConfiguration *> ailConfigurationBackup(&ailConfigurationTable[productFamily]); AILWhitebox<productFamily> ail;
ail.processName = "Adobe Premiere Pro";
AILMock<productFamily> ailTemp;
ailTemp.processName = "Adobe Premiere Pro";
ailConfigurationTable[productFamily] = &ailTemp;
auto ailConfiguration = AILConfiguration::get(productFamily);
ASSERT_NE(nullptr, ailConfiguration);
NEO::RuntimeCapabilityTable rtTable = {}; NEO::RuntimeCapabilityTable rtTable = {};
rtTable.preferredPlatformName = nullptr; rtTable.preferredPlatformName = nullptr;
ailConfiguration->apply(rtTable); ail.apply(rtTable);
EXPECT_NE(nullptr, rtTable.preferredPlatformName); EXPECT_NE(nullptr, rtTable.preferredPlatformName);
EXPECT_STREQ("Intel(R) OpenCL", rtTable.preferredPlatformName); EXPECT_STREQ("Intel(R) OpenCL", rtTable.preferredPlatformName);
} }
HWTEST2_F(AILTests, whenCheckingIfSourcesContainKernelThenCorrectResultIsReturned, IsAtLeastGen12lp) { HWTEST2_F(AILTests, whenCheckingIfSourcesContainKernelThenCorrectResultIsReturned, IsAtLeastGen12lp) {
VariableBackup<AILConfiguration *> ailConfigurationBackup(&ailConfigurationTable[productFamily]); AILWhitebox<productFamily> ail;
AILMock<productFamily> ail;
ailConfigurationTable[productFamily] = &ail;
auto ailConfiguration = AILConfiguration::get(productFamily);
ASSERT_NE(nullptr, ailConfiguration);
std::string kernelSources = R"( std::string kernelSources = R"(
__kernel void CopyBufferToBufferLeftLeftover( __kernel void CopyBufferToBufferLeftLeftover(
@@ -96,11 +79,7 @@ __kernel void CopyBufferToBufferMiddle(
} }
HWTEST2_F(AILTests, whenCheckingIsKernelHashCorrectThenCorrectResultIsReturned, IsAtLeastGen12lp) { HWTEST2_F(AILTests, whenCheckingIsKernelHashCorrectThenCorrectResultIsReturned, IsAtLeastGen12lp) {
VariableBackup<AILConfiguration *> ailConfigurationBackup(&ailConfigurationTable[productFamily]); AILWhitebox<productFamily> ail;
AILMock<productFamily> ail;
ailConfigurationTable[productFamily] = &ail;
auto ailConfiguration = AILConfiguration::get(productFamily);
ASSERT_NE(nullptr, ailConfiguration);
std::string kernelSources = R"( std::string kernelSources = R"(
__kernel void CopyBufferToBufferLeftLeftover( __kernel void CopyBufferToBufferLeftLeftover(
@@ -125,11 +104,7 @@ __kernel void CopyBufferToBufferLeftLeftover(
} }
HWTEST2_F(AILTests, whenModifyKernelIfRequiredIsCalledThenDontChangeKernelSources, IsAtLeastGen12lp) { HWTEST2_F(AILTests, whenModifyKernelIfRequiredIsCalledThenDontChangeKernelSources, IsAtLeastGen12lp) {
VariableBackup<AILConfiguration *> ailConfigurationBackup(&ailConfigurationTable[productFamily]); AILWhitebox<productFamily> ail;
AILMock<productFamily> ail;
ailConfigurationTable[productFamily] = &ail;
auto ailConfiguration = AILConfiguration::get(productFamily);
ASSERT_NE(nullptr, ailConfiguration);
std::string kernelSources = "example_kernel(){}"; std::string kernelSources = "example_kernel(){}";
auto copyKernel = kernelSources; auto copyKernel = kernelSources;
@@ -140,99 +115,48 @@ HWTEST2_F(AILTests, whenModifyKernelIfRequiredIsCalledThenDontChangeKernelSource
} }
HWTEST2_F(AILTests, givenPreGen12AndProcessNameIsResolveWhenApplyWithDavinciResolveThenHostPtrTrackingIsDisabled, IsHostPtrTrackingDisabled) { HWTEST2_F(AILTests, givenPreGen12AndProcessNameIsResolveWhenApplyWithDavinciResolveThenHostPtrTrackingIsDisabled, IsHostPtrTrackingDisabled) {
VariableBackup<AILConfiguration *> ailConfigurationBackup(&ailConfigurationTable[productFamily]); AILWhitebox<productFamily> ail;
ail.processName = "resolve";
AILMock<productFamily> ailTemp;
ailTemp.processName = "resolve";
ailConfigurationTable[productFamily] = &ailTemp;
auto ailConfiguration = AILConfiguration::get(productFamily);
ASSERT_NE(nullptr, ailConfiguration);
NEO::RuntimeCapabilityTable rtTable = {}; NEO::RuntimeCapabilityTable rtTable = {};
rtTable.hostPtrTrackingEnabled = true; rtTable.hostPtrTrackingEnabled = true;
ailConfiguration->apply(rtTable); ail.apply(rtTable);
EXPECT_FALSE(rtTable.hostPtrTrackingEnabled); EXPECT_FALSE(rtTable.hostPtrTrackingEnabled);
} }
HWTEST2_F(AILTests, givenPreGen12AndAndProcessNameIsNotResolveWhenApplyWithDavinciResolveThenHostPtrTrackingIsEnabled, IsHostPtrTrackingDisabled) { HWTEST2_F(AILTests, givenPreGen12AndAndProcessNameIsNotResolveWhenApplyWithDavinciResolveThenHostPtrTrackingIsEnabled, IsHostPtrTrackingDisabled) {
VariableBackup<AILConfiguration *> ailConfigurationBackup(&ailConfigurationTable[productFamily]); AILWhitebox<productFamily> ail;
ail.processName = "usualProcessName";
AILMock<productFamily> ailTemp;
ailTemp.processName = "usualProcessName";
ailConfigurationTable[productFamily] = &ailTemp;
auto ailConfiguration = AILConfiguration::get(productFamily);
ASSERT_NE(nullptr, ailConfiguration);
NEO::RuntimeCapabilityTable rtTable = {}; NEO::RuntimeCapabilityTable rtTable = {};
rtTable.hostPtrTrackingEnabled = true; rtTable.hostPtrTrackingEnabled = true;
ailConfiguration->apply(rtTable); ail.apply(rtTable);
EXPECT_TRUE(rtTable.hostPtrTrackingEnabled); EXPECT_TRUE(rtTable.hostPtrTrackingEnabled);
} }
HWTEST_F(AILTests, whenAilIsDisabledByDebugVariableThenAilIsNotInitialized) {
DebugManagerStateRestore restore;
NEO::DebugManager.flags.EnableAIL.set(false);
VariableBackup<AILConfiguration *> ailConfigurationBackup(&ailConfigurationTable[productFamily]);
MockAILConfiguration ailConfig;
ailConfigurationTable[productFamily] = &ailConfig;
HardwareInfo hwInfo{};
hwInfo.platform.eProductFamily = productFamily;
hwInfo.platform.eRenderCoreFamily = renderCoreFamily;
NEO::MockExecutionEnvironment executionEnvironment{&hwInfo, true, 1};
auto rootDeviceEnvironment = executionEnvironment.rootDeviceEnvironments[0].get();
rootDeviceEnvironment->initAilConfiguration();
EXPECT_EQ(false, ailConfig.initCalled);
}
HWTEST_F(AILTests, whenAilIsEnabledByDebugVariableThenAilIsInitialized) {
DebugManagerStateRestore restore;
NEO::DebugManager.flags.EnableAIL.set(true);
VariableBackup<AILConfiguration *> ailConfigurationBackup(&ailConfigurationTable[productFamily]);
MockAILConfiguration ailConfig;
ailConfigurationTable[productFamily] = &ailConfig;
HardwareInfo hwInfo{};
hwInfo.platform.eProductFamily = productFamily;
hwInfo.platform.eRenderCoreFamily = renderCoreFamily;
NEO::MockExecutionEnvironment executionEnvironment{&hwInfo, true, 1};
auto rootDeviceEnvironment = executionEnvironment.rootDeviceEnvironments[0].get();
rootDeviceEnvironment->initAilConfiguration();
EXPECT_EQ(true, ailConfig.initCalled);
}
HWTEST_F(AILTests, GivenPlatformHasNoAilAvailableWhenAilIsEnabledThenAilInitializationReturnsTrue) { HWTEST_F(AILTests, GivenPlatformHasNoAilAvailableWhenAilIsEnabledThenAilInitializationReturnsTrue) {
DebugManagerStateRestore restore; DebugManagerStateRestore restore;
NEO::DebugManager.flags.EnableAIL.set(true); NEO::DebugManager.flags.EnableAIL.set(true);
VariableBackup<AILConfiguration *> ailConfigurationBackup(&ailConfigurationTable[productFamily]);
ailConfigurationTable[productFamily] = nullptr;
HardwareInfo hwInfo{}; HardwareInfo hwInfo{};
hwInfo.platform.eProductFamily = productFamily; hwInfo.platform.eProductFamily = productFamily;
hwInfo.platform.eRenderCoreFamily = renderCoreFamily; hwInfo.platform.eRenderCoreFamily = renderCoreFamily;
NEO::MockExecutionEnvironment executionEnvironment{&hwInfo, true, 1}; NEO::MockExecutionEnvironment executionEnvironment{&hwInfo, true, 1};
auto rootDeviceEnvironment = executionEnvironment.rootDeviceEnvironments[0].get(); auto rootDeviceEnvironment = executionEnvironment.rootDeviceEnvironments[0].get();
rootDeviceEnvironment->ailConfiguration.reset(nullptr);
EXPECT_TRUE(rootDeviceEnvironment->initAilConfiguration()); EXPECT_TRUE(rootDeviceEnvironment->initAilConfiguration());
} }
HWTEST2_F(AILTests, GivenAilWhenCheckingContextSyncFlagRequiredThenExpectFalse, IsAtLeastGen9) { HWTEST2_F(AILTests, GivenAilWhenCheckingContextSyncFlagRequiredThenExpectFalse, IsAtLeastGen9) {
AILMock<productFamily> ailTemp; AILWhitebox<productFamily> ail;
ailTemp.processName = "other"; ail.processName = "other";
EXPECT_FALSE(ailTemp.isContextSyncFlagRequired()); EXPECT_FALSE(ail.isContextSyncFlagRequired());
} }
} // namespace NEO } // namespace NEO

View File

@@ -5,9 +5,9 @@
* *
*/ */
#include "shared/source/ail/ail_configuration.h"
#include "shared/test/common/helpers/default_hw_info.h" #include "shared/test/common/helpers/default_hw_info.h"
#include "shared/test/common/helpers/variable_backup.h" #include "shared/test/common/helpers/variable_backup.h"
#include "shared/test/common/mocks/mock_ail_configuration.h"
#include "shared/test/common/test_macros/hw_test.h" #include "shared/test/common/test_macros/hw_test.h"
namespace NEO { namespace NEO {
@@ -27,15 +27,7 @@ HWTEST2_F(AILBaseTests, whenKernelSourceIsNotANGenDummyKernelThenDoNotEnforcePat
} }
HWTEST2_F(AILBaseTests, givenApplicationNamesThatRequirAILWhenCheckingIfPatchtokenFallbackIsRequiredThenIsCorrectResult, IsAtLeastSkl) { HWTEST2_F(AILBaseTests, givenApplicationNamesThatRequirAILWhenCheckingIfPatchtokenFallbackIsRequiredThenIsCorrectResult, IsAtLeastSkl) {
class AILMock : public AILConfigurationHw<productFamily> { AILWhitebox<productFamily> ail;
public:
using AILConfiguration::processName;
};
VariableBackup<AILConfiguration *> ailConfigurationBackup(&ailConfigurationTable[productFamily]);
AILMock ail;
ailConfigurationTable[productFamily] = &ail;
for (const auto &name : {"Resolve", for (const auto &name : {"Resolve",
"ArcControlAssist", "ArcControlAssist",
"ArcControl"}) { "ArcControl"}) {

View File

@@ -5,9 +5,9 @@
* *
*/ */
#include "shared/source/ail/ail_configuration.h"
#include "shared/test/common/helpers/unit_test_helper.h" #include "shared/test/common/helpers/unit_test_helper.h"
#include "shared/test/common/helpers/variable_backup.h" #include "shared/test/common/helpers/variable_backup.h"
#include "shared/test/common/mocks/mock_ail_configuration.h"
#include "shared/test/common/test_macros/hw_test.h" #include "shared/test/common/test_macros/hw_test.h"
namespace NEO { namespace NEO {
@@ -17,52 +17,37 @@ namespace SysCalls {
extern const wchar_t *currentLibraryPath; extern const wchar_t *currentLibraryPath;
} }
template <PRODUCT_FAMILY productFamily>
class AILMock : public AILConfigurationHw<productFamily> {
public:
using AILConfiguration::processName;
};
HWTEST2_F(AILTests, givenValidApplicationPathWhenAILinitProcessExecutableNameThenProperProcessNameIsReturned, IsAtLeastGen12lp) { HWTEST2_F(AILTests, givenValidApplicationPathWhenAILinitProcessExecutableNameThenProperProcessNameIsReturned, IsAtLeastGen12lp) {
VariableBackup<const wchar_t *> applicationPathBackup(&SysCalls::currentLibraryPath); VariableBackup<const wchar_t *> applicationPathBackup(&SysCalls::currentLibraryPath);
applicationPathBackup = L"C\\Users\\Administrator\\application.exe"; applicationPathBackup = L"C\\Users\\Administrator\\application.exe";
VariableBackup<AILConfiguration *> ailConfigurationBackup(&ailConfigurationTable[productFamily]); AILWhitebox<productFamily> ail;
AILMock<productFamily> ailTemp; EXPECT_EQ(ail.initProcessExecutableName(), true);
ailConfigurationTable[productFamily] = &ailTemp;
EXPECT_EQ(ailTemp.initProcessExecutableName(), true); EXPECT_EQ("application", ail.processName);
EXPECT_EQ("application", ailTemp.processName);
} }
HWTEST2_F(AILTests, givenValidApplicationPathWithoutLongNameWhenAILinitProcessExecutableNameThenProperProcessNameIsReturned, IsAtLeastGen12lp) { HWTEST2_F(AILTests, givenValidApplicationPathWithoutLongNameWhenAILinitProcessExecutableNameThenProperProcessNameIsReturned, IsAtLeastGen12lp) {
VariableBackup<const wchar_t *> applicationPathBackup(&SysCalls::currentLibraryPath); VariableBackup<const wchar_t *> applicationPathBackup(&SysCalls::currentLibraryPath);
applicationPathBackup = L"C\\Users\\Administrator\\application"; applicationPathBackup = L"C\\Users\\Administrator\\application";
VariableBackup<AILConfiguration *> ailConfigurationBackup(&ailConfigurationTable[productFamily]); AILWhitebox<productFamily> ail;
AILMock<productFamily> ailTemp; EXPECT_EQ(ail.initProcessExecutableName(), true);
ailConfigurationTable[productFamily] = &ailTemp;
EXPECT_EQ(ailTemp.initProcessExecutableName(), true); EXPECT_EQ("application", ail.processName);
EXPECT_EQ("application", ailTemp.processName);
} }
HWTEST2_F(AILTests, givenApplicationPathWithNonLatinCharactersWhenAILinitProcessExecutableNameThenProperProcessNameIsReturned, IsAtLeastGen12lp) { HWTEST2_F(AILTests, givenApplicationPathWithNonLatinCharactersWhenAILinitProcessExecutableNameThenProperProcessNameIsReturned, IsAtLeastGen12lp) {
VariableBackup<const wchar_t *> applicationPathBackup(&SysCalls::currentLibraryPath); VariableBackup<const wchar_t *> applicationPathBackup(&SysCalls::currentLibraryPath);
applicationPathBackup = L"C\\\u4E20\u4E24\\application"; applicationPathBackup = L"C\\\u4E20\u4E24\\application";
VariableBackup<AILConfiguration *> ailConfigurationBackup(&ailConfigurationTable[productFamily]); AILWhitebox<productFamily> ail;
AILMock<productFamily> ailTemp; EXPECT_EQ(ail.initProcessExecutableName(), true);
ailConfigurationTable[productFamily] = &ailTemp;
EXPECT_EQ(ailTemp.initProcessExecutableName(), true); EXPECT_EQ("application", ail.processName);
EXPECT_EQ("application", ailTemp.processName);
} }
} // namespace NEO } // namespace NEO

View File

@@ -207,6 +207,17 @@ TEST(RootDeviceEnvironment, givenHardwareInfoAndDebugVariableNodeOrdinalEqualsCc
EXPECT_TRUE(hwInfo->featureTable.flags.ftrRcsNode); EXPECT_TRUE(hwInfo->featureTable.flags.ftrRcsNode);
} }
TEST(RootDeviceEnvironment, givenEnableAILFlagSetToFalseWhenInitializingAILConfigurationThenSkipInitializingIt) {
DebugManagerStateRestore restorer;
DebugManager.flags.EnableAIL.set(false);
MockExecutionEnvironment executionEnvironment;
auto rootDeviceEnvironment = static_cast<MockRootDeviceEnvironment *>(executionEnvironment.rootDeviceEnvironments[0].get());
ASSERT_EQ(nullptr, rootDeviceEnvironment->ailConfiguration);
rootDeviceEnvironment->initAilConfiguration();
EXPECT_EQ(nullptr, rootDeviceEnvironment->ailConfiguration);
}
TEST(ExecutionEnvironment, givenExecutionEnvironmentWhenInitializeMemoryManagerIsCalledThenLocalMemorySupportedInMemoryManagerHasCorrectValue) { TEST(ExecutionEnvironment, givenExecutionEnvironmentWhenInitializeMemoryManagerIsCalledThenLocalMemorySupportedInMemoryManagerHasCorrectValue) {
const HardwareInfo *hwInfo = defaultHwInfo.get(); const HardwareInfo *hwInfo = defaultHwInfo.get();
auto device = std::unique_ptr<Device>(MockDevice::createWithNewExecutionEnvironment<MockDevice>(hwInfo)); auto device = std::unique_ptr<Device>(MockDevice::createWithNewExecutionEnvironment<MockDevice>(hwInfo));

View File

@@ -6,7 +6,6 @@
*/ */
#include "shared/source/ail/ail_configuration.h" #include "shared/source/ail/ail_configuration.h"
#include "shared/test/common/helpers/variable_backup.h"
#include "shared/test/common/mocks/mock_execution_environment.h" #include "shared/test/common/mocks/mock_execution_environment.h"
#include "shared/test/common/test_macros/hw_test.h" #include "shared/test/common/test_macros/hw_test.h"
#include "shared/test/common/utilities/destructor_counted.h" #include "shared/test/common/utilities/destructor_counted.h"
@@ -25,11 +24,7 @@ HWTEST2_F(RootDeviceEnvironmentTests, givenRootDeviceEnvironmentWhenAILInitProce
return false; return false;
} }
}; };
VariableBackup<AILConfiguration *> ailConfiguration(&ailConfigurationTable[productFamily]); rootDeviceEnvironment->ailConfiguration.reset(new AILDG1());
AILDG1 ailDg1;
ailConfigurationTable[productFamily] = &ailDg1;
EXPECT_EQ(false, rootDeviceEnvironment->initAilConfiguration()); EXPECT_EQ(false, rootDeviceEnvironment->initAilConfiguration());
} }
} // namespace NEO } // namespace NEO

View File

@@ -28,12 +28,7 @@ HWTEST2_F(AILTestsDg2, givenFixesForApplicationsWhenModifyKernelIfRequiredIsCall
bool hashCorrect = {true}; bool hashCorrect = {true};
}; };
VariableBackup<AILConfiguration *> ailConfigurationBackup(&ailConfigurationTable[productFamily]);
AILMock ail; AILMock ail;
ailConfigurationTable[productFamily] = &ail;
auto ailConfiguration = AILConfiguration::get(defaultHwInfo->platform.eProductFamily);
ASSERT_NE(nullptr, ailConfiguration);
std::string_view fixCode = "else { SYNC_WARPS; }"; std::string_view fixCode = "else { SYNC_WARPS; }";
for (auto name : {"FAHBench-gui", "FAHBench-cmd"}) { for (auto name : {"FAHBench-gui", "FAHBench-cmd"}) {

View File

@@ -6,7 +6,6 @@
*/ */
#include "shared/test/common/helpers/default_hw_info.h" #include "shared/test/common/helpers/default_hw_info.h"
#include "shared/test/common/helpers/variable_backup.h"
#include "shared/test/common/mocks/mock_ail_configuration.h" #include "shared/test/common/mocks/mock_ail_configuration.h"
#include "shared/test/common/test_macros/hw_test.h" #include "shared/test/common/test_macros/hw_test.h"
@@ -15,9 +14,7 @@ namespace NEO {
using AILTestsMTL = ::testing::Test; using AILTestsMTL = ::testing::Test;
HWTEST2_F(AILTestsMTL, givenMtlWhenSvchostAppIsDetectedThenDisableDirectSubmission, IsMTL) { HWTEST2_F(AILTestsMTL, givenMtlWhenSvchostAppIsDetectedThenDisableDirectSubmission, IsMTL) {
VariableBackup<AILConfiguration *> ailConfigurationBackup(&ailConfigurationTable[productFamily]); AILWhitebox<productFamily> ail;
AILMock<productFamily> ail;
ailConfigurationTable[productFamily] = &ail;
auto capabilityTable = defaultHwInfo->capabilityTable; auto capabilityTable = defaultHwInfo->capabilityTable;
auto defaultEngineSupportedValue = capabilityTable.directSubmissionEngines.data[aub_stream::ENGINE_CCS].engineSupported; auto defaultEngineSupportedValue = capabilityTable.directSubmissionEngines.data[aub_stream::ENGINE_CCS].engineSupported;