mirror of
https://github.com/intel/compute-runtime.git
synced 2026-01-03 14:55:24 +08:00
Create MAP_ALLOCATION as non-svm allocation when host ptr tracking is disabled.
Change-Id: I57c64706e798efa4b23e34b582be5a490d592e87 Signed-off-by: Pawel Wilma <pawel.wilma@intel.com>
This commit is contained in:
@@ -336,8 +336,7 @@ GraphicsAllocation *MemoryManager::allocateGraphicsMemory(const AllocationData &
|
|||||||
if (allocationData.flags.shareable) {
|
if (allocationData.flags.shareable) {
|
||||||
return allocateShareableMemory(allocationData);
|
return allocateShareableMemory(allocationData);
|
||||||
}
|
}
|
||||||
if (allocationData.type == GraphicsAllocation::AllocationType::EXTERNAL_HOST_PTR &&
|
if (useNonSvmHostPtrAlloc(allocationData.type)) {
|
||||||
(!peekExecutionEnvironment().isFullRangeSvm() || !isHostPointerTrackingEnabled())) {
|
|
||||||
auto allocation = allocateGraphicsMemoryForNonSvmHostPtr(allocationData);
|
auto allocation = allocateGraphicsMemoryForNonSvmHostPtr(allocationData);
|
||||||
if (allocation) {
|
if (allocation) {
|
||||||
allocation->setFlushL3Required(allocationData.flags.flushL3);
|
allocation->setFlushL3Required(allocationData.flags.flushL3);
|
||||||
@@ -483,6 +482,7 @@ void *MemoryManager::getReservedMemory(size_t size, size_t alignment) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool MemoryManager::isHostPointerTrackingEnabled() {
|
bool MemoryManager::isHostPointerTrackingEnabled() {
|
||||||
|
|
||||||
if (DebugManager.flags.EnableHostPtrTracking.get() != -1) {
|
if (DebugManager.flags.EnableHostPtrTracking.get() != -1) {
|
||||||
return !!DebugManager.flags.EnableHostPtrTracking.get();
|
return !!DebugManager.flags.EnableHostPtrTracking.get();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -193,6 +193,10 @@ class MemoryManager {
|
|||||||
return allocationType == GraphicsAllocation::AllocationType::KERNEL_ISA ||
|
return allocationType == GraphicsAllocation::AllocationType::KERNEL_ISA ||
|
||||||
allocationType == GraphicsAllocation::AllocationType::INTERNAL_HEAP;
|
allocationType == GraphicsAllocation::AllocationType::INTERNAL_HEAP;
|
||||||
}
|
}
|
||||||
|
bool useNonSvmHostPtrAlloc(GraphicsAllocation::AllocationType allocationType) {
|
||||||
|
return ((allocationType == GraphicsAllocation::AllocationType::EXTERNAL_HOST_PTR || allocationType == GraphicsAllocation::AllocationType::MAP_ALLOCATION) &&
|
||||||
|
(!peekExecutionEnvironment().isFullRangeSvm() || !isHostPointerTrackingEnabled()));
|
||||||
|
}
|
||||||
StorageInfo createStorageInfoFromProperties(const AllocationProperties &properties);
|
StorageInfo createStorageInfoFromProperties(const AllocationProperties &properties);
|
||||||
|
|
||||||
virtual GraphicsAllocation *createGraphicsAllocation(OsHandleStorage &handleStorage, const AllocationData &allocationData) = 0;
|
virtual GraphicsAllocation *createGraphicsAllocation(OsHandleStorage &handleStorage, const AllocationData &allocationData) = 0;
|
||||||
|
|||||||
@@ -1995,3 +1995,25 @@ TEST_F(MemoryManagerMultiRootDeviceTests, globalsSurfaceHasCorrectRootDeviceInde
|
|||||||
context->getSVMAllocsManager()->freeSVMAlloc(allocation->getUnderlyingBuffer());
|
context->getSVMAllocsManager()->freeSVMAlloc(allocation->getUnderlyingBuffer());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
HWTEST_F(MemoryAllocatorTest, givenMemoryManagerWhenHostPtrTrackingDisabledThenNonSvmHostPtrUsageIsSet) {
|
||||||
|
DebugManagerStateRestore dbgRestore;
|
||||||
|
DebugManager.flags.EnableHostPtrTracking.set(0);
|
||||||
|
|
||||||
|
auto result = memoryManager->useNonSvmHostPtrAlloc(GraphicsAllocation::AllocationType::EXTERNAL_HOST_PTR);
|
||||||
|
EXPECT_TRUE(result);
|
||||||
|
|
||||||
|
result = memoryManager->useNonSvmHostPtrAlloc(GraphicsAllocation::AllocationType::MAP_ALLOCATION);
|
||||||
|
EXPECT_TRUE(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
HWTEST_F(MemoryAllocatorTest, givenMemoryManagerWhenHostPtrTrackingEnabledThenNonSvmHostPtrUsageDependsOnFullRangeSvm) {
|
||||||
|
DebugManagerStateRestore dbgRestore;
|
||||||
|
DebugManager.flags.EnableHostPtrTracking.set(1);
|
||||||
|
|
||||||
|
auto result = memoryManager->useNonSvmHostPtrAlloc(GraphicsAllocation::AllocationType::EXTERNAL_HOST_PTR);
|
||||||
|
EXPECT_EQ(!executionEnvironment->isFullRangeSvm(), result);
|
||||||
|
|
||||||
|
result = memoryManager->useNonSvmHostPtrAlloc(GraphicsAllocation::AllocationType::MAP_ALLOCATION);
|
||||||
|
EXPECT_EQ(!executionEnvironment->isFullRangeSvm(), result);
|
||||||
|
}
|
||||||
|
|||||||
@@ -45,6 +45,7 @@ class MockMemoryManager : public MemoryManagerCreate<OsAgnosticMemoryManager> {
|
|||||||
using MemoryManager::registeredEngines;
|
using MemoryManager::registeredEngines;
|
||||||
using MemoryManager::supportsMultiStorageResources;
|
using MemoryManager::supportsMultiStorageResources;
|
||||||
using MemoryManager::useInternal32BitAllocator;
|
using MemoryManager::useInternal32BitAllocator;
|
||||||
|
using MemoryManager::useNonSvmHostPtrAlloc;
|
||||||
using OsAgnosticMemoryManager::allocateGraphicsMemoryForImageFromHostPtr;
|
using OsAgnosticMemoryManager::allocateGraphicsMemoryForImageFromHostPtr;
|
||||||
using MemoryManagerCreate<OsAgnosticMemoryManager>::MemoryManagerCreate;
|
using MemoryManagerCreate<OsAgnosticMemoryManager>::MemoryManagerCreate;
|
||||||
using MemoryManager::reservedMemory;
|
using MemoryManager::reservedMemory;
|
||||||
|
|||||||
Reference in New Issue
Block a user