fix: disable usm reuse if debugger enabled

Related-To: NEO-6893

Signed-off-by: Dominik Dabek <dominik.dabek@intel.com>
This commit is contained in:
Dominik Dabek
2025-07-01 10:20:14 +00:00
committed by Compute-Runtime-Automation
parent 441c7fe319
commit e52fa32271
2 changed files with 39 additions and 6 deletions

View File

@@ -929,7 +929,10 @@ void SVMAllocsManager::initUsmHostAllocationsCache() {
}
void SVMAllocsManager::initUsmAllocationsCaches(Device &device) {
bool usmDeviceAllocationsCacheEnabled = NEO::ApiSpecificConfig::isDeviceAllocationCacheEnabled() && device.getProductHelper().isDeviceUsmAllocationReuseSupported();
const bool debuggerEnabled = nullptr != device.getDebugger();
bool usmDeviceAllocationsCacheEnabled = NEO::ApiSpecificConfig::isDeviceAllocationCacheEnabled() &&
device.getProductHelper().isDeviceUsmAllocationReuseSupported() &&
!debuggerEnabled;
if (debugManager.flags.ExperimentalEnableDeviceAllocationCache.get() != -1) {
usmDeviceAllocationsCacheEnabled = !!debugManager.flags.ExperimentalEnableDeviceAllocationCache.get();
}
@@ -938,7 +941,9 @@ void SVMAllocsManager::initUsmAllocationsCaches(Device &device) {
this->initUsmDeviceAllocationsCache(device);
}
bool usmHostAllocationsCacheEnabled = NEO::ApiSpecificConfig::isHostAllocationCacheEnabled() && device.getProductHelper().isHostUsmAllocationReuseSupported();
bool usmHostAllocationsCacheEnabled = NEO::ApiSpecificConfig::isHostAllocationCacheEnabled() &&
device.getProductHelper().isHostUsmAllocationReuseSupported() &&
!debuggerEnabled;
if (debugManager.flags.ExperimentalEnableHostAllocationCache.get() != -1) {
usmHostAllocationsCacheEnabled = !!debugManager.flags.ExperimentalEnableHostAllocationCache.get();
}

View File

@@ -10,6 +10,7 @@
#include "shared/test/common/helpers/debug_manager_state_restore.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_debugger.h"
#include "shared/test/common/mocks/mock_deferred_deleter.h"
#include "shared/test/common/mocks/mock_device.h"
#include "shared/test/common/mocks/mock_graphics_allocation.h"
@@ -242,10 +243,10 @@ TEST_F(SvmDeviceAllocationCacheTest, givenAllocationCacheEnabledAndMaxSizeZeroWh
svmManager->cleanupUSMAllocCaches();
}
HWTEST_F(SvmDeviceAllocationCacheTest, givenOclApiSpecificConfigWhenCheckingIfEnabledItIsEnabledIfProductHelperMethodReturnsTrue) {
HWTEST_F(SvmDeviceAllocationCacheTest, givenOclApiSpecificConfigAndProductHelperAndDebuggerWhenCheckingIfEnabledThenEnableCorrectly) {
VariableBackup<ApiSpecificConfig::ApiType> backup(&apiTypeForUlts, ApiSpecificConfig::OCL);
auto deviceFactory = std::make_unique<UltDeviceFactory>(1, 1);
auto device = deviceFactory->rootDevices[0];
MockDevice *device = deviceFactory->rootDevices[0];
RAIIProductHelperFactory<MockProductHelper> raii(*device->getExecutionEnvironment()->rootDeviceEnvironments[0]);
MockAILConfiguration mockAilConfigurationHelper;
device->mockAilConfigurationHelper = &mockAilConfigurationHelper;
@@ -279,6 +280,20 @@ HWTEST_F(SvmDeviceAllocationCacheTest, givenOclApiSpecificConfigWhenCheckingIfEn
EXPECT_EQ(nullptr, svmManager->usmDeviceAllocationsCache);
EXPECT_EQ(0u, device->usmReuseInfo.getMaxAllocationsSavedForReuseSize());
}
{
device->getRootDeviceEnvironmentRef().debugger.reset(new MockDebugger);
raii.mockProductHelper->isDeviceUsmAllocationReuseSupportedResult = true;
mockAilConfigurationHelper.limitAmountOfDeviceMemoryForRecyclingReturn = false;
device->initUsmReuseLimits();
auto svmManager = std::make_unique<MockSVMAllocsManager>(device->getMemoryManager());
EXPECT_EQ(nullptr, svmManager->usmDeviceAllocationsCache);
svmManager->initUsmAllocationsCaches(*device);
EXPECT_EQ(nullptr, svmManager->usmDeviceAllocationsCache);
device->getRootDeviceEnvironmentRef().debugger.reset(nullptr);
svmManager->initUsmAllocationsCaches(*device);
EXPECT_NE(nullptr, svmManager->usmDeviceAllocationsCache);
}
}
TEST_F(SvmDeviceAllocationCacheTest, givenAllocationCacheEnabledWhenDirectSubmissionLightActiveThenCleanerDisabled) {
@@ -1249,10 +1264,10 @@ TEST_F(SvmHostAllocationCacheTest, givenAllocationCacheDisabledWhenCheckingIfEna
EXPECT_EQ(nullptr, svmManager->usmHostAllocationsCache);
}
HWTEST_F(SvmHostAllocationCacheTest, givenOclApiSpecificConfigWhenCheckingIfEnabledItIsEnabledIfProductHelperMethodReturnsTrue) {
HWTEST_F(SvmHostAllocationCacheTest, givenOclApiSpecificConfigAndProductHelperAndDebuggerWhenCheckingIfEnabledThenEnableCorrectly) {
VariableBackup<ApiSpecificConfig::ApiType> backup(&apiTypeForUlts, ApiSpecificConfig::OCL);
auto deviceFactory = std::make_unique<UltDeviceFactory>(1, 1);
auto device = deviceFactory->rootDevices[0];
MockDevice *device = deviceFactory->rootDevices[0];
device->initUsmReuseLimits();
RAIIProductHelperFactory<MockProductHelper> raii(*device->getExecutionEnvironment()->rootDeviceEnvironments[0]);
const auto expectedMaxSize = static_cast<size_t>(0.02 * device->getMemoryManager()->getSystemSharedMemory(0u));
@@ -1274,6 +1289,19 @@ HWTEST_F(SvmHostAllocationCacheTest, givenOclApiSpecificConfigWhenCheckingIfEnab
svmManager->initUsmAllocationsCaches(*device);
EXPECT_NE(nullptr, svmManager->usmHostAllocationsCache);
}
{
device->getRootDeviceEnvironmentRef().debugger.reset(new MockDebugger);
raii.mockProductHelper->isHostUsmAllocationReuseSupportedResult = true;
device->getMemoryManager()->initUsmReuseLimits();
auto svmManager = std::make_unique<MockSVMAllocsManager>(device->getMemoryManager());
EXPECT_EQ(nullptr, svmManager->usmHostAllocationsCache);
svmManager->initUsmAllocationsCaches(*device);
EXPECT_EQ(nullptr, svmManager->usmHostAllocationsCache);
device->getRootDeviceEnvironmentRef().debugger.reset(nullptr);
svmManager->initUsmAllocationsCaches(*device);
EXPECT_NE(nullptr, svmManager->usmHostAllocationsCache);
}
}
TEST_F(SvmHostAllocationCacheTest, givenReuseLimitFlagWhenInitUsmReuseLimitCalledThenLimitThresholdSetCorrectly) {