refactor: remove not needed code

Signed-off-by: Michal Mrozek <michal.mrozek@intel.com>
This commit is contained in:
Michal Mrozek
2025-11-28 10:19:50 +00:00
committed by Compute-Runtime-Automation
parent 231cfdc472
commit 68d01f398f
24 changed files with 20 additions and 794 deletions

View File

@@ -263,7 +263,7 @@ class CommandStreamReceiverHw : public CommandStreamReceiver {
const IndirectHeap *ssh,
DispatchFlags &dispatchFlags,
Device &device, LinearStream &commandStreamCSR,
bool force32BitAllocations, bool sshDirty, bool bindingTablePoolCommandNeeded);
bool sshDirty, bool bindingTablePoolCommandNeeded);
inline void programStateBaseAddressCommon(const IndirectHeap *dsh,
const IndirectHeap *ioh,
const IndirectHeap *ssh,

View File

@@ -1687,14 +1687,12 @@ inline void CommandStreamReceiverHw<GfxFamily>::programStateBaseAddress(const In
surfaceStateBaseAddress, surfaceStateSize);
}
auto force32BitAllocations = getMemoryManager()->peekForce32BitAllocations();
stateBaseAddressDirty |= ((gsbaFor32BitProgrammed ^ dispatchFlags.gsba32BitRequired) && force32BitAllocations);
bool isStateBaseAddressDirty = dshDirty || iohDirty || sshDirty || stateBaseAddressDirty;
handleStateBaseAddressStateTransition(dispatchFlags, isStateBaseAddressDirty);
// reprogram state base address command if required
if (isStateBaseAddressDirty) {
reprogramStateBaseAddress(dsh, ioh, ssh, dispatchFlags, device, commandStreamCSR, force32BitAllocations, sshDirty, bindingTablePoolCommandNeeded);
reprogramStateBaseAddress(dsh, ioh, ssh, dispatchFlags, device, commandStreamCSR, sshDirty, bindingTablePoolCommandNeeded);
}
if (hasDsh) {
@@ -1718,16 +1716,12 @@ inline void CommandStreamReceiverHw<GfxFamily>::programStateBaseAddress(const In
}
template <typename GfxFamily>
inline void CommandStreamReceiverHw<GfxFamily>::reprogramStateBaseAddress(const IndirectHeap *dsh, const IndirectHeap *ioh, const IndirectHeap *ssh, DispatchFlags &dispatchFlags, Device &device, LinearStream &commandStreamCSR, bool force32BitAllocations, bool sshDirty, bool bindingTablePoolCommandNeeded) {
inline void CommandStreamReceiverHw<GfxFamily>::reprogramStateBaseAddress(const IndirectHeap *dsh, const IndirectHeap *ioh, const IndirectHeap *ssh, DispatchFlags &dispatchFlags, Device &device, LinearStream &commandStreamCSR, bool sshDirty, bool bindingTablePoolCommandNeeded) {
uint64_t newGshBase = 0;
gsbaFor32BitProgrammed = false;
if (is64bit && scratchSpaceController->getScratchSpaceSlot0Allocation() && !force32BitAllocations) {
if (is64bit && scratchSpaceController->getScratchSpaceSlot0Allocation()) {
newGshBase = scratchSpaceController->calculateNewGSH();
} else if (is64bit && force32BitAllocations && dispatchFlags.gsba32BitRequired) {
bool useLocalMemory = scratchSpaceController->getScratchSpaceSlot0Allocation() ? scratchSpaceController->getScratchSpaceSlot0Allocation()->isAllocatedInLocalMemoryPool() : false;
newGshBase = getMemoryManager()->getExternalHeapBaseAddress(rootDeviceIndex, useLocalMemory);
gsbaFor32BitProgrammed = true;
}
uint64_t indirectObjectStateBaseAddress = getMemoryManager()->getInternalHeapBaseAddress(rootDeviceIndex, ioh->getGraphicsAllocation()->isAllocatedInLocalMemoryPool());

View File

@@ -39,8 +39,7 @@ void ScratchSpaceControllerBase::setRequiredScratchSpace(void *sshBaseAddress,
}
createScratchSpaceAllocation();
vfeStateDirty = true;
force32BitAllocation = getMemoryManager()->peekForce32BitAllocations();
if (is64bit && !force32BitAllocation) {
if (is64bit) {
stateBaseAddressDirty = true;
}
}
@@ -64,10 +63,11 @@ uint64_t ScratchSpaceControllerBase::getScratchPatchAddress() {
// and "0 + scratchSpaceOffsetFor64bit" is being programmed in Media VFE state
uint64_t scratchAddress = 0;
if (scratchSlot0Allocation) {
scratchAddress = scratchSlot0Allocation->getGpuAddressToPatch();
if (is64bit && !getMemoryManager()->peekForce32BitAllocations()) {
if (is64bit) {
// this is to avoid scratch allocation offset "0"
scratchAddress = ScratchSpaceConstants::scratchSpaceOffsetFor64Bit;
} else {
scratchAddress = scratchSlot0Allocation->getGpuAddressToPatch();
}
}
return scratchAddress;

View File

@@ -329,8 +329,6 @@ bool Device::initDeviceFully() {
}
}
executionEnvironment->memoryManager->setForce32BitAllocations(false);
if (debugManager.flags.EnableSWTags.get() && !getRootDeviceEnvironment().tagsManager->isInitialized()) {
getRootDeviceEnvironment().tagsManager->initialize(*this);
}

View File

@@ -881,8 +881,7 @@ GraphicsAllocation *MemoryManager::allocateGraphicsMemory(const AllocationData &
bool use32Allocator = heapAssigners[allocationData.rootDeviceIndex]->use32BitHeap(allocationData.type);
bool isAllocationOnLimitedGPU = isLimitedGPUOnType(allocationData.rootDeviceIndex, allocationData.type);
if (use32Allocator || isAllocationOnLimitedGPU ||
(force32bitAllocations && allocationData.flags.allow32Bit && is64bit)) {
if (use32Allocator || isAllocationOnLimitedGPU) {
return allocate32BitGraphicsMemoryImpl(allocationData);
}
if (allocationData.flags.isUSMHostAllocation && allocationData.hostPtr) {

View File

@@ -192,8 +192,6 @@ class MemoryManager {
MOCKABLE_VIRTUAL bool isLimitedRange(uint32_t rootDeviceIndex);
bool peek64kbPagesEnabled(uint32_t rootDeviceIndex) const;
bool peekForce32BitAllocations() const { return force32bitAllocations; }
void setForce32BitAllocations(bool newValue) { force32bitAllocations = newValue; }
DeferredDeleter *getDeferredDeleter() const {
return deferredDeleter.get();
@@ -298,7 +296,7 @@ class MemoryManager {
bool isLocalMemoryUsedForIsa(uint32_t rootDeviceIndex);
MOCKABLE_VIRTUAL bool isNonSvmBuffer(const void *hostPtr, AllocationType allocationType, uint32_t rootDeviceIndex) {
return !force32bitAllocations && hostPtr && !isHostPointerTrackingEnabled(rootDeviceIndex) && (allocationType == AllocationType::bufferHostMemory);
return hostPtr && !isHostPointerTrackingEnabled(rootDeviceIndex) && (allocationType == AllocationType::bufferHostMemory);
}
virtual void releaseDeviceSpecificMemResources(uint32_t rootDeviceIndex){};
@@ -411,7 +409,6 @@ class MemoryManager {
bool initialized = false;
bool forceNonSvmForExternalHostPtr = false;
bool force32bitAllocations = false;
bool singleTemporaryAllocationsList = false;
std::unique_ptr<DeferredDeleter> deferredDeleter;
bool asyncDeleterEnabled = false;

View File

@@ -624,7 +624,7 @@ MemoryAllocation *OsAgnosticMemoryManager::createMemoryAllocation(AllocationType
size_t alignedSize = alignSizeWholePage(pMem, memSize);
auto heap = (force32bitAllocations || requireSpecificBitness) ? HeapIndex::heapExternal : HeapIndex::heapStandard;
auto heap = requireSpecificBitness ? HeapIndex::heapExternal : HeapIndex::heapStandard;
auto gfxPartition = getGfxPartition(rootDeviceIndex);
uint64_t limitedGpuAddress = gfxPartition->heapAllocate(heap, alignedSize);
@@ -698,7 +698,7 @@ GraphicsAllocation *OsAgnosticMemoryManager::allocateGraphicsMemoryInDevicePool(
return nullptr;
}
if (allocationData.flags.useSystemMemory || (allocationData.flags.allow32Bit && this->force32bitAllocations)) {
if (allocationData.flags.useSystemMemory) {
return nullptr;
}
bool use32Allocator = heapAssigners[allocationData.rootDeviceIndex]->use32BitHeap(allocationData.type);

View File

@@ -1312,10 +1312,6 @@ GraphicsAllocation *DrmMemoryManager::createGraphicsAllocationFromSharedHandle(c
}
auto getHeapIndex = [&] {
if (requireSpecificBitness && this->force32bitAllocations) {
return HeapIndex::heapExternal;
}
auto gfxPartition = getGfxPartition(properties.rootDeviceIndex);
auto prefer57bitAddressing = (gfxPartition->getHeapLimit(HeapIndex::heapExtended) > 0);
if (prefer57bitAddressing) {
@@ -1359,12 +1355,6 @@ GraphicsAllocation *DrmMemoryManager::createGraphicsAllocationFromSharedHandle(c
osHandleData.handle, memoryPool, canonizedGpuAddress);
this->makeAllocationResident(drmAllocation);
if (requireSpecificBitness && this->force32bitAllocations) {
drmAllocation->set32BitAllocation(true);
auto gmmHelper = getGmmHelper(properties.rootDeviceIndex);
drmAllocation->setGpuBaseAddress(gmmHelper->canonize(getExternalHeapBaseAddress(properties.rootDeviceIndex, drmAllocation->isAllocatedInLocalMemoryPool())));
}
if (properties.imgInfo) {
GemGetTiling getTiling{};
getTiling.handle = boHandle;
@@ -2250,7 +2240,6 @@ GraphicsAllocation *DrmMemoryManager::allocateGraphicsMemoryInDevicePool(const A
status = AllocationStatus::RetryInNonDevicePool;
if (!this->localMemorySupported[allocationData.rootDeviceIndex] ||
allocationData.flags.useSystemMemory ||
(allocationData.flags.allow32Bit && this->force32bitAllocations) ||
allocationData.type == AllocationType::sharedResourceCopy) {
return nullptr;
}

View File

@@ -647,10 +647,6 @@ GraphicsAllocation *WddmMemoryManager::createGraphicsAllocationFromSharedHandle(
return nullptr;
}
allocation->setReservedAddressRange(ptr, size);
} else if (requireSpecificBitness && this->force32bitAllocations) {
allocation->set32BitAllocation(true);
auto gmmHelper = getGmmHelper(allocation->getRootDeviceIndex());
allocation->setGpuBaseAddress(gmmHelper->canonize(getExternalHeapBaseAddress(allocation->getRootDeviceIndex(), false)));
}
status = mapGpuVirtualAddress(allocation.get(), allocation->getReservedAddressPtr());
} else {
@@ -929,26 +925,6 @@ void WddmMemoryManager::cleanOsHandles(OsHandleStorage &handleStorage, uint32_t
}
}
void WddmMemoryManager::obtainGpuAddressFromFragments(WddmAllocation *allocation, OsHandleStorage &handleStorage) {
if (this->force32bitAllocations && (handleStorage.fragmentCount > 0)) {
auto hostPtr = allocation->getUnderlyingBuffer();
auto fragment = hostPtrManager->getFragment({hostPtr, allocation->getRootDeviceIndex()});
if (fragment && fragment->driverAllocation) {
auto osHandle0 = static_cast<OsHandleWin *>(handleStorage.fragmentStorageData[0].osHandleStorage);
auto gpuPtr = osHandle0->gpuPtr;
for (uint32_t i = 1; i < handleStorage.fragmentCount; i++) {
auto osHandle = static_cast<OsHandleWin *>(handleStorage.fragmentStorageData[i].osHandleStorage);
if (osHandle->gpuPtr < gpuPtr) {
gpuPtr = osHandle->gpuPtr;
}
}
allocation->setAllocationOffset(reinterpret_cast<uint64_t>(hostPtr) & MemoryConstants::pageMask);
allocation->setGpuAddress(gpuPtr);
}
}
}
GraphicsAllocation *WddmMemoryManager::createGraphicsAllocation(OsHandleStorage &handleStorage, const AllocationData &allocationData) {
auto gmmHelper = getGmmHelper(allocationData.rootDeviceIndex);
auto canonizedAddress = gmmHelper->canonize(castToUint64(const_cast<void *>(allocationData.hostPtr)));
@@ -961,7 +937,6 @@ GraphicsAllocation *WddmMemoryManager::createGraphicsAllocation(OsHandleStorage
0u, // shareable
maxOsContextCount);
allocation->fragmentsStorage = handleStorage;
obtainGpuAddressFromFragments(allocation, handleStorage);
return allocation;
}
@@ -1470,8 +1445,7 @@ GraphicsAllocation *WddmMemoryManager::allocateGraphicsMemoryInDevicePool(const
status = AllocationStatus::RetryInNonDevicePool;
if (!this->localMemorySupported[allocationData.rootDeviceIndex] ||
allocationData.flags.useSystemMemory ||
(allocationData.flags.allow32Bit && this->force32bitAllocations)) {
allocationData.flags.useSystemMemory) {
return nullptr;
}

View File

@@ -43,8 +43,6 @@ class WddmMemoryManager : public MemoryManager, NEO::NonCopyableAndNonMovableCla
AllocationStatus populateOsHandles(OsHandleStorage &handleStorage, uint32_t rootDeviceIndex) override;
void cleanOsHandles(OsHandleStorage &handleStorage, uint32_t rootDeviceIndex) override;
void obtainGpuAddressFromFragments(WddmAllocation *allocation, OsHandleStorage &handleStorage);
uint64_t getSystemSharedMemory(uint32_t rootDeviceIndex) override;
uint64_t getLocalMemorySize(uint32_t rootDeviceIndex, uint32_t deviceBitfield) override;
double getPercentOfGlobalMemoryAvailable(uint32_t rootDeviceIndex) override;

View File

@@ -67,9 +67,6 @@ class MockWddmMemoryManager : public MemoryManagerCreate<WddmMemoryManager> {
void setDeferredDeleter(DeferredDeleter *deleter) {
this->deferredDeleter.reset(deleter);
}
void setForce32bitAllocations(bool newValue) {
this->force32bitAllocations = newValue;
}
bool validateAllocationMock(WddmAllocation *graphicsAllocation) {
return this->validateAllocation(graphicsAllocation);
}

View File

@@ -680,13 +680,6 @@ TEST_F(CommandStreamReceiverTest, WhenDebugSurfaceIsAllocatedThenCorrectTypeIsSe
EXPECT_EQ(AllocationType::debugContextSaveArea, allocation->getAllocationType());
}
TEST_F(CommandStreamReceiverTest, givenForced32BitAddressingWhenDebugSurfaceIsAllocatedThenRegularAllocationIsReturned) {
auto *memoryManager = commandStreamReceiver->getMemoryManager();
memoryManager->setForce32BitAllocations(true);
auto allocation = commandStreamReceiver->allocateDebugSurface(1024);
EXPECT_FALSE(allocation->is32BitAllocation());
}
HWTEST_F(CommandStreamReceiverTest, givenDefaultCommandStreamReceiverThenDefaultDispatchingPolicyIsImmediateSubmission) {
auto &csr = pDevice->getUltCommandStreamReceiver<FamilyType>();
EXPECT_EQ(DispatchMode::immediateDispatch, csr.dispatchMode);

View File

@@ -38,22 +38,6 @@ TEST(MemoryManagerTest, givenSetUseSytemMemoryWhenGraphicsAllocationInDevicePool
EXPECT_EQ(MemoryManager::AllocationStatus::RetryInNonDevicePool, status);
}
TEST(MemoryManagerTest, givenAllowed32BitAndFroce32BitWhenGraphicsAllocationInDevicePoolIsAllocatedThenNullptrIsReturned) {
MockExecutionEnvironment executionEnvironment(defaultHwInfo.get());
MockMemoryManager memoryManager(false, false, executionEnvironment);
memoryManager.setForce32BitAllocations(true);
MemoryManager::AllocationStatus status = MemoryManager::AllocationStatus::Success;
AllocationData allocData;
allocData.size = MemoryConstants::pageSize;
allocData.flags.allow32Bit = true;
allocData.flags.allocateMemory = true;
auto allocation = memoryManager.allocateGraphicsMemoryInDevicePool(allocData, status);
EXPECT_EQ(nullptr, allocation);
EXPECT_EQ(MemoryManager::AllocationStatus::RetryInNonDevicePool, status);
}
TEST(AllocationFlagsTest, givenAllocateMemoryFlagWhenGetAllocationFlagsIsCalledThenAllocateFlagIsCorrectlySet) {
HardwareInfo hwInfo(*defaultHwInfo);
UltDeviceFactory deviceFactory{1, 0};
@@ -195,27 +179,9 @@ TEST(MemoryManagerTest, givenEnabledLocalMemoryAndUseSytemMemoryWhenGraphicsAllo
EXPECT_EQ(MemoryManager::AllocationStatus::RetryInNonDevicePool, status);
}
TEST(MemoryManagerTest, givenEnabledLocalMemoryAndAllowed32BitAndForce32BitWhenGraphicsAllocationInDevicePoolIsAllocatedThenNullptrIsReturned) {
MockExecutionEnvironment executionEnvironment(defaultHwInfo.get());
MockMemoryManager memoryManager(false, true, executionEnvironment);
memoryManager.setForce32BitAllocations(true);
MemoryManager::AllocationStatus status = MemoryManager::AllocationStatus::Success;
AllocationData allocData;
allocData.allFlags = 0;
allocData.size = MemoryConstants::pageSize;
allocData.flags.allow32Bit = true;
allocData.flags.allocateMemory = true;
auto allocation = memoryManager.allocateGraphicsMemoryInDevicePool(allocData, status);
EXPECT_EQ(nullptr, allocation);
EXPECT_EQ(MemoryManager::AllocationStatus::RetryInNonDevicePool, status);
}
TEST(MemoryManagerTest, givenEnabledLocalMemoryAndAllowed32BitWhen32BitIsNotForcedThenGraphicsAllocationInDevicePoolReturnsLocalMemoryAllocation) {
MockExecutionEnvironment executionEnvironment(defaultHwInfo.get());
MockMemoryManager memoryManager(false, true, executionEnvironment);
memoryManager.setForce32BitAllocations(false);
MemoryManager::AllocationStatus status = MemoryManager::AllocationStatus::Success;
AllocationData allocData;
@@ -301,25 +267,6 @@ HWTEST_F(MemoryManagerTests, givenEnabledLocalMemoryWhenAllocatingDebugAreaThenH
osAgnosticMemoryManager.freeGraphicsMemory(moduleDebugArea);
}
TEST(BaseMemoryManagerTest, givenMemoryManagerWithForced32BitsWhenSystemMemoryIsNotSetAnd32BitNotAllowedThenAllocateInDevicePoolReturnsLocalMemory) {
MockExecutionEnvironment executionEnvironment(defaultHwInfo.get());
MockMemoryManagerBaseImplementationOfDevicePool memoryManager(false, true, executionEnvironment);
MemoryManager::AllocationStatus status = MemoryManager::AllocationStatus::Error;
AllocationData allocData;
allocData.allFlags = 0;
allocData.size = MemoryConstants::pageSize;
allocData.flags.allocateMemory = true;
memoryManager.setForce32BitAllocations(true);
auto allocation = memoryManager.allocateGraphicsMemoryInDevicePool(allocData, status);
EXPECT_NE(nullptr, allocation);
EXPECT_EQ(MemoryManager::AllocationStatus::Success, status);
EXPECT_EQ(MemoryPool::localMemory, allocation->getMemoryPool());
memoryManager.freeGraphicsMemory(allocation);
}
TEST(BaseMemoryManagerTest, givenDebugVariableSetWhenCompressedBufferIsCreatedThenCreateCompressedGmm) {
DebugManagerStateRestore restore;
MockExecutionEnvironment executionEnvironment(defaultHwInfo.get());
@@ -513,43 +460,6 @@ TEST(BaseMemoryManagerTest, givenCalltoAllocatePhysicalGraphicsMemoryWithFailedL
EXPECT_EQ(nullptr, allocationBuffer);
}
TEST(BaseMemoryManagerTest, givenMemoryManagerWithForced32BitsWhenSystemMemoryIsNotSetAnd32BitAllowedThenAllocateInDevicePoolReturnsRetryInNonDevicePool) {
MockExecutionEnvironment executionEnvironment(defaultHwInfo.get());
MockMemoryManagerBaseImplementationOfDevicePool memoryManager(false, true, executionEnvironment);
MemoryManager::AllocationStatus status = MemoryManager::AllocationStatus::Error;
AllocationData allocData;
allocData.allFlags = 0;
allocData.size = MemoryConstants::pageSize;
allocData.flags.allocateMemory = true;
allocData.flags.allow32Bit = true;
memoryManager.setForce32BitAllocations(true);
auto allocation = memoryManager.allocateGraphicsMemoryInDevicePool(allocData, status);
EXPECT_EQ(nullptr, allocation);
EXPECT_EQ(MemoryManager::AllocationStatus::RetryInNonDevicePool, status);
memoryManager.freeGraphicsMemory(allocation);
}
TEST(BaseMemoryManagerTest, givenMemoryManagerWhenAllocateFailsThenAllocateInDevicePoolReturnsError) {
MockExecutionEnvironment executionEnvironment(defaultHwInfo.get());
MockMemoryManagerBaseImplementationOfDevicePool memoryManager(false, true, executionEnvironment);
MemoryManager::AllocationStatus status = MemoryManager::AllocationStatus::Error;
AllocationData allocData;
allocData.allFlags = 0;
allocData.size = MemoryConstants::pageSize;
allocData.flags.allocateMemory = true;
allocData.flags.allow32Bit = true;
memoryManager.failInAllocate = true;
auto allocation = memoryManager.allocateGraphicsMemoryInDevicePool(allocData, status);
EXPECT_EQ(nullptr, allocation);
EXPECT_EQ(MemoryManager::AllocationStatus::Error, status);
memoryManager.freeGraphicsMemory(allocation);
}
TEST(BaseMemoryManagerTest, givenSvmGpuAllocationTypeWhenAllocateSystemMemoryFailsThenReturnNull) {
MockExecutionEnvironment executionEnvironment(defaultHwInfo.get());

View File

@@ -253,29 +253,6 @@ INSTANTIATE_TEST_SUITE_P(Disallow32BitAnd64kbPagesTypes,
MemoryManagerGetAlloctionData32BitAnd64kbPagesNotAllowedTest,
::testing::ValuesIn(allocationTypesWith32BitAnd64KbPagesNotAllowed));
TEST(MemoryManagerTest, givenForced32BitSetWhenGraphicsMemoryFor32BitAllowedTypeIsAllocatedThen32BitAllocationIsReturned) {
MockExecutionEnvironment executionEnvironment(defaultHwInfo.get());
MockMemoryManager memoryManager(false, false, executionEnvironment);
memoryManager.setForce32BitAllocations(true);
AllocationData allocData;
AllocationProperties properties(mockRootDeviceIndex, 10, AllocationType::buffer, mockDeviceBitfield);
memoryManager.getAllocationData(allocData, properties, nullptr, memoryManager.createStorageInfoFromProperties(properties));
auto allocation = memoryManager.allocateGraphicsMemory(allocData);
ASSERT_NE(nullptr, allocation);
if constexpr (is64bit) {
EXPECT_TRUE(allocation->is32BitAllocation());
EXPECT_EQ(MemoryPool::system4KBPagesWith32BitGpuAddressing, allocation->getMemoryPool());
} else {
EXPECT_FALSE(allocation->is32BitAllocation());
EXPECT_EQ(MemoryPool::system4KBPages, allocation->getMemoryPool());
}
memoryManager.freeGraphicsMemory(allocation);
}
TEST(MemoryManagerTest, givenEnabledShareableWhenGraphicsAllocationIsAllocatedThenAllocationIsReturned) {
MockExecutionEnvironment executionEnvironment(defaultHwInfo.get());
executionEnvironment.initGmm();
@@ -313,41 +290,6 @@ TEST(MemoryManagerTest, givenEnabledShareableWhenGraphicsAllocationIsCalledAndSy
memoryManager.freeGraphicsMemory(allocation);
}
TEST(MemoryManagerTest, givenForced32BitEnabledWhenGraphicsMemoryWihtoutAllow32BitFlagIsAllocatedThenNon32BitAllocationIsReturned) {
MockExecutionEnvironment executionEnvironment(defaultHwInfo.get());
MockMemoryManager memoryManager(executionEnvironment);
memoryManager.setForce32BitAllocations(true);
AllocationData allocData;
AllocationProperties properties(mockRootDeviceIndex, 10, AllocationType::buffer, mockDeviceBitfield);
memoryManager.getAllocationData(allocData, properties, nullptr, memoryManager.createStorageInfoFromProperties(properties));
allocData.flags.allow32Bit = false;
auto allocation = memoryManager.allocateGraphicsMemory(allocData);
ASSERT_NE(nullptr, allocation);
EXPECT_FALSE(allocation->is32BitAllocation());
memoryManager.freeGraphicsMemory(allocation);
}
TEST(MemoryManagerTest, givenForced32BitDisabledWhenGraphicsMemoryWith32BitFlagFor32BitAllowedTypeIsAllocatedThenNon32BitAllocationIsReturned) {
MockExecutionEnvironment executionEnvironment(defaultHwInfo.get());
MockMemoryManager memoryManager(executionEnvironment);
memoryManager.setForce32BitAllocations(false);
AllocationData allocData;
AllocationProperties properties(mockRootDeviceIndex, 10, AllocationType::buffer, mockDeviceBitfield);
memoryManager.getAllocationData(allocData, properties, nullptr, memoryManager.createStorageInfoFromProperties(properties));
auto allocation = memoryManager.allocateGraphicsMemory(allocData);
ASSERT_NE(nullptr, allocation);
EXPECT_FALSE(allocation->is32BitAllocation());
memoryManager.freeGraphicsMemory(allocation);
}
TEST(MemoryManagerTest, givenEnabled64kbPagesWhenGraphicsMemoryMustBeHostMemoryAndIsAllocatedWithNullptrForBufferThen64kbAllocationIsReturned) {
MockExecutionEnvironment executionEnvironment(defaultHwInfo.get());
executionEnvironment.initGmm();
@@ -433,27 +375,6 @@ TEST(MemoryManagerTest, givenDisabled64kbPagesWhenGraphicsMemoryMustBeHostMemory
memoryManager.freeGraphicsMemory(allocation);
}
TEST(MemoryManagerTest, givenForced32BitAndEnabled64kbPagesWhenGraphicsMemoryMustBeHostMemoryAndIsAllocatedWithNullptrForBufferThen32BitAllocationOver64kbIsChosen) {
MockExecutionEnvironment executionEnvironment(defaultHwInfo.get());
MockMemoryManager memoryManager(false, false, executionEnvironment);
memoryManager.setForce32BitAllocations(true);
AllocationData allocData;
AllocationProperties properties(mockRootDeviceIndex, 10, AllocationType::bufferHostMemory, mockDeviceBitfield);
memoryManager.getAllocationData(allocData, properties, nullptr, memoryManager.createStorageInfoFromProperties(properties));
auto allocation = memoryManager.allocateGraphicsMemory(allocData);
ASSERT_NE(nullptr, allocation);
if constexpr (is64bit) {
EXPECT_TRUE(allocation->is32BitAllocation());
} else {
EXPECT_FALSE(allocation->is32BitAllocation());
}
memoryManager.freeGraphicsMemory(allocation);
}
TEST(MemoryManagerTest, givenEnabled64kbPagesWhenGraphicsMemoryIsAllocatedWithHostPtrForBufferThenExistingMemoryIsUsedForAllocation) {
MockExecutionEnvironment executionEnvironment(defaultHwInfo.get());
MockMemoryManager memoryManager(true, false, executionEnvironment);

View File

@@ -1135,19 +1135,6 @@ TEST(OsAgnosticMemoryManager, givenDefaultMemoryManagerWhenItIsCreatedAndGfxPart
EXPECT_FALSE(memoryManager.isInitialized());
}
TEST(OsAgnosticMemoryManager, givenDefaultMemoryManagerWhenItIsCreatedThenForce32BitAllocationsIsFalse) {
MockExecutionEnvironment executionEnvironment(defaultHwInfo.get());
OsAgnosticMemoryManager memoryManager(executionEnvironment);
EXPECT_FALSE(memoryManager.peekForce32BitAllocations());
}
TEST(OsAgnosticMemoryManager, givenDefaultMemoryManagerWhenForce32bitallocationIsCalledWithTrueThenMemoryManagerForces32BitAlloactions) {
MockExecutionEnvironment executionEnvironment(defaultHwInfo.get());
OsAgnosticMemoryManager memoryManager(executionEnvironment);
memoryManager.setForce32BitAllocations(true);
EXPECT_TRUE(memoryManager.peekForce32BitAllocations());
}
TEST(OsAgnosticMemoryManager, givenMultipleRootDevicesWhenUpdateLatestContextIdForRootDeviceThenRootDeviceIndexToContextIdUpdateProperly) {
class TestedOsAgnosticMemoryManager : public OsAgnosticMemoryManager {
public:
@@ -1232,25 +1219,6 @@ TEST(OsAgnosticMemoryManager, givenMemoryManagerWhenIsLimitedGPUOnTypeIsCalledTh
}
}
TEST(OsAgnosticMemoryManager, givenMemoryManagerWhenAskedFor32BitAllocationWhenLimitedAllocationIsEnabledThenGpuRangeFromExternalHeapIsAllocatiedAndBaseAddressIsSet) {
if (is32bit) {
GTEST_SKIP();
}
MockExecutionEnvironment executionEnvironment(defaultHwInfo.get());
MockMemoryManager memoryManager(executionEnvironment);
memoryManager.setForce32BitAllocations(true);
memoryManager.forceLimitedRangeAllocator(0, 0xFFFFFFFFF);
AllocationData allocationData;
memoryManager.getAllocationData(allocationData, {mockRootDeviceIndex, MemoryConstants::pageSize, AllocationType::buffer, mockDeviceBitfield}, nullptr, StorageInfo{});
auto gfxAllocation = memoryManager.allocateGraphicsMemoryWithAlignment(allocationData);
ASSERT_NE(gfxAllocation, nullptr);
EXPECT_NE(gfxAllocation->getGpuBaseAddress(), 0ull);
EXPECT_EQ(gfxAllocation->getGpuBaseAddress(), memoryManager.getExternalHeapBaseAddress(gfxAllocation->getRootDeviceIndex(), gfxAllocation->isAllocatedInLocalMemoryPool()));
memoryManager.freeGraphicsMemory(gfxAllocation);
}
TEST(OsAgnosticMemoryManager, givenMemoryManagerWhenAskedForNon32BitAllocationWhenLimitedAllocationIsEnabledThenGpuRangeFromiStandardHeapIsAllocatiedAndBaseAddressIsNotSet) {
if (is32bit) {
GTEST_SKIP();
@@ -2166,26 +2134,6 @@ TEST(MemoryManager, givenBufferHostMemoryWhenAllocatingGraphicsMemoryThenAllocat
memoryManager.freeGraphicsMemory(bufferAllocation);
}
TEST(MemoryManager, givenBufferHostMemoryAndForce32bitAllocationsWhenAllocatingGraphicsMemoryThenAllocateGraphicsMemoryForNonSvmHostPtrIsNotCalled) {
MockExecutionEnvironment executionEnvironment{};
HardwareInfo hwInfoLocal = *defaultHwInfo;
executionEnvironment.rootDeviceEnvironments[0u]->setHwInfoAndInitHelpers(&hwInfoLocal);
executionEnvironment.rootDeviceEnvironments[0u]->initGmm();
MockMemoryManager memoryManager(false, true, executionEnvironment);
memoryManager.setForce32BitAllocations(true);
char bufferData[4096]{};
AllocationData allocationData{};
allocationData.hostPtr = bufferData;
allocationData.size = 4096u;
allocationData.type = AllocationType::bufferHostMemory;
auto bufferAllocation = memoryManager.allocateGraphicsMemory(allocationData);
EXPECT_NE(nullptr, bufferAllocation);
EXPECT_FALSE(memoryManager.allocateGraphicsMemoryForNonSvmHostPtrCalled);
memoryManager.freeGraphicsMemory(bufferAllocation);
}
TEST(MemoryManager, givenShareableWhenAllocatingGraphicsMemoryThenAllocateShareableIsCalled) {
MockExecutionEnvironment executionEnvironment{};
MockMemoryManager memoryManager(false, true, executionEnvironment);

View File

@@ -2337,46 +2337,6 @@ HWTEST_TEMPLATED_F(DrmMemoryManagerTest, GivenMisalignedHostPtrAndMultiplePagesS
EXPECT_EQ(0u, hostPtrManager->getFragmentCount());
}
HWTEST_TEMPLATED_F(DrmMemoryManagerTest, givenMemoryManagerWhenAskedFor32BitAllocationThen32BitDrmAllocationIsBeingReturned) {
mock->ioctlExpected.gemUserptr = 1;
mock->ioctlExpected.gemWait = 1;
mock->ioctlExpected.gemClose = 1;
auto size = 10u;
memoryManager->setForce32BitAllocations(true);
auto allocation = memoryManager->allocate32BitGraphicsMemory(rootDeviceIndex, size, nullptr, AllocationType::buffer);
EXPECT_NE(nullptr, allocation);
EXPECT_NE(nullptr, allocation->getUnderlyingBuffer());
EXPECT_GE(allocation->getUnderlyingBufferSize(), size);
auto address64bit = allocation->getGpuAddressToPatch();
EXPECT_LT(address64bit, MemoryConstants::max32BitAddress);
EXPECT_TRUE(allocation->is32BitAllocation());
auto gmmHelper = device->getGmmHelper();
EXPECT_EQ(gmmHelper->canonize(memoryManager->getExternalHeapBaseAddress(allocation->getRootDeviceIndex(), allocation->isAllocatedInLocalMemoryPool())), allocation->getGpuBaseAddress());
memoryManager->freeGraphicsMemory(allocation);
}
HWTEST_TEMPLATED_F(DrmMemoryManagerTest, givenMemoryManagerWhenAskedFor32BitAllocationWhenLimitedAllocationEnabledThen32BitDrmAllocationWithGpuAddrDifferentFromCpuAddrIsBeingReturned) {
mock->ioctlExpected.gemUserptr = 1;
mock->ioctlExpected.gemWait = 1;
mock->ioctlExpected.gemClose = 1;
memoryManager->forceLimitedRangeAllocator(0xFFFFFFFFF);
auto size = 10u;
memoryManager->setForce32BitAllocations(true);
auto allocation = memoryManager->allocate32BitGraphicsMemory(rootDeviceIndex, size, nullptr, AllocationType::buffer);
EXPECT_NE(nullptr, allocation);
EXPECT_NE(nullptr, allocation->getUnderlyingBuffer());
EXPECT_GE(allocation->getUnderlyingBufferSize(), size);
EXPECT_NE((uint64_t)allocation->getGpuAddress(), (uint64_t)allocation->getUnderlyingBuffer());
memoryManager->freeGraphicsMemory(allocation);
}
HWTEST_TEMPLATED_F(DrmMemoryManagerTest, givenMemoryManagerWhenLimitedRangeAllocatorSetThenHeapSizeAndEndAddrCorrectlySetForGivenGpuRange) {
memoryManager->forceLimitedRangeAllocator(0xFFFFFFFFF);
@@ -2408,35 +2368,6 @@ HWTEST_TEMPLATED_F(DrmMemoryManagerTest, givenMemoryManagerWhenAskedForAllocatio
EXPECT_EQ(nullptr, memoryManager->allocateGraphicsMemoryWithAlignment(allocationData));
}
HWTEST_TEMPLATED_F(DrmMemoryManagerTest, givenMemoryManagerWhenAskedFor32BitAllocationWithHostPtrAndAllocUserptrFailsThenFails) {
mock->ioctlExpected.gemUserptr = 1;
this->ioctlResExt = {mock->ioctlCnt.total, -1};
mock->ioctlResExt = &ioctlResExt;
auto size = 10u;
void *hostPtr = reinterpret_cast<void *>(0x1000);
memoryManager->setForce32BitAllocations(true);
auto allocation = memoryManager->allocate32BitGraphicsMemory(rootDeviceIndex, size, hostPtr, AllocationType::buffer);
EXPECT_EQ(nullptr, allocation);
mock->ioctlResExt = &mock->none;
}
HWTEST_TEMPLATED_F(DrmMemoryManagerTest, givenMemoryManagerWhenAskedFor32BitAllocationAndAllocUserptrFailsThenFails) {
mock->ioctlExpected.gemUserptr = 1;
this->ioctlResExt = {mock->ioctlCnt.total, -1};
mock->ioctlResExt = &ioctlResExt;
auto size = 10u;
memoryManager->setForce32BitAllocations(true);
auto allocation = memoryManager->allocate32BitGraphicsMemory(rootDeviceIndex, size, nullptr, AllocationType::buffer);
EXPECT_EQ(nullptr, allocation);
mock->ioctlResExt = &mock->none;
}
HWTEST_TEMPLATED_F(DrmMemoryManagerTest, givenLimitedRangeAllocatorWhenAskedForInternal32BitAllocationAndAllocUserptrFailsThenFails) {
mock->ioctlExpected.gemUserptr = 1;
@@ -2675,48 +2606,6 @@ HWTEST_TEMPLATED_F(DrmMemoryManagerTest, givenDrmMemoryManagerAndThreeOsHandlesW
}
}
HWTEST_TEMPLATED_F(DrmMemoryManagerTest, given32BitAddressingWhenBufferFromSharedHandleAndBitnessRequiredIsCreatedThenItis32BitAllocation) {
mock->ioctlExpected.primeFdToHandle = 1;
mock->ioctlExpected.gemWait = 1;
mock->ioctlExpected.gemClose = 1;
SysCalls::lseekCalledCount = 0;
memoryManager->setForce32BitAllocations(true);
TestedDrmMemoryManager::OsHandleData osHandleData{1u};
this->mock->outputHandle = 2u;
AllocationProperties properties(rootDeviceIndex, false, MemoryConstants::pageSize, AllocationType::sharedBuffer, false, mockDeviceBitfield);
auto graphicsAllocation = memoryManager->createGraphicsAllocationFromSharedHandle(osHandleData, properties, true, false, true, nullptr);
auto drmAllocation = static_cast<DrmAllocation *>(graphicsAllocation);
EXPECT_TRUE(graphicsAllocation->is32BitAllocation());
EXPECT_EQ(1, SysCalls::lseekCalledCount);
auto gmmHelper = device->getGmmHelper();
EXPECT_EQ(gmmHelper->canonize(memoryManager->getExternalHeapBaseAddress(graphicsAllocation->getRootDeviceIndex(), drmAllocation->isAllocatedInLocalMemoryPool())), drmAllocation->getGpuBaseAddress());
memoryManager->freeGraphicsMemory(graphicsAllocation);
}
HWTEST_TEMPLATED_F(DrmMemoryManagerTest, given32BitAddressingWhenBufferFromSharedHandleIsCreatedAndDoesntRequireBitnessThenItIsNot32BitAllocation) {
mock->ioctlExpected.primeFdToHandle = 1;
mock->ioctlExpected.gemWait = 1;
mock->ioctlExpected.gemClose = 1;
SysCalls::lseekCalledCount = 0;
memoryManager->setForce32BitAllocations(true);
TestedDrmMemoryManager::OsHandleData osHandleData{1u};
this->mock->outputHandle = 2u;
AllocationProperties properties(rootDeviceIndex, false, MemoryConstants::pageSize, AllocationType::sharedBuffer, false, mockDeviceBitfield);
auto graphicsAllocation = memoryManager->createGraphicsAllocationFromSharedHandle(osHandleData, properties, false, false, true, nullptr);
auto drmAllocation = static_cast<DrmAllocation *>(graphicsAllocation);
EXPECT_FALSE(graphicsAllocation->is32BitAllocation());
EXPECT_EQ(1, SysCalls::lseekCalledCount);
EXPECT_EQ(0llu, drmAllocation->getGpuBaseAddress());
memoryManager->freeGraphicsMemory(graphicsAllocation);
}
HWTEST_TEMPLATED_F(DrmMemoryManagerTest, givenLimitedRangeAllocatorWhenBufferFromSharedHandleIsCreatedThenItIsLimitedRangeAllocation) {
mock->ioctlExpected.primeFdToHandle = 1;
mock->ioctlExpected.gemWait = 1;
@@ -2742,7 +2631,6 @@ HWTEST_TEMPLATED_F(DrmMemoryManagerTest, givenNon32BitAddressingWhenBufferFromSh
mock->ioctlExpected.gemClose = 1;
SysCalls::lseekCalledCount = 0;
memoryManager->setForce32BitAllocations(false);
TestedDrmMemoryManager::OsHandleData osHandleData{1u};
this->mock->outputHandle = 2u;
AllocationProperties properties(rootDeviceIndex, false, MemoryConstants::pageSize, AllocationType::sharedBuffer, false, mockDeviceBitfield);
@@ -3143,25 +3031,6 @@ HWTEST_TEMPLATED_F(DrmMemoryManagerTest, givenLimitedRangeAllocatorWhenAskedForI
memoryManager->freeGraphicsMemory(drmAllocation);
}
HWTEST_TEMPLATED_F(DrmMemoryManagerTest, givenLimitedRangeAllocatorWhenAskedForExternalAllocationWithNoPointerThenAllocationFromInternalHeapIsReturned) {
mock->ioctlExpected.gemUserptr = 1;
mock->ioctlExpected.gemWait = 1;
mock->ioctlExpected.gemClose = 1;
memoryManager->setForce32BitAllocations(true);
memoryManager->forceLimitedRangeAllocator(0xFFFFFFFFF);
auto bufferSize = MemoryConstants::pageSize;
void *ptr = nullptr;
auto drmAllocation = static_cast<DrmAllocation *>(memoryManager->allocate32BitGraphicsMemory(rootDeviceIndex, bufferSize, ptr, AllocationType::buffer));
ASSERT_NE(nullptr, drmAllocation);
EXPECT_NE(nullptr, drmAllocation->getUnderlyingBuffer());
EXPECT_TRUE(drmAllocation->is32BitAllocation());
memoryManager->freeGraphicsMemory(drmAllocation);
}
HWTEST_TEMPLATED_F(DrmMemoryManagerTest, givenLimitedRangeAllocatorWhenAskedForInternalAllocationWithNoPointerAndHugeBufferSizeThenAllocationFromInternalHeapFailed) {
memoryManager->forceLimitedRangeAllocator(0xFFFFFFFFF);
@@ -3422,25 +3291,6 @@ TEST_F(DrmMemoryManagerWithExplicitExpectationsTest, givenMemoryManagerWhenAlloc
memoryManager->freeGraphicsMemory(allocation);
}
TEST_F(DrmMemoryManagerBasic, givenMemoryManagerWhenAllocate32BitGraphicsMemoryWithPtrIsCalledThenMemoryPoolIsSystem4KBPagesWith32BitGpuAddressing) {
std::unique_ptr<TestedDrmMemoryManager> memoryManager(new (std::nothrow) TestedDrmMemoryManager(false,
false,
true,
executionEnvironment));
memoryManager->setForce32BitAllocations(true);
void *ptr = reinterpret_cast<void *>(0x1001);
auto size = MemoryConstants::pageSize;
auto allocation = memoryManager->allocate32BitGraphicsMemory(rootDeviceIndex, size, ptr, AllocationType::buffer);
ASSERT_NE(nullptr, allocation);
EXPECT_EQ(MemoryPool::system4KBPagesWith32BitGpuAddressing, allocation->getMemoryPool());
memoryManager->freeGraphicsMemory(allocation);
}
TEST_F(DrmMemoryManagerBasic, givenMemoryManagerWhenCreateAllocationFromHandleIsCalledThenMemoryPoolIsSystemCpuInaccessible) {
std::unique_ptr<TestedDrmMemoryManager> memoryManager(new (std::nothrow) TestedDrmMemoryManager(false,
false,
@@ -7159,26 +7009,7 @@ TEST_F(DrmMemoryManagerWithLocalMemoryAndExplicitExpectationsTest, givenSvmGpuAl
memoryManager->freeGraphicsMemory(allocation);
}
TEST_F(DrmMemoryManagerWithLocalMemoryAndExplicitExpectationsTest, givenAllowed32BitAndForce32BitWhenGraphicsAllocationInDevicePoolIsAllocatedThenNullptrIsReturned) {
memoryManager->setForce32BitAllocations(true);
MemoryManager::AllocationStatus status = MemoryManager::AllocationStatus::Success;
AllocationData allocData;
allocData.allFlags = 0;
allocData.size = MemoryConstants::pageSize;
allocData.flags.allow32Bit = true;
allocData.flags.allocateMemory = true;
allocData.type = AllocationType::buffer;
allocData.rootDeviceIndex = rootDeviceIndex;
auto allocation = memoryManager->allocateGraphicsMemoryInDevicePool(allocData, status);
EXPECT_EQ(nullptr, allocation);
EXPECT_EQ(MemoryManager::AllocationStatus::RetryInNonDevicePool, status);
}
TEST_F(DrmMemoryManagerWithLocalMemoryAndExplicitExpectationsTest, givenAllowed32BitWhen32BitIsNotForcedThenGraphicsAllocationInDevicePoolReturnsLocalMemoryAllocation) {
memoryManager->setForce32BitAllocations(false);
MemoryManager::AllocationStatus status = MemoryManager::AllocationStatus::Success;
AllocationData allocData;
allocData.allFlags = 0;

View File

@@ -2330,27 +2330,10 @@ TEST_F(WddmMemoryManagerSimpleTest, givenEnabledLocalMemoryAndUseSytemMemoryWhen
EXPECT_EQ(MemoryManager::AllocationStatus::RetryInNonDevicePool, status);
}
TEST_F(WddmMemoryManagerSimpleTest, givenEnabledLocalMemoryAndAllowed32BitAndForce32BitWhenGraphicsAllocationInDevicePoolIsAllocatedThenNullptrIsReturned) {
memoryManager = std::make_unique<MockWddmMemoryManager>(false, true, executionEnvironment);
memoryManager->setForce32BitAllocations(true);
MemoryManager::AllocationStatus status = MemoryManager::AllocationStatus::Success;
AllocationData allocData;
allocData.allFlags = 0;
allocData.size = MemoryConstants::pageSize;
allocData.flags.allow32Bit = true;
allocData.flags.allocateMemory = true;
auto allocation = memoryManager->allocateGraphicsMemoryInDevicePool(allocData, status);
EXPECT_EQ(nullptr, allocation);
EXPECT_EQ(MemoryManager::AllocationStatus::RetryInNonDevicePool, status);
}
TEST_F(WddmMemoryManagerSimpleTest, givenEnabledLocalMemoryAndAllowed32BitWhen32BitIsNotForcedThenGraphicsAllocationInDevicePoolReturnsLocalMemoryAllocation) {
const bool localMemoryEnabled = true;
memoryManager = std::make_unique<MockWddmMemoryManager>(false, localMemoryEnabled, executionEnvironment);
memoryManager->setForce32BitAllocations(false);
MemoryManager::AllocationStatus status = MemoryManager::AllocationStatus::Success;
AllocationData allocData;
@@ -3133,59 +3116,6 @@ TEST_F(WddmMemoryManagerTest, givenWddmMemoryManagerWhenLockUnlockIsCalledThenRe
memoryManager->freeGraphicsMemory(alloc);
}
TEST_F(WddmMemoryManagerTest, GivenForce32bitAddressingAndRequireSpecificBitnessWhenCreatingAllocationFromSharedHandleThen32BitAllocationIsReturned) {
MockWddmMemoryManager::OsHandleData osHandleData{1u};
void *pSysMem = reinterpret_cast<void *>(0x1000);
GmmRequirements gmmRequirements{};
gmmRequirements.allowLargePages = true;
gmmRequirements.preferCompressed = false;
std::unique_ptr<Gmm> gmm(new Gmm(rootDeviceEnvironment->getGmmHelper(), pSysMem, 4096u, 0, GMM_RESOURCE_USAGE_OCL_BUFFER, {}, gmmRequirements));
void *gmmPtrArray[]{gmm->gmmResourceInfo.get()};
setSizesFcn(gmmPtrArray, 1u, 1024u, 1u);
memoryManager->setForce32BitAllocations(true);
AllocationProperties properties(0, false, 4096u, AllocationType::sharedBuffer, false, false, 0);
auto *gpuAllocation = memoryManager->createGraphicsAllocationFromSharedHandle(osHandleData, properties, true, false, true, nullptr);
ASSERT_NE(nullptr, gpuAllocation);
if constexpr (is64bit) {
EXPECT_TRUE(gpuAllocation->is32BitAllocation());
uint64_t base = memoryManager->getExternalHeapBaseAddress(gpuAllocation->getRootDeviceIndex(), gpuAllocation->isAllocatedInLocalMemoryPool());
auto gmmHelper = memoryManager->getGmmHelper(gpuAllocation->getRootDeviceIndex());
EXPECT_EQ(gmmHelper->canonize(base), gpuAllocation->getGpuBaseAddress());
}
memoryManager->freeGraphicsMemory(gpuAllocation);
}
TEST_F(WddmMemoryManagerTest, GivenForce32bitAddressingAndNotRequiredSpecificBitnessWhenCreatingAllocationFromSharedHandleThenNon32BitAllocationIsReturned) {
MockWddmMemoryManager::OsHandleData osHandleData{1u};
void *pSysMem = reinterpret_cast<void *>(0x1000);
GmmRequirements gmmRequirements{};
gmmRequirements.allowLargePages = true;
gmmRequirements.preferCompressed = false;
std::unique_ptr<Gmm> gmm(new Gmm(rootDeviceEnvironment->getGmmHelper(), pSysMem, 4096u, 0, GMM_RESOURCE_USAGE_OCL_BUFFER, {}, gmmRequirements));
void *gmmPtrArray[]{gmm->gmmResourceInfo.get()};
setSizesFcn(gmmPtrArray, 1u, 1024u, 1u);
memoryManager->setForce32BitAllocations(true);
AllocationProperties properties(0, false, 4096u, AllocationType::sharedBuffer, false, false, 0);
auto *gpuAllocation = memoryManager->createGraphicsAllocationFromSharedHandle(osHandleData, properties, false, false, true, nullptr);
ASSERT_NE(nullptr, gpuAllocation);
EXPECT_FALSE(gpuAllocation->is32BitAllocation());
if constexpr (is64bit) {
uint64_t base = 0;
EXPECT_EQ(base, gpuAllocation->getGpuBaseAddress());
}
memoryManager->freeGraphicsMemory(gpuAllocation);
}
TEST_F(WddmMemoryManagerTest, givenWddmMemoryManagerWhenFreeAllocFromSharedHandleIsCalledThenDestroyResourceHandle) {
MockWddmMemoryManager::OsHandleData osHandleData{1u};
void *pSysMem = reinterpret_cast<void *>(0x1000);