refactor: add ail context sync flag

Signed-off-by: Zbigniew Zdanowicz <zbigniew.zdanowicz@intel.com>
This commit is contained in:
Zbigniew Zdanowicz 2023-10-14 11:32:40 +00:00 committed by Compute-Runtime-Automation
parent dae8c34f81
commit 0b7e6d90a3
9 changed files with 106 additions and 34 deletions

View File

@ -10,6 +10,7 @@
#include "igfxfmid.h"
#include <cstdint>
#include <set>
#include <string>
/*
@ -56,6 +57,8 @@ class AILConfiguration {
virtual bool isFallbackToPatchtokensRequired(const std::string &kernelSources) = 0;
virtual bool isContextSyncFlagRequired() = 0;
protected:
virtual void applyExt(RuntimeCapabilityTable &runtimeCapabilityTable) = 0;
std::string processName;
@ -66,6 +69,8 @@ class AILConfiguration {
extern AILConfiguration *ailConfigurationTable[IGFX_MAX_PRODUCT];
extern const std::set<std::string_view> applicationsContextSyncFlag;
template <PRODUCT_FAMILY Product>
class AILConfigurationHw : public AILConfiguration {
public:
@ -78,6 +83,7 @@ class AILConfigurationHw : public AILConfiguration {
void modifyKernelIfRequired(std::string &kernel) override;
bool isFallbackToPatchtokensRequired(const std::string &kernelSources) override;
bool isContextSyncFlagRequired() override;
};
template <PRODUCT_FAMILY product>

View File

@ -40,4 +40,9 @@ template <PRODUCT_FAMILY Product>
inline void AILConfigurationHw<Product>::applyExt(RuntimeCapabilityTable &runtimeCapabilityTable) {
}
template <PRODUCT_FAMILY Product>
inline bool AILConfigurationHw<Product>::isContextSyncFlagRequired() {
return false;
}
} // namespace NEO

View File

@ -24,6 +24,8 @@ std::map<std::string_view, std::vector<AILEnumeration>> applicationMap = {{"blen
// Modify reported platform name to ensure older versions of Adobe Premiere Pro are able to recognize the GPU device
{"Adobe Premiere Pro", {AILEnumeration::ENABLE_LEGACY_PLATFORM_NAME}}};
const std::set<std::string_view> applicationsContextSyncFlag = {};
AILConfiguration *ailConfigurationTable[IGFX_MAX_PRODUCT] = {};
AILConfiguration *AILConfiguration::get(PRODUCT_FAMILY productFamily) {

View File

@ -0,0 +1,15 @@
/*
* Copyright (C) 2023 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#include "shared/source/ail/ail_configuration_base.inl"
namespace NEO {
static EnableAIL<IGFX_BROADWELL> enableAILBDW;
template class AILConfigurationHw<IGFX_BROADWELL>;
} // namespace NEO

View File

@ -33,6 +33,12 @@ void AILConfigurationHw<IGFX_METEORLAKE>::applyExt(RuntimeCapabilityTable &runti
}
}
template <>
bool AILConfigurationHw<IGFX_METEORLAKE>::isContextSyncFlagRequired() {
auto iterator = applicationsContextSyncFlag.find(processName);
return iterator != applicationsContextSyncFlag.end();
}
template class AILConfigurationHw<IGFX_METEORLAKE>;
} // namespace NEO

View File

@ -16,6 +16,7 @@ set_property(GLOBAL PROPERTY NEO_CORE_tests_compiler_mocks ${NEO_CORE_tests_comp
set(NEO_CORE_tests_mocks
${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt
${CMAKE_CURRENT_SOURCE_DIR}/debugger_l0_create.cpp
${CMAKE_CURRENT_SOURCE_DIR}/mock_ail_configuration.h
${CMAKE_CURRENT_SOURCE_DIR}/mock_allocation_properties.h
${CMAKE_CURRENT_SOURCE_DIR}/mock_assert_handler.h
${CMAKE_CURRENT_SOURCE_DIR}/mock_aub_center.h

View File

@ -0,0 +1,44 @@
/*
* Copyright (C) 2023 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#pragma once
#include "shared/source/ail/ail_configuration.h"
namespace NEO {
class MockAILConfiguration : public AILConfiguration {
public:
bool initProcessExecutableName() override {
initCalled = true;
return true;
}
bool initCalled = false;
void modifyKernelIfRequired(std::string &kernel) override {}
bool isFallbackToPatchtokensRequired(const std::string &kernelSources) override {
return false;
}
bool contextSyncFlagReturn = false;
bool isContextSyncFlagRequired() override {
return contextSyncFlagReturn;
}
protected:
void applyExt(RuntimeCapabilityTable &runtimeCapabilityTable) override {}
};
template <PRODUCT_FAMILY productFamily>
class AILMock : public AILConfigurationHw<productFamily> {
public:
using AILConfiguration::apply;
using AILConfiguration::isKernelHashCorrect;
using AILConfiguration::processName;
using AILConfiguration::sourcesContain;
};
} // namespace NEO

View File

@ -5,10 +5,10 @@
*
*/
#include "shared/source/ail/ail_configuration.h"
#include "shared/test/common/helpers/debug_manager_state_restore.h"
#include "shared/test/common/helpers/unit_test_helper.h"
#include "shared/test/common/helpers/variable_backup.h"
#include "shared/test/common/mocks/mock_ail_configuration.h"
#include "shared/test/common/mocks/mock_execution_environment.h"
#include "shared/test/common/test_macros/hw_test.h"
@ -18,13 +18,6 @@ using IsDG2 = IsProduct<IGFX_DG2>;
using IsHostPtrTrackingDisabled = IsWithinGfxCore<IGFX_GEN9_CORE, IGFX_GEN11LP_CORE>;
using AILTests = ::testing::Test;
template <PRODUCT_FAMILY productFamily>
class AILMock : public AILConfigurationHw<productFamily> {
public:
using AILConfiguration::isKernelHashCorrect;
using AILConfiguration::processName;
using AILConfiguration::sourcesContain;
};
HWTEST2_F(AILTests, givenInitializedTemplateWhenGetAILConfigurationThenNullptrIsNotReturned, IsSKL) {
auto ailConfiguration = AILConfiguration::get(productFamily);
@ -182,23 +175,6 @@ HWTEST2_F(AILTests, givenPreGen12AndAndProcessNameIsNotResolveWhenApplyWithDavin
EXPECT_TRUE(rtTable.hostPtrTrackingEnabled);
}
class MockAILConfiguration : public AILConfiguration {
public:
bool initProcessExecutableName() override {
initCalled = true;
return true;
}
bool initCalled = false;
void modifyKernelIfRequired(std::string &kernel) override {}
bool isFallbackToPatchtokensRequired(const std::string &kernelSources) override {
return false;
}
protected:
void applyExt(RuntimeCapabilityTable &runtimeCapabilityTable) override {}
};
HWTEST_F(AILTests, whenAilIsDisabledByDebugVariableThenAilIsNotInitialized) {
DebugManagerStateRestore restore;
NEO::DebugManager.flags.EnableAIL.set(false);
@ -237,4 +213,26 @@ HWTEST_F(AILTests, whenAilIsEnabledByDebugVariableThenAilIsInitialized) {
EXPECT_EQ(true, ailConfig.initCalled);
}
HWTEST_F(AILTests, GivenPlatformHasNoAilAvailableWhenAilIsEnabledThenAilInitializationReturnsTrue) {
DebugManagerStateRestore restore;
NEO::DebugManager.flags.EnableAIL.set(true);
VariableBackup<AILConfiguration *> ailConfigurationBackup(&ailConfigurationTable[productFamily]);
ailConfigurationTable[productFamily] = nullptr;
HardwareInfo hwInfo{};
hwInfo.platform.eProductFamily = productFamily;
hwInfo.platform.eRenderCoreFamily = renderCoreFamily;
NEO::MockExecutionEnvironment executionEnvironment{&hwInfo, true, 1};
auto rootDeviceEnvironment = executionEnvironment.rootDeviceEnvironments[0].get();
EXPECT_TRUE(rootDeviceEnvironment->initAilConfiguration());
}
HWTEST2_F(AILTests, GivenAilWhenCheckingContextSyncFlagRequiredThenExpectFalse, IsAtLeastGen9) {
AILMock<productFamily> ailTemp;
ailTemp.processName = "other";
EXPECT_FALSE(ailTemp.isContextSyncFlagRequired());
}
} // 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/variable_backup.h"
#include "shared/test/common/mocks/mock_ail_configuration.h"
#include "shared/test/common/test_macros/hw_test.h"
namespace NEO {
@ -15,14 +15,8 @@ namespace NEO {
using AILTestsMTL = ::testing::Test;
HWTEST2_F(AILTestsMTL, givenMtlWhenSvchostAppIsDetectedThenDisableDirectSubmission, IsMTL) {
class AILMock : public AILConfigurationHw<productFamily> {
public:
using AILConfiguration::apply;
using AILConfiguration::processName;
};
VariableBackup<AILConfiguration *> ailConfigurationBackup(&ailConfigurationTable[productFamily]);
AILMock ail;
AILMock<productFamily> ail;
ailConfigurationTable[productFamily] = &ail;
auto capabilityTable = defaultHwInfo->capabilityTable;
@ -36,4 +30,5 @@ HWTEST2_F(AILTestsMTL, givenMtlWhenSvchostAppIsDetectedThenDisableDirectSubmissi
ail.apply(capabilityTable);
EXPECT_FALSE(capabilityTable.directSubmissionEngines.data[aub_stream::ENGINE_CCS].engineSupported);
}
} // namespace NEO
} // namespace NEO