mirror of
https://github.com/intel/compute-runtime.git
synced 2026-01-08 14:02:58 +08:00
refactor: prework for defining preferred allocation method per allocation type
Related-To: HSD-18032442707, HSD-18032440987 Signed-off-by: Mateusz Jablonski <mateusz.jablonski@intel.com>
This commit is contained in:
committed by
Compute-Runtime-Automation
parent
819908ec94
commit
a4addad510
@@ -117,6 +117,7 @@ struct AllocationData {
|
||||
static_assert(sizeof(AllocationData::flags) == sizeof(AllocationData::allFlags), "");
|
||||
AllocationType type = AllocationType::UNKNOWN;
|
||||
GraphicsAllocation::UsmInitialPlacement usmInitialPlacement = GraphicsAllocation::UsmInitialPlacement::DEFAULT;
|
||||
GfxMemoryAllocationMethod allocationMethod = GfxMemoryAllocationMethod::NotDefined;
|
||||
const void *hostPtr = nullptr;
|
||||
uint64_t gpuAddress = 0;
|
||||
size_t size = 0;
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
|
||||
#pragma once
|
||||
#include <cstdint>
|
||||
#include <limits>
|
||||
|
||||
namespace NEO {
|
||||
enum class AllocationType {
|
||||
@@ -62,6 +63,7 @@ enum class AllocationType {
|
||||
|
||||
enum class GfxMemoryAllocationMethod : uint32_t {
|
||||
UseUmdSystemPtr,
|
||||
AllocateByKmd
|
||||
AllocateByKmd,
|
||||
NotDefined = std::numeric_limits<uint32_t>::max()
|
||||
};
|
||||
} // namespace NEO
|
||||
|
||||
@@ -526,10 +526,15 @@ bool MemoryManager::getAllocationData(AllocationData &allocationData, const Allo
|
||||
|
||||
allocationData.storageInfo.systemMemoryPlacement = allocationData.flags.useSystemMemory;
|
||||
allocationData.storageInfo.systemMemoryForced = properties.flags.forceSystemMemory;
|
||||
allocationData.allocationMethod = getPreferredAllocationMethod(properties);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
GfxMemoryAllocationMethod MemoryManager::getPreferredAllocationMethod(const AllocationProperties &allocationProperties) const {
|
||||
return GfxMemoryAllocationMethod::NotDefined;
|
||||
}
|
||||
|
||||
GraphicsAllocation *MemoryManager::allocatePhysicalGraphicsMemory(const AllocationProperties &properties) {
|
||||
AllocationData allocationData;
|
||||
GraphicsAllocation *allocation = nullptr;
|
||||
|
||||
@@ -314,6 +314,7 @@ class MemoryManager {
|
||||
virtual void unlockResourceImpl(GraphicsAllocation &graphicsAllocation) = 0;
|
||||
virtual void freeAssociatedResourceImpl(GraphicsAllocation &graphicsAllocation) { return unlockResourceImpl(graphicsAllocation); };
|
||||
virtual void registerAllocationInOs(GraphicsAllocation *allocation) {}
|
||||
virtual GfxMemoryAllocationMethod getPreferredAllocationMethod(const AllocationProperties &allocationProperties) const;
|
||||
bool isAllocationTypeToCapture(AllocationType type) const;
|
||||
void zeroCpuMemoryIfRequested(const AllocationData &allocationData, void *cpuPtr, size_t size);
|
||||
void updateLatestContextIdForRootDevice(uint32_t rootDeviceIndex);
|
||||
|
||||
@@ -44,6 +44,7 @@ using ProductHelperCreateFunctionType = std::unique_ptr<ProductHelper> (*)();
|
||||
extern ProductHelperCreateFunctionType productHelperFactory[IGFX_MAX_PRODUCT];
|
||||
|
||||
enum class GfxMemoryAllocationMethod : uint32_t;
|
||||
enum class AllocationType;
|
||||
|
||||
enum class UsmAccessCapabilities {
|
||||
Host = 0,
|
||||
@@ -209,7 +210,7 @@ class ProductHelper {
|
||||
virtual bool isSkippingStatefulInformationRequired(const KernelDescriptor &kernelDescriptor) const = 0;
|
||||
virtual bool getMediaFrequencyTileIndex(const ReleaseHelper *releaseHelper, uint32_t &tileIndex) const = 0;
|
||||
virtual bool isResolvingBuiltinsNeeded(const ReleaseHelper *releaseHelper) const = 0;
|
||||
virtual std::optional<GfxMemoryAllocationMethod> getPreferredAllocationMethod() const = 0;
|
||||
virtual std::optional<GfxMemoryAllocationMethod> getPreferredAllocationMethod(AllocationType allocationType) const = 0;
|
||||
virtual uint64_t overridePatIndex(bool isUncachedType, uint64_t patIndex) const = 0;
|
||||
|
||||
virtual ~ProductHelper() = default;
|
||||
|
||||
@@ -796,7 +796,7 @@ bool ProductHelperHw<gfxProduct>::isSkippingStatefulInformationRequired(const Ke
|
||||
}
|
||||
|
||||
template <PRODUCT_FAMILY gfxProduct>
|
||||
std::optional<GfxMemoryAllocationMethod> ProductHelperHw<gfxProduct>::getPreferredAllocationMethod() const {
|
||||
std::optional<GfxMemoryAllocationMethod> ProductHelperHw<gfxProduct>::getPreferredAllocationMethod(AllocationType allocationType) const {
|
||||
return {};
|
||||
}
|
||||
|
||||
|
||||
@@ -160,7 +160,7 @@ class ProductHelperHw : public ProductHelper {
|
||||
bool isSkippingStatefulInformationRequired(const KernelDescriptor &kernelDescriptor) const override;
|
||||
bool getMediaFrequencyTileIndex(const ReleaseHelper *releaseHelper, uint32_t &tileIndex) const override;
|
||||
bool isResolvingBuiltinsNeeded(const ReleaseHelper *releaseHelper) const override;
|
||||
std::optional<GfxMemoryAllocationMethod> getPreferredAllocationMethod() const override;
|
||||
std::optional<GfxMemoryAllocationMethod> getPreferredAllocationMethod(AllocationType allocationType) const override;
|
||||
uint64_t overridePatIndex(bool isUncachedType, uint64_t patIndex) const override;
|
||||
|
||||
~ProductHelperHw() override = default;
|
||||
|
||||
@@ -72,15 +72,16 @@ WddmMemoryManager::WddmMemoryManager(ExecutionEnvironment &executionEnvironment)
|
||||
initialized = true;
|
||||
}
|
||||
|
||||
GfxMemoryAllocationMethod WddmMemoryManager::getPreferredAllocationMethod(uint32_t rootDeviceIndex) {
|
||||
GfxMemoryAllocationMethod WddmMemoryManager::getPreferredAllocationMethod(const AllocationProperties &allocationProperties) const {
|
||||
if (DebugManager.flags.ForcePreferredAllocationMethod.get() != -1) {
|
||||
return static_cast<GfxMemoryAllocationMethod>(DebugManager.flags.ForcePreferredAllocationMethod.get());
|
||||
}
|
||||
auto rootDeviceEnvironment = executionEnvironment.rootDeviceEnvironments[rootDeviceIndex].get();
|
||||
auto rootDeviceEnvironment = executionEnvironment.rootDeviceEnvironments[allocationProperties.rootDeviceIndex].get();
|
||||
UNRECOVERABLE_IF(!rootDeviceEnvironment);
|
||||
auto &productHelper = rootDeviceEnvironment->getHelper<ProductHelper>();
|
||||
if (productHelper.getPreferredAllocationMethod()) {
|
||||
return *productHelper.getPreferredAllocationMethod();
|
||||
auto preference = productHelper.getPreferredAllocationMethod(allocationProperties.allocationType);
|
||||
if (preference) {
|
||||
return *preference;
|
||||
}
|
||||
|
||||
return preferredAllocationMethod;
|
||||
@@ -184,7 +185,7 @@ GraphicsAllocation *WddmMemoryManager::allocateGraphicsMemoryUsingKmdAndMapItToC
|
||||
}
|
||||
|
||||
// algin gpu address of device part of usm shared allocation to 64kb for WSL2
|
||||
auto alignGpuAddressTo64KB = getPreferredAllocationMethod(allocationData.rootDeviceIndex) == GfxMemoryAllocationMethod::AllocateByKmd && allocationData.makeGPUVaDifferentThanCPUPtr;
|
||||
auto alignGpuAddressTo64KB = allocationData.allocationMethod == GfxMemoryAllocationMethod::AllocateByKmd && allocationData.makeGPUVaDifferentThanCPUPtr;
|
||||
|
||||
if (alignGpuAddressTo64KB) {
|
||||
sizeAligned = sizeAligned + allocationData.alignment;
|
||||
@@ -334,7 +335,7 @@ GraphicsAllocation *WddmMemoryManager::allocateUSMHostGraphicsMemory(const Alloc
|
||||
GraphicsAllocation *WddmMemoryManager::allocateGraphicsMemoryWithAlignment(const AllocationData &allocationData) {
|
||||
auto pageSize = NEO::OSInterface::osEnabled64kbPages ? MemoryConstants::pageSize64k : MemoryConstants::pageSize;
|
||||
bool requiresNonStandardAlignment = allocationData.alignment > pageSize;
|
||||
if ((getPreferredAllocationMethod(allocationData.rootDeviceIndex) == GfxMemoryAllocationMethod::UseUmdSystemPtr) || (requiresNonStandardAlignment && allocationData.forceKMDAllocation == false)) {
|
||||
if ((allocationData.allocationMethod == GfxMemoryAllocationMethod::UseUmdSystemPtr) || (requiresNonStandardAlignment && allocationData.forceKMDAllocation == false)) {
|
||||
return allocateSystemMemoryAndCreateGraphicsAllocationFromIt(allocationData);
|
||||
} else {
|
||||
return allocateGraphicsMemoryUsingKmdAndMapItToCpuVA(allocationData, NEO::OSInterface::osEnabled64kbPages);
|
||||
@@ -482,7 +483,7 @@ GraphicsAllocation *WddmMemoryManager::allocate32BitGraphicsMemoryImpl(const All
|
||||
ptrAligned = alignDown(allocationData.hostPtr, MemoryConstants::allocationAlignment);
|
||||
sizeAligned = alignSizeWholePage(allocationData.hostPtr, sizeAligned);
|
||||
offset = ptrDiff(allocationData.hostPtr, ptrAligned);
|
||||
} else if (getPreferredAllocationMethod(allocationData.rootDeviceIndex) == GfxMemoryAllocationMethod::UseUmdSystemPtr) {
|
||||
} else if (allocationData.allocationMethod == GfxMemoryAllocationMethod::UseUmdSystemPtr) {
|
||||
sizeAligned = alignUp(sizeAligned, MemoryConstants::allocationAlignment);
|
||||
pSysMem = allocateSystemMemory(sizeAligned, MemoryConstants::allocationAlignment);
|
||||
if (pSysMem == nullptr) {
|
||||
@@ -511,7 +512,7 @@ GraphicsAllocation *WddmMemoryManager::allocate32BitGraphicsMemoryImpl(const All
|
||||
auto hwInfo = executionEnvironment.rootDeviceEnvironments[allocationData.rootDeviceIndex]->getHardwareInfo();
|
||||
|
||||
StorageInfo storageInfo{};
|
||||
storageInfo.isLockable = getPreferredAllocationMethod(allocationData.rootDeviceIndex) != GfxMemoryAllocationMethod::UseUmdSystemPtr;
|
||||
storageInfo.isLockable = allocationData.allocationMethod != GfxMemoryAllocationMethod::UseUmdSystemPtr;
|
||||
|
||||
gmm = new Gmm(executionEnvironment.rootDeviceEnvironments[allocationData.rootDeviceIndex]->getGmmHelper(), ptrAligned, sizeAligned, 0u,
|
||||
CacheSettingsHelper::getGmmUsageType(wddmAllocation->getAllocationType(), !!allocationData.flags.uncacheable, productHelper), false, storageInfo, true);
|
||||
|
||||
@@ -75,7 +75,7 @@ class WddmMemoryManager : public MemoryManager {
|
||||
MOCKABLE_VIRTUAL NTSTATUS createInternalNTHandle(D3DKMT_HANDLE *resourceHandle, HANDLE *ntHandle, uint32_t rootDeviceIndex);
|
||||
|
||||
protected:
|
||||
GfxMemoryAllocationMethod getPreferredAllocationMethod(uint32_t rootDeviceIndex);
|
||||
GfxMemoryAllocationMethod getPreferredAllocationMethod(const AllocationProperties &allocationProperties) const override;
|
||||
GraphicsAllocation *createGraphicsAllocation(OsHandleStorage &handleStorage, const AllocationData &allocationData) override;
|
||||
GraphicsAllocation *allocateGraphicsMemoryForNonSvmHostPtr(const AllocationData &allocationData) override;
|
||||
GraphicsAllocation *allocateUSMHostGraphicsMemory(const AllocationData &allocationData) override;
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
namespace NEO {
|
||||
|
||||
template <>
|
||||
std::optional<GfxMemoryAllocationMethod> ProductHelperHw<gfxProduct>::getPreferredAllocationMethod() const {
|
||||
std::optional<GfxMemoryAllocationMethod> ProductHelperHw<gfxProduct>::getPreferredAllocationMethod(AllocationType allocationType) const {
|
||||
return GfxMemoryAllocationMethod::AllocateByKmd;
|
||||
}
|
||||
|
||||
|
||||
@@ -50,6 +50,7 @@ class MockMemoryManager : public MemoryManagerCreate<OsAgnosticMemoryManager> {
|
||||
using OsAgnosticMemoryManager::allocateGraphicsMemoryForImageFromHostPtr;
|
||||
using MemoryManagerCreate<OsAgnosticMemoryManager>::MemoryManagerCreate;
|
||||
using MemoryManager::enable64kbpages;
|
||||
using MemoryManager::getPreferredAllocationMethod;
|
||||
using MemoryManager::isaInLocalMemory;
|
||||
using MemoryManager::isAllocationTypeToCapture;
|
||||
using MemoryManager::isCopyRequired;
|
||||
|
||||
@@ -72,6 +72,14 @@ TEST(MemoryManagerTest, givenDefaultMemoryManagerWhenGraphicsAllocationContainsE
|
||||
memoryManager.freeGraphicsMemory(graphicsAllocation);
|
||||
}
|
||||
|
||||
TEST(MemoryManagerTest, whenGettingPreferredAllocationMethodThenNotDefinedIsReturned) {
|
||||
MockMemoryManager memoryManager;
|
||||
for (auto i = 0; i < static_cast<int>(AllocationType::COUNT); i++) {
|
||||
AllocationProperties allocationProperties{0u, 0u, static_cast<AllocationType>(i), {}};
|
||||
EXPECT_EQ(GfxMemoryAllocationMethod::NotDefined, memoryManager.getPreferredAllocationMethod(allocationProperties));
|
||||
}
|
||||
}
|
||||
|
||||
TEST(MemoryManagerTest, WhenCallingIsAllocationTypeToCaptureThenScratchAndPrivateTypesReturnTrue) {
|
||||
MockMemoryManager mockMemoryManager;
|
||||
|
||||
|
||||
@@ -104,13 +104,16 @@ class WddmMemoryManagerTests : public ::testing::Test {
|
||||
};
|
||||
|
||||
TEST_F(WddmMemoryManagerTests, GivenAllocDataWithSVMCPUSetWhenAllocateGraphicsMemoryWithAlignmentThenProperFunctionIsUsed) {
|
||||
AllocationProperties allocationProperties{0u, 0u, NEO::AllocationType::SVM_CPU, {}};
|
||||
NEO::AllocationData allocData = {};
|
||||
allocData.type = NEO::AllocationType::SVM_CPU;
|
||||
allocData.rootDeviceIndex = allocationProperties.rootDeviceIndex;
|
||||
allocData.type = allocationProperties.allocationType;
|
||||
allocData.forceKMDAllocation = true;
|
||||
allocData.makeGPUVaDifferentThanCPUPtr = true;
|
||||
allocData.allocationMethod = memoryManager->getPreferredAllocationMethod(allocationProperties);
|
||||
memoryManager->allocateGraphicsMemoryWithAlignment(allocData);
|
||||
|
||||
if (memoryManager->getPreferredAllocationMethod(allocData.rootDeviceIndex) == GfxMemoryAllocationMethod::AllocateByKmd) {
|
||||
if (allocData.allocationMethod == GfxMemoryAllocationMethod::AllocateByKmd) {
|
||||
EXPECT_TRUE(memoryManager->allocateGraphicsMemoryUsingKmdAndMapItToCpuVACalled);
|
||||
} else {
|
||||
EXPECT_TRUE(memoryManager->allocateSystemMemoryAndCreateGraphicsAllocationFromItCalled);
|
||||
@@ -234,13 +237,16 @@ class WddmMemoryManagerAllocPathTests : public ::testing::Test {
|
||||
|
||||
TEST_F(WddmMemoryManagerAllocPathTests, givenAllocateGraphicsMemoryUsingKmdAndMapItToCpuVAWhenPreferedAllocationMethodThenProperArgumentsAreSet) {
|
||||
{
|
||||
AllocationProperties allocationProperties{0u, 0u, NEO::AllocationType::SVM_CPU, {}};
|
||||
NEO::AllocationData allocData = {};
|
||||
allocData.type = NEO::AllocationType::SVM_CPU;
|
||||
allocData.rootDeviceIndex = allocationProperties.rootDeviceIndex;
|
||||
allocData.type = allocationProperties.allocationType;
|
||||
allocData.forceKMDAllocation = true;
|
||||
allocData.makeGPUVaDifferentThanCPUPtr = true;
|
||||
allocData.allocationMethod = memoryManager->getPreferredAllocationMethod(allocationProperties);
|
||||
auto graphicsAllocation = memoryManager->allocateGraphicsMemoryUsingKmdAndMapItToCpuVA(allocData, false);
|
||||
|
||||
if (memoryManager->getPreferredAllocationMethod(allocData.rootDeviceIndex) == GfxMemoryAllocationMethod::AllocateByKmd && is64bit) {
|
||||
if (allocData.allocationMethod == GfxMemoryAllocationMethod::AllocateByKmd && is64bit) {
|
||||
EXPECT_FALSE(memoryManager->mapGpuVirtualAddressWithCpuPtr);
|
||||
} else {
|
||||
EXPECT_TRUE(memoryManager->mapGpuVirtualAddressWithCpuPtr);
|
||||
@@ -510,17 +516,20 @@ TEST_F(WddmMemoryManagerTests, givenTypeWhenCallIsStatelessAccessRequiredThenPro
|
||||
}
|
||||
|
||||
TEST_F(WddmMemoryManagerTests, givenForcePreferredAllocationMethodFlagSetWhenGettingPreferredAllocationMethodThenValueFlagIsReturned) {
|
||||
DebugManagerStateRestore restorer;
|
||||
auto &productHelper = executionEnvironment->rootDeviceEnvironments[0]->getProductHelper();
|
||||
if (productHelper.getPreferredAllocationMethod()) {
|
||||
EXPECT_EQ(*productHelper.getPreferredAllocationMethod(), memoryManager->getPreferredAllocationMethod(0));
|
||||
for (auto i = 0; i < static_cast<int>(AllocationType::COUNT); i++) {
|
||||
AllocationProperties allocationProperties{0u, 0u, static_cast<AllocationType>(i), {}};
|
||||
if (productHelper.getPreferredAllocationMethod(allocationProperties.allocationType)) {
|
||||
EXPECT_EQ(*productHelper.getPreferredAllocationMethod(allocationProperties.allocationType), memoryManager->getPreferredAllocationMethod(allocationProperties));
|
||||
} else {
|
||||
EXPECT_EQ(preferredAllocationMethod, memoryManager->getPreferredAllocationMethod(0));
|
||||
EXPECT_EQ(preferredAllocationMethod, memoryManager->getPreferredAllocationMethod(allocationProperties));
|
||||
}
|
||||
|
||||
DebugManagerStateRestore restorer;
|
||||
for (const auto &allocationMethod : {GfxMemoryAllocationMethod::UseUmdSystemPtr, GfxMemoryAllocationMethod::AllocateByKmd}) {
|
||||
DebugManager.flags.ForcePreferredAllocationMethod.set(static_cast<int32_t>(allocationMethod));
|
||||
EXPECT_EQ(allocationMethod, memoryManager->getPreferredAllocationMethod(0));
|
||||
EXPECT_EQ(allocationMethod, memoryManager->getPreferredAllocationMethod(allocationProperties));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1453,8 +1462,12 @@ TEST_F(WddmMemoryManagerSimpleTest, whenAlignmentRequirementExceedsPageSizeThenA
|
||||
|
||||
MockWddmMemoryManagerAllocateWithAlignment memoryManager(true, true, executionEnvironment);
|
||||
|
||||
AllocationData allocData = {};
|
||||
allocData.size = 1024;
|
||||
AllocationProperties allocationProperties{0u, 1024, NEO::AllocationType::BUFFER, {}};
|
||||
NEO::AllocationData allocData = {};
|
||||
allocData.rootDeviceIndex = allocationProperties.rootDeviceIndex;
|
||||
allocData.type = allocationProperties.allocationType;
|
||||
allocData.size = allocationProperties.size;
|
||||
allocData.allocationMethod = memoryManager.getPreferredAllocationMethod(allocationProperties);
|
||||
allocData.alignment = MemoryConstants::pageSize64k * 4;
|
||||
memoryManager.allocateGraphicsMemoryWithAlignment(allocData);
|
||||
EXPECT_EQ(1, memoryManager.callCount.allocateSystemMemoryAndCreateGraphicsAllocationFromIt);
|
||||
@@ -1466,7 +1479,7 @@ TEST_F(WddmMemoryManagerSimpleTest, whenAlignmentRequirementExceedsPageSizeThenA
|
||||
allocData.size = 1024;
|
||||
allocData.alignment = MemoryConstants::pageSize;
|
||||
memoryManager.allocateGraphicsMemoryWithAlignment(allocData);
|
||||
if (memoryManager.getPreferredAllocationMethod(allocData.rootDeviceIndex) == GfxMemoryAllocationMethod::AllocateByKmd) {
|
||||
if (allocData.allocationMethod == GfxMemoryAllocationMethod::AllocateByKmd) {
|
||||
EXPECT_EQ(0, memoryManager.callCount.allocateSystemMemoryAndCreateGraphicsAllocationFromIt);
|
||||
EXPECT_EQ(1, memoryManager.callCount.allocateGraphicsMemoryUsingKmdAndMapItToCpuVA);
|
||||
} else {
|
||||
|
||||
@@ -52,16 +52,19 @@ class GlobalBindlessWddmMemManagerFixture {
|
||||
using WddmGlobalBindlessAllocatorTests = Test<GlobalBindlessWddmMemManagerFixture>;
|
||||
|
||||
TEST_F(WddmGlobalBindlessAllocatorTests, givenAllocateInFrontWindowPoolFlagWhenWddmAllocate32BitGraphicsMemoryThenAllocateAtHeapBegining) {
|
||||
AllocationData allocData = {};
|
||||
allocData.type = AllocationType::BUFFER;
|
||||
AllocationProperties allocationProperties{0u, MemoryConstants::kiloByte, NEO::AllocationType::BUFFER, {}};
|
||||
NEO::AllocationData allocData = {};
|
||||
allocData.rootDeviceIndex = allocationProperties.rootDeviceIndex;
|
||||
allocData.type = allocationProperties.allocationType;
|
||||
allocData.size = allocationProperties.size;
|
||||
allocData.allocationMethod = memManager->getPreferredAllocationMethod(allocationProperties);
|
||||
EXPECT_FALSE(GraphicsAllocation::isLockable(allocData.type));
|
||||
allocData.flags.use32BitFrontWindow = true;
|
||||
allocData.size = MemoryConstants::kiloByte;
|
||||
auto allocation = memManager->allocate32BitGraphicsMemoryImpl(allocData, false);
|
||||
auto gmmHelper = memManager->getGmmHelper(allocData.rootDeviceIndex);
|
||||
EXPECT_EQ(allocation->getGpuBaseAddress(), gmmHelper->canonize(allocation->getGpuAddress()));
|
||||
|
||||
if (memManager->getPreferredAllocationMethod(allocData.rootDeviceIndex) == GfxMemoryAllocationMethod::AllocateByKmd) {
|
||||
if (allocData.allocationMethod == GfxMemoryAllocationMethod::AllocateByKmd) {
|
||||
EXPECT_TRUE(allocation->isAllocationLockable());
|
||||
} else {
|
||||
EXPECT_FALSE(allocation->isAllocationLockable());
|
||||
|
||||
@@ -181,9 +181,7 @@ MTLTEST_F(ProductHelperTestMtl, givenMtlWhenCheckIsCachingOnCpuAvailableThenAlwa
|
||||
|
||||
MTLTEST_F(ProductHelperTestMtl, givenMtlWhenCheckPreferredAllocationMethodThenAllocateByKmdIsReturned) {
|
||||
const auto &productHelper = getHelper<ProductHelper>();
|
||||
auto preferredAllocationMethod = productHelper.getPreferredAllocationMethod();
|
||||
EXPECT_TRUE(preferredAllocationMethod.has_value());
|
||||
EXPECT_EQ(GfxMemoryAllocationMethod::AllocateByKmd, preferredAllocationMethod.value());
|
||||
XeLpgTests::testPreferredAllocationMethod(productHelper);
|
||||
}
|
||||
|
||||
MTLTEST_F(ProductHelperTestMtl, givenBooleanUncachedWhenCallOverridePatIndexThenProperPatIndexIsReturned) {
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
|
||||
#include "shared/test/unit_test/xe_hpg_core/os_agnostic_product_helper_xe_lpg_tests.h"
|
||||
|
||||
#include "shared/source/memory_manager/allocation_type.h"
|
||||
#include "shared/source/os_interface/product_helper.h"
|
||||
#include "shared/test/common/test_macros/test.h"
|
||||
|
||||
@@ -19,3 +20,11 @@ void XeLpgTests::testOverridePatIndex(const ProductHelper &productHelper) {
|
||||
isUncached = false;
|
||||
EXPECT_EQ(patIndex, productHelper.overridePatIndex(isUncached, patIndex));
|
||||
}
|
||||
|
||||
void XeLpgTests::testPreferredAllocationMethod(const ProductHelper &productHelper) {
|
||||
for (auto i = 0; i < static_cast<int>(AllocationType::COUNT); i++) {
|
||||
auto preferredAllocationMethod = productHelper.getPreferredAllocationMethod(static_cast<AllocationType>(i));
|
||||
EXPECT_TRUE(preferredAllocationMethod.has_value());
|
||||
EXPECT_EQ(GfxMemoryAllocationMethod::AllocateByKmd, preferredAllocationMethod.value());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,5 +9,6 @@ namespace NEO {
|
||||
class ProductHelper;
|
||||
struct XeLpgTests {
|
||||
static void testOverridePatIndex(const ProductHelper &productHelper);
|
||||
static void testPreferredAllocationMethod(const ProductHelper &productHelper);
|
||||
};
|
||||
} // namespace NEO
|
||||
Reference in New Issue
Block a user