mirror of
https://github.com/intel/compute-runtime.git
synced 2025-12-21 09:14:47 +08:00
performance(ocl): enable device usm alloc reuse
Enabling on MTL+ Limited to use max 2% of global device memory. Related-To: NEO-6893, NEO-11463 Signed-off-by: Dominik Dabek <dominik.dabek@intel.com>
This commit is contained in:
committed by
Compute-Runtime-Automation
parent
95b7929d97
commit
a236171f0d
@@ -412,6 +412,11 @@ bool ProductHelperHw<gfxProduct>::isUsmPoolAllocatorSupported() const {
|
||||
return false;
|
||||
}
|
||||
|
||||
template <PRODUCT_FAMILY gfxProduct>
|
||||
bool ProductHelperHw<gfxProduct>::isDeviceUsmAllocationReuseSupported() const {
|
||||
return false;
|
||||
}
|
||||
|
||||
template <PRODUCT_FAMILY gfxProduct>
|
||||
bool ProductHelperHw<gfxProduct>::useLocalPreferredForCacheableBuffers() const {
|
||||
return false;
|
||||
|
||||
@@ -20,5 +20,6 @@ struct MockProductHelper : ProductHelperHw<IGFX_UNKNOWN> {
|
||||
ADDMETHOD_NOBASE(configureHwInfoWddm, int, 0, (const HardwareInfo *inHwInfo, HardwareInfo *outHwInfo, const RootDeviceEnvironment &rootDeviceEnvironment));
|
||||
ADDMETHOD_CONST_NOBASE(supportReadOnlyAllocations, bool, false, ());
|
||||
ADDMETHOD_CONST_NOBASE(isBlitCopyRequiredForLocalMemory, bool, true, (const RootDeviceEnvironment &rootDeviceEnvironment, const GraphicsAllocation &allocation));
|
||||
ADDMETHOD_CONST_NOBASE(isDeviceUsmAllocationReuseSupported, bool, false, ());
|
||||
};
|
||||
} // namespace NEO
|
||||
|
||||
@@ -40,7 +40,11 @@ bool ApiSpecificConfig::getBindlessMode(const ReleaseHelper *) {
|
||||
}
|
||||
|
||||
bool ApiSpecificConfig::isDeviceAllocationCacheEnabled() {
|
||||
return false;
|
||||
if (apiTypeForUlts == ApiSpecificConfig::L0) {
|
||||
return false;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
bool ApiSpecificConfig::isHostAllocationCacheEnabled() {
|
||||
|
||||
@@ -5,17 +5,22 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include "shared/source/helpers/api_specific_config.h"
|
||||
#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_device.h"
|
||||
#include "shared/test/common/mocks/mock_graphics_allocation.h"
|
||||
#include "shared/test/common/mocks/mock_memory_manager.h"
|
||||
#include "shared/test/common/mocks/mock_product_helper.h"
|
||||
#include "shared/test/common/mocks/mock_svm_manager.h"
|
||||
#include "shared/test/common/mocks/ult_device_factory.h"
|
||||
#include "shared/test/common/test_macros/hw_test.h"
|
||||
#include "shared/test/common/test_macros/test.h"
|
||||
|
||||
#include "gtest/gtest.h"
|
||||
namespace NEO {
|
||||
|
||||
using namespace NEO;
|
||||
extern ApiSpecificConfig::ApiType apiTypeForUlts;
|
||||
|
||||
TEST(SortedVectorBasedAllocationTrackerTests, givenSortedVectorBasedAllocationTrackerWhenInsertRemoveAndGetThenStoreDataProperly) {
|
||||
SvmAllocationData data(1u);
|
||||
@@ -99,16 +104,38 @@ struct SvmAllocationCacheTestFixture {
|
||||
|
||||
using SvmDeviceAllocationCacheTest = Test<SvmAllocationCacheTestFixture>;
|
||||
|
||||
TEST_F(SvmDeviceAllocationCacheTest, givenAllocationCacheDefaultWhenCheckingIfEnabledThenItIsDisabled) {
|
||||
TEST_F(SvmDeviceAllocationCacheTest, givenAllocationCacheDisabledWhenCheckingIfEnabledThenItIsDisabled) {
|
||||
DebugManagerStateRestore restorer;
|
||||
std::unique_ptr<UltDeviceFactory> deviceFactory(new UltDeviceFactory(1, 1));
|
||||
auto device = deviceFactory->rootDevices[0];
|
||||
auto svmManager = std::make_unique<MockSVMAllocsManager>(device->getMemoryManager(), false);
|
||||
ASSERT_EQ(debugManager.flags.ExperimentalEnableDeviceAllocationCache.get(), -1);
|
||||
debugManager.flags.ExperimentalEnableDeviceAllocationCache.set(0);
|
||||
EXPECT_FALSE(svmManager->usmDeviceAllocationsCacheEnabled);
|
||||
svmManager->initUsmAllocationsCaches(*device);
|
||||
EXPECT_FALSE(svmManager->usmDeviceAllocationsCacheEnabled);
|
||||
}
|
||||
|
||||
HWTEST_F(SvmDeviceAllocationCacheTest, givenOclApiSpecificConfigWhenCheckingIfEnabledItIsEnabledIfProductHelperMethodReturnsTrue) {
|
||||
VariableBackup<ApiSpecificConfig::ApiType> backup(&apiTypeForUlts, ApiSpecificConfig::OCL);
|
||||
std::unique_ptr<UltDeviceFactory> deviceFactory(new UltDeviceFactory(1, 1));
|
||||
auto device = deviceFactory->rootDevices[0];
|
||||
RAIIProductHelperFactory<MockProductHelper> raii(*device->getExecutionEnvironment()->rootDeviceEnvironments[0]);
|
||||
{
|
||||
raii.mockProductHelper->isDeviceUsmAllocationReuseSupportedResult = false;
|
||||
auto svmManager = std::make_unique<MockSVMAllocsManager>(device->getMemoryManager(), false);
|
||||
EXPECT_FALSE(svmManager->usmDeviceAllocationsCacheEnabled);
|
||||
svmManager->initUsmAllocationsCaches(*device);
|
||||
EXPECT_FALSE(svmManager->usmDeviceAllocationsCacheEnabled);
|
||||
}
|
||||
{
|
||||
raii.mockProductHelper->isDeviceUsmAllocationReuseSupportedResult = true;
|
||||
auto svmManager = std::make_unique<MockSVMAllocsManager>(device->getMemoryManager(), false);
|
||||
EXPECT_FALSE(svmManager->usmDeviceAllocationsCacheEnabled);
|
||||
svmManager->initUsmAllocationsCaches(*device);
|
||||
EXPECT_TRUE(svmManager->usmDeviceAllocationsCacheEnabled);
|
||||
}
|
||||
}
|
||||
|
||||
struct SvmDeviceAllocationCacheSimpleTestDataType {
|
||||
size_t allocationSize;
|
||||
void *allocation;
|
||||
@@ -889,4 +916,5 @@ TEST_F(SvmHostAllocationCacheTest, givenHostOutOfMemoryWhenAllocatingThenCacheIs
|
||||
|
||||
svmManager->trimUSMHostAllocCache();
|
||||
ASSERT_EQ(svmManager->usmHostAllocationsCache.allocations.size(), 0u);
|
||||
}
|
||||
}
|
||||
} // namespace NEO
|
||||
@@ -828,6 +828,18 @@ HWTEST2_F(ProductHelperTest, givenProductHelperWhenCheckingIsUsmPoolAllocatorSup
|
||||
EXPECT_TRUE(productHelper->isUsmPoolAllocatorSupported());
|
||||
}
|
||||
|
||||
HWTEST2_F(ProductHelperTest, givenProductHelperWhenCheckingIsDeviceUsmAllocationReuseSupportedThenCorrectValueIsReturned, IsAtMostDg2) {
|
||||
EXPECT_FALSE(productHelper->isDeviceUsmAllocationReuseSupported());
|
||||
}
|
||||
|
||||
HWTEST2_F(ProductHelperTest, givenProductHelperWhenCheckingIsDeviceUsmAllocationReuseSupportedThenCorrectValueIsReturned, IsXeHpcCore) {
|
||||
EXPECT_FALSE(productHelper->isDeviceUsmAllocationReuseSupported());
|
||||
}
|
||||
|
||||
HWTEST2_F(ProductHelperTest, givenProductHelperWhenCheckingIsDeviceUsmAllocationReuseSupportedThenCorrectValueIsReturned, IsAtLeastMtl) {
|
||||
EXPECT_TRUE(productHelper->isDeviceUsmAllocationReuseSupported());
|
||||
}
|
||||
|
||||
HWTEST_F(ProductHelperTest, givenProductHelperWhenCheckingIsUnlockingLockedPtrNecessaryThenReturnFalse) {
|
||||
EXPECT_FALSE(productHelper->isUnlockingLockedPtrNecessary(pInHwInfo));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user