mirror of
https://github.com/intel/compute-runtime.git
synced 2025-09-15 13:01:45 +08:00
Refactor a createUnifiedMemoryAllocation method
Related-To: NEO-3330 Change-Id: I3703d2474b7b3c91d584c165952d2762c7423bab Signed-off-by: Jobczyk, Lukasz <lukasz.jobczyk@intel.com>
This commit is contained in:

committed by
sys_ocldev

parent
f4008336f8
commit
b25422deb1
@ -3407,7 +3407,7 @@ void *clHostMemAllocINTEL(
|
|||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
return neoContext->getSVMAllocsManager()->createUnifiedMemoryAllocation(size, SVMAllocsManager::UnifiedMemoryProperties(InternalMemoryType::HOST_UNIFIED_MEMORY), neoContext->getSpecialQueue());
|
return neoContext->getSVMAllocsManager()->createUnifiedMemoryAllocation(size, SVMAllocsManager::UnifiedMemoryProperties(InternalMemoryType::HOST_UNIFIED_MEMORY));
|
||||||
}
|
}
|
||||||
|
|
||||||
void *clDeviceMemAllocINTEL(
|
void *clDeviceMemAllocINTEL(
|
||||||
@ -3428,7 +3428,7 @@ void *clDeviceMemAllocINTEL(
|
|||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
return neoContext->getSVMAllocsManager()->createUnifiedMemoryAllocation(size, SVMAllocsManager::UnifiedMemoryProperties(InternalMemoryType::DEVICE_UNIFIED_MEMORY), neoContext->getSpecialQueue());
|
return neoContext->getSVMAllocsManager()->createUnifiedMemoryAllocation(size, SVMAllocsManager::UnifiedMemoryProperties(InternalMemoryType::DEVICE_UNIFIED_MEMORY));
|
||||||
}
|
}
|
||||||
|
|
||||||
void *clSharedMemAllocINTEL(
|
void *clSharedMemAllocINTEL(
|
||||||
@ -3449,7 +3449,7 @@ void *clSharedMemAllocINTEL(
|
|||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
return neoContext->getSVMAllocsManager()->createUnifiedMemoryAllocation(size, SVMAllocsManager::UnifiedMemoryProperties(InternalMemoryType::SHARED_UNIFIED_MEMORY), neoContext->getSpecialQueue());
|
return neoContext->getSVMAllocsManager()->createSharedUnifiedMemoryAllocation(size, SVMAllocsManager::UnifiedMemoryProperties(InternalMemoryType::SHARED_UNIFIED_MEMORY), neoContext->getSpecialQueue());
|
||||||
}
|
}
|
||||||
|
|
||||||
cl_int clMemFreeINTEL(
|
cl_int clMemFreeINTEL(
|
||||||
|
@ -92,26 +92,7 @@ void *SVMAllocsManager::createSVMAlloc(size_t size, const SvmAllocationPropertie
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void *SVMAllocsManager::createUnifiedMemoryAllocation(size_t size, const UnifiedMemoryProperties memoryProperties, void *cmdQ) {
|
void *SVMAllocsManager::createUnifiedMemoryAllocation(size_t size, const UnifiedMemoryProperties memoryProperties) {
|
||||||
auto supportDualStorageSharedMemory = memoryManager->isLocalMemorySupported();
|
|
||||||
|
|
||||||
if (DebugManager.flags.AllocateSharedAllocationsWithCpuAndGpuStorage.get() != -1) {
|
|
||||||
supportDualStorageSharedMemory = !!DebugManager.flags.AllocateSharedAllocationsWithCpuAndGpuStorage.get();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (memoryProperties.memoryType == InternalMemoryType::SHARED_UNIFIED_MEMORY && supportDualStorageSharedMemory) {
|
|
||||||
auto unifiedMemoryPointer = createUnifiedAllocationWithDeviceStorage(size, {});
|
|
||||||
UNRECOVERABLE_IF(unifiedMemoryPointer == nullptr);
|
|
||||||
auto unifiedMemoryAllocation = this->getSVMAlloc(unifiedMemoryPointer);
|
|
||||||
unifiedMemoryAllocation->memoryType = memoryProperties.memoryType;
|
|
||||||
|
|
||||||
UNRECOVERABLE_IF(cmdQ == nullptr);
|
|
||||||
auto pageFaultManager = this->memoryManager->getPageFaultManager();
|
|
||||||
pageFaultManager->insertAllocation(unifiedMemoryPointer, size, this, cmdQ);
|
|
||||||
|
|
||||||
return unifiedMemoryPointer;
|
|
||||||
}
|
|
||||||
|
|
||||||
size_t alignedSize = alignUp<size_t>(size, MemoryConstants::pageSize64k);
|
size_t alignedSize = alignUp<size_t>(size, MemoryConstants::pageSize64k);
|
||||||
|
|
||||||
AllocationProperties unifiedMemoryProperties{true,
|
AllocationProperties unifiedMemoryProperties{true,
|
||||||
@ -132,6 +113,28 @@ void *SVMAllocsManager::createUnifiedMemoryAllocation(size_t size, const Unified
|
|||||||
return reinterpret_cast<void *>(unifiedMemoryAllocation->getGpuAddress());
|
return reinterpret_cast<void *>(unifiedMemoryAllocation->getGpuAddress());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void *SVMAllocsManager::createSharedUnifiedMemoryAllocation(size_t size, const UnifiedMemoryProperties memoryProperties, void *cmdQ) {
|
||||||
|
auto supportDualStorageSharedMemory = memoryManager->isLocalMemorySupported();
|
||||||
|
|
||||||
|
if (DebugManager.flags.AllocateSharedAllocationsWithCpuAndGpuStorage.get() != -1) {
|
||||||
|
supportDualStorageSharedMemory = !!DebugManager.flags.AllocateSharedAllocationsWithCpuAndGpuStorage.get();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (supportDualStorageSharedMemory) {
|
||||||
|
auto unifiedMemoryPointer = createUnifiedAllocationWithDeviceStorage(size, {});
|
||||||
|
UNRECOVERABLE_IF(unifiedMemoryPointer == nullptr);
|
||||||
|
auto unifiedMemoryAllocation = this->getSVMAlloc(unifiedMemoryPointer);
|
||||||
|
unifiedMemoryAllocation->memoryType = memoryProperties.memoryType;
|
||||||
|
|
||||||
|
UNRECOVERABLE_IF(cmdQ == nullptr);
|
||||||
|
auto pageFaultManager = this->memoryManager->getPageFaultManager();
|
||||||
|
pageFaultManager->insertAllocation(unifiedMemoryPointer, size, this, cmdQ);
|
||||||
|
|
||||||
|
return unifiedMemoryPointer;
|
||||||
|
}
|
||||||
|
return createUnifiedMemoryAllocation(size, memoryProperties);
|
||||||
|
}
|
||||||
|
|
||||||
SvmAllocationData *SVMAllocsManager::getSVMAlloc(const void *ptr) {
|
SvmAllocationData *SVMAllocsManager::getSVMAlloc(const void *ptr) {
|
||||||
std::unique_lock<SpinLock> lock(mtx);
|
std::unique_lock<SpinLock> lock(mtx);
|
||||||
return SVMAllocs.get(ptr);
|
return SVMAllocs.get(ptr);
|
||||||
|
@ -75,7 +75,8 @@ class SVMAllocsManager {
|
|||||||
|
|
||||||
SVMAllocsManager(MemoryManager *memoryManager);
|
SVMAllocsManager(MemoryManager *memoryManager);
|
||||||
void *createSVMAlloc(size_t size, const SvmAllocationProperties svmProperties);
|
void *createSVMAlloc(size_t size, const SvmAllocationProperties svmProperties);
|
||||||
void *createUnifiedMemoryAllocation(size_t size, const UnifiedMemoryProperties svmProperties, void *cmdQ);
|
void *createUnifiedMemoryAllocation(size_t size, const UnifiedMemoryProperties svmProperties);
|
||||||
|
void *createSharedUnifiedMemoryAllocation(size_t size, const UnifiedMemoryProperties svmProperties, void *cmdQ);
|
||||||
SvmAllocationData *getSVMAlloc(const void *ptr);
|
SvmAllocationData *getSVMAlloc(const void *ptr);
|
||||||
bool freeSVMAlloc(void *ptr);
|
bool freeSVMAlloc(void *ptr);
|
||||||
size_t getNumAllocs() const { return SVMAllocs.getNumAllocs(); }
|
size_t getNumAllocs() const { return SVMAllocs.getNumAllocs(); }
|
||||||
|
@ -1263,7 +1263,7 @@ HWTEST_F(EnqueueSvmTest, whenInternalAllocationsAreMadeResidentThenOnlyNonSvmAll
|
|||||||
auto allocationSize = 4096u;
|
auto allocationSize = 4096u;
|
||||||
auto svmManager = this->context->getSVMAllocsManager();
|
auto svmManager = this->context->getSVMAllocsManager();
|
||||||
EXPECT_NE(0u, svmManager->getNumAllocs());
|
EXPECT_NE(0u, svmManager->getNumAllocs());
|
||||||
auto unifiedMemoryPtr = svmManager->createUnifiedMemoryAllocation(allocationSize, unifiedMemoryProperties, this->context->getSpecialQueue());
|
auto unifiedMemoryPtr = svmManager->createUnifiedMemoryAllocation(allocationSize, unifiedMemoryProperties);
|
||||||
EXPECT_NE(nullptr, unifiedMemoryPtr);
|
EXPECT_NE(nullptr, unifiedMemoryPtr);
|
||||||
EXPECT_EQ(2u, svmManager->getNumAllocs());
|
EXPECT_EQ(2u, svmManager->getNumAllocs());
|
||||||
|
|
||||||
|
@ -1724,7 +1724,7 @@ HWTEST_F(KernelResidencyTest, givenKernelWhenItUsesIndirectUnifiedMemoryDeviceAl
|
|||||||
auto &commandStreamReceiver = this->pDevice->getUltCommandStreamReceiver<FamilyType>();
|
auto &commandStreamReceiver = this->pDevice->getUltCommandStreamReceiver<FamilyType>();
|
||||||
|
|
||||||
auto svmAllocationsManager = mockKernel.mockContext->getSVMAllocsManager();
|
auto svmAllocationsManager = mockKernel.mockContext->getSVMAllocsManager();
|
||||||
auto unifiedMemoryAllocation = svmAllocationsManager->createUnifiedMemoryAllocation(4096u, SVMAllocsManager::UnifiedMemoryProperties(InternalMemoryType::DEVICE_UNIFIED_MEMORY), nullptr);
|
auto unifiedMemoryAllocation = svmAllocationsManager->createUnifiedMemoryAllocation(4096u, SVMAllocsManager::UnifiedMemoryProperties(InternalMemoryType::DEVICE_UNIFIED_MEMORY));
|
||||||
|
|
||||||
mockKernel.mockKernel->makeResident(this->pDevice->getGpgpuCommandStreamReceiver());
|
mockKernel.mockKernel->makeResident(this->pDevice->getGpgpuCommandStreamReceiver());
|
||||||
|
|
||||||
@ -1748,8 +1748,8 @@ HWTEST_F(KernelResidencyTest, givenKernelUsingIndirectHostMemoryWhenMakeResident
|
|||||||
auto &commandStreamReceiver = this->pDevice->getUltCommandStreamReceiver<FamilyType>();
|
auto &commandStreamReceiver = this->pDevice->getUltCommandStreamReceiver<FamilyType>();
|
||||||
|
|
||||||
auto svmAllocationsManager = mockKernel.mockContext->getSVMAllocsManager();
|
auto svmAllocationsManager = mockKernel.mockContext->getSVMAllocsManager();
|
||||||
auto unifiedDeviceMemoryAllocation = svmAllocationsManager->createUnifiedMemoryAllocation(4096u, SVMAllocsManager::UnifiedMemoryProperties(InternalMemoryType::DEVICE_UNIFIED_MEMORY), nullptr);
|
auto unifiedDeviceMemoryAllocation = svmAllocationsManager->createUnifiedMemoryAllocation(4096u, SVMAllocsManager::UnifiedMemoryProperties(InternalMemoryType::DEVICE_UNIFIED_MEMORY));
|
||||||
auto unifiedHostMemoryAllocation = svmAllocationsManager->createUnifiedMemoryAllocation(4096u, SVMAllocsManager::UnifiedMemoryProperties(InternalMemoryType::HOST_UNIFIED_MEMORY), nullptr);
|
auto unifiedHostMemoryAllocation = svmAllocationsManager->createUnifiedMemoryAllocation(4096u, SVMAllocsManager::UnifiedMemoryProperties(InternalMemoryType::HOST_UNIFIED_MEMORY));
|
||||||
|
|
||||||
mockKernel.mockKernel->makeResident(this->pDevice->getGpgpuCommandStreamReceiver());
|
mockKernel.mockKernel->makeResident(this->pDevice->getGpgpuCommandStreamReceiver());
|
||||||
EXPECT_EQ(0u, commandStreamReceiver.getResidencyAllocations().size());
|
EXPECT_EQ(0u, commandStreamReceiver.getResidencyAllocations().size());
|
||||||
@ -1768,8 +1768,8 @@ HWTEST_F(KernelResidencyTest, givenKernelUsingIndirectSharedMemoryWhenMakeReside
|
|||||||
auto &commandStreamReceiver = this->pDevice->getUltCommandStreamReceiver<FamilyType>();
|
auto &commandStreamReceiver = this->pDevice->getUltCommandStreamReceiver<FamilyType>();
|
||||||
|
|
||||||
auto svmAllocationsManager = mockKernel.mockContext->getSVMAllocsManager();
|
auto svmAllocationsManager = mockKernel.mockContext->getSVMAllocsManager();
|
||||||
auto unifiedSharedMemoryAllocation = svmAllocationsManager->createUnifiedMemoryAllocation(4096u, SVMAllocsManager::UnifiedMemoryProperties(InternalMemoryType::SHARED_UNIFIED_MEMORY), mockKernel.mockContext->getSpecialQueue());
|
auto unifiedSharedMemoryAllocation = svmAllocationsManager->createSharedUnifiedMemoryAllocation(4096u, SVMAllocsManager::UnifiedMemoryProperties(InternalMemoryType::SHARED_UNIFIED_MEMORY), mockKernel.mockContext->getSpecialQueue());
|
||||||
auto unifiedHostMemoryAllocation = svmAllocationsManager->createUnifiedMemoryAllocation(4096u, SVMAllocsManager::UnifiedMemoryProperties(InternalMemoryType::HOST_UNIFIED_MEMORY), nullptr);
|
auto unifiedHostMemoryAllocation = svmAllocationsManager->createUnifiedMemoryAllocation(4096u, SVMAllocsManager::UnifiedMemoryProperties(InternalMemoryType::HOST_UNIFIED_MEMORY));
|
||||||
|
|
||||||
mockKernel.mockKernel->makeResident(this->pDevice->getGpgpuCommandStreamReceiver());
|
mockKernel.mockKernel->makeResident(this->pDevice->getGpgpuCommandStreamReceiver());
|
||||||
EXPECT_EQ(0u, commandStreamReceiver.getResidencyAllocations().size());
|
EXPECT_EQ(0u, commandStreamReceiver.getResidencyAllocations().size());
|
||||||
@ -1792,7 +1792,7 @@ HWTEST_F(KernelResidencyTest, givenDeviceUnifiedMemoryAndPageFaultManagerWhenMak
|
|||||||
auto &commandStreamReceiver = this->pDevice->getUltCommandStreamReceiver<FamilyType>();
|
auto &commandStreamReceiver = this->pDevice->getUltCommandStreamReceiver<FamilyType>();
|
||||||
|
|
||||||
auto svmAllocationsManager = mockKernel.mockContext->getSVMAllocsManager();
|
auto svmAllocationsManager = mockKernel.mockContext->getSVMAllocsManager();
|
||||||
auto unifiedMemoryAllocation = svmAllocationsManager->createUnifiedMemoryAllocation(4096u, SVMAllocsManager::UnifiedMemoryProperties(InternalMemoryType::DEVICE_UNIFIED_MEMORY), nullptr);
|
auto unifiedMemoryAllocation = svmAllocationsManager->createUnifiedMemoryAllocation(4096u, SVMAllocsManager::UnifiedMemoryProperties(InternalMemoryType::DEVICE_UNIFIED_MEMORY));
|
||||||
auto unifiedMemoryGraphicsAllocation = svmAllocationsManager->getSVMAlloc(unifiedMemoryAllocation);
|
auto unifiedMemoryGraphicsAllocation = svmAllocationsManager->getSVMAlloc(unifiedMemoryAllocation);
|
||||||
|
|
||||||
EXPECT_EQ(0u, mockKernel.mockKernel->kernelUnifiedMemoryGfxAllocations.size());
|
EXPECT_EQ(0u, mockKernel.mockKernel->kernelUnifiedMemoryGfxAllocations.size());
|
||||||
@ -1822,7 +1822,7 @@ HWTEST_F(KernelResidencyTest, givenSharedUnifiedMemoryAndPageFaultManagerWhenMak
|
|||||||
auto &commandStreamReceiver = this->pDevice->getUltCommandStreamReceiver<FamilyType>();
|
auto &commandStreamReceiver = this->pDevice->getUltCommandStreamReceiver<FamilyType>();
|
||||||
|
|
||||||
auto svmAllocationsManager = mockKernel.mockContext->getSVMAllocsManager();
|
auto svmAllocationsManager = mockKernel.mockContext->getSVMAllocsManager();
|
||||||
auto unifiedMemoryAllocation = svmAllocationsManager->createUnifiedMemoryAllocation(4096u, SVMAllocsManager::UnifiedMemoryProperties(InternalMemoryType::SHARED_UNIFIED_MEMORY), mockKernel.mockContext->getSpecialQueue());
|
auto unifiedMemoryAllocation = svmAllocationsManager->createSharedUnifiedMemoryAllocation(4096u, SVMAllocsManager::UnifiedMemoryProperties(InternalMemoryType::SHARED_UNIFIED_MEMORY), mockKernel.mockContext->getSpecialQueue());
|
||||||
auto unifiedMemoryGraphicsAllocation = svmAllocationsManager->getSVMAlloc(unifiedMemoryAllocation);
|
auto unifiedMemoryGraphicsAllocation = svmAllocationsManager->getSVMAlloc(unifiedMemoryAllocation);
|
||||||
mockMemoryManager->pageFaultManager->insertAllocation(unifiedMemoryAllocation, 4096u, svmAllocationsManager, mockKernel.mockContext->getSpecialQueue());
|
mockMemoryManager->pageFaultManager->insertAllocation(unifiedMemoryAllocation, 4096u, svmAllocationsManager, mockKernel.mockContext->getSpecialQueue());
|
||||||
|
|
||||||
@ -1859,7 +1859,7 @@ HWTEST_F(KernelResidencyTest, givenSharedUnifiedMemoryAndNotRequiredMemSyncWhenM
|
|||||||
auto &commandStreamReceiver = this->pDevice->getUltCommandStreamReceiver<FamilyType>();
|
auto &commandStreamReceiver = this->pDevice->getUltCommandStreamReceiver<FamilyType>();
|
||||||
|
|
||||||
auto svmAllocationsManager = mockKernel.mockContext->getSVMAllocsManager();
|
auto svmAllocationsManager = mockKernel.mockContext->getSVMAllocsManager();
|
||||||
auto unifiedMemoryAllocation = svmAllocationsManager->createUnifiedMemoryAllocation(4096u, SVMAllocsManager::UnifiedMemoryProperties(InternalMemoryType::SHARED_UNIFIED_MEMORY), mockKernel.mockContext->getSpecialQueue());
|
auto unifiedMemoryAllocation = svmAllocationsManager->createSharedUnifiedMemoryAllocation(4096u, SVMAllocsManager::UnifiedMemoryProperties(InternalMemoryType::SHARED_UNIFIED_MEMORY), mockKernel.mockContext->getSpecialQueue());
|
||||||
auto unifiedMemoryGraphicsAllocation = svmAllocationsManager->getSVMAlloc(unifiedMemoryAllocation);
|
auto unifiedMemoryGraphicsAllocation = svmAllocationsManager->getSVMAlloc(unifiedMemoryAllocation);
|
||||||
mockMemoryManager->pageFaultManager->insertAllocation(unifiedMemoryAllocation, 4096u, svmAllocationsManager, mockKernel.mockContext->getSpecialQueue());
|
mockMemoryManager->pageFaultManager->insertAllocation(unifiedMemoryAllocation, 4096u, svmAllocationsManager, mockKernel.mockContext->getSpecialQueue());
|
||||||
|
|
||||||
@ -1889,7 +1889,7 @@ HWTEST_F(KernelResidencyTest, givenSharedUnifiedMemoryAllocPageFaultManagerAndIn
|
|||||||
auto &commandStreamReceiver = this->pDevice->getUltCommandStreamReceiver<FamilyType>();
|
auto &commandStreamReceiver = this->pDevice->getUltCommandStreamReceiver<FamilyType>();
|
||||||
|
|
||||||
auto svmAllocationsManager = mockKernel.mockContext->getSVMAllocsManager();
|
auto svmAllocationsManager = mockKernel.mockContext->getSVMAllocsManager();
|
||||||
auto unifiedMemoryAllocation = svmAllocationsManager->createUnifiedMemoryAllocation(4096u, SVMAllocsManager::UnifiedMemoryProperties(InternalMemoryType::SHARED_UNIFIED_MEMORY), mockKernel.mockContext->getSpecialQueue());
|
auto unifiedMemoryAllocation = svmAllocationsManager->createSharedUnifiedMemoryAllocation(4096u, SVMAllocsManager::UnifiedMemoryProperties(InternalMemoryType::SHARED_UNIFIED_MEMORY), mockKernel.mockContext->getSpecialQueue());
|
||||||
mockMemoryManager->pageFaultManager->insertAllocation(unifiedMemoryAllocation, 4096u, svmAllocationsManager, mockKernel.mockContext->getSpecialQueue());
|
mockMemoryManager->pageFaultManager->insertAllocation(unifiedMemoryAllocation, 4096u, svmAllocationsManager, mockKernel.mockContext->getSpecialQueue());
|
||||||
|
|
||||||
auto mockPageFaultManager = static_cast<MockPageFaultManager *>(mockMemoryManager->pageFaultManager.get());
|
auto mockPageFaultManager = static_cast<MockPageFaultManager *>(mockMemoryManager->pageFaultManager.get());
|
||||||
@ -1918,7 +1918,7 @@ HWTEST_F(KernelResidencyTest, givenKernelWhenSetKernelExecInfoWithUnifiedMemoryI
|
|||||||
auto &commandStreamReceiver = this->pDevice->getUltCommandStreamReceiver<FamilyType>();
|
auto &commandStreamReceiver = this->pDevice->getUltCommandStreamReceiver<FamilyType>();
|
||||||
|
|
||||||
auto svmAllocationsManager = mockKernel.mockContext->getSVMAllocsManager();
|
auto svmAllocationsManager = mockKernel.mockContext->getSVMAllocsManager();
|
||||||
auto unifiedMemoryAllocation = svmAllocationsManager->createUnifiedMemoryAllocation(4096u, SVMAllocsManager::UnifiedMemoryProperties(InternalMemoryType::DEVICE_UNIFIED_MEMORY), nullptr);
|
auto unifiedMemoryAllocation = svmAllocationsManager->createUnifiedMemoryAllocation(4096u, SVMAllocsManager::UnifiedMemoryProperties(InternalMemoryType::DEVICE_UNIFIED_MEMORY));
|
||||||
auto unifiedMemoryGraphicsAllocation = svmAllocationsManager->getSVMAlloc(unifiedMemoryAllocation);
|
auto unifiedMemoryGraphicsAllocation = svmAllocationsManager->getSVMAlloc(unifiedMemoryAllocation);
|
||||||
|
|
||||||
EXPECT_EQ(0u, mockKernel.mockKernel->kernelUnifiedMemoryGfxAllocations.size());
|
EXPECT_EQ(0u, mockKernel.mockKernel->kernelUnifiedMemoryGfxAllocations.size());
|
||||||
@ -1941,9 +1941,9 @@ HWTEST_F(KernelResidencyTest, givenKernelWhenclSetKernelExecInfoWithUnifiedMemor
|
|||||||
MockKernelWithInternals mockKernel(*this->pDevice);
|
MockKernelWithInternals mockKernel(*this->pDevice);
|
||||||
|
|
||||||
auto svmAllocationsManager = mockKernel.mockContext->getSVMAllocsManager();
|
auto svmAllocationsManager = mockKernel.mockContext->getSVMAllocsManager();
|
||||||
auto unifiedMemoryAllocation = svmAllocationsManager->createUnifiedMemoryAllocation(4096u, SVMAllocsManager::UnifiedMemoryProperties(InternalMemoryType::DEVICE_UNIFIED_MEMORY), nullptr);
|
auto unifiedMemoryAllocation = svmAllocationsManager->createUnifiedMemoryAllocation(4096u, SVMAllocsManager::UnifiedMemoryProperties(InternalMemoryType::DEVICE_UNIFIED_MEMORY));
|
||||||
|
|
||||||
auto unifiedMemoryAllocation2 = svmAllocationsManager->createUnifiedMemoryAllocation(4096u, SVMAllocsManager::UnifiedMemoryProperties(InternalMemoryType::DEVICE_UNIFIED_MEMORY), nullptr);
|
auto unifiedMemoryAllocation2 = svmAllocationsManager->createUnifiedMemoryAllocation(4096u, SVMAllocsManager::UnifiedMemoryProperties(InternalMemoryType::DEVICE_UNIFIED_MEMORY));
|
||||||
|
|
||||||
auto status = clSetKernelExecInfo(mockKernel.mockKernel, CL_KERNEL_EXEC_INFO_USM_PTRS_INTEL, sizeof(unifiedMemoryAllocation), &unifiedMemoryAllocation);
|
auto status = clSetKernelExecInfo(mockKernel.mockKernel, CL_KERNEL_EXEC_INFO_USM_PTRS_INTEL, sizeof(unifiedMemoryAllocation), &unifiedMemoryAllocation);
|
||||||
EXPECT_EQ(CL_SUCCESS, status);
|
EXPECT_EQ(CL_SUCCESS, status);
|
||||||
|
@ -157,7 +157,7 @@ TEST_F(SVMLocalMemoryAllocatorTest, whenDeviceAllocationIsCreatedThenItIsStoredW
|
|||||||
SVMAllocsManager::UnifiedMemoryProperties unifiedMemoryProperties;
|
SVMAllocsManager::UnifiedMemoryProperties unifiedMemoryProperties;
|
||||||
unifiedMemoryProperties.memoryType = InternalMemoryType::DEVICE_UNIFIED_MEMORY;
|
unifiedMemoryProperties.memoryType = InternalMemoryType::DEVICE_UNIFIED_MEMORY;
|
||||||
auto allocationSize = 4096u;
|
auto allocationSize = 4096u;
|
||||||
auto ptr = svmManager->createUnifiedMemoryAllocation(4096u, unifiedMemoryProperties, nullptr);
|
auto ptr = svmManager->createUnifiedMemoryAllocation(4096u, unifiedMemoryProperties);
|
||||||
EXPECT_NE(nullptr, ptr);
|
EXPECT_NE(nullptr, ptr);
|
||||||
auto allocation = svmManager->getSVMAlloc(ptr);
|
auto allocation = svmManager->getSVMAlloc(ptr);
|
||||||
EXPECT_EQ(nullptr, allocation->cpuAllocation);
|
EXPECT_EQ(nullptr, allocation->cpuAllocation);
|
||||||
@ -176,7 +176,7 @@ TEST_F(SVMMemoryAllocatorTest, whenHostAllocationIsCreatedThenItIsStoredWithProp
|
|||||||
SVMAllocsManager::UnifiedMemoryProperties unifiedMemoryProperties;
|
SVMAllocsManager::UnifiedMemoryProperties unifiedMemoryProperties;
|
||||||
unifiedMemoryProperties.memoryType = InternalMemoryType::HOST_UNIFIED_MEMORY;
|
unifiedMemoryProperties.memoryType = InternalMemoryType::HOST_UNIFIED_MEMORY;
|
||||||
auto allocationSize = 4096u;
|
auto allocationSize = 4096u;
|
||||||
auto ptr = svmManager->createUnifiedMemoryAllocation(4096u, unifiedMemoryProperties, nullptr);
|
auto ptr = svmManager->createUnifiedMemoryAllocation(4096u, unifiedMemoryProperties);
|
||||||
EXPECT_NE(nullptr, ptr);
|
EXPECT_NE(nullptr, ptr);
|
||||||
auto allocation = svmManager->getSVMAlloc(ptr);
|
auto allocation = svmManager->getSVMAlloc(ptr);
|
||||||
EXPECT_EQ(nullptr, allocation->cpuAllocation);
|
EXPECT_EQ(nullptr, allocation->cpuAllocation);
|
||||||
@ -196,7 +196,7 @@ TEST_F(SVMMemoryAllocatorTest, whenSharedAllocationIsCreatedThenItIsStoredWithPr
|
|||||||
SVMAllocsManager::UnifiedMemoryProperties unifiedMemoryProperties;
|
SVMAllocsManager::UnifiedMemoryProperties unifiedMemoryProperties;
|
||||||
unifiedMemoryProperties.memoryType = InternalMemoryType::SHARED_UNIFIED_MEMORY;
|
unifiedMemoryProperties.memoryType = InternalMemoryType::SHARED_UNIFIED_MEMORY;
|
||||||
auto allocationSize = 4096u;
|
auto allocationSize = 4096u;
|
||||||
auto ptr = svmManager->createUnifiedMemoryAllocation(4096u, unifiedMemoryProperties, &cmdQ);
|
auto ptr = svmManager->createSharedUnifiedMemoryAllocation(4096u, unifiedMemoryProperties, &cmdQ);
|
||||||
EXPECT_NE(nullptr, ptr);
|
EXPECT_NE(nullptr, ptr);
|
||||||
auto allocation = svmManager->getSVMAlloc(ptr);
|
auto allocation = svmManager->getSVMAlloc(ptr);
|
||||||
EXPECT_EQ(nullptr, allocation->cpuAllocation);
|
EXPECT_EQ(nullptr, allocation->cpuAllocation);
|
||||||
@ -219,7 +219,7 @@ TEST_F(SVMLocalMemoryAllocatorTest, whenSharedAllocationIsCreatedWithDebugFlagSe
|
|||||||
SVMAllocsManager::UnifiedMemoryProperties unifiedMemoryProperties;
|
SVMAllocsManager::UnifiedMemoryProperties unifiedMemoryProperties;
|
||||||
unifiedMemoryProperties.memoryType = InternalMemoryType::SHARED_UNIFIED_MEMORY;
|
unifiedMemoryProperties.memoryType = InternalMemoryType::SHARED_UNIFIED_MEMORY;
|
||||||
auto allocationSize = 4096u;
|
auto allocationSize = 4096u;
|
||||||
auto ptr = svmManager->createUnifiedMemoryAllocation(4096u, unifiedMemoryProperties, &cmdQ);
|
auto ptr = svmManager->createSharedUnifiedMemoryAllocation(4096u, unifiedMemoryProperties, &cmdQ);
|
||||||
EXPECT_NE(nullptr, ptr);
|
EXPECT_NE(nullptr, ptr);
|
||||||
auto allocation = svmManager->getSVMAlloc(ptr);
|
auto allocation = svmManager->getSVMAlloc(ptr);
|
||||||
EXPECT_NE(nullptr, allocation->cpuAllocation);
|
EXPECT_NE(nullptr, allocation->cpuAllocation);
|
||||||
@ -248,7 +248,7 @@ TEST_F(SVMLocalMemoryAllocatorTest, whenSharedAllocationIsCreatedWithLocalMemory
|
|||||||
SVMAllocsManager::UnifiedMemoryProperties unifiedMemoryProperties;
|
SVMAllocsManager::UnifiedMemoryProperties unifiedMemoryProperties;
|
||||||
unifiedMemoryProperties.memoryType = InternalMemoryType::SHARED_UNIFIED_MEMORY;
|
unifiedMemoryProperties.memoryType = InternalMemoryType::SHARED_UNIFIED_MEMORY;
|
||||||
auto allocationSize = 4096u;
|
auto allocationSize = 4096u;
|
||||||
auto ptr = svmManager->createUnifiedMemoryAllocation(4096u, unifiedMemoryProperties, &cmdQ);
|
auto ptr = svmManager->createSharedUnifiedMemoryAllocation(4096u, unifiedMemoryProperties, &cmdQ);
|
||||||
EXPECT_NE(nullptr, ptr);
|
EXPECT_NE(nullptr, ptr);
|
||||||
auto allocation = svmManager->getSVMAlloc(ptr);
|
auto allocation = svmManager->getSVMAlloc(ptr);
|
||||||
EXPECT_NE(nullptr, allocation->cpuAllocation);
|
EXPECT_NE(nullptr, allocation->cpuAllocation);
|
||||||
@ -276,7 +276,7 @@ TEST_F(SVMMemoryAllocatorTest, givenSharedAllocationsDebugFlagWhenDeviceMemoryIs
|
|||||||
SVMAllocsManager::UnifiedMemoryProperties unifiedMemoryProperties;
|
SVMAllocsManager::UnifiedMemoryProperties unifiedMemoryProperties;
|
||||||
unifiedMemoryProperties.memoryType = InternalMemoryType::DEVICE_UNIFIED_MEMORY;
|
unifiedMemoryProperties.memoryType = InternalMemoryType::DEVICE_UNIFIED_MEMORY;
|
||||||
auto allocationSize = 4096u;
|
auto allocationSize = 4096u;
|
||||||
auto ptr = svmManager->createUnifiedMemoryAllocation(4096u, unifiedMemoryProperties, nullptr);
|
auto ptr = svmManager->createUnifiedMemoryAllocation(4096u, unifiedMemoryProperties);
|
||||||
EXPECT_NE(nullptr, ptr);
|
EXPECT_NE(nullptr, ptr);
|
||||||
auto allocation = svmManager->getSVMAlloc(ptr);
|
auto allocation = svmManager->getSVMAlloc(ptr);
|
||||||
EXPECT_EQ(nullptr, allocation->cpuAllocation);
|
EXPECT_EQ(nullptr, allocation->cpuAllocation);
|
||||||
|
Reference in New Issue
Block a user