mirror of
https://github.com/intel/compute-runtime.git
synced 2025-12-19 16:24:18 +08:00
refactor: tests for buffer pool
add support for future AIL Related-To: NEO-11694 Signed-off-by: Dominik Dabek <dominik.dabek@intel.com>
This commit is contained in:
committed by
Compute-Runtime-Automation
parent
f910f94ef9
commit
b6d86d2648
@@ -7,11 +7,13 @@
|
||||
|
||||
#include "opencl/source/context/context.h"
|
||||
|
||||
#include "shared/source/ail/ail_configuration.h"
|
||||
#include "shared/source/built_ins/built_ins.h"
|
||||
#include "shared/source/command_stream/command_stream_receiver.h"
|
||||
#include "shared/source/compiler_interface/compiler_interface.h"
|
||||
#include "shared/source/debug_settings/debug_settings_manager.h"
|
||||
#include "shared/source/device/sub_device.h"
|
||||
#include "shared/source/execution_environment/root_device_environment.h"
|
||||
#include "shared/source/helpers/api_specific_config.h"
|
||||
#include "shared/source/helpers/get_info.h"
|
||||
#include "shared/source/helpers/hw_info.h"
|
||||
@@ -539,8 +541,9 @@ bool Context::BufferPoolAllocator::isAggregatedSmallBuffersEnabled(Context *cont
|
||||
bool isSupportedForSingleDeviceContexts = false;
|
||||
bool isSupportedForAllContexts = false;
|
||||
if (context->getNumDevices() > 0) {
|
||||
auto ailConfiguration = context->getDevices()[0]->getRootDeviceEnvironment().getAILConfigurationHelper();
|
||||
auto &productHelper = context->getDevices()[0]->getProductHelper();
|
||||
isSupportedForSingleDeviceContexts = productHelper.isBufferPoolAllocatorSupported();
|
||||
isSupportedForSingleDeviceContexts = productHelper.isBufferPoolAllocatorSupported() && (ailConfiguration ? ailConfiguration->isBufferPoolEnabled() : true);
|
||||
}
|
||||
|
||||
if (debugManager.flags.ExperimentalSmallBufferPoolAllocator.get() != -1) {
|
||||
|
||||
@@ -9,6 +9,9 @@
|
||||
#include "shared/source/utilities/buffer_pool_allocator.inl"
|
||||
#include "shared/source/utilities/heap_allocator.h"
|
||||
#include "shared/test/common/helpers/debug_manager_state_restore.h"
|
||||
#include "shared/test/common/helpers/mock_product_helper_hw.h"
|
||||
#include "shared/test/common/helpers/raii_product_helper.h"
|
||||
#include "shared/test/common/mocks/mock_ail_configuration.h"
|
||||
#include "shared/test/common/mocks/mock_memory_manager.h"
|
||||
#include "shared/test/common/test_macros/hw_test.h"
|
||||
#include "shared/test/common/test_macros/test.h"
|
||||
@@ -99,13 +102,9 @@ class AggregatedSmallBuffersKernelTest : public AggregatedSmallBuffersTestTempla
|
||||
|
||||
using AggregatedSmallBuffersDefaultTest = AggregatedSmallBuffersTestTemplate<-1>;
|
||||
|
||||
HWTEST2_F(AggregatedSmallBuffersDefaultTest, givenDifferentFlagValuesAndSingleOrMultiDeviceContextWhenCheckIfEnabledThenReturnCorrectValue, IsBeforeXeHpgCore) {
|
||||
HWTEST_F(AggregatedSmallBuffersDefaultTest, givenDifferentFlagValuesAndSingleOrMultiDeviceContextWhenCheckIfEnabledThenReturnCorrectValue) {
|
||||
DebugManagerStateRestore restore;
|
||||
// Single device context
|
||||
{
|
||||
debugManager.flags.ExperimentalSmallBufferPoolAllocator.set(-1);
|
||||
EXPECT_FALSE(context->getBufferPoolAllocator().isAggregatedSmallBuffersEnabled(context.get()));
|
||||
}
|
||||
{
|
||||
debugManager.flags.ExperimentalSmallBufferPoolAllocator.set(0);
|
||||
EXPECT_FALSE(context->getBufferPoolAllocator().isAggregatedSmallBuffersEnabled(context.get()));
|
||||
@@ -120,10 +119,6 @@ HWTEST2_F(AggregatedSmallBuffersDefaultTest, givenDifferentFlagValuesAndSingleOr
|
||||
}
|
||||
// Multi device context
|
||||
context->devices.push_back(nullptr);
|
||||
{
|
||||
debugManager.flags.ExperimentalSmallBufferPoolAllocator.set(-1);
|
||||
EXPECT_FALSE(context->getBufferPoolAllocator().isAggregatedSmallBuffersEnabled(context.get()));
|
||||
}
|
||||
{
|
||||
debugManager.flags.ExperimentalSmallBufferPoolAllocator.set(0);
|
||||
EXPECT_FALSE(context->getBufferPoolAllocator().isAggregatedSmallBuffersEnabled(context.get()));
|
||||
@@ -139,44 +134,28 @@ HWTEST2_F(AggregatedSmallBuffersDefaultTest, givenDifferentFlagValuesAndSingleOr
|
||||
context->devices.pop_back();
|
||||
}
|
||||
|
||||
HWTEST2_F(AggregatedSmallBuffersDefaultTest, givenDifferentFlagValuesAndSingleOrMultiDeviceContextWhenCheckIfEnabledThenReturnCorrectValue, IsXeHpcCore) {
|
||||
DebugManagerStateRestore restore;
|
||||
// Single device context
|
||||
{
|
||||
debugManager.flags.ExperimentalSmallBufferPoolAllocator.set(-1);
|
||||
EXPECT_FALSE(context->getBufferPoolAllocator().isAggregatedSmallBuffersEnabled(context.get()));
|
||||
}
|
||||
{
|
||||
debugManager.flags.ExperimentalSmallBufferPoolAllocator.set(0);
|
||||
EXPECT_FALSE(context->getBufferPoolAllocator().isAggregatedSmallBuffersEnabled(context.get()));
|
||||
}
|
||||
{
|
||||
debugManager.flags.ExperimentalSmallBufferPoolAllocator.set(1);
|
||||
HWTEST2_F(AggregatedSmallBuffersDefaultTest, givenSupportsOclBufferPoolCapabilityWhenCheckIfEnabledThenReturnCorrectValue, MatchAny) {
|
||||
auto &rootDeviceEnvironment = *device->getExecutionEnvironment()->rootDeviceEnvironments[1];
|
||||
NEO::RAIIProductHelperFactory<MockProductHelperHw<productFamily>> raii(rootDeviceEnvironment);
|
||||
|
||||
rootDeviceEnvironment.ailConfiguration.reset(new MockAILConfiguration());
|
||||
auto mockAIL = static_cast<MockAILConfiguration *>(rootDeviceEnvironment.ailConfiguration.get());
|
||||
|
||||
raii.mockProductHelper->isBufferPoolAllocatorSupportedValue = true;
|
||||
mockAIL->isBufferPoolEnabledReturn = true;
|
||||
EXPECT_TRUE(context->getBufferPoolAllocator().isAggregatedSmallBuffersEnabled(context.get()));
|
||||
}
|
||||
{
|
||||
debugManager.flags.ExperimentalSmallBufferPoolAllocator.set(2);
|
||||
EXPECT_TRUE(context->getBufferPoolAllocator().isAggregatedSmallBuffersEnabled(context.get()));
|
||||
}
|
||||
// Multi device context
|
||||
context->devices.push_back(nullptr);
|
||||
{
|
||||
debugManager.flags.ExperimentalSmallBufferPoolAllocator.set(-1);
|
||||
|
||||
raii.mockProductHelper->isBufferPoolAllocatorSupportedValue = true;
|
||||
mockAIL->isBufferPoolEnabledReturn = false;
|
||||
EXPECT_FALSE(context->getBufferPoolAllocator().isAggregatedSmallBuffersEnabled(context.get()));
|
||||
}
|
||||
{
|
||||
debugManager.flags.ExperimentalSmallBufferPoolAllocator.set(0);
|
||||
|
||||
raii.mockProductHelper->isBufferPoolAllocatorSupportedValue = false;
|
||||
mockAIL->isBufferPoolEnabledReturn = true;
|
||||
EXPECT_FALSE(context->getBufferPoolAllocator().isAggregatedSmallBuffersEnabled(context.get()));
|
||||
}
|
||||
{
|
||||
debugManager.flags.ExperimentalSmallBufferPoolAllocator.set(1);
|
||||
|
||||
raii.mockProductHelper->isBufferPoolAllocatorSupportedValue = false;
|
||||
mockAIL->isBufferPoolEnabledReturn = false;
|
||||
EXPECT_FALSE(context->getBufferPoolAllocator().isAggregatedSmallBuffersEnabled(context.get()));
|
||||
}
|
||||
{
|
||||
debugManager.flags.ExperimentalSmallBufferPoolAllocator.set(2);
|
||||
EXPECT_TRUE(context->getBufferPoolAllocator().isAggregatedSmallBuffersEnabled(context.get()));
|
||||
}
|
||||
context->devices.pop_back();
|
||||
}
|
||||
|
||||
using AggregatedSmallBuffersDisabledTest = AggregatedSmallBuffersTestTemplate<0>;
|
||||
|
||||
@@ -68,6 +68,8 @@ class AILConfiguration {
|
||||
|
||||
virtual bool isContextSyncFlagRequired() = 0;
|
||||
|
||||
virtual bool isBufferPoolEnabled() = 0;
|
||||
|
||||
virtual ~AILConfiguration() = default;
|
||||
|
||||
virtual bool useLegacyValidationLogic() = 0;
|
||||
@@ -84,6 +86,7 @@ class AILConfiguration {
|
||||
|
||||
extern const std::set<std::string_view> applicationsContextSyncFlag;
|
||||
extern const std::set<std::string_view> applicationsForceRcsDg2;
|
||||
extern const std::set<std::string_view> applicationsBufferPoolDisabledDG2;
|
||||
|
||||
template <PRODUCT_FAMILY product>
|
||||
class AILConfigurationHw : public AILConfiguration {
|
||||
@@ -98,6 +101,7 @@ class AILConfigurationHw : public AILConfiguration {
|
||||
void modifyKernelIfRequired(std::string &kernel) override;
|
||||
bool isFallbackToPatchtokensRequired(const std::string &kernelSources) override;
|
||||
bool isContextSyncFlagRequired() override;
|
||||
bool isBufferPoolEnabled() override;
|
||||
bool useLegacyValidationLogic() override;
|
||||
bool forceRcs() override;
|
||||
|
||||
|
||||
@@ -45,6 +45,11 @@ inline bool AILConfigurationHw<product>::isContextSyncFlagRequired() {
|
||||
return false;
|
||||
}
|
||||
|
||||
template <PRODUCT_FAMILY product>
|
||||
inline bool AILConfigurationHw<product>::isBufferPoolEnabled() {
|
||||
return true;
|
||||
}
|
||||
|
||||
template <PRODUCT_FAMILY product>
|
||||
inline bool AILConfigurationHw<product>::useLegacyValidationLogic() {
|
||||
return false;
|
||||
|
||||
@@ -30,6 +30,8 @@ const std::set<std::string_view> applicationsForceRcsDg2 = {};
|
||||
|
||||
const std::set<std::string_view> applicationsContextSyncFlag = {};
|
||||
|
||||
const std::set<std::string_view> applicationsBufferPoolDisabledDG2 = {};
|
||||
|
||||
AILConfigurationCreateFunctionType ailConfigurationFactory[IGFX_MAX_PRODUCT];
|
||||
|
||||
void AILConfiguration::apply(RuntimeCapabilityTable &runtimeCapabilityTable) {
|
||||
|
||||
@@ -64,6 +64,12 @@ inline void AILConfigurationHw<IGFX_DG2>::applyExt(RuntimeCapabilityTable &runti
|
||||
}
|
||||
}
|
||||
|
||||
template <>
|
||||
bool AILConfigurationHw<IGFX_DG2>::isBufferPoolEnabled() {
|
||||
auto iterator = applicationsBufferPoolDisabledDG2.find(processName);
|
||||
return iterator == applicationsBufferPoolDisabledDG2.end();
|
||||
}
|
||||
|
||||
template class AILConfigurationHw<IGFX_DG2>;
|
||||
|
||||
} // namespace NEO
|
||||
|
||||
@@ -26,6 +26,7 @@ struct MockProductHelperHw : NEO::ProductHelperHw<productFamily> {
|
||||
bool isUnlockingLockedPtrNecessary(const HardwareInfo &hwInfo) const override;
|
||||
std::vector<uint32_t> getSupportedNumGrfs(const ReleaseHelper *releaseHelper) const override;
|
||||
aub_stream::EngineType getDefaultCopyEngine() const override;
|
||||
bool isBufferPoolAllocatorSupported() const override;
|
||||
|
||||
bool use128MbEdram = false;
|
||||
bool enableMidThreadPreemption = false;
|
||||
@@ -34,6 +35,7 @@ struct MockProductHelperHw : NEO::ProductHelperHw<productFamily> {
|
||||
bool failOnConfigureHardwareCustom = false;
|
||||
bool isCooperativeEngineSupportedValue = true;
|
||||
bool returnedIsUnlockingLockedPtrNecessary = false;
|
||||
bool isBufferPoolAllocatorSupportedValue = true;
|
||||
uint32_t returnedStepping = 0;
|
||||
uint32_t returnedL1CachePolicy = 0;
|
||||
uint32_t returnedL1CachePolicyIfDebugger = 0;
|
||||
|
||||
@@ -75,6 +75,11 @@ bool MockProductHelperHw<gfxProduct>::isUnlockingLockedPtrNecessary(const Hardwa
|
||||
return this->returnedIsUnlockingLockedPtrNecessary;
|
||||
}
|
||||
|
||||
template <>
|
||||
bool MockProductHelperHw<gfxProduct>::isBufferPoolAllocatorSupported() const {
|
||||
return this->isBufferPoolAllocatorSupportedValue;
|
||||
}
|
||||
|
||||
template <>
|
||||
std::vector<uint32_t> MockProductHelperHw<gfxProduct>::getSupportedNumGrfs(const ReleaseHelper *releaseHelper) const {
|
||||
if (releaseHelper) {
|
||||
|
||||
@@ -27,6 +27,11 @@ class MockAILConfiguration : public AILConfiguration {
|
||||
return contextSyncFlagReturn;
|
||||
}
|
||||
|
||||
bool isBufferPoolEnabledReturn = true;
|
||||
bool isBufferPoolEnabled() override {
|
||||
return isBufferPoolEnabledReturn;
|
||||
}
|
||||
|
||||
bool fallbackToLegacyValidationLogic = false;
|
||||
bool useLegacyValidationLogic() override {
|
||||
return fallbackToLegacyValidationLogic;
|
||||
|
||||
Reference in New Issue
Block a user