feature: Add debug keys for chunking allocation and size

Related-to: NEO-7695

New debug keys added:

EnableBOChunking is now a mask
0 = no chunking (default).
1 = shared allocations only
2 = device allocations only
3 = shared and device allocations

MinimalAllocationSizeForChunking sets the minimum allocation
size to apply chunking. Default is 2MB.

Signed-off-by: Jaime Arteaga <jaime.a.arteaga.molina@intel.com>
This commit is contained in:
Jaime Arteaga 2023-07-05 21:41:17 +00:00 committed by Compute-Runtime-Automation
parent aa0beb8191
commit 23eeaf816d
11 changed files with 304 additions and 11 deletions

View File

@ -509,9 +509,10 @@ DECLARE_DEBUG_VARIABLE(bool, EnableConcurrentSharedCrossP2PDeviceAccess, false,
DECLARE_DEBUG_VARIABLE(bool, AllocateSharedAllocationsInHeapExtendedHost, true, "When enabled driver can allocate shared unified memory allocation in heap extended host. (0 - disable, 1 - enable)")
DECLARE_DEBUG_VARIABLE(bool, AllocateHostAllocationsInHeapExtendedHost, true, "When enabled driver can allocate host unified memory allocation in heap extended host. (0 - disable, 1 - enable)")
DECLARE_DEBUG_VARIABLE(bool, PrintBOChunkingLogs, false, "Print some logs on BO chunking")
DECLARE_DEBUG_VARIABLE(bool, EnableBOChunking, false, "Enables use of chunking of BOs in the KMD.")
DECLARE_DEBUG_VARIABLE(bool, EnableBOChunkingPreferredLocationHint, false, "Enables preferred location advise on chunks")
DECLARE_DEBUG_VARIABLE(int32_t, EnableBOChunking, 0, "Enables use of chunking of BOs in the KMD, mask: 0 = no chunking, 1 = shared allocations only, 2 = device allocations only, 3 = shared and device allocations .")
DECLARE_DEBUG_VARIABLE(int32_t, NumberOfBOChunks, 2, "Number of chunks to use. Must be a power of two)")
DECLARE_DEBUG_VARIABLE(int32_t, MinimalAllocationSizeForChunking, -1, "2097152: default, >0: size in B. Minimal size an allocation should have to use chunking.")
DECLARE_DEBUG_VARIABLE(int32_t, ForceAutoGrfCompilationMode, -1, "Adds build option -*-intel-enable-auto-large-GRF-mode to force kernel compilation")
DECLARE_DEBUG_VARIABLE(int32_t, ForceOCLVersion, 0, "Force specific OpenCL API version")
DECLARE_DEBUG_VARIABLE(int32_t, ForceOCL21FeaturesSupport, -1, "-1: default, 0: disable, 1:enable. Force support of OpenCL 2.0 and OpenCL 2.1 API features")

View File

@ -1869,20 +1869,23 @@ bool DrmMemoryManager::createDrmAllocation(Drm *drm, DrmAllocation *allocation,
size_t boTotalChunkSize = 0;
if (AllocationType::BUFFER == allocation->getAllocationType() &&
drm->getChunkingAvailable()) {
(drm->getChunkingMode() & 0x02)) {
boTotalChunkSize = allocation->getUnderlyingBufferSize();
uint32_t numOfChunks = DebugManager.flags.NumberOfBOChunks.get();
size_t chunkingSize = boTotalChunkSize / numOfChunks;
// Dont chunk for sizes less than chunkThreshold
if (!(chunkingSize & (MemoryConstants::chunkThreshold - 1))) {
if (boTotalChunkSize >= drm->getMinimalSizeForChunking() &&
!(chunkingSize & (MemoryConstants::chunkThreshold - 1))) {
handles = 1;
allocation->resizeBufferObjects(handles);
bos.resize(handles);
useChunking = true;
}
} else if (storageInfo.colouringPolicy == ColouringPolicy::ChunkSizeBased) {
handles = allocation->getNumGmms();
allocation->resizeBufferObjects(handles);
@ -2219,7 +2222,9 @@ GraphicsAllocation *DrmMemoryManager::createSharedUnifiedMemoryAllocation(const
size_t chunkingSize = size / numOfChunks;
// Dont chunk for sizes less than chunkThreshold
if (drm.getChunkingAvailable() && !(chunkingSize & (MemoryConstants::chunkThreshold - 1))) {
if ((drm.getChunkingMode() & 0x01) &&
!(chunkingSize & (MemoryConstants::chunkThreshold - 1)) &&
size >= drm.getMinimalSizeForChunking()) {
numHandles = 1;
useChunking = true;
}

View File

@ -1146,14 +1146,24 @@ bool Drm::isSetPairAvailable() {
}
bool Drm::isChunkingAvailable() {
if (DebugManager.flags.EnableBOChunking.get()) {
if (DebugManager.flags.EnableBOChunking.get() != 0) {
std::call_once(checkChunkingOnce, [this]() {
int ret = ioctlHelper->isChunkingAvailable();
if (ret) {
chunkingAvailable = true;
chunkingMode = DebugManager.flags.EnableBOChunking.get();
}
if (DebugManager.flags.MinimalAllocationSizeForChunking.get() != -1) {
minimalChunkingSize = DebugManager.flags.MinimalAllocationSizeForChunking.get();
}
printDebugString(DebugManager.flags.PrintBOChunkingLogs.get(), stdout,
"Chunking available: %d\n", chunkingAvailable);
"Chunking available: %d; enabled for: shared allocations %d, device allocations %d; minimalChunkingSize: %zd\n",
chunkingAvailable,
(chunkingMode & 0x01),
(chunkingMode & 0x02),
minimalChunkingSize);
});
}
return chunkingAvailable;

View File

@ -7,6 +7,7 @@
#pragma once
#include "shared/source/gmm_helper/gmm_lib.h"
#include "shared/source/helpers/constants.h"
#include "shared/source/helpers/driver_model_type.h"
#include "shared/source/memory_manager/definitions/engine_limits.h"
#include "shared/source/os_interface/linux/drm_debug.h"
@ -151,6 +152,8 @@ class Drm : public DriverModel {
MOCKABLE_VIRTUAL bool getSetPairAvailable() { return setPairAvailable; }
MOCKABLE_VIRTUAL bool isChunkingAvailable();
MOCKABLE_VIRTUAL bool getChunkingAvailable() { return chunkingAvailable; }
MOCKABLE_VIRTUAL uint32_t getChunkingMode() { return chunkingMode; }
uint32_t getMinimalSizeForChunking() { return minimalChunkingSize; }
MOCKABLE_VIRTUAL bool useVMBindImmediate() const;
@ -334,6 +337,8 @@ class Drm : public DriverModel {
bool directSubmissionActive = false;
bool setPairAvailable = false;
bool chunkingAvailable = false;
uint32_t chunkingMode = 0;
uint32_t minimalChunkingSize = MemoryConstants::pageSize2Mb;
bool contextDebugSupported = false;
bool pageFaultSupported = false;
bool completionFenceSupported = false;

View File

@ -29,6 +29,7 @@ class DrmMock : public Drm {
using Drm::cacheInfo;
using Drm::checkQueueSliceSupport;
using Drm::chunkingAvailable;
using Drm::chunkingMode;
using Drm::classHandles;
using Drm::completionFenceSupported;
using Drm::contextDebugSupported;
@ -39,6 +40,7 @@ class DrmMock : public Drm {
using Drm::getQueueSliceCount;
using Drm::ioctlHelper;
using Drm::memoryInfo;
using Drm::minimalChunkingSize;
using Drm::nonPersistentContextsSupported;
using Drm::pageFaultSupported;
using Drm::pagingFence;
@ -149,6 +151,13 @@ class DrmMock : public Drm {
return chunkingAvailable;
}
uint32_t getChunkingMode() override {
if (callBaseChunkingMode) {
return Drm::isChunkingAvailable();
}
return chunkingMode;
}
bool getSetPairAvailable() override {
if (callBaseGetSetPairAvailable) {
return Drm::getSetPairAvailable();
@ -207,6 +216,8 @@ class DrmMock : public Drm {
bool callBaseIsVmBindAvailable = false;
bool callBaseIsSetPairAvailable = false;
bool callBaseIsChunkingAvailable = false;
bool callBaseGetChunkingMode = false;
bool callBaseChunkingMode = false;
bool callBaseGetSetPairAvailable = false;
bool unrecoverableContextSet = false;
bool failRetHwIpVersion = false;

View File

@ -279,3 +279,12 @@ bool DrmMockCustom::getChunkingAvailable() {
return getChunkingAvailableCall.returnValue;
}
}
uint32_t DrmMockCustom::getChunkingMode() {
getChunkingModeCall.called++;
if (getChunkingModeCall.callParent) {
return Drm::getChunkingMode();
} else {
return getChunkingModeCall.returnValue;
}
}

View File

@ -127,6 +127,12 @@ class DrmMockCustom : public Drm {
uint32_t called = 0u;
};
struct ChunkingModeCall {
bool callParent = true;
uint32_t returnValue = 0x00;
uint32_t called = 0u;
};
DrmMockCustom(RootDeviceEnvironment &rootDeviceEnvironment);
int waitUserFence(uint32_t ctxId, uint64_t address, uint64_t value, ValueWidth dataWidth, int64_t timeout, uint16_t flags) override;
@ -134,6 +140,7 @@ class DrmMockCustom : public Drm {
bool getSetPairAvailable() override;
bool getChunkingAvailable() override;
uint32_t getChunkingMode() override;
bool isChunkingAvailable() override;
bool isVmBindAvailable() override;
@ -181,6 +188,7 @@ class DrmMockCustom : public Drm {
IsVmBindAvailableCall isVmBindAvailableCall{};
IsChunkingAvailableCall getChunkingAvailableCall{};
ChunkingModeCall getChunkingModeCall{};
IsChunkingAvailableCall isChunkingAvailableCall{};
std::atomic<int> ioctlRes;

View File

@ -520,9 +520,10 @@ OptimizeIoqBarriersHandling = -1
AllocateSharedAllocationsInHeapExtendedHost = 1
AllocateHostAllocationsInHeapExtendedHost = 1
PrintBOChunkingLogs = 0
EnableBOChunking = 0
EnableBOChunkingPreferredLocationHint = 0
NumberOfBOChunks = 2
EnableBOChunking = 0
MinimalAllocationSizeForChunking = -1
DirectSubmissionControllerMaxTimeout = -1
ExitOnSubmissionNumber = -1
ExitOnSubmissionMode = 0

View File

@ -365,6 +365,132 @@ TEST_F(DrmMemoryManagerLocalMemoryPrelimTest,
memoryManager->freeGraphicsMemory(allocation);
}
TEST_F(DrmMemoryManagerLocalMemoryPrelimTest,
whenCreateUnifiedMemoryAllocationWithChunkingAndModeNotSetToSharedThenChunkingIsNotUsed) {
std::vector<MemoryRegion> regionInfo(2);
regionInfo[0].region = {drm_i915_gem_memory_class::I915_MEMORY_CLASS_SYSTEM, 1};
regionInfo[1].region = {drm_i915_gem_memory_class::I915_MEMORY_CLASS_DEVICE, DrmMockHelper::getEngineOrMemoryInstanceValue(0, 0)};
mock->memoryInfo.reset(new MemoryInfo(regionInfo, *mock));
mock->queryEngineInfo();
mock->ioctlCallsCount = 0;
mock->chunkingAvailable = true;
mock->callBaseIsChunkingAvailable = true;
mock->chunkingMode = 0x02;
AllocationProperties gpuProperties{0u,
MemoryConstants::chunkThreshold,
AllocationType::UNIFIED_SHARED_MEMORY,
1u};
gpuProperties.alignment = 2 * MemoryConstants::megaByte;
gpuProperties.usmInitialPlacement = GraphicsAllocation::UsmInitialPlacement::CPU;
auto allocation = memoryManager->allocateGraphicsMemoryWithProperties(gpuProperties);
ASSERT_NE(allocation, nullptr);
EXPECT_NE(static_cast<DrmAllocation *>(allocation)->getMmapPtr(), nullptr);
EXPECT_NE(static_cast<DrmAllocation *>(allocation)->getMmapSize(), 0u);
EXPECT_EQ(allocation->getAllocationOffset(), 0u);
EXPECT_FALSE(allocation->storageInfo.isChunked);
const auto &createExt = mock->context.receivedCreateGemExt.value();
EXPECT_EQ(1u, createExt.handle);
const auto &memRegions = createExt.memoryRegions;
ASSERT_EQ(memRegions.size(), 2u);
EXPECT_EQ(memRegions[0].memoryClass, drm_i915_gem_memory_class::I915_MEMORY_CLASS_SYSTEM);
EXPECT_EQ(memRegions[0].memoryInstance, 1u);
EXPECT_EQ(memRegions[1].memoryClass, drm_i915_gem_memory_class::I915_MEMORY_CLASS_DEVICE);
EXPECT_EQ(memRegions[1].memoryInstance, regionInfo[1].region.memoryInstance);
memoryManager->freeGraphicsMemory(allocation);
}
TEST_F(DrmMemoryManagerLocalMemoryPrelimTest,
whenCreateUnifiedMemoryAllocationWithChunkingAndSizeLessThanMinimalThenChunkingIsNotUsed) {
std::vector<MemoryRegion> regionInfo(2);
regionInfo[0].region = {drm_i915_gem_memory_class::I915_MEMORY_CLASS_SYSTEM, 1};
regionInfo[1].region = {drm_i915_gem_memory_class::I915_MEMORY_CLASS_DEVICE, DrmMockHelper::getEngineOrMemoryInstanceValue(0, 0)};
mock->memoryInfo.reset(new MemoryInfo(regionInfo, *mock));
mock->queryEngineInfo();
mock->ioctlCallsCount = 0;
mock->chunkingAvailable = true;
mock->callBaseIsChunkingAvailable = true;
mock->chunkingMode = 0x01;
AllocationProperties gpuProperties{0u,
mock->minimalChunkingSize / 2,
AllocationType::UNIFIED_SHARED_MEMORY,
1u};
gpuProperties.alignment = 2 * MemoryConstants::megaByte;
gpuProperties.usmInitialPlacement = GraphicsAllocation::UsmInitialPlacement::CPU;
auto allocation = memoryManager->allocateGraphicsMemoryWithProperties(gpuProperties);
ASSERT_NE(allocation, nullptr);
EXPECT_NE(static_cast<DrmAllocation *>(allocation)->getMmapPtr(), nullptr);
EXPECT_NE(static_cast<DrmAllocation *>(allocation)->getMmapSize(), 0u);
EXPECT_EQ(allocation->getAllocationOffset(), 0u);
EXPECT_FALSE(allocation->storageInfo.isChunked);
const auto &createExt = mock->context.receivedCreateGemExt.value();
EXPECT_EQ(1u, createExt.handle);
const auto &memRegions = createExt.memoryRegions;
ASSERT_EQ(memRegions.size(), 2u);
EXPECT_EQ(memRegions[0].memoryClass, drm_i915_gem_memory_class::I915_MEMORY_CLASS_SYSTEM);
EXPECT_EQ(memRegions[0].memoryInstance, 1u);
EXPECT_EQ(memRegions[1].memoryClass, drm_i915_gem_memory_class::I915_MEMORY_CLASS_DEVICE);
EXPECT_EQ(memRegions[1].memoryInstance, regionInfo[1].region.memoryInstance);
memoryManager->freeGraphicsMemory(allocation);
}
TEST_F(DrmMemoryManagerLocalMemoryPrelimTest,
whenCreateUnifiedMemoryAllocationWithChunkingModeSetToSharedAndSizeGreaterThanMinimalThenChunkingIsUsed) {
std::vector<MemoryRegion> regionInfo(2);
regionInfo[0].region = {drm_i915_gem_memory_class::I915_MEMORY_CLASS_SYSTEM, 1};
regionInfo[1].region = {drm_i915_gem_memory_class::I915_MEMORY_CLASS_DEVICE, DrmMockHelper::getEngineOrMemoryInstanceValue(0, 0)};
mock->memoryInfo.reset(new MemoryInfo(regionInfo, *mock));
mock->queryEngineInfo();
mock->ioctlCallsCount = 0;
mock->chunkingAvailable = true;
mock->callBaseIsChunkingAvailable = true;
mock->chunkingMode = 0x01;
AllocationProperties gpuProperties{0u,
mock->minimalChunkingSize * 2,
AllocationType::UNIFIED_SHARED_MEMORY,
1u};
gpuProperties.alignment = 2 * MemoryConstants::megaByte;
gpuProperties.usmInitialPlacement = GraphicsAllocation::UsmInitialPlacement::CPU;
auto allocation = memoryManager->allocateGraphicsMemoryWithProperties(gpuProperties);
ASSERT_NE(allocation, nullptr);
EXPECT_NE(static_cast<DrmAllocation *>(allocation)->getMmapPtr(), nullptr);
EXPECT_NE(static_cast<DrmAllocation *>(allocation)->getMmapSize(), 0u);
EXPECT_EQ(allocation->getAllocationOffset(), 0u);
EXPECT_TRUE(allocation->storageInfo.isChunked);
const auto &createExt = mock->context.receivedCreateGemExt.value();
EXPECT_EQ(1u, createExt.handle);
const auto &memRegions = createExt.memoryRegions;
ASSERT_EQ(memRegions.size(), 2u);
EXPECT_EQ(memRegions[0].memoryClass, drm_i915_gem_memory_class::I915_MEMORY_CLASS_SYSTEM);
EXPECT_EQ(memRegions[0].memoryInstance, 1u);
EXPECT_EQ(memRegions[1].memoryClass, drm_i915_gem_memory_class::I915_MEMORY_CLASS_DEVICE);
EXPECT_EQ(memRegions[1].memoryInstance, regionInfo[1].region.memoryInstance);
memoryManager->freeGraphicsMemory(allocation);
}
TEST_F(DrmMemoryManagerLocalMemoryPrelimTest,
whenCreateUnifiedMemoryAllocationWithChunkingAndNoEnableBOChunkingPreferredLocationHintSetThenGemCreateExtIsUsedWithoutPreferredLocation) {
std::vector<MemoryRegion> regionInfo(2);

View File

@ -5285,11 +5285,13 @@ TEST_F(DrmMemoryManagerWithLocalMemoryAndExplicitExpectationsTest,
givenMemoryAllocationWithMoreThanChunkingSizeAllowedThenChunkingIsUsed) {
VariableBackup<bool> backupChunkingCallParent{&mock->getChunkingAvailableCall.callParent, false};
VariableBackup<bool> backupChunkingReturnValue{&mock->getChunkingAvailableCall.returnValue, true};
VariableBackup<bool> backupChunkingModeCallParent{&mock->getChunkingModeCall.callParent, false};
VariableBackup<uint32_t> backupChunkingModeReturnValue{&mock->getChunkingModeCall.returnValue, 0x3};
MemoryManager::AllocationStatus status = MemoryManager::AllocationStatus::Success;
AllocationData allocData;
allocData.allFlags = 0;
allocData.size = MemoryConstants::chunkThreshold * 2;
allocData.size = MemoryConstants::pageSize2Mb;
allocData.type = AllocationType::BUFFER;
allocData.rootDeviceIndex = rootDeviceIndex;
allocData.storageInfo.memoryBanks = 0b11;
@ -5304,14 +5306,107 @@ TEST_F(DrmMemoryManagerWithLocalMemoryAndExplicitExpectationsTest,
}
TEST_F(DrmMemoryManagerWithLocalMemoryAndExplicitExpectationsTest,
givenMemoryAllocationWithMoreThanChunkingSizeAllowedAndFailGemCreateExtThenNullptrIsReturned) {
givenDeviceMemoryAllocationWithChunkingModeSetToSharedThenNoChunkingIsNotUsed) {
VariableBackup<bool> backupChunkingCallParent{&mock->getChunkingAvailableCall.callParent, false};
VariableBackup<bool> backupChunkingReturnValue{&mock->getChunkingAvailableCall.returnValue, true};
VariableBackup<bool> backupChunkingModeCallParent{&mock->getChunkingModeCall.callParent, false};
VariableBackup<uint32_t> backupChunkingModeReturnValue{&mock->getChunkingModeCall.returnValue, 0x1};
MemoryManager::AllocationStatus status = MemoryManager::AllocationStatus::Success;
AllocationData allocData;
allocData.allFlags = 0;
allocData.size = MemoryConstants::chunkThreshold * 2;
allocData.size = MemoryConstants::pageSize2Mb;
allocData.type = AllocationType::BUFFER;
allocData.rootDeviceIndex = rootDeviceIndex;
allocData.storageInfo.memoryBanks = 0b11;
auto allocation = memoryManager->allocateGraphicsMemoryInDevicePool(allocData, status);
EXPECT_NE(nullptr, allocation);
EXPECT_FALSE(allocation->storageInfo.isChunked);
memoryManager->freeGraphicsMemory(allocation);
}
TEST_F(DrmMemoryManagerWithLocalMemoryAndExplicitExpectationsTest,
givenDeviceMemoryAllocationWithChunkingModeSetToDeviceThenChunkingIsUsed) {
VariableBackup<bool> backupChunkingCallParent{&mock->getChunkingAvailableCall.callParent, false};
VariableBackup<bool> backupChunkingReturnValue{&mock->getChunkingAvailableCall.returnValue, true};
VariableBackup<bool> backupChunkingModeCallParent{&mock->getChunkingModeCall.callParent, false};
VariableBackup<uint32_t> backupChunkingModeReturnValue{&mock->getChunkingModeCall.returnValue, 0x2};
MemoryManager::AllocationStatus status = MemoryManager::AllocationStatus::Success;
AllocationData allocData;
allocData.allFlags = 0;
allocData.size = MemoryConstants::pageSize2Mb;
allocData.type = AllocationType::BUFFER;
allocData.rootDeviceIndex = rootDeviceIndex;
allocData.storageInfo.memoryBanks = 0b11;
auto allocation = memoryManager->allocateGraphicsMemoryInDevicePool(allocData, status);
EXPECT_NE(nullptr, allocation);
EXPECT_TRUE(allocation->storageInfo.isChunked);
memoryManager->freeGraphicsMemory(allocation);
}
TEST_F(DrmMemoryManagerWithLocalMemoryAndExplicitExpectationsTest,
givenDeviceMemoryAllocationWithChunkingModeSetToDeviceAndChunkingSizeNotAlignedThenChunkingIsNotUsed) {
DebugManagerStateRestore restorer;
DebugManager.flags.NumberOfBOChunks.set(64);
VariableBackup<bool> backupChunkingCallParent{&mock->getChunkingAvailableCall.callParent, false};
VariableBackup<bool> backupChunkingReturnValue{&mock->getChunkingAvailableCall.returnValue, true};
VariableBackup<bool> backupChunkingModeCallParent{&mock->getChunkingModeCall.callParent, false};
VariableBackup<uint32_t> backupChunkingModeReturnValue{&mock->getChunkingModeCall.returnValue, 0x2};
MemoryManager::AllocationStatus status = MemoryManager::AllocationStatus::Success;
AllocationData allocData;
allocData.allFlags = 0;
allocData.size = MemoryConstants::pageSize2Mb;
allocData.type = AllocationType::BUFFER;
allocData.rootDeviceIndex = rootDeviceIndex;
allocData.storageInfo.memoryBanks = 0b11;
auto allocation = memoryManager->allocateGraphicsMemoryInDevicePool(allocData, status);
EXPECT_NE(nullptr, allocation);
EXPECT_FALSE(allocation->storageInfo.isChunked);
memoryManager->freeGraphicsMemory(allocation);
}
TEST_F(DrmMemoryManagerWithLocalMemoryAndExplicitExpectationsTest,
givenDeviceMemoryAllocationWithChunkingModeSetToDeviceAndSizeLessThanMinimalThenChunkingIsNotUsed) {
VariableBackup<bool> backupChunkingCallParent{&mock->getChunkingAvailableCall.callParent, false};
VariableBackup<bool> backupChunkingReturnValue{&mock->getChunkingAvailableCall.returnValue, true};
VariableBackup<bool> backupChunkingModeCallParent{&mock->getChunkingModeCall.callParent, false};
VariableBackup<uint32_t> backupChunkingModeReturnValue{&mock->getChunkingModeCall.returnValue, 0x2};
MemoryManager::AllocationStatus status = MemoryManager::AllocationStatus::Success;
AllocationData allocData;
allocData.allFlags = 0;
allocData.size = MemoryConstants::pageSize;
allocData.type = AllocationType::BUFFER;
allocData.rootDeviceIndex = rootDeviceIndex;
allocData.storageInfo.memoryBanks = 0b11;
auto allocation = memoryManager->allocateGraphicsMemoryInDevicePool(allocData, status);
EXPECT_NE(nullptr, allocation);
EXPECT_FALSE(allocation->storageInfo.isChunked);
memoryManager->freeGraphicsMemory(allocation);
}
TEST_F(DrmMemoryManagerWithLocalMemoryAndExplicitExpectationsTest,
givenMemoryAllocationWithMoreThanChunkingSizeAllowedAndFailGemCreateExtThenNullptrIsReturned) {
VariableBackup<bool> backupChunkingCallParent{&mock->getChunkingAvailableCall.callParent, false};
VariableBackup<bool> backupChunkingReturnValue{&mock->getChunkingAvailableCall.returnValue, true};
VariableBackup<bool> backupChunkingModeCallParent{&mock->getChunkingModeCall.callParent, false};
VariableBackup<uint32_t> backupChunkingModeReturnValue{&mock->getChunkingModeCall.returnValue, 0x3};
MemoryManager::AllocationStatus status = MemoryManager::AllocationStatus::Success;
AllocationData allocData;
allocData.allFlags = 0;
allocData.size = MemoryConstants::pageSize2Mb;
allocData.type = AllocationType::BUFFER;
allocData.rootDeviceIndex = rootDeviceIndex;
allocData.storageInfo.memoryBanks = 0b11;

View File

@ -1399,8 +1399,9 @@ TEST(DrmChunkingTests, whenQueryingForChunkingAvailableAndNoDebugKeyThenFalseIsR
EXPECT_EQ(0u, drm.context.chunkingQueryCalled);
drm.callBaseIsChunkingAvailable = true;
EXPECT_FALSE(drm.isChunkingAvailable());
EXPECT_FALSE(drm.chunkingAvailable);
EXPECT_FALSE(drm.getChunkingAvailable());
EXPECT_EQ(0u, drm.context.chunkingQueryCalled);
EXPECT_EQ(0u, drm.getChunkingMode());
}
TEST(DrmSetPairTests, whenQueryingForSetPairAvailableAndDebugKeySetAndNoSupportAvailableThenFalseIsReturned) {
@ -1535,6 +1536,27 @@ TEST(DrmResidencyHandlerTests, whenQueryingForChunkingAvailableAndSupportAvailab
EXPECT_EQ(1u, drm.context.chunkingQueryCalled);
}
TEST(DrmResidencyHandlerTests, whenQueryingForChunkingAvailableAndChangingMinimalSizeForChunkingAndSupportAvailableThenExpectedValuesAreReturned) {
DebugManagerStateRestore restorer;
DebugManager.flags.EnableBOChunking.set(1);
const uint64_t minimalSizeForChunking = 65536;
DebugManager.flags.MinimalAllocationSizeForChunking.set(minimalSizeForChunking);
auto executionEnvironment = std::make_unique<MockExecutionEnvironment>();
DrmQueryMock drm{*executionEnvironment->rootDeviceEnvironments[0]};
drm.context.chunkingQueryValue = 1;
drm.context.chunkingQueryReturn = 0;
EXPECT_FALSE(drm.chunkingAvailable);
EXPECT_EQ(0u, drm.context.chunkingQueryCalled);
drm.callBaseIsChunkingAvailable = true;
EXPECT_TRUE(drm.isChunkingAvailable());
EXPECT_TRUE(drm.chunkingAvailable);
EXPECT_EQ(1u, drm.context.chunkingQueryCalled);
EXPECT_EQ(minimalSizeForChunking, drm.minimalChunkingSize);
}
TEST(DrmResidencyHandlerTests, whenQueryingForChunkingAvailableAndFailureInQueryThenFalseIsReturned) {
DebugManagerStateRestore restorer;
DebugManager.flags.EnableBOChunking.set(1);