diff --git a/opencl/source/helpers/mem_properties_parser_helper.cpp b/opencl/source/helpers/mem_properties_parser_helper.cpp index 8edc38747b..873828ddbd 100644 --- a/opencl/source/helpers/mem_properties_parser_helper.cpp +++ b/opencl/source/helpers/mem_properties_parser_helper.cpp @@ -49,7 +49,7 @@ bool NEO::MemoryPropertiesParser::parseMemoryProperties(const cl_mem_properties_ return true; } -void MemoryPropertiesParser::fillPoliciesInProperties(AllocationProperties &allocationProperties, const MemoryPropertiesFlags &memoryProperties) { +void MemoryPropertiesParser::fillPoliciesInProperties(AllocationProperties &allocationProperties, const MemoryPropertiesFlags &memoryProperties, const HardwareInfo &hwInfo) { fillCachePolicyInProperties(allocationProperties, memoryProperties.flags.locallyUncachedResource, memoryProperties.flags.readOnly, diff --git a/opencl/source/helpers/mem_properties_parser_helper.h b/opencl/source/helpers/mem_properties_parser_helper.h index 02d712a53a..a53ecf08c9 100644 --- a/opencl/source/helpers/mem_properties_parser_helper.h +++ b/opencl/source/helpers/mem_properties_parser_helper.h @@ -27,13 +27,13 @@ class MemoryPropertiesParser { cl_mem_flags &flags, cl_mem_flags_intel &flagsIntel, cl_mem_alloc_flags_intel &allocflags, ObjType objectType); static AllocationProperties getAllocationProperties(uint32_t rootDeviceIndex, MemoryPropertiesFlags memoryProperties, bool allocateMemory, - size_t size, GraphicsAllocation::AllocationType type, bool multiStorageResource) { + size_t size, GraphicsAllocation::AllocationType type, bool multiStorageResource, const HardwareInfo &hwInfo) { AllocationProperties allocationProperties(rootDeviceIndex, allocateMemory, size, type, multiStorageResource); - fillPoliciesInProperties(allocationProperties, memoryProperties); + fillPoliciesInProperties(allocationProperties, memoryProperties, hwInfo); return allocationProperties; } - static void fillPoliciesInProperties(AllocationProperties &allocationProperties, const MemoryPropertiesFlags &memoryProperties); + static void fillPoliciesInProperties(AllocationProperties &allocationProperties, const MemoryPropertiesFlags &memoryProperties, const HardwareInfo &hwInfo); static void fillCachePolicyInProperties(AllocationProperties &allocationProperties, bool uncached, bool readOnly, bool deviceOnlyVisibilty) { diff --git a/opencl/source/mem_obj/buffer.cpp b/opencl/source/mem_obj/buffer.cpp index 52797dac6e..c0cdfe445c 100644 --- a/opencl/source/mem_obj/buffer.cpp +++ b/opencl/source/mem_obj/buffer.cpp @@ -228,7 +228,7 @@ Buffer *Buffer::create(Context *context, } if (!memory) { - AllocationProperties allocProperties = MemoryPropertiesParser::getAllocationProperties(rootDeviceIndex, memoryProperties, allocateMemory, size, allocationType, context->areMultiStorageAllocationsPreferred()); + AllocationProperties allocProperties = MemoryPropertiesParser::getAllocationProperties(rootDeviceIndex, memoryProperties, allocateMemory, size, allocationType, context->areMultiStorageAllocationsPreferred(), context->getDevice(0)->getHardwareInfo()); memory = memoryManager->allocateGraphicsMemoryWithProperties(allocProperties, hostPtr); } @@ -241,7 +241,7 @@ Buffer *Buffer::create(Context *context, allocationType = GraphicsAllocation::AllocationType::BUFFER_HOST_MEMORY; zeroCopyAllowed = false; copyMemoryFromHostPtr = true; - AllocationProperties allocProperties = MemoryPropertiesParser::getAllocationProperties(rootDeviceIndex, memoryProperties, true, size, allocationType, context->areMultiStorageAllocationsPreferred()); + AllocationProperties allocProperties = MemoryPropertiesParser::getAllocationProperties(rootDeviceIndex, memoryProperties, true, size, allocationType, context->areMultiStorageAllocationsPreferred(), context->getDevice(0)->getHardwareInfo()); memory = memoryManager->allocateGraphicsMemoryWithProperties(allocProperties); } diff --git a/opencl/source/mem_obj/image.cpp b/opencl/source/mem_obj/image.cpp index 16a373f893..ec5b83fc37 100644 --- a/opencl/source/mem_obj/image.cpp +++ b/opencl/source/mem_obj/image.cpp @@ -268,7 +268,7 @@ Image *Image::create(Context *context, if (memoryProperties.flags.useHostPtr) { if (!context->isSharedContext) { - AllocationProperties allocProperties = MemObjHelper::getAllocationPropertiesWithImageInfo(rootDeviceIndex, imgInfo, false, memoryProperties); + AllocationProperties allocProperties = MemObjHelper::getAllocationPropertiesWithImageInfo(rootDeviceIndex, imgInfo, false, memoryProperties, context->getDevice(0)->getHardwareInfo()); memory = memoryManager->allocateGraphicsMemoryWithProperties(allocProperties, hostPtr); @@ -292,7 +292,7 @@ Image *Image::create(Context *context, mapAllocation = memoryManager->allocateGraphicsMemoryWithProperties(properties, hostPtr); } } else { - AllocationProperties allocProperties = MemObjHelper::getAllocationPropertiesWithImageInfo(rootDeviceIndex, imgInfo, true, memoryProperties); + AllocationProperties allocProperties = MemObjHelper::getAllocationPropertiesWithImageInfo(rootDeviceIndex, imgInfo, true, memoryProperties, context->getDevice(0)->getHardwareInfo()); memory = memoryManager->allocateGraphicsMemoryWithProperties(allocProperties); if (memory && MemoryPool::isSystemMemoryPool(memory->getMemoryPool())) { diff --git a/opencl/source/mem_obj/mem_obj_helper.h b/opencl/source/mem_obj/mem_obj_helper.h index 35d6216478..7ac05bdcc2 100644 --- a/opencl/source/mem_obj/mem_obj_helper.h +++ b/opencl/source/mem_obj/mem_obj_helper.h @@ -32,7 +32,7 @@ class MemObjHelper { static bool validateMemoryPropertiesForBuffer(const MemoryPropertiesFlags &memoryProperties, cl_mem_flags flags, cl_mem_flags_intel flagsIntel); static bool validateMemoryPropertiesForImage(const MemoryPropertiesFlags &memoryProperties, cl_mem_flags flags, cl_mem_flags_intel flagsIntel, cl_mem parent); - static AllocationProperties getAllocationPropertiesWithImageInfo(uint32_t rootDeviceIndex, ImageInfo &imgInfo, bool allocateMemory, const MemoryPropertiesFlags &memoryProperties); + static AllocationProperties getAllocationPropertiesWithImageInfo(uint32_t rootDeviceIndex, ImageInfo &imgInfo, bool allocateMemory, const MemoryPropertiesFlags &memoryProperties, const HardwareInfo &hwInfo); static bool checkMemFlagsForSubBuffer(cl_mem_flags flags); static SVMAllocsManager::SvmAllocationProperties getSvmAllocationProperties(cl_mem_flags flags); static bool isSuitableForRenderCompression(bool renderCompressed, const MemoryPropertiesFlags &properties, Context &context, bool preferCompression); diff --git a/opencl/source/mem_obj/mem_obj_helper_common.inl b/opencl/source/mem_obj/mem_obj_helper_common.inl index b4a66f1801..bbb04dc909 100644 --- a/opencl/source/mem_obj/mem_obj_helper_common.inl +++ b/opencl/source/mem_obj/mem_obj_helper_common.inl @@ -67,9 +67,9 @@ bool MemObjHelper::validateMemoryPropertiesForImage(const MemoryPropertiesFlags return validateExtraMemoryProperties(memoryProperties, flags, flagsIntel); } -AllocationProperties MemObjHelper::getAllocationPropertiesWithImageInfo(uint32_t rootDeviceIndex, ImageInfo &imgInfo, bool allocateMemory, const MemoryPropertiesFlags &memoryProperties) { +AllocationProperties MemObjHelper::getAllocationPropertiesWithImageInfo(uint32_t rootDeviceIndex, ImageInfo &imgInfo, bool allocateMemory, const MemoryPropertiesFlags &memoryProperties, const HardwareInfo &hwInfo) { AllocationProperties allocationProperties{rootDeviceIndex, allocateMemory, imgInfo, GraphicsAllocation::AllocationType::IMAGE}; - MemoryPropertiesParser::fillPoliciesInProperties(allocationProperties, memoryProperties); + MemoryPropertiesParser::fillPoliciesInProperties(allocationProperties, memoryProperties, hwInfo); return allocationProperties; } diff --git a/opencl/source/mem_obj/pipe.cpp b/opencl/source/mem_obj/pipe.cpp index 9102778062..b8baf03203 100644 --- a/opencl/source/mem_obj/pipe.cpp +++ b/opencl/source/mem_obj/pipe.cpp @@ -59,7 +59,7 @@ Pipe *Pipe::create(Context *context, auto size = static_cast(packetSize * (maxPackets + 1) + intelPipeHeaderReservedSpace); auto rootDeviceIndex = context->getDevice(0)->getRootDeviceIndex(); AllocationProperties allocProperties = - MemoryPropertiesParser::getAllocationProperties(rootDeviceIndex, memoryPropertiesFlags, true, size, GraphicsAllocation::AllocationType::PIPE, false); + MemoryPropertiesParser::getAllocationProperties(rootDeviceIndex, memoryPropertiesFlags, true, size, GraphicsAllocation::AllocationType::PIPE, false, context->getDevice(0)->getHardwareInfo()); GraphicsAllocation *memory = memoryManager->allocateGraphicsMemoryWithProperties(allocProperties); if (!memory) { errcodeRet = CL_OUT_OF_HOST_MEMORY; diff --git a/opencl/source/sharings/d3d/d3d_surface.cpp b/opencl/source/sharings/d3d/d3d_surface.cpp index 317618dbe0..bbf9de7307 100644 --- a/opencl/source/sharings/d3d/d3d_surface.cpp +++ b/opencl/source/sharings/d3d/d3d_surface.cpp @@ -95,7 +95,7 @@ Image *D3DSurface::create(Context *context, cl_dx9_surface_info_khr *surfaceInfo imgInfo.imgDesc.imageHeight /= 2; } MemoryPropertiesFlags memoryProperties = MemoryPropertiesFlagsParser::createMemoryPropertiesFlags(flags, 0, 0); - AllocationProperties allocProperties = MemObjHelper::getAllocationPropertiesWithImageInfo(rootDeviceIndex, imgInfo, true, memoryProperties); + AllocationProperties allocProperties = MemObjHelper::getAllocationPropertiesWithImageInfo(rootDeviceIndex, imgInfo, true, memoryProperties, context->getDevice(0)->getHardwareInfo()); allocProperties.allocationType = GraphicsAllocation::AllocationType::SHARED_RESOURCE_COPY; alloc = context->getMemoryManager()->allocateGraphicsMemoryInPreferredPool(allocProperties, nullptr); diff --git a/opencl/test/unit_test/command_stream/aub_command_stream_receiver_2_tests.cpp b/opencl/test/unit_test/command_stream/aub_command_stream_receiver_2_tests.cpp index 4b25f1c57e..8889bd8e63 100644 --- a/opencl/test/unit_test/command_stream/aub_command_stream_receiver_2_tests.cpp +++ b/opencl/test/unit_test/command_stream/aub_command_stream_receiver_2_tests.cpp @@ -472,7 +472,7 @@ HWTEST_F(AubCommandStreamReceiverNoHostPtrTests, givenAubCommandStreamReceiverWh auto imgInfo = MockGmm::initImgInfo(imgDesc, 0, nullptr); - AllocationProperties allocProperties = MemObjHelper::getAllocationPropertiesWithImageInfo(aubCsr->getRootDeviceIndex(), imgInfo, true, {}); + AllocationProperties allocProperties = MemObjHelper::getAllocationPropertiesWithImageInfo(aubCsr->getRootDeviceIndex(), imgInfo, true, {}, *hwInfo); auto imageAllocation = memoryManager->allocateGraphicsMemoryInPreferredPool(allocProperties, nullptr); ASSERT_NE(nullptr, imageAllocation); diff --git a/opencl/test/unit_test/mem_obj/image_tests.cpp b/opencl/test/unit_test/mem_obj/image_tests.cpp index d8a548124f..8a1814bf0e 100644 --- a/opencl/test/unit_test/mem_obj/image_tests.cpp +++ b/opencl/test/unit_test/mem_obj/image_tests.cpp @@ -1422,7 +1422,7 @@ HWTEST_F(HwImageTest, givenImageHwWithUnifiedSurfaceAndMcsWhenSettingParamsForMu cl_image_format format = {}; auto imgInfo = MockGmm::initImgInfo(imgDesc, 0, nullptr); - AllocationProperties allocProperties = MemObjHelper::getAllocationPropertiesWithImageInfo(0, imgInfo, true, {}); + AllocationProperties allocProperties = MemObjHelper::getAllocationPropertiesWithImageInfo(0, imgInfo, true, {}, context.getDevice(0)->getHardwareInfo()); auto graphicsAllocation = memoryManager.allocateGraphicsMemoryInPreferredPool(allocProperties, nullptr); diff --git a/opencl/test/unit_test/memory_manager/memory_manager_allocate_in_device_pool_tests.inl b/opencl/test/unit_test/memory_manager/memory_manager_allocate_in_device_pool_tests.inl index 0931fe79ef..c2b3926da4 100644 --- a/opencl/test/unit_test/memory_manager/memory_manager_allocate_in_device_pool_tests.inl +++ b/opencl/test/unit_test/memory_manager/memory_manager_allocate_in_device_pool_tests.inl @@ -49,35 +49,38 @@ TEST(MemoryManagerTest, givenAllowed32BitAndFroce32BitWhenGraphicsAllocationInDe } TEST(AllocationFlagsTest, givenAllocateMemoryFlagWhenGetAllocationFlagsIsCalledThenAllocateFlagIsCorrectlySet) { - auto allocationProperties = MemoryPropertiesParser::getAllocationProperties(0, {}, true, 0, GraphicsAllocation::AllocationType::BUFFER, false); + HardwareInfo hwInfo(*platformDevices[0]); + auto allocationProperties = MemoryPropertiesParser::getAllocationProperties(0, {}, true, 0, GraphicsAllocation::AllocationType::BUFFER, false, hwInfo); EXPECT_TRUE(allocationProperties.flags.allocateMemory); - auto allocationProperties2 = MemoryPropertiesParser::getAllocationProperties(0, {}, false, 0, GraphicsAllocation::AllocationType::BUFFER, false); + auto allocationProperties2 = MemoryPropertiesParser::getAllocationProperties(0, {}, false, 0, GraphicsAllocation::AllocationType::BUFFER, false, hwInfo); EXPECT_FALSE(allocationProperties2.flags.allocateMemory); } TEST(UncacheableFlagsTest, givenUncachedResourceFlagWhenGetAllocationFlagsIsCalledThenUncacheableFlagIsCorrectlySet) { cl_mem_flags_intel flagsIntel = CL_MEM_LOCALLY_UNCACHED_RESOURCE; + HardwareInfo hwInfo(*platformDevices[0]); MemoryPropertiesFlags memoryProperties = MemoryPropertiesFlagsParser::createMemoryPropertiesFlags(0, flagsIntel, 0); - auto allocationFlags = MemoryPropertiesParser::getAllocationProperties(0, memoryProperties, false, 0, GraphicsAllocation::AllocationType::BUFFER, false); + auto allocationFlags = MemoryPropertiesParser::getAllocationProperties(0, memoryProperties, false, 0, GraphicsAllocation::AllocationType::BUFFER, false, hwInfo); EXPECT_TRUE(allocationFlags.flags.uncacheable); flagsIntel = 0; memoryProperties = MemoryPropertiesFlagsParser::createMemoryPropertiesFlags(0, flagsIntel, 0); - auto allocationFlags2 = MemoryPropertiesParser::getAllocationProperties(0, memoryProperties, false, 0, GraphicsAllocation::AllocationType::BUFFER, false); + auto allocationFlags2 = MemoryPropertiesParser::getAllocationProperties(0, memoryProperties, false, 0, GraphicsAllocation::AllocationType::BUFFER, false, hwInfo); EXPECT_FALSE(allocationFlags2.flags.uncacheable); } TEST(AllocationFlagsTest, givenReadOnlyResourceFlagWhenGetAllocationFlagsIsCalledThenFlushL3FlagsAreCorrectlySet) { cl_mem_flags flags = CL_MEM_READ_ONLY; MemoryPropertiesFlags memoryProperties = MemoryPropertiesFlagsParser::createMemoryPropertiesFlags(flags, 0, 0); + HardwareInfo hwInfo(*platformDevices[0]); auto allocationFlags = - MemoryPropertiesParser::getAllocationProperties(0, memoryProperties, true, 0, GraphicsAllocation::AllocationType::BUFFER, false); + MemoryPropertiesParser::getAllocationProperties(0, memoryProperties, true, 0, GraphicsAllocation::AllocationType::BUFFER, false, hwInfo); EXPECT_FALSE(allocationFlags.flags.flushL3RequiredForRead); EXPECT_FALSE(allocationFlags.flags.flushL3RequiredForWrite); - auto allocationFlags2 = MemoryPropertiesParser::getAllocationProperties(0, {}, true, 0, GraphicsAllocation::AllocationType::BUFFER, false); + auto allocationFlags2 = MemoryPropertiesParser::getAllocationProperties(0, {}, true, 0, GraphicsAllocation::AllocationType::BUFFER, false, hwInfo); EXPECT_TRUE(allocationFlags2.flags.flushL3RequiredForRead); EXPECT_TRUE(allocationFlags2.flags.flushL3RequiredForWrite); } diff --git a/opencl/test/unit_test/os_interface/windows/wddm_memory_manager_tests.cpp b/opencl/test/unit_test/os_interface/windows/wddm_memory_manager_tests.cpp index 713759df03..0bb588e8c7 100644 --- a/opencl/test/unit_test/os_interface/windows/wddm_memory_manager_tests.cpp +++ b/opencl/test/unit_test/os_interface/windows/wddm_memory_manager_tests.cpp @@ -1303,8 +1303,7 @@ TEST_F(WddmMemoryManagerWithAsyncDeleterTest, givenMemoryManagerWithAsyncDeleter EXPECT_EQ(0, deleter->drainCalled); EXPECT_EQ(0u, wddm->createAllocationResult.called); deleter->expectDrainBlockingValue(true); - - AllocationProperties allocProperties = MemObjHelper::getAllocationPropertiesWithImageInfo(0, imgInfo, true, {}); + AllocationProperties allocProperties = MemObjHelper::getAllocationPropertiesWithImageInfo(0, imgInfo, true, {}, *hwInfo); memoryManager->allocateGraphicsMemoryInPreferredPool(allocProperties, nullptr); EXPECT_EQ(1, deleter->drainCalled); @@ -1323,7 +1322,7 @@ TEST_F(WddmMemoryManagerWithAsyncDeleterTest, givenMemoryManagerWithAsyncDeleter EXPECT_EQ(0u, wddm->createAllocationResult.called); EXPECT_EQ(0u, wddm->mapGpuVirtualAddressResult.called); - AllocationProperties allocProperties = MemObjHelper::getAllocationPropertiesWithImageInfo(0, imgInfo, true, {}); + AllocationProperties allocProperties = MemObjHelper::getAllocationPropertiesWithImageInfo(0, imgInfo, true, {}, *hwInfo); auto allocation = memoryManager->allocateGraphicsMemoryInPreferredPool(allocProperties, nullptr); EXPECT_EQ(0, deleter->drainCalled); @@ -1341,7 +1340,7 @@ TEST_F(WddmMemoryManagerWithAsyncDeleterTest, givenMemoryManagerWithoutAsyncDele wddm->createAllocationStatus = STATUS_GRAPHICS_NO_VIDEO_MEMORY; EXPECT_EQ(0u, wddm->createAllocationResult.called); - AllocationProperties allocProperties = MemObjHelper::getAllocationPropertiesWithImageInfo(0, imgInfo, true, {}); + AllocationProperties allocProperties = MemObjHelper::getAllocationPropertiesWithImageInfo(0, imgInfo, true, {}, *hwInfo); memoryManager->allocateGraphicsMemoryInPreferredPool(allocProperties, nullptr); EXPECT_EQ(1u, wddm->createAllocationResult.called);