diff --git a/opencl/test/unit_test/memory_manager/unified_memory_manager_tests.cpp b/opencl/test/unit_test/memory_manager/unified_memory_manager_tests.cpp index 03fe7e3873..24b8ec0761 100644 --- a/opencl/test/unit_test/memory_manager/unified_memory_manager_tests.cpp +++ b/opencl/test/unit_test/memory_manager/unified_memory_manager_tests.cpp @@ -855,6 +855,26 @@ TEST_F(UnifiedMemoryManagerPropertiesTest, svmManager->freeSVMAlloc(ptr); } +TEST_F(UnifiedMemoryManagerPropertiesTest, + givenCALAndSizeGreaterThan2mbWhenDiscretGpuAndCreateHostUSMThenDoNotAlignSizeAndVATo2mb) { + DebugManagerStateRestore restorer; + debugManager.flags.NEO_CAL_ENABLED.set(1); + + RootDeviceIndicesContainer rootDeviceIndices = {mockRootDeviceIndex}; + std::map deviceBitfields{{mockRootDeviceIndex, DeviceBitfield(0x1)}}; + SVMAllocsManager::UnifiedMemoryProperties unifiedMemoryProperties(InternalMemoryType::hostUnifiedMemory, 1, rootDeviceIndices, deviceBitfields); + + svmManager->multiOsContextSupport = true; + auto ptr = svmManager->createHostUnifiedMemoryAllocation(4 * MemoryConstants::pageSize2M + MemoryConstants::pageSize64k, unifiedMemoryProperties); + + auto allocation = svmManager->getSVMAlloc(ptr); + + EXPECT_EQ(4 * MemoryConstants::pageSize2M + MemoryConstants::pageSize64k, allocation->gpuAllocations.getDefaultGraphicsAllocation()->getUnderlyingBufferSize()); + EXPECT_TRUE(isAligned(allocation->gpuAllocations.getDefaultGraphicsAllocation()->getGpuAddress(), MemoryConstants::pageSize)); + + svmManager->freeSVMAlloc(ptr); +} + TEST_F(UnifiedMemoryManagerPropertiesTest, given1ByteAsAllocationSizeWhenHostMemAllocIsCreatedItIsAlignedTo4k) { RootDeviceIndicesContainer rootDeviceIndices = {mockRootDeviceIndex}; diff --git a/shared/source/memory_manager/unified_memory_manager.cpp b/shared/source/memory_manager/unified_memory_manager.cpp index a3a0d6ea16..84e44d1859 100644 --- a/shared/source/memory_manager/unified_memory_manager.cpp +++ b/shared/source/memory_manager/unified_memory_manager.cpp @@ -296,7 +296,7 @@ void *SVMAllocsManager::createSVMAlloc(size_t size, const SvmAllocationPropertie void *SVMAllocsManager::createHostUnifiedMemoryAllocation(size_t size, const UnifiedMemoryProperties &memoryProperties) { bool isDiscrete = false; - if (size >= MemoryConstants::pageSize2M) { + if (size >= MemoryConstants::pageSize2M && !debugManager.flags.NEO_CAL_ENABLED.get()) { for (const auto rootDeviceIndex : memoryProperties.rootDeviceIndices) { isDiscrete |= !this->memoryManager->peekExecutionEnvironment().rootDeviceEnvironments[rootDeviceIndex]->getHardwareInfo()->capabilityTable.isIntegratedDevice; if (isDiscrete) {