performance: enable l0 device usm pool

Disable if debugging is enabled.

Related-To: NEO-6893

Signed-off-by: Dominik Dabek <dominik.dabek@intel.com>
This commit is contained in:
Dominik Dabek
2025-06-02 14:19:46 +00:00
committed by Compute-Runtime-Automation
parent a015188166
commit cf87684644
5 changed files with 40 additions and 15 deletions

View File

@@ -370,7 +370,9 @@ void DriverHandleImp::initHostUsmAllocPool() {
void DriverHandleImp::initDeviceUsmAllocPool(NEO::Device &device) {
const uint64_t minServicedSize = 0u;
const uint64_t maxServicedSize = 1 * MemoryConstants::megaByte;
bool enabled = NEO::ApiSpecificConfig::isDeviceUsmPoolingEnabled() && device.getProductHelper().isDeviceUsmPoolAllocatorSupported();
bool enabled = NEO::ApiSpecificConfig::isDeviceUsmPoolingEnabled() &&
device.getProductHelper().isDeviceUsmPoolAllocatorSupported() &&
nullptr == device.getL0Debugger();
uint64_t poolSize = 2 * MemoryConstants::megaByte;
if (NEO::debugManager.flags.EnableDeviceUsmAllocationPool.get() != -1) {

View File

@@ -60,7 +60,7 @@ bool ApiSpecificConfig::isHostAllocationCacheEnabled() {
}
bool ApiSpecificConfig::isDeviceUsmPoolingEnabled() {
return false;
return true;
}
bool ApiSpecificConfig::isHostUsmPoolingEnabled() {

View File

@@ -197,6 +197,11 @@ void MemoryExportImportWSLTest::SetUp() {
}
void MemoryExportImportWSLTest::TearDown() {
// cleanup pool before restoring memory manager
for (auto device : driverHandle->devices) {
device->getNEODevice()->cleanupUsmAllocationPool();
device->getNEODevice()->resetUsmAllocationPool(nullptr);
}
driverHandle->setMemoryManager(prevMemoryManager);
delete currMemoryManager;
}

View File

@@ -48,9 +48,9 @@ TEST(ApiSpecificConfigL0Tests, WhenCheckingIfHostDeviceAllocationCacheIsEnabledT
EXPECT_FALSE(ApiSpecificConfig::isDeviceAllocationCacheEnabled());
}
TEST(ApiSpecificConfigL0Tests, WhenCheckingIfUsmAllocPoolingIsEnabledThenReturnFalse) {
TEST(ApiSpecificConfigL0Tests, WhenCheckingIfUsmAllocPoolingIsEnabledThenReturnCorrectValue) {
EXPECT_FALSE(ApiSpecificConfig::isHostUsmPoolingEnabled());
EXPECT_FALSE(ApiSpecificConfig::isDeviceUsmPoolingEnabled());
EXPECT_TRUE(ApiSpecificConfig::isDeviceUsmPoolingEnabled());
}
TEST(ApiSpecificConfigL0Tests, GivenDebugFlagCombinationsGetCorrectSharedAllocPrefetchEnabled) {

View File

@@ -5,6 +5,7 @@
*
*/
#include "shared/source/debugger/debugger_l0.h"
#include "shared/source/os_interface/device_factory.h"
#include "shared/test/common/helpers/debug_manager_state_restore.h"
#include "shared/test/common/mocks/mock_device.h"
@@ -39,7 +40,7 @@ struct AllocUsmPoolMemoryTest : public ::testing::Test {
executionEnvironment->rootDeviceEnvironments[i]->productHelper.reset(mockProductHelpers[i]);
executionEnvironment->rootDeviceEnvironments[i]->setHwInfoAndInitHelpers(NEO::defaultHwInfo.get());
executionEnvironment->rootDeviceEnvironments[i]->initGmm();
if (1 == deviceUsmPoolFlag) {
if constexpr (deviceUsmPoolFlag > 0) {
mockProductHelpers[i]->isDeviceUsmPoolAllocatorSupportedResult = true;
}
}
@@ -257,16 +258,33 @@ TEST_F(AllocUsmHostEnabledMemoryTest, givenDrmDriverModelWhenOpeningIpcHandleFro
using AllocUsmDeviceDefaultMemoryTest = AllocUsmPoolMemoryTest<-1, -1>;
TEST_F(AllocUsmDeviceDefaultMemoryTest, givenDeviceWhenCallingAllocDeviceMemThenDoNotUsePool) {
EXPECT_EQ(nullptr, l0Devices[0]->getNEODevice()->getUsmMemAllocPool());
void *ptr = nullptr;
ze_device_mem_alloc_desc_t deviceDesc = {};
ze_result_t result = context->allocDeviceMem(l0Devices[0], &deviceDesc, 1u, 0u, &ptr);
EXPECT_EQ(ZE_RESULT_SUCCESS, result);
EXPECT_NE(nullptr, ptr);
EXPECT_EQ(nullptr, l0Devices[0]->getNEODevice()->getUsmMemAllocPool());
result = context->freeMem(ptr);
EXPECT_EQ(ZE_RESULT_SUCCESS, result);
TEST_F(AllocUsmDeviceDefaultMemoryTest, givenDeviceWhenCallingInitDeviceUsmAllocPoolThenInitIfEnabled) {
auto neoDevice = l0Devices[0]->getNEODevice();
{
neoDevice->cleanupUsmAllocationPool();
neoDevice->resetUsmAllocationPool(nullptr);
executionEnvironment->rootDeviceEnvironments[0]->debugger.reset(nullptr);
mockProductHelpers[0]->isDeviceUsmPoolAllocatorSupportedResult = true;
driverHandle->initDeviceUsmAllocPool(*neoDevice);
EXPECT_NE(nullptr, neoDevice->getUsmMemAllocPool());
}
{
neoDevice->cleanupUsmAllocationPool();
neoDevice->resetUsmAllocationPool(nullptr);
executionEnvironment->rootDeviceEnvironments[0]->debugger.reset(nullptr);
mockProductHelpers[0]->isDeviceUsmPoolAllocatorSupportedResult = false;
driverHandle->initDeviceUsmAllocPool(*neoDevice);
EXPECT_EQ(nullptr, neoDevice->getUsmMemAllocPool());
}
{
auto debuggerL0 = DebuggerL0::create(neoDevice);
neoDevice->cleanupUsmAllocationPool();
neoDevice->resetUsmAllocationPool(nullptr);
executionEnvironment->rootDeviceEnvironments[0]->debugger.reset(debuggerL0.release());
mockProductHelpers[0]->isDeviceUsmPoolAllocatorSupportedResult = true;
driverHandle->initDeviceUsmAllocPool(*neoDevice);
EXPECT_EQ(nullptr, neoDevice->getUsmMemAllocPool());
}
}
using AllocUsmDeviceDisabledMemoryTest = AllocUsmPoolMemoryTest<-1, 0>;