performance: change preferred allocation method on MTL devices

prefer allocating resources by KMD

Related-To: NEO-7194
Signed-off-by: Mateusz Jablonski <mateusz.jablonski@intel.com>
This commit is contained in:
Mateusz Jablonski
2023-07-31 09:41:13 +00:00
committed by Compute-Runtime-Automation
parent 30426d35c8
commit 98fd9f5687
6 changed files with 29 additions and 9 deletions

View File

@@ -6,6 +6,7 @@
*/
#pragma once
#include <cstdint>
namespace NEO {
enum class AllocationType {
@@ -58,4 +59,9 @@ enum class AllocationType {
ASSERT_BUFFER,
COUNT
};
enum class GfxMemoryAllocationMethod : uint32_t {
UseUmdSystemPtr,
AllocateByKmd
};
} // namespace NEO

View File

@@ -43,10 +43,6 @@ class HostPtrManager;
class OsContext;
class PrefetchManager;
enum class GfxMemoryAllocationMethod : uint32_t {
UseUmdSystemPtr,
AllocateByKmd
};
enum AllocationUsage {
TEMPORARY_ALLOCATION,
REUSABLE_ALLOCATION,

View File

@@ -22,6 +22,11 @@ void ProductHelperHw<gfxProduct>::adjustSamplerState(void *sampler, const Hardwa
}
}
template <>
std::optional<GfxMemoryAllocationMethod> ProductHelperHw<gfxProduct>::getPreferredAllocationMethod() const {
return GfxMemoryAllocationMethod::AllocateByKmd;
}
template <>
uint64_t ProductHelperHw<gfxProduct>::getHostMemCapabilitiesValue() const {
return (UNIFIED_SHARED_MEMORY_ACCESS | UNIFIED_SHARED_MEMORY_ATOMIC_ACCESS);

View File

@@ -110,7 +110,7 @@ TEST_F(WddmMemoryManagerTests, GivenAllocDataWithSVMCPUSetWhenAllocateGraphicsMe
allocData.makeGPUVaDifferentThanCPUPtr = true;
memoryManager->allocateGraphicsMemoryWithAlignment(allocData);
if (preferredAllocationMethod == GfxMemoryAllocationMethod::AllocateByKmd) {
if (memoryManager->getPreferredAllocationMethod(allocData.rootDeviceIndex) == GfxMemoryAllocationMethod::AllocateByKmd) {
EXPECT_TRUE(memoryManager->allocateGraphicsMemoryUsingKmdAndMapItToCpuVACalled);
} else {
EXPECT_TRUE(memoryManager->allocateSystemMemoryAndCreateGraphicsAllocationFromItCalled);
@@ -185,6 +185,7 @@ class MockAllocateGraphicsMemoryUsingKmdAndMapItToCpuVAWddm : public MemoryManag
using WddmMemoryManager::adjustGpuPtrToHostAddressSpace;
using WddmMemoryManager::allocateGraphicsMemoryUsingKmdAndMapItToCpuVA;
using WddmMemoryManager::allocateMemoryByKMD;
using WddmMemoryManager::getPreferredAllocationMethod;
using WddmMemoryManager::mapGpuVirtualAddress;
MockAllocateGraphicsMemoryUsingKmdAndMapItToCpuVAWddm(ExecutionEnvironment &executionEnvironment) : MemoryManagerCreate(false, false, executionEnvironment) {}
@@ -239,7 +240,7 @@ TEST_F(WddmMemoryManagerAllocPathTests, givenAllocateGraphicsMemoryUsingKmdAndMa
allocData.makeGPUVaDifferentThanCPUPtr = true;
auto graphicsAllocation = memoryManager->allocateGraphicsMemoryUsingKmdAndMapItToCpuVA(allocData, false);
if (preferredAllocationMethod == GfxMemoryAllocationMethod::AllocateByKmd) {
if (memoryManager->getPreferredAllocationMethod(allocData.rootDeviceIndex) == GfxMemoryAllocationMethod::AllocateByKmd && is64bit) {
EXPECT_FALSE(memoryManager->mapGpuVirtualAddressWithCpuPtr);
} else {
EXPECT_TRUE(memoryManager->mapGpuVirtualAddressWithCpuPtr);
@@ -510,7 +511,12 @@ TEST_F(WddmMemoryManagerTests, givenTypeWhenCallIsStatelessAccessRequiredThenPro
TEST_F(WddmMemoryManagerTests, givenForcePreferredAllocationMethodFlagSetWhenGettingPreferredAllocationMethodThenValueFlagIsReturned) {
DebugManagerStateRestore restorer;
EXPECT_EQ(preferredAllocationMethod, memoryManager->getPreferredAllocationMethod(0));
auto &productHelper = executionEnvironment->rootDeviceEnvironments[0]->getProductHelper();
if (productHelper.getPreferredAllocationMethod()) {
EXPECT_EQ(*productHelper.getPreferredAllocationMethod(), memoryManager->getPreferredAllocationMethod(0));
} else {
EXPECT_EQ(preferredAllocationMethod, memoryManager->getPreferredAllocationMethod(0));
}
for (const auto &allocationMethod : {GfxMemoryAllocationMethod::UseUmdSystemPtr, GfxMemoryAllocationMethod::AllocateByKmd}) {
DebugManager.flags.ForcePreferredAllocationMethod.set(static_cast<int32_t>(allocationMethod));
@@ -1460,7 +1466,7 @@ TEST_F(WddmMemoryManagerSimpleTest, whenAlignmentRequirementExceedsPageSizeThenA
allocData.size = 1024;
allocData.alignment = MemoryConstants::pageSize;
memoryManager.allocateGraphicsMemoryWithAlignment(allocData);
if (preferredAllocationMethod == GfxMemoryAllocationMethod::AllocateByKmd) {
if (memoryManager.getPreferredAllocationMethod(allocData.rootDeviceIndex) == GfxMemoryAllocationMethod::AllocateByKmd) {
EXPECT_EQ(0, memoryManager.callCount.allocateSystemMemoryAndCreateGraphicsAllocationFromIt);
EXPECT_EQ(1, memoryManager.callCount.allocateGraphicsMemoryUsingKmdAndMapItToCpuVA);
} else {

View File

@@ -56,7 +56,7 @@ TEST_F(WddmFrontWindowPoolAllocatorTests, givenAllocateInFrontWindowPoolFlagWhen
auto gmmHelper = memManager->getGmmHelper(allocData.rootDeviceIndex);
EXPECT_EQ(allocation->getGpuBaseAddress(), gmmHelper->canonize(allocation->getGpuAddress()));
if (preferredAllocationMethod == GfxMemoryAllocationMethod::AllocateByKmd) {
if (memManager->getPreferredAllocationMethod(allocData.rootDeviceIndex) == GfxMemoryAllocationMethod::AllocateByKmd) {
EXPECT_TRUE(allocation->isAllocationLockable());
} else {
EXPECT_FALSE(allocation->isAllocationLockable());

View File

@@ -364,3 +364,10 @@ MTLTEST_F(ProductHelperTestMtl, givenMtlWhenCheckIsCachingOnCpuAvailableThenAlwa
const auto &productHelper = getHelper<ProductHelper>();
EXPECT_FALSE(productHelper.isCachingOnCpuAvailable());
}
MTLTEST_F(ProductHelperTestMtl, givenMtlWhenCheckPreferredAllocationMethodThenAllocateByKmdIsReturned) {
const auto &productHelper = getHelper<ProductHelper>();
auto preferredAllocationMethod = productHelper.getPreferredAllocationMethod();
EXPECT_TRUE(preferredAllocationMethod.has_value());
EXPECT_EQ(GfxMemoryAllocationMethod::AllocateByKmd, preferredAllocationMethod.value());
}