mirror of
https://github.com/intel/compute-runtime.git
synced 2025-12-20 08:53:55 +08:00
Prevent null allocation in createSharedUnifiedMemoryAllocation
Related-To: NEO-3860 Change-Id: I3954279414b226ea332da4a3fd1580853e59bd54 Signed-off-by: Gibala <krzysztof.gibala@intel.com>
This commit is contained in:
@@ -126,7 +126,9 @@ void *SVMAllocsManager::createSharedUnifiedMemoryAllocation(size_t size, const U
|
||||
|
||||
if (supportDualStorageSharedMemory) {
|
||||
auto unifiedMemoryPointer = createUnifiedAllocationWithDeviceStorage(size, {});
|
||||
UNRECOVERABLE_IF(unifiedMemoryPointer == nullptr);
|
||||
if (!unifiedMemoryPointer) {
|
||||
return nullptr;
|
||||
}
|
||||
auto unifiedMemoryAllocation = this->getSVMAlloc(unifiedMemoryPointer);
|
||||
unifiedMemoryAllocation->memoryType = memoryProperties.memoryType;
|
||||
unifiedMemoryAllocation->allocationFlagsProperty = memoryProperties.allocationFlags;
|
||||
|
||||
@@ -203,6 +203,21 @@ TEST_F(SVMMemoryAllocatorTest, whenHostAllocationIsCreatedThenItIsStoredWithProp
|
||||
svmManager->freeSVMAlloc(ptr);
|
||||
}
|
||||
|
||||
TEST_F(SVMMemoryAllocatorTest, whenCouldNotAllocateInMemoryManagerThenCreateSharedUnifiedMemoryAllocationReturnsNullAndDoesNotChangeAllocsMap) {
|
||||
MockCommandQueue cmdQ;
|
||||
DebugManagerStateRestore restore;
|
||||
DebugManager.flags.AllocateSharedAllocationsWithCpuAndGpuStorage.set(true);
|
||||
FailMemoryManager failMemoryManager(executionEnvironment);
|
||||
svmManager->memoryManager = &failMemoryManager;
|
||||
|
||||
SVMAllocsManager::UnifiedMemoryProperties unifiedMemoryProperties;
|
||||
unifiedMemoryProperties.memoryType = InternalMemoryType::SHARED_UNIFIED_MEMORY;
|
||||
auto ptr = svmManager->createSharedUnifiedMemoryAllocation(4096u, unifiedMemoryProperties, &cmdQ);
|
||||
EXPECT_EQ(nullptr, ptr);
|
||||
EXPECT_EQ(0u, svmManager->SVMAllocs.getNumAllocs());
|
||||
svmManager->freeSVMAlloc(ptr);
|
||||
}
|
||||
|
||||
TEST_F(SVMMemoryAllocatorTest, whenSharedAllocationIsCreatedThenItIsStoredWithProperTypeInAllocationMap) {
|
||||
MockCommandQueue cmdQ;
|
||||
SVMAllocsManager::UnifiedMemoryProperties unifiedMemoryProperties;
|
||||
|
||||
Reference in New Issue
Block a user