From 33ab962121629e101cb2e355c3d3b9f72dcc54c4 Mon Sep 17 00:00:00 2001 From: Szymon Morek Date: Thu, 18 Jul 2024 10:37:23 +0000 Subject: [PATCH] fix: adjust compression hint usage for ocl buffers Related-To: NEO-11989 Also, use zero-copy on lnl Signed-off-by: Szymon Morek --- opencl/source/mem_obj/buffer.cpp | 12 ++--- opencl/source/mem_obj/buffer.h | 2 +- opencl/source/mem_obj/mem_obj.cpp | 2 +- opencl/source/mem_obj/mem_obj_helper.cpp | 4 +- opencl/test/unit_test/api/cl_api_tests.h | 3 +- .../unit_test/api/cl_create_buffer_tests.cpp | 2 +- .../compression_aub_tests_xehp_and_later.cpp | 1 + .../copy_engine_aub_tests_xehp_and_later.h | 10 ++--- .../enqueue_map_buffer_tests.cpp | 12 ++--- .../enqueue_read_buffer_event_tests.cpp | 2 +- .../enqueue_read_buffer_rect_tests.cpp | 10 ++--- .../enqueue_read_buffer_tests.cpp | 4 +- .../enqueue_unmap_memobject_tests.cpp | 2 +- .../enqueue_write_buffer_event_tests.cpp | 4 +- .../enqueue_write_buffer_rect_tests.cpp | 12 ++--- .../enqueue_write_buffer_tests.cpp | 4 +- .../read_write_buffer_cpu_copy.cpp | 21 +++++---- ...and_stream_receiver_flush_task_2_tests.cpp | 2 +- .../context/driver_diagnostics_tests.h | 2 +- .../test/unit_test/mem_obj/buffer_tests.cpp | 44 +++++++++---------- .../mem_obj/mem_obj_helper_tests.cpp | 12 ++--- .../unit_test/mem_obj/zero_copy_tests.cpp | 4 +- .../copy_engine_tests_xe_hpg_core.cpp | 4 +- shared/source/os_interface/product_helper.h | 1 + shared/source/os_interface/product_helper.inl | 5 +++ .../source/os_interface/product_helper_hw.h | 1 + .../os_agnostic_product_helper_xe_lpg.inl | 5 +++ .../os_interface/product_helper_tests.cpp | 4 ++ .../arl/excludes_xe_hpg_core_arl.cpp | 1 + .../mtl/excludes_xe_hpg_core_mtl.cpp | 1 + ...s_agnostic_product_helper_xe_lpg_tests.cpp | 4 ++ 31 files changed, 109 insertions(+), 88 deletions(-) diff --git a/opencl/source/mem_obj/buffer.cpp b/opencl/source/mem_obj/buffer.cpp index de9a3b2896..df8badd8b7 100644 --- a/opencl/source/mem_obj/buffer.cpp +++ b/opencl/source/mem_obj/buffer.cpp @@ -342,10 +342,10 @@ Buffer *Buffer::create(Context *context, bool compressionEnabled = MemObjHelper::isSuitableForCompression(GfxCoreHelper::compressedBuffersSupported(*hwInfo), memoryProperties, *context, gfxCoreHelper.isBufferSizeSuitableForCompression(size)); - auto isNewCoherencyModelSupported = productHelper.isNewCoherencyModelSupported(); + auto isZeroCopyCpuAccessPreferred = productHelper.isZeroCopyCpuAccessPreferred(); allocationInfo.allocationType = getGraphicsAllocationTypeAndCompressionPreference(memoryProperties, compressionEnabled, memoryManager->isLocalMemorySupported(rootDeviceIndex), - isNewCoherencyModelSupported); + isZeroCopyCpuAccessPreferred); if (allocationCpuPtr) { forceCopyHostPtr = !useHostPtr && !copyHostPtr; @@ -373,7 +373,7 @@ Buffer *Buffer::create(Context *context, allocationInfo.zeroCopyAllowed = false; allocationInfo.allocateMemory = true; } - } else if (isNewCoherencyModelSupported) { + } else if (!isZeroCopyCpuAccessPreferred) { allocationInfo.zeroCopyAllowed = false; allocationInfo.allocateMemory = true; } @@ -470,7 +470,7 @@ Buffer *Buffer::create(Context *context, return nullptr; } - if (!isSystemMemory || (isNewCoherencyModelSupported && !memoryProperties.flags.forceHostMemory)) { + if (!isSystemMemory || (!isZeroCopyCpuAccessPreferred && !memoryProperties.flags.forceHostMemory)) { allocationInfo.zeroCopyAllowed = false; if (hostPtr) { if (!allocationInfo.isHostPtrSVM) { @@ -643,13 +643,13 @@ void Buffer::checkMemory(const MemoryProperties &memoryProperties, AllocationType Buffer::getGraphicsAllocationTypeAndCompressionPreference(const MemoryProperties &properties, bool &compressionEnabled, bool isLocalMemoryEnabled, - bool isNewCoherencyModelSupported) { + bool isZeroCopyCpuAccessPreferred) { if (properties.flags.forceHostMemory) { compressionEnabled = false; return AllocationType::bufferHostMemory; } - if (properties.flags.useHostPtr && (!isLocalMemoryEnabled && !isNewCoherencyModelSupported)) { + if (properties.flags.useHostPtr && (!isLocalMemoryEnabled && isZeroCopyCpuAccessPreferred)) { compressionEnabled = false; return AllocationType::bufferHostMemory; } diff --git a/opencl/source/mem_obj/buffer.h b/opencl/source/mem_obj/buffer.h index a4fbca27a2..ca61138537 100644 --- a/opencl/source/mem_obj/buffer.h +++ b/opencl/source/mem_obj/buffer.h @@ -209,7 +209,7 @@ class Buffer : public MemObj { bool forceCopyHostPtr); static AllocationType getGraphicsAllocationTypeAndCompressionPreference(const MemoryProperties &properties, bool &compressionEnabled, bool localMemoryEnabled, - bool isNewCoherencyModelSupported); + bool isZeroCopyCpuAccessPreferred); static bool isReadOnlyMemoryPermittedByFlags(const MemoryProperties &properties); void transferData(void *dst, void *src, size_t copySize, size_t copyOffset); diff --git a/opencl/source/mem_obj/mem_obj.cpp b/opencl/source/mem_obj/mem_obj.cpp index cf48274202..6fd1d891ac 100644 --- a/opencl/source/mem_obj/mem_obj.cpp +++ b/opencl/source/mem_obj/mem_obj.cpp @@ -454,7 +454,7 @@ bool MemObj::allowCpuAccess() const { return !(isNonCoherentSystemAllocation); } - return !graphicsAllocation->getDefaultGmm()->getPreferNoCpuAccess() && !(isNonCoherentSystemAllocation); + return !graphicsAllocation->getDefaultGmm()->getPreferNoCpuAccess(); } bool MemObj::allowCpuForMapUnmap() const { diff --git a/opencl/source/mem_obj/mem_obj_helper.cpp b/opencl/source/mem_obj/mem_obj_helper.cpp index 85c112b09b..28459203a3 100644 --- a/opencl/source/mem_obj/mem_obj_helper.cpp +++ b/opencl/source/mem_obj/mem_obj_helper.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2018-2023 Intel Corporation + * Copyright (C) 2018-2024 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -145,7 +145,7 @@ bool MemObjHelper::isSuitableForCompression(bool compressionSupported, const Mem return true; } - return properties.flags.compressedHint; + return false; } bool MemObjHelper::validateExtraMemoryProperties(const MemoryProperties &memoryProperties, cl_mem_flags flags, cl_mem_flags_intel flagsIntel, const Context &context) { diff --git a/opencl/test/unit_test/api/cl_api_tests.h b/opencl/test/unit_test/api/cl_api_tests.h index 1e35041e4a..98ecefe15a 100644 --- a/opencl/test/unit_test/api/cl_api_tests.h +++ b/opencl/test/unit_test/api/cl_api_tests.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2018-2023 Intel Corporation + * Copyright (C) 2018-2024 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -30,7 +30,6 @@ struct ApiFixture { void setUp() { debugManager.flags.CreateMultipleRootDevices.set(numRootDevices); - debugManager.flags.EnableCpuCacheForResources.set(true); executionEnvironment = new ClExecutionEnvironment(); prepareDeviceEnvironments(*executionEnvironment); for (auto i = 0u; i < executionEnvironment->rootDeviceEnvironments.size(); i++) { diff --git a/opencl/test/unit_test/api/cl_create_buffer_tests.cpp b/opencl/test/unit_test/api/cl_create_buffer_tests.cpp index 4db3093275..81835a3ba5 100644 --- a/opencl/test/unit_test/api/cl_create_buffer_tests.cpp +++ b/opencl/test/unit_test/api/cl_create_buffer_tests.cpp @@ -497,7 +497,7 @@ TEST_F(clCreateBufferTestsWithRestrictions, GivenMemoryManagerRestrictionsAndOld Buffer *bufferObj = NEO::castToObject(buffer); auto &productHelper = device->getProductHelper(); - if (productHelper.isNewCoherencyModelSupported()) { + if (!productHelper.isZeroCopyCpuAccessPreferred()) { EXPECT_FALSE(bufferObj->isMemObjZeroCopy()); } else { EXPECT_TRUE(bufferObj->isMemObjZeroCopy()); diff --git a/opencl/test/unit_test/aub_tests/command_queue/compression_aub_tests_xehp_and_later.cpp b/opencl/test/unit_test/aub_tests/command_queue/compression_aub_tests_xehp_and_later.cpp index 4f85aaad4e..584b3f2cfc 100644 --- a/opencl/test/unit_test/aub_tests/command_queue/compression_aub_tests_xehp_and_later.cpp +++ b/opencl/test/unit_test/aub_tests/command_queue/compression_aub_tests_xehp_and_later.cpp @@ -35,6 +35,7 @@ struct CompressionXeHPAndLater : public AUBFixture, debugRestorer = std::make_unique(); debugManager.flags.RenderCompressedBuffersEnabled.set(true); debugManager.flags.RenderCompressedImagesEnabled.set(true); + debugManager.flags.OverrideBufferSuitableForRenderCompression.set(true); debugManager.flags.EnableLocalMemory.set(useLocalMemory); debugManager.flags.NodeOrdinal.set(GetParam()); diff --git a/opencl/test/unit_test/aub_tests/command_stream/copy_engine_aub_tests_xehp_and_later.h b/opencl/test/unit_test/aub_tests/command_stream/copy_engine_aub_tests_xehp_and_later.h index ad622a1247..8c033c57dc 100644 --- a/opencl/test/unit_test/aub_tests/command_stream/copy_engine_aub_tests_xehp_and_later.h +++ b/opencl/test/unit_test/aub_tests/command_stream/copy_engine_aub_tests_xehp_and_later.h @@ -178,7 +178,7 @@ void CopyEngineXeHPAndLater::givenNotCompressedBuffer if (!compressionSupported()) { GTEST_SKIP(); } - + debugManager.flags.OverrideBufferSuitableForRenderCompression.set(true); auto srcNotCompressedBuffer = createBuffer(false, testLocalMemory, compressiblePattern.get()); auto dstNotCompressedBuffer = createBuffer(false, testLocalMemory, nullptr); auto dstCompressedBuffer = createBuffer(true, testLocalMemory, nullptr); @@ -219,7 +219,7 @@ void CopyEngineXeHPAndLater::givenHostPtrWhenBlitComm if (!compressionSupported()) { GTEST_SKIP(); } - + debugManager.flags.OverrideBufferSuitableForRenderCompression.set(true); auto dstCompressedBuffer = createBuffer(true, testLocalMemory, nullptr); // HostPtr to Buffer - System -> compressed HBM @@ -248,7 +248,7 @@ void CopyEngineXeHPAndLater::givenDstHostPtrWhenBlitC if (!compressionSupported()) { GTEST_SKIP(); } - + debugManager.flags.OverrideBufferSuitableForRenderCompression.set(true); auto srcCompressedBuffer = createBuffer(true, testLocalMemory, nullptr); auto blitProperties = BlitProperties::constructPropertiesForReadWrite(BlitterConstants::BlitDirection::hostPtrToBuffer, *bcsCsr, srcCompressedBuffer->getGraphicsAllocation(rootDeviceIndex), @@ -372,7 +372,7 @@ void CopyEngineXeHPAndLater::givenSrcCompressedBuffer if (!compressionSupported()) { GTEST_SKIP(); } - + debugManager.flags.OverrideBufferSuitableForRenderCompression.set(true); auto srcBuffer = createBuffer(true, testLocalMemory, nullptr); auto blitProperties = BlitProperties::constructPropertiesForReadWrite(BlitterConstants::BlitDirection::hostPtrToBuffer, *bcsCsr, srcBuffer->getGraphicsAllocation(rootDeviceIndex), @@ -407,7 +407,7 @@ void CopyEngineXeHPAndLater::givenCompressedBufferWhe // no support for scenarios where stateless is mixed with blitter compression GTEST_SKIP(); } - + debugManager.flags.OverrideBufferSuitableForRenderCompression.set(true); auto buffer = createBuffer(true, testLocalMemory, compressiblePattern.get()); { diff --git a/opencl/test/unit_test/command_queue/enqueue_map_buffer_tests.cpp b/opencl/test/unit_test/command_queue/enqueue_map_buffer_tests.cpp index 0103bce1e1..12d94aca77 100644 --- a/opencl/test/unit_test/command_queue/enqueue_map_buffer_tests.cpp +++ b/opencl/test/unit_test/command_queue/enqueue_map_buffer_tests.cpp @@ -515,7 +515,7 @@ TEST_F(EnqueueMapBufferTest, givenNonBlockingMapBufferAfterL3IsAlreadyFlushedThe taskCount = commandStreamReceiver.peekTaskCount(); auto expectedTaskCount = 1u; auto &productHelper = BufferDefaults::context->getDevice(0)->getProductHelper(); - if (productHelper.isNewCoherencyModelSupported()) { + if (!productHelper.isZeroCopyCpuAccessPreferred()) { expectedTaskCount++; } EXPECT_EQ(expectedTaskCount, taskCount); @@ -716,7 +716,7 @@ TEST_F(EnqueueMapBufferTest, givenBufferWithoutUseHostPtrFlagWhenMappedOnCpuThen std::unique_ptr buffer(Buffer::create(BufferDefaults::context, CL_MEM_READ_WRITE, 10, nullptr, retVal)); EXPECT_NE(nullptr, buffer); auto &productHelper = BufferDefaults::context->getDevice(0)->getProductHelper(); - EXPECT_EQ(!productHelper.isNewCoherencyModelSupported(), buffer->mappingOnCpuAllowed()); + EXPECT_EQ(productHelper.isZeroCopyCpuAccessPreferred(), buffer->mappingOnCpuAllowed()); size_t mapSize = 3; size_t mapOffset = 2; @@ -738,7 +738,7 @@ TEST_F(EnqueueMapBufferTest, givenBufferWithoutUseHostPtrFlagWhenMappedOnCpuThen EXPECT_EQ(0u, mappedInfo.size[2]); auto expectedPtr = ptrOffset(buffer->getCpuAddressForMapping(), mapOffset); - if (!productHelper.isNewCoherencyModelSupported()) { + if (productHelper.isZeroCopyCpuAccessPreferred()) { EXPECT_EQ(mappedPtr, expectedPtr); } } @@ -748,7 +748,7 @@ TEST_F(EnqueueMapBufferTest, givenBufferWithUseHostPtrFlagWhenMappedOnCpuThenSet std::unique_ptr buffer(Buffer::create(BufferDefaults::context, CL_MEM_READ_WRITE | CL_MEM_USE_HOST_PTR, 10, hostPtr, retVal)); EXPECT_NE(nullptr, buffer); auto &productHelper = BufferDefaults::context->getDevice(0)->getProductHelper(); - EXPECT_EQ(!productHelper.isNewCoherencyModelSupported(), buffer->mappingOnCpuAllowed()); + EXPECT_EQ(productHelper.isZeroCopyCpuAccessPreferred(), buffer->mappingOnCpuAllowed()); size_t mapSize = 3; size_t mapOffset = 2; @@ -779,7 +779,7 @@ HWTEST_F(EnqueueMapBufferTest, givenMapBufferOnGpuWhenMappingBufferThenStoreGrap std::unique_ptr bufferForCpuMap(Buffer::create(context, CL_MEM_READ_WRITE | CL_MEM_USE_HOST_PTR, 10, hostPtr, retVal)); ASSERT_NE(nullptr, bufferForCpuMap); auto &productHelper = context->getDevice(0)->getProductHelper(); - if (productHelper.isNewCoherencyModelSupported()) { + if (!productHelper.isZeroCopyCpuAccessPreferred()) { ASSERT_FALSE(bufferForCpuMap->mappingOnCpuAllowed()); } else { ASSERT_TRUE(bufferForCpuMap->mappingOnCpuAllowed()); @@ -798,7 +798,7 @@ HWTEST_F(EnqueueMapBufferTest, givenMapBufferOnGpuWhenMappingBufferThenStoreGrap MapInfo mapInfo{}; EXPECT_TRUE(bufferForCpuMap->findMappedPtr(pointerMappedOnCpu, mapInfo)); - if (productHelper.isNewCoherencyModelSupported()) { + if (!productHelper.isZeroCopyCpuAccessPreferred()) { EXPECT_NE(nullptr, mapInfo.graphicsAllocation); } else { EXPECT_EQ(nullptr, mapInfo.graphicsAllocation); diff --git a/opencl/test/unit_test/command_queue/enqueue_read_buffer_event_tests.cpp b/opencl/test/unit_test/command_queue/enqueue_read_buffer_event_tests.cpp index bded1900aa..30b3096117 100644 --- a/opencl/test/unit_test/command_queue/enqueue_read_buffer_event_tests.cpp +++ b/opencl/test/unit_test/command_queue/enqueue_read_buffer_event_tests.cpp @@ -105,7 +105,7 @@ struct EnqueueReadBufferOnCpuTest : public EnqueueReadBuffer { void SetUp() override { EnqueueReadBuffer::setUp(); auto &productHelper = BufferDefaults::context->getDevice(0)->getProductHelper(); - if (productHelper.isNewCoherencyModelSupported()) { + if (!productHelper.isZeroCopyCpuAccessPreferred()) { // These tests verify cpu transfer logic GTEST_SKIP(); } diff --git a/opencl/test/unit_test/command_queue/enqueue_read_buffer_rect_tests.cpp b/opencl/test/unit_test/command_queue/enqueue_read_buffer_rect_tests.cpp index 27bf8561de..0fec9ad28b 100644 --- a/opencl/test/unit_test/command_queue/enqueue_read_buffer_rect_tests.cpp +++ b/opencl/test/unit_test/command_queue/enqueue_read_buffer_rect_tests.cpp @@ -391,7 +391,7 @@ HWTEST_F(EnqueueReadBufferRectTest, givenInOrderQueueAndDstPtrEqualSrcPtrWithEve auto expectedTaskLevel = 19u; auto &productHelper = context->getDevice(0)->getProductHelper(); - if (productHelper.isNewCoherencyModelSupported()) { + if (!productHelper.isZeroCopyCpuAccessPreferred()) { expectedTaskLevel++; } auto pEvent = (Event *)event; @@ -446,7 +446,7 @@ HWTEST_F(EnqueueReadBufferRectTest, givenOutOfOrderQueueAndDstPtrEqualSrcPtrWith ASSERT_NE(nullptr, event); auto expectedTaskLevel = 19u; auto &productHelper = context->getDevice(0)->getProductHelper(); - if (productHelper.isNewCoherencyModelSupported()) { + if (!productHelper.isZeroCopyCpuAccessPreferred()) { expectedTaskLevel++; } auto pEvent = (Event *)event; @@ -480,7 +480,7 @@ HWTEST_F(EnqueueReadBufferRectTest, givenInOrderQueueAndRowPitchEqualZeroAndDstP EXPECT_EQ(CL_SUCCESS, retVal); auto expectedTaskLevel = 0u; auto &productHelper = context->getDevice(0)->getProductHelper(); - if (productHelper.isNewCoherencyModelSupported()) { + if (!productHelper.isZeroCopyCpuAccessPreferred()) { expectedTaskLevel++; } EXPECT_EQ(pCmdQ->taskLevel, expectedTaskLevel); @@ -510,7 +510,7 @@ HWTEST_F(EnqueueReadBufferRectTest, givenInOrderQueueAndSlicePitchEqualZeroAndDs EXPECT_EQ(CL_SUCCESS, retVal); auto expectedTaskLevel = 0u; auto &productHelper = context->getDevice(0)->getProductHelper(); - if (productHelper.isNewCoherencyModelSupported()) { + if (!productHelper.isZeroCopyCpuAccessPreferred()) { expectedTaskLevel++; } EXPECT_EQ(pCmdQ->taskLevel, expectedTaskLevel); @@ -542,7 +542,7 @@ HWTEST_F(EnqueueReadBufferRectTest, givenInOrderQueueAndMemObjWithOffsetPointThe EXPECT_EQ(CL_SUCCESS, retVal); auto expectedTaskLevel = 0u; auto &productHelper = context->getDevice(0)->getProductHelper(); - if (productHelper.isNewCoherencyModelSupported()) { + if (!productHelper.isZeroCopyCpuAccessPreferred()) { expectedTaskLevel++; } EXPECT_EQ(pCmdQ->taskLevel, expectedTaskLevel); diff --git a/opencl/test/unit_test/command_queue/enqueue_read_buffer_tests.cpp b/opencl/test/unit_test/command_queue/enqueue_read_buffer_tests.cpp index 339f5df3d1..62fd4244ce 100644 --- a/opencl/test/unit_test/command_queue/enqueue_read_buffer_tests.cpp +++ b/opencl/test/unit_test/command_queue/enqueue_read_buffer_tests.cpp @@ -476,7 +476,7 @@ HWTEST_F(EnqueueReadBufferTypeTest, givenInOrderQueueAndEnabledSupportCpuCopiesA EXPECT_EQ(CL_SUCCESS, retVal); auto expectedTaskLevel = 0u; auto &productHelper = context->getDevice(0)->getProductHelper(); - if (productHelper.isNewCoherencyModelSupported()) { + if (!productHelper.isZeroCopyCpuAccessPreferred()) { expectedTaskLevel++; } EXPECT_EQ(pCmdQ->taskLevel, expectedTaskLevel); @@ -500,7 +500,7 @@ HWTEST_F(EnqueueReadBufferTypeTest, givenInOrderQueueAndDisabledSupportCpuCopies EXPECT_EQ(CL_SUCCESS, retVal); auto expectedTaskLevel = 0u; auto &productHelper = context->getDevice(0)->getProductHelper(); - if (productHelper.isNewCoherencyModelSupported()) { + if (!productHelper.isZeroCopyCpuAccessPreferred()) { expectedTaskLevel++; } EXPECT_EQ(pCmdQ->taskLevel, expectedTaskLevel); diff --git a/opencl/test/unit_test/command_queue/enqueue_unmap_memobject_tests.cpp b/opencl/test/unit_test/command_queue/enqueue_unmap_memobject_tests.cpp index e246873194..b6c18bc04a 100644 --- a/opencl/test/unit_test/command_queue/enqueue_unmap_memobject_tests.cpp +++ b/opencl/test/unit_test/command_queue/enqueue_unmap_memobject_tests.cpp @@ -183,7 +183,7 @@ TEST_F(EnqueueUnmapMemObjTest, WhenUnmappingMemoryObjectThenWaitEventIsUpdated) Event *rEvent = castToObject(retEvent); auto &productHelper = pCmdQ->getClDevice().getProductHelper(); - if (productHelper.isNewCoherencyModelSupported()) { + if (!productHelper.isZeroCopyCpuAccessPreferred()) { // In new coherency model wait event is not immediately updated as unmap is sent to GPU // Instead, verify that timestamp packets were correctly assigned from waitEvent to retEvent auto waitNodes = wEvent->getTimestampPacketNodes()->peekNodes(); diff --git a/opencl/test/unit_test/command_queue/enqueue_write_buffer_event_tests.cpp b/opencl/test/unit_test/command_queue/enqueue_write_buffer_event_tests.cpp index 7b4f4e046b..9e921f0d49 100644 --- a/opencl/test/unit_test/command_queue/enqueue_write_buffer_event_tests.cpp +++ b/opencl/test/unit_test/command_queue/enqueue_write_buffer_event_tests.cpp @@ -105,7 +105,7 @@ struct EnqueueWriteBufferOnCpuTypeTest : public EnqueueWriteBufferTypeTest { void SetUp() override { EnqueueWriteBufferTypeTest::SetUp(); auto &productHelper = BufferDefaults::context->getDevice(0)->getProductHelper(); - if (productHelper.isNewCoherencyModelSupported()) { + if (!productHelper.isZeroCopyCpuAccessPreferred()) { // These tests verify cpu transfer logic GTEST_SKIP(); } @@ -113,7 +113,7 @@ struct EnqueueWriteBufferOnCpuTypeTest : public EnqueueWriteBufferTypeTest { void TearDown() override { auto &productHelper = BufferDefaults::context->getDevice(0)->getProductHelper(); - if (productHelper.isNewCoherencyModelSupported()) { + if (!productHelper.isZeroCopyCpuAccessPreferred()) { // These tests verify cpu transfer logic GTEST_SKIP(); } diff --git a/opencl/test/unit_test/command_queue/enqueue_write_buffer_rect_tests.cpp b/opencl/test/unit_test/command_queue/enqueue_write_buffer_rect_tests.cpp index 2b12e56468..51c1b1a3d4 100644 --- a/opencl/test/unit_test/command_queue/enqueue_write_buffer_rect_tests.cpp +++ b/opencl/test/unit_test/command_queue/enqueue_write_buffer_rect_tests.cpp @@ -324,7 +324,7 @@ HWTEST_F(EnqueueWriteBufferRectTest, givenInOrderQueueAndDstPtrEqualSrcPtrWhenWr EXPECT_EQ(CL_SUCCESS, retVal); auto expectedTaskLevel = 0u; auto &productHelper = context->getDevice(0)->getProductHelper(); - if (productHelper.isNewCoherencyModelSupported()) { + if (!productHelper.isZeroCopyCpuAccessPreferred()) { expectedTaskLevel++; } EXPECT_EQ(pCmdQ->taskLevel, expectedTaskLevel); @@ -395,7 +395,7 @@ HWTEST_F(EnqueueWriteBufferRectTest, givenInOrderQueueAndDstPtrEqualSrcPtrWithEv auto expectedTaskLevel = 19u; auto &productHelper = context->getDevice(0)->getProductHelper(); - if (productHelper.isNewCoherencyModelSupported()) { + if (!productHelper.isZeroCopyCpuAccessPreferred()) { expectedTaskLevel++; } auto pEvent = (Event *)event; @@ -451,7 +451,7 @@ HWTEST_F(EnqueueWriteBufferRectTest, givenOutOfOrderQueueAndDstPtrEqualSrcPtrWit auto expectedTaskLevel = 19u; auto &productHelper = context->getDevice(0)->getProductHelper(); - if (productHelper.isNewCoherencyModelSupported()) { + if (!productHelper.isZeroCopyCpuAccessPreferred()) { expectedTaskLevel++; } auto pEvent = (Event *)event; @@ -486,7 +486,7 @@ HWTEST_F(EnqueueWriteBufferRectTest, givenInOrderQueueAndRowPitchEqualZeroAndDst EXPECT_EQ(CL_SUCCESS, retVal); auto expectedTaskLevel = 0u; auto &productHelper = context->getDevice(0)->getProductHelper(); - if (productHelper.isNewCoherencyModelSupported()) { + if (!productHelper.isZeroCopyCpuAccessPreferred()) { expectedTaskLevel++; } EXPECT_EQ(pCmdQ->taskLevel, expectedTaskLevel); @@ -516,7 +516,7 @@ HWTEST_F(EnqueueWriteBufferRectTest, givenInOrderQueueAndSlicePitchEqualZeroAndD EXPECT_EQ(CL_SUCCESS, retVal); auto &productHelper = context->getDevice(0)->getProductHelper(); auto expectedTaskLevel = 0u; - if (productHelper.isNewCoherencyModelSupported()) { + if (!productHelper.isZeroCopyCpuAccessPreferred()) { expectedTaskLevel++; } EXPECT_EQ(pCmdQ->taskLevel, expectedTaskLevel); @@ -547,7 +547,7 @@ HWTEST_F(EnqueueWriteBufferRectTest, givenInOrderQueueAndMemObjWithOffsetPointTh auto expectedTaskLevel = 0u; auto &productHelper = context->getDevice(0)->getProductHelper(); - if (productHelper.isNewCoherencyModelSupported()) { + if (!productHelper.isZeroCopyCpuAccessPreferred()) { expectedTaskLevel++; } EXPECT_EQ(pCmdQ->taskLevel, expectedTaskLevel); diff --git a/opencl/test/unit_test/command_queue/enqueue_write_buffer_tests.cpp b/opencl/test/unit_test/command_queue/enqueue_write_buffer_tests.cpp index fb0a85d5ee..a22af2f33f 100644 --- a/opencl/test/unit_test/command_queue/enqueue_write_buffer_tests.cpp +++ b/opencl/test/unit_test/command_queue/enqueue_write_buffer_tests.cpp @@ -340,7 +340,7 @@ HWTEST_F(EnqueueWriteBufferTypeTest, givenInOrderQueueAndEnabledSupportCpuCopies EXPECT_EQ(CL_SUCCESS, retVal); auto expectedTaskLevel = 0u; auto &productHelper = context->getDevice(0)->getProductHelper(); - if (productHelper.isNewCoherencyModelSupported()) { + if (!productHelper.isZeroCopyCpuAccessPreferred()) { expectedTaskLevel++; } EXPECT_EQ(pCmdQ->taskLevel, expectedTaskLevel); @@ -364,7 +364,7 @@ HWTEST_F(EnqueueWriteBufferTypeTest, givenInOrderQueueAndDisabledSupportCpuCopie EXPECT_EQ(CL_SUCCESS, retVal); auto expectedTaskLevel = 0u; auto &productHelper = context->getDevice(0)->getProductHelper(); - if (productHelper.isNewCoherencyModelSupported()) { + if (!productHelper.isZeroCopyCpuAccessPreferred()) { expectedTaskLevel++; } EXPECT_EQ(pCmdQ->taskLevel, expectedTaskLevel); diff --git a/opencl/test/unit_test/command_queue/read_write_buffer_cpu_copy.cpp b/opencl/test/unit_test/command_queue/read_write_buffer_cpu_copy.cpp index 1dab6aebfd..4bd3c7f84c 100644 --- a/opencl/test/unit_test/command_queue/read_write_buffer_cpu_copy.cpp +++ b/opencl/test/unit_test/command_queue/read_write_buffer_cpu_copy.cpp @@ -37,8 +37,7 @@ HWTEST_F(ReadWriteBufferCpuCopyTest, givenCompressedGmmWhenAskingForCpuOperation auto alignedPtr = alignedMalloc(2, MemoryConstants::cacheLineSize); auto unalignedPtr = ptrOffset(alignedPtr, 1); EXPECT_EQ(1u, allocation->storageInfo.getNumBanks()); - auto isNewCoherencyModel = pDevice->getProductHelper().isNewCoherencyModelSupported(); - EXPECT_EQ(!isNewCoherencyModel, buffer->isReadWriteOnCpuAllowed(*pDevice)); + EXPECT_TRUE(buffer->isReadWriteOnCpuAllowed(*pDevice)); EXPECT_TRUE(buffer->isReadWriteOnCpuPreferred(unalignedPtr, 1, *pDevice)); gmm->setCompressionEnabled(true); @@ -145,7 +144,7 @@ HWTEST_F(ReadWriteBufferCpuCopyTest, GivenUnalignedSrcPtrWhenWritingBufferThenMe delete[] bufferPtrBase; } -HWTEST_F(ReadWriteBufferCpuCopyTest, GivenSpecificMemoryStructuresAndOldCoherencyModelWhenReadingWritingMemoryThenCpuReadWriteIsAllowed) { +HWTEST_F(ReadWriteBufferCpuCopyTest, GivenSpecificMemoryStructuresAndCpuCachingAvailableWhenReadingWritingMemoryThenCpuReadWriteIsAllowed) { DebugManagerStateRestore restorer; debugManager.flags.ForceLocalMemoryAccessMode.set(static_cast(LocalMemoryAccessMode::defaultMode)); cl_int retVal; @@ -162,7 +161,7 @@ HWTEST_F(ReadWriteBufferCpuCopyTest, GivenSpecificMemoryStructuresAndOldCoherenc auto memoryManager = static_cast(mockDevice->getMemoryManager()); memoryManager->turnOnFakingBigAllocations(); auto &productHelper = mockDevice->getProductHelper(); - auto isZeroCopyAllowed = !productHelper.isNewCoherencyModelSupported(); + auto isZeroCopyAllowed = productHelper.isZeroCopyCpuAccessPreferred(); std::unique_ptr buffer(Buffer::create(context, CL_MEM_USE_HOST_PTR, size, alignedBufferPtr, retVal)); EXPECT_EQ(retVal, CL_SUCCESS); EXPECT_EQ(isZeroCopyAllowed, buffer->isMemObjZeroCopy()); @@ -199,7 +198,7 @@ HWTEST_F(ReadWriteBufferCpuCopyTest, GivenSpecificMemoryStructuresAndOldCoherenc alignedFree(alignedBufferPtr); } -HWTEST_F(ReadWriteBufferCpuCopyTest, GivenSpecificMemoryStructuresAndOldCoherencyModelWhenReadingWritingMemoryThenCpuReadWriteIsNotAllowed) { +HWTEST_F(ReadWriteBufferCpuCopyTest, GivenSpecificMemoryStructuresAndIsZeroCopyCpuAccessPreferredWhenReadingWritingMemoryThenCpuReadWriteIsNotAllowed) { cl_int retVal; size_t size = MemoryConstants::cacheLineSize; auto alignedBufferPtr = alignedMalloc(MemoryConstants::cacheLineSize + 1, MemoryConstants::cacheLineSize); @@ -215,7 +214,7 @@ HWTEST_F(ReadWriteBufferCpuCopyTest, GivenSpecificMemoryStructuresAndOldCoherenc auto memoryManager = static_cast(mockDevice->getMemoryManager()); memoryManager->turnOnFakingBigAllocations(); auto &productHelper = mockDevice->getProductHelper(); - auto isZeroCopyAllowed = !productHelper.isNewCoherencyModelSupported(); + auto isZeroCopyAllowed = productHelper.isZeroCopyCpuAccessPreferred(); std::unique_ptr buffer(Buffer::create(context, CL_MEM_USE_HOST_PTR, size, alignedBufferPtr, retVal)); EXPECT_EQ(retVal, CL_SUCCESS); EXPECT_EQ(isZeroCopyAllowed, buffer->isMemObjZeroCopy()); @@ -282,9 +281,9 @@ TEST(ReadWriteBufferOnCpu, givenNoHostPtrAndAlignedSizeWhenMemoryAllocationIsInN std::unique_ptr buffer(Buffer::create(&ctx, flags, MemoryConstants::pageSize, nullptr, retVal)); ASSERT_NE(nullptr, buffer.get()); - auto isNewCoherencyModelSupported = device->getProductHelper().isNewCoherencyModelSupported(); - EXPECT_EQ(!isNewCoherencyModelSupported, buffer->isReadWriteOnCpuAllowed(device->getDevice())); - EXPECT_EQ(!isNewCoherencyModelSupported, buffer->isReadWriteOnCpuPreferred(reinterpret_cast(0x1000), MemoryConstants::pageSize, device->getDevice())); + auto isZeroCopyCpuAccessPreferred = device->getProductHelper().isZeroCopyCpuAccessPreferred(); + EXPECT_EQ(isZeroCopyCpuAccessPreferred, buffer->isReadWriteOnCpuAllowed(device->getDevice())); + EXPECT_EQ(isZeroCopyCpuAccessPreferred, buffer->isReadWriteOnCpuPreferred(reinterpret_cast(0x1000), MemoryConstants::pageSize, device->getDevice())); reinterpret_cast(buffer->getGraphicsAllocation(device->getRootDeviceIndex()))->overrideMemoryPool(MemoryPool::systemCpuInaccessible); // read write on CPU is allowed, but not preferred. We can access this memory via Lock. EXPECT_TRUE(buffer->isReadWriteOnCpuAllowed(device->getDevice())); @@ -312,8 +311,8 @@ TEST(ReadWriteBufferOnCpu, givenPointerThatRequiresCpuCopyWhenCpuCopyIsEvaluated EXPECT_FALSE(mockCommandQueue->bufferCpuCopyAllowed(buffer.get(), CL_COMMAND_READ_BUFFER, false, MemoryConstants::pageSize, nullptr, 0u, nullptr)); memoryManager->cpuCopyRequired = true; // cpu copy is never allowed with new coherency model - auto isNewCoherencyModelSupported = device->getProductHelper().isNewCoherencyModelSupported(); - EXPECT_EQ(!isNewCoherencyModelSupported, mockCommandQueue->bufferCpuCopyAllowed(buffer.get(), CL_COMMAND_READ_BUFFER, false, MemoryConstants::pageSize, nullptr, 0u, nullptr)); + auto isZeroCopyCpuAccessPreferred = device->getProductHelper().isZeroCopyCpuAccessPreferred(); + EXPECT_EQ(isZeroCopyCpuAccessPreferred, mockCommandQueue->bufferCpuCopyAllowed(buffer.get(), CL_COMMAND_READ_BUFFER, false, MemoryConstants::pageSize, nullptr, 0u, nullptr)); } TEST(ReadWriteBufferOnCpu, givenPointerThatRequiresCpuCopyButItIsNotPossibleWhenCpuCopyIsEvaluatedThenFalseIsReturned) { diff --git a/opencl/test/unit_test/command_stream/command_stream_receiver_flush_task_2_tests.cpp b/opencl/test/unit_test/command_stream/command_stream_receiver_flush_task_2_tests.cpp index 0b7f1db105..8b0b9d2cba 100644 --- a/opencl/test/unit_test/command_stream/command_stream_receiver_flush_task_2_tests.cpp +++ b/opencl/test/unit_test/command_stream/command_stream_receiver_flush_task_2_tests.cpp @@ -253,7 +253,7 @@ HWTEST_F(CommandStreamReceiverFlushTaskTests, GivenDcFlushWhenFinishingThenTaskC auto ptr = mockCmdQueue.enqueueMapBuffer(buffer, CL_TRUE, CL_MAP_READ, 0, sizeof(tempBuffer), 0, nullptr, nullptr, retVal); EXPECT_EQ(retVal, CL_SUCCESS); auto &productHelper = pDevice->getProductHelper(); - auto expectFlushForMapUnmap = productHelper.isNewCoherencyModelSupported(); + auto expectFlushForMapUnmap = !productHelper.isZeroCopyCpuAccessPreferred(); EXPECT_EQ(1u + expectFlushForMapUnmap, commandStreamReceiver.peekLatestSentTaskCount()); // cmdQ task count = 2, finish again diff --git a/opencl/test/unit_test/context/driver_diagnostics_tests.h b/opencl/test/unit_test/context/driver_diagnostics_tests.h index 3c770555b0..779b32d1b7 100644 --- a/opencl/test/unit_test/context/driver_diagnostics_tests.h +++ b/opencl/test/unit_test/context/driver_diagnostics_tests.h @@ -142,7 +142,7 @@ struct PerformanceHintEnqueueBufferTest : public PerformanceHintEnqueueTest { address, retVal); auto &productHelper = context->getDevice(0)->getProductHelper(); - isZeroCopyAllowed = !productHelper.isNewCoherencyModelSupported(); + isZeroCopyAllowed = productHelper.isZeroCopyCpuAccessPreferred(); } void TearDown() override { diff --git a/opencl/test/unit_test/mem_obj/buffer_tests.cpp b/opencl/test/unit_test/mem_obj/buffer_tests.cpp index fc0d9de3d4..9d08328761 100644 --- a/opencl/test/unit_test/mem_obj/buffer_tests.cpp +++ b/opencl/test/unit_test/mem_obj/buffer_tests.cpp @@ -376,8 +376,8 @@ TEST(Buffer, givenNullptrPassedToBufferCreateWhenNoSharedContextOrCompressedBuff std::unique_ptr buffer(Buffer::create(&ctx, flags, MemoryConstants::pageSize, nullptr, retVal)); ASSERT_NE(nullptr, buffer.get()); - auto isNewCoherencyModelSupported = device->getProductHelper().isNewCoherencyModelSupported(); - if (MemoryPoolHelper::isSystemMemoryPool(buffer->getGraphicsAllocation(device->getRootDeviceIndex())->getMemoryPool()) && !isNewCoherencyModelSupported) { + auto isZeroCopyCpuAccessPreferred = device->getProductHelper().isZeroCopyCpuAccessPreferred(); + if (MemoryPoolHelper::isSystemMemoryPool(buffer->getGraphicsAllocation(device->getRootDeviceIndex())->getMemoryPool()) && isZeroCopyCpuAccessPreferred) { EXPECT_EQ(AllocationType::bufferHostMemory, buffer->getGraphicsAllocation(device->getRootDeviceIndex())->getAllocationType()); } else { EXPECT_EQ(AllocationType::buffer, buffer->getGraphicsAllocation(device->getRootDeviceIndex())->getAllocationType()); @@ -417,7 +417,7 @@ TEST(Buffer, givenAlignedHostPtrPassedToBufferCreateWhenNoSharedContextOrCompres std::unique_ptr buffer(Buffer::create(&ctx, flags, MemoryConstants::pageSize, hostPtr, retVal)); ASSERT_NE(nullptr, buffer.get()); - if (device->getProductHelper().isNewCoherencyModelSupported()) { + if (!device->getProductHelper().isZeroCopyCpuAccessPreferred()) { EXPECT_EQ(AllocationType::buffer, buffer->getMultiGraphicsAllocation().getAllocationType()); } else { EXPECT_EQ(AllocationType::bufferHostMemory, buffer->getMultiGraphicsAllocation().getAllocationType()); @@ -434,7 +434,7 @@ TEST(Buffer, givenAllocHostPtrFlagPassedToBufferCreateWhenNoSharedContextOrCompr std::unique_ptr buffer(Buffer::create(&ctx, flags, MemoryConstants::pageSize, nullptr, retVal)); ASSERT_NE(nullptr, buffer.get()); - if (device->getProductHelper().isNewCoherencyModelSupported()) { + if (!device->getProductHelper().isZeroCopyCpuAccessPreferred()) { EXPECT_EQ(AllocationType::buffer, buffer->getMultiGraphicsAllocation().getAllocationType()); } else { EXPECT_EQ(AllocationType::bufferHostMemory, buffer->getMultiGraphicsAllocation().getAllocationType()); @@ -449,7 +449,7 @@ TEST(Buffer, givenCompressedBuffersEnabledWhenAllocationTypeIsQueriedThenBufferC bool compressionEnabled = MemObjHelper::isSuitableForCompression(true, memoryProperties, context, true); EXPECT_TRUE(compressionEnabled); - auto type = MockPublicAccessBuffer::getGraphicsAllocationTypeAndCompressionPreference(memoryProperties, compressionEnabled, false, false); + auto type = MockPublicAccessBuffer::getGraphicsAllocationTypeAndCompressionPreference(memoryProperties, compressionEnabled, false, true); EXPECT_TRUE(compressionEnabled); EXPECT_EQ(AllocationType::buffer, type); } @@ -462,7 +462,7 @@ TEST(Buffer, givenCompressedBuffersDisabledLocalMemoryEnabledWhenAllocationTypeI bool compressionEnabled = MemObjHelper::isSuitableForCompression(false, memoryProperties, context, true); EXPECT_FALSE(compressionEnabled); - auto type = MockPublicAccessBuffer::getGraphicsAllocationTypeAndCompressionPreference(memoryProperties, compressionEnabled, true, false); + auto type = MockPublicAccessBuffer::getGraphicsAllocationTypeAndCompressionPreference(memoryProperties, compressionEnabled, true, true); EXPECT_FALSE(compressionEnabled); EXPECT_EQ(AllocationType::buffer, type); } @@ -476,7 +476,7 @@ TEST(Buffer, givenUseHostPtrFlagAndLocalMemoryDisabledWhenAllocationTypeIsQuerie bool compressionEnabled = MemObjHelper::isSuitableForCompression(false, memoryProperties, context, true); EXPECT_FALSE(compressionEnabled); - auto type = MockPublicAccessBuffer::getGraphicsAllocationTypeAndCompressionPreference(memoryProperties, compressionEnabled, false, false); + auto type = MockPublicAccessBuffer::getGraphicsAllocationTypeAndCompressionPreference(memoryProperties, compressionEnabled, false, true); EXPECT_FALSE(compressionEnabled); EXPECT_EQ(AllocationType::bufferHostMemory, type); } @@ -490,7 +490,7 @@ TEST(Buffer, givenUseHostPtrFlagAndLocalMemoryEnabledWhenAllocationTypeIsQueried bool compressionEnabled = MemObjHelper::isSuitableForCompression(false, memoryProperties, context, true); EXPECT_FALSE(compressionEnabled); - auto type = MockPublicAccessBuffer::getGraphicsAllocationTypeAndCompressionPreference(memoryProperties, compressionEnabled, true, false); + auto type = MockPublicAccessBuffer::getGraphicsAllocationTypeAndCompressionPreference(memoryProperties, compressionEnabled, true, true); EXPECT_FALSE(compressionEnabled); EXPECT_EQ(AllocationType::buffer, type); } @@ -504,7 +504,7 @@ TEST(Buffer, givenAllocHostPtrFlagWhenAllocationTypeIsQueriedThenBufferTypeIsRet bool compressionEnabled = MemObjHelper::isSuitableForCompression(false, memoryProperties, context, true); EXPECT_FALSE(compressionEnabled); - auto type = MockPublicAccessBuffer::getGraphicsAllocationTypeAndCompressionPreference(memoryProperties, compressionEnabled, false, false); + auto type = MockPublicAccessBuffer::getGraphicsAllocationTypeAndCompressionPreference(memoryProperties, compressionEnabled, false, true); EXPECT_FALSE(compressionEnabled); EXPECT_EQ(AllocationType::buffer, type); } @@ -518,7 +518,7 @@ TEST(Buffer, givenUseHostPtrFlagAndLocalMemoryDisabledAndCompressedBuffersEnable bool compressionEnabled = MemObjHelper::isSuitableForCompression(true, memoryProperties, context, true); EXPECT_TRUE(compressionEnabled); - auto type = MockPublicAccessBuffer::getGraphicsAllocationTypeAndCompressionPreference(memoryProperties, compressionEnabled, false, false); + auto type = MockPublicAccessBuffer::getGraphicsAllocationTypeAndCompressionPreference(memoryProperties, compressionEnabled, false, true); EXPECT_FALSE(compressionEnabled); EXPECT_EQ(AllocationType::bufferHostMemory, type); } @@ -532,7 +532,7 @@ TEST(Buffer, givenUseHostPtrFlagAndLocalMemoryEnabledAndCompressedBuffersEnabled bool compressionEnabled = MemObjHelper::isSuitableForCompression(true, memoryProperties, context, true); EXPECT_TRUE(compressionEnabled); - auto type = MockPublicAccessBuffer::getGraphicsAllocationTypeAndCompressionPreference(memoryProperties, compressionEnabled, true, false); + auto type = MockPublicAccessBuffer::getGraphicsAllocationTypeAndCompressionPreference(memoryProperties, compressionEnabled, true, true); EXPECT_TRUE(compressionEnabled); EXPECT_EQ(AllocationType::buffer, type); } @@ -546,7 +546,7 @@ TEST(Buffer, givenUseHostPointerFlagAndForceSharedPhysicalStorageWhenLocalMemory bool compressionEnabled = MemObjHelper::isSuitableForCompression(true, memoryProperties, context, true); EXPECT_TRUE(compressionEnabled); - auto type = MockPublicAccessBuffer::getGraphicsAllocationTypeAndCompressionPreference(memoryProperties, compressionEnabled, true, false); + auto type = MockPublicAccessBuffer::getGraphicsAllocationTypeAndCompressionPreference(memoryProperties, compressionEnabled, true, true); EXPECT_FALSE(compressionEnabled); EXPECT_EQ(AllocationType::bufferHostMemory, type); } @@ -560,7 +560,7 @@ TEST(Buffer, givenAllocHostPtrFlagAndCompressedBuffersEnabledWhenAllocationTypeI bool compressionEnabled = MemObjHelper::isSuitableForCompression(true, memoryProperties, context, true); EXPECT_TRUE(compressionEnabled); - auto type = MockPublicAccessBuffer::getGraphicsAllocationTypeAndCompressionPreference(memoryProperties, compressionEnabled, false, false); + auto type = MockPublicAccessBuffer::getGraphicsAllocationTypeAndCompressionPreference(memoryProperties, compressionEnabled, false, true); EXPECT_TRUE(compressionEnabled); EXPECT_EQ(AllocationType::buffer, type); } @@ -573,12 +573,12 @@ TEST(Buffer, givenZeroFlagsNoSharedContextAndCompressedBuffersDisabledWhenAlloca bool compressionEnabled = MemObjHelper::isSuitableForCompression(false, memoryProperties, context, true); EXPECT_FALSE(compressionEnabled); - auto type = MockPublicAccessBuffer::getGraphicsAllocationTypeAndCompressionPreference(memoryProperties, compressionEnabled, false, false); + auto type = MockPublicAccessBuffer::getGraphicsAllocationTypeAndCompressionPreference(memoryProperties, compressionEnabled, false, true); EXPECT_FALSE(compressionEnabled); EXPECT_EQ(AllocationType::buffer, type); } -TEST(Buffer, givenUseHostPtrFlagAndLocalMemoryDisabledAndCompressedBuffersEnabledAndNewCoherencyModelEnabledWhenAllocationTypeIsQueriedThenBufferMemoryTypeIsReturned) { +TEST(Buffer, givenUseHostPtrFlagAndLocalMemoryDisabledAndCompressedBuffersEnabledAndCachingOnCpuNotAvailableWhenAllocationTypeIsQueriedThenBufferMemoryTypeIsReturned) { cl_mem_flags flags = CL_MEM_USE_HOST_PTR; MockContext context; MemoryProperties memoryProperties = ClMemoryPropertiesHelper::createMemoryProperties(flags, 0, 0, &context.getDevice(0)->getDevice()); @@ -586,7 +586,7 @@ TEST(Buffer, givenUseHostPtrFlagAndLocalMemoryDisabledAndCompressedBuffersEnable bool compressionEnabled = MemObjHelper::isSuitableForCompression(true, memoryProperties, context, true); EXPECT_TRUE(compressionEnabled); - auto type = MockPublicAccessBuffer::getGraphicsAllocationTypeAndCompressionPreference(memoryProperties, compressionEnabled, false, true); + auto type = MockPublicAccessBuffer::getGraphicsAllocationTypeAndCompressionPreference(memoryProperties, compressionEnabled, false, false); EXPECT_TRUE(compressionEnabled); EXPECT_EQ(AllocationType::buffer, type); } @@ -772,7 +772,7 @@ TEST_F(CompressedBuffersTests, givenBufferNotCompressedAllocationAndNoHostPtrWhe buffer.reset(Buffer::create(context.get(), 0, bufferSize, nullptr, retVal)); auto allocation = buffer->getGraphicsAllocation(device->getRootDeviceIndex()); auto &productHelper = context->getDevice(0)->getProductHelper(); - if (MemoryPoolHelper::isSystemMemoryPool(allocation->getMemoryPool()) && !productHelper.isNewCoherencyModelSupported()) { + if (MemoryPoolHelper::isSystemMemoryPool(allocation->getMemoryPool()) && productHelper.isZeroCopyCpuAccessPreferred()) { EXPECT_EQ(allocation->getAllocationType(), AllocationType::bufferHostMemory); EXPECT_TRUE(buffer->isMemObjZeroCopy()); } else { @@ -789,7 +789,7 @@ TEST_F(CompressedBuffersTests, givenBufferNotCompressedAllocationAndNoHostPtrWhe if (gfxCoreHelper.isBufferSizeSuitableForCompression(bufferSize)) { EXPECT_EQ(allocation->getAllocationType(), AllocationType::buffer); EXPECT_EQ(!memoryManager->allocate32BitGraphicsMemoryImplCalled, allocation->isCompressionEnabled()); - } else if (productHelper.isNewCoherencyModelSupported()) { + } else if (!productHelper.isZeroCopyCpuAccessPreferred()) { EXPECT_EQ(allocation->getAllocationType(), AllocationType::buffer); } else { EXPECT_EQ(allocation->getAllocationType(), AllocationType::bufferHostMemory); @@ -811,7 +811,7 @@ TEST_F(CompressedBuffersTests, givenDebugVariableSetWhenHwFlagIsNotSetThenSelect if (gfxCoreHelper.isBufferSizeSuitableForCompression(bufferSize)) { EXPECT_EQ(graphicsAllocation->getAllocationType(), AllocationType::buffer); EXPECT_EQ(!memoryManager->allocate32BitGraphicsMemoryImplCalled, graphicsAllocation->isCompressionEnabled()); - } else if (productHelper.isNewCoherencyModelSupported()) { + } else if (!productHelper.isZeroCopyCpuAccessPreferred()) { EXPECT_EQ(graphicsAllocation->getAllocationType(), AllocationType::buffer); } else { EXPECT_EQ(graphicsAllocation->getAllocationType(), AllocationType::bufferHostMemory); @@ -1038,7 +1038,7 @@ TEST_P(NoHostPtr, WhenGettingAllocationTypeThenCorrectBufferTypeIsReturned) { auto allocation = buffer->getGraphicsAllocation(pClDevice->getRootDeviceIndex()); auto &productHelper = context->getDevice(0)->getProductHelper(); - if (MemoryPoolHelper::isSystemMemoryPool(allocation->getMemoryPool()) && !productHelper.isNewCoherencyModelSupported()) { + if (MemoryPoolHelper::isSystemMemoryPool(allocation->getMemoryPool()) && productHelper.isZeroCopyCpuAccessPreferred()) { EXPECT_EQ(allocation->getAllocationType(), AllocationType::bufferHostMemory); } else { EXPECT_EQ(allocation->getAllocationType(), AllocationType::buffer); @@ -1394,7 +1394,7 @@ TEST(Buffers64on32Tests, given32BitBufferCreatedWithUseHostPtrFlagThatIsZeroCopy EXPECT_EQ((void *)offsetedPtr, buffer->getCpuAddressForMapping()); auto &productHelper = context.getDevice(0)->getProductHelper(); - if (productHelper.isNewCoherencyModelSupported()) { + if (!productHelper.isZeroCopyCpuAccessPreferred()) { EXPECT_FALSE(buffer->isMemObjZeroCopy()); } else { EXPECT_TRUE(buffer->isMemObjZeroCopy()); @@ -1422,7 +1422,7 @@ TEST(Buffers64on32Tests, given32BitBufferCreatedWithAllocHostPtrFlagThatIsZeroCo retVal); EXPECT_EQ(CL_SUCCESS, retVal); auto &productHelper = context.getDevice(0)->getProductHelper(); - EXPECT_EQ(!productHelper.isNewCoherencyModelSupported(), buffer->isMemObjZeroCopy()); + EXPECT_EQ(productHelper.isZeroCopyCpuAccessPreferred(), buffer->isMemObjZeroCopy()); EXPECT_EQ(buffer->getCpuAddress(), buffer->getCpuAddressForMapping()); EXPECT_EQ(buffer->getCpuAddress(), buffer->getCpuAddressForMemoryTransfer()); diff --git a/opencl/test/unit_test/mem_obj/mem_obj_helper_tests.cpp b/opencl/test/unit_test/mem_obj/mem_obj_helper_tests.cpp index 211d7841b2..a106b47b18 100644 --- a/opencl/test/unit_test/mem_obj/mem_obj_helper_tests.cpp +++ b/opencl/test/unit_test/mem_obj/mem_obj_helper_tests.cpp @@ -170,22 +170,22 @@ TEST(MemObjHelper, givenContextWithMultipleRootDevicesWhenIsSuitableForCompressi EXPECT_FALSE(MemObjHelper::isSuitableForCompression(true, memoryProperties, context, true)); } -TEST(MemObjHelper, givenCompressionEnabledButNotPreferredWhenCompressionHintIsPassedThenCompressionIsUsed) { +TEST(MemObjHelper, givenCompressionEnabledButNotPreferredWhenCompressionHintIsPassedThenCompressionIsNotUsed) { cl_mem_flags_intel flagsIntel = CL_MEM_COMPRESSED_HINT_INTEL; cl_mem_flags flags = CL_MEM_COMPRESSED_HINT_INTEL; MockContext context; MemoryProperties memoryProperties = ClMemoryPropertiesHelper::createMemoryProperties(flags, flagsIntel, 0, &context.getDevice(0)->getDevice()); context.contextType = ContextType::CONTEXT_TYPE_DEFAULT; - EXPECT_TRUE(MemObjHelper::isSuitableForCompression(true, memoryProperties, context, false)); + EXPECT_FALSE(MemObjHelper::isSuitableForCompression(true, memoryProperties, context, false)); flags = CL_MEM_COMPRESSED_HINT_INTEL; flagsIntel = 0; memoryProperties = ClMemoryPropertiesHelper::createMemoryProperties(flags, flagsIntel, 0, &context.getDevice(0)->getDevice()); - EXPECT_TRUE(MemObjHelper::isSuitableForCompression(true, memoryProperties, context, false)); + EXPECT_FALSE(MemObjHelper::isSuitableForCompression(true, memoryProperties, context, false)); flagsIntel = CL_MEM_COMPRESSED_HINT_INTEL; flags = 0; memoryProperties = ClMemoryPropertiesHelper::createMemoryProperties(flags, flagsIntel, 0, &context.getDevice(0)->getDevice()); - EXPECT_TRUE(MemObjHelper::isSuitableForCompression(true, memoryProperties, context, false)); + EXPECT_FALSE(MemObjHelper::isSuitableForCompression(true, memoryProperties, context, false)); } TEST(MemObjHelper, givenCompressionEnabledAndPreferredWhenCompressionHintIsPassedThenCompressionIsUsed) { @@ -431,7 +431,7 @@ TEST(MemObjHelper, givenDifferentCapabilityAndDebugFlagValuesWhenCheckingBufferC bool compressionEnabled = MemObjHelper::isSuitableForCompression(GfxCoreHelper::compressedBuffersSupported(*defaultHwInfo), memoryProperties, context, true); MockPublicAccessBuffer::getGraphicsAllocationTypeAndCompressionPreference( - memoryProperties, compressionEnabled, false, false); + memoryProperties, compressionEnabled, false, true); bool expectBufferCompressed = ftrRenderCompressedBuffers && (enableMultiTileCompressionValue == 1); if (expectBufferCompressed) { @@ -483,7 +483,7 @@ TEST(MemObjHelper, givenDifferentValuesWhenCheckingBufferCompressionSupportThenC bool compressionEnabled = MemObjHelper::isSuitableForCompression(GfxCoreHelper::compressedBuffersSupported(*defaultHwInfo), memoryProperties, context, true); MockPublicAccessBuffer::getGraphicsAllocationTypeAndCompressionPreference( - memoryProperties, compressionEnabled, false, false); + memoryProperties, compressionEnabled, false, true); bool isCompressionDisabled = isValueSet(flags, CL_MEM_UNCOMPRESSED_HINT_INTEL) || isValueSet(flagsIntel, CL_MEM_UNCOMPRESSED_HINT_INTEL); diff --git a/opencl/test/unit_test/mem_obj/zero_copy_tests.cpp b/opencl/test/unit_test/mem_obj/zero_copy_tests.cpp index 48f9d605b1..16e96eff2e 100644 --- a/opencl/test/unit_test/mem_obj/zero_copy_tests.cpp +++ b/opencl/test/unit_test/mem_obj/zero_copy_tests.cpp @@ -85,7 +85,7 @@ TEST_P(ZeroCopyBufferTest, GivenCacheAlignedPointerWhenCreatingBufferThenZeroCop retVal); EXPECT_EQ(CL_SUCCESS, retVal); auto &productHelper = pClDevice->getProductHelper(); - shouldBeZeroCopy = shouldBeZeroCopy && !productHelper.isNewCoherencyModelSupported(); + shouldBeZeroCopy = shouldBeZeroCopy && productHelper.isZeroCopyCpuAccessPreferred(); EXPECT_EQ(shouldBeZeroCopy, buffer->isMemObjZeroCopy()) << "Zero Copy not handled properly"; if (!shouldBeZeroCopy && flags & CL_MEM_USE_HOST_PTR) { EXPECT_NE(buffer->getCpuAddress(), hostPtr); @@ -162,7 +162,7 @@ TEST(ZeroCopyBufferWith32BitAddressing, GivenDeviceSupporting32BitAddressingAndO std::unique_ptr buffer(Buffer::create(&context, CL_MEM_USE_HOST_PTR, size, hostPtr, retVal)); EXPECT_EQ(CL_SUCCESS, retVal); auto &productHelper = context.getDevice(0)->getProductHelper(); - if (productHelper.isNewCoherencyModelSupported()) { + if (!productHelper.isZeroCopyCpuAccessPreferred()) { EXPECT_FALSE(buffer->isMemObjZeroCopy()); } else { EXPECT_TRUE(buffer->isMemObjZeroCopy()); diff --git a/opencl/test/unit_test/xe_hpg_core/copy_engine_tests_xe_hpg_core.cpp b/opencl/test/unit_test/xe_hpg_core/copy_engine_tests_xe_hpg_core.cpp index 4217210ed2..0132a0bf8d 100644 --- a/opencl/test/unit_test/xe_hpg_core/copy_engine_tests_xe_hpg_core.cpp +++ b/opencl/test/unit_test/xe_hpg_core/copy_engine_tests_xe_hpg_core.cpp @@ -398,7 +398,7 @@ XE_HPG_CORETEST_F(BlitXeHpgCoreTests, givenCompressedBufferWhenProgrammingBltCom auto csr = static_cast *>(clDevice->getEngine(aub_stream::EngineType::ENGINE_BCS, EngineUsage::regular).commandStreamReceiver); MockContext context(clDevice.get()); - + debugManager.flags.OverrideBufferSuitableForRenderCompression.set(true); cl_int retVal = CL_SUCCESS; auto bufferCompressed = clUniquePtr(Buffer::create(&context, CL_MEM_READ_WRITE | CL_MEM_COMPRESSED_HINT_INTEL, 2048, nullptr, retVal)); bufferCompressed->getGraphicsAllocation(clDevice->getRootDeviceIndex())->getDefaultGmm()->setCompressionEnabled(true); @@ -460,7 +460,7 @@ XE_HPG_CORETEST_F(BlitXeHpgCoreTests, givenDebugFlagSetWhenCompressionEnabledThe uint32_t compressionFormat = 3; debugManager.flags.ForceBufferCompressionFormat.set(compressionFormat); - + debugManager.flags.OverrideBufferSuitableForRenderCompression.set(true); auto csr = static_cast *>(clDevice->getEngine(aub_stream::EngineType::ENGINE_BCS, EngineUsage::regular).commandStreamReceiver); MockContext context(clDevice.get()); diff --git a/shared/source/os_interface/product_helper.h b/shared/source/os_interface/product_helper.h index 215733b874..dd6731f03f 100644 --- a/shared/source/os_interface/product_helper.h +++ b/shared/source/os_interface/product_helper.h @@ -231,6 +231,7 @@ class ProductHelper { virtual std::optional getPreferredAllocationMethod(AllocationType allocationType) const = 0; virtual bool isCachingOnCpuAvailable() const = 0; virtual bool isNewCoherencyModelSupported() const = 0; + virtual bool isZeroCopyCpuAccessPreferred() const = 0; virtual bool deferMOCSToPatIndex() const = 0; virtual const std::vector getSupportedLocalDispatchSizes(const HardwareInfo &hwInfo) const = 0; virtual bool supportReadOnlyAllocations() const = 0; diff --git a/shared/source/os_interface/product_helper.inl b/shared/source/os_interface/product_helper.inl index 4818078703..1bd00ae080 100644 --- a/shared/source/os_interface/product_helper.inl +++ b/shared/source/os_interface/product_helper.inl @@ -873,6 +873,11 @@ bool ProductHelperHw::isNewCoherencyModelSupported() const { return false; } +template +bool ProductHelperHw::isZeroCopyCpuAccessPreferred() const { + return true; +} + template bool ProductHelperHw::supportReadOnlyAllocations() const { return false; diff --git a/shared/source/os_interface/product_helper_hw.h b/shared/source/os_interface/product_helper_hw.h index 191217c8cd..715c8356a1 100644 --- a/shared/source/os_interface/product_helper_hw.h +++ b/shared/source/os_interface/product_helper_hw.h @@ -175,6 +175,7 @@ class ProductHelperHw : public ProductHelper { std::optional getPreferredAllocationMethod(AllocationType allocationType) const override; bool isCachingOnCpuAvailable() const override; bool isNewCoherencyModelSupported() const override; + bool isZeroCopyCpuAccessPreferred() const override; bool deferMOCSToPatIndex() const override; bool supportReadOnlyAllocations() const override; const std::vector getSupportedLocalDispatchSizes(const HardwareInfo &hwInfo) const override; diff --git a/shared/source/xe_hpg_core/xe_lpg/os_agnostic_product_helper_xe_lpg.inl b/shared/source/xe_hpg_core/xe_lpg/os_agnostic_product_helper_xe_lpg.inl index b2613e324b..77cef20f31 100644 --- a/shared/source/xe_hpg_core/xe_lpg/os_agnostic_product_helper_xe_lpg.inl +++ b/shared/source/xe_hpg_core/xe_lpg/os_agnostic_product_helper_xe_lpg.inl @@ -108,6 +108,11 @@ bool ProductHelperHw::isNewCoherencyModelSupported() const { return true; } +template <> +bool ProductHelperHw::isZeroCopyCpuAccessPreferred() const { + return false; +} + template <> std::optional ProductHelperHw::isCoherentAllocation(uint64_t patIndex) const { std::array listOfCoherentPatIndexes = {3, 4}; diff --git a/shared/test/unit_test/os_interface/product_helper_tests.cpp b/shared/test/unit_test/os_interface/product_helper_tests.cpp index 0c11a590ce..ed1bea90a0 100644 --- a/shared/test/unit_test/os_interface/product_helper_tests.cpp +++ b/shared/test/unit_test/os_interface/product_helper_tests.cpp @@ -953,6 +953,10 @@ HWTEST_F(ProductHelperTest, givenProductHelperWhenAskingForDeviceToHostCopySigna EXPECT_FALSE(productHelper->isDeviceToHostCopySignalingFenceRequired()); } +HWTEST_F(ProductHelperTest, givenProductHelperWhenIsZeroCopyCpuAccessPreferredCalledThenReturnTrue) { + EXPECT_TRUE(productHelper->isZeroCopyCpuAccessPreferred()); +} + HWTEST2_F(ProductHelperTest, givenPatIndexWhenCheckIsCoherentAllocationThenReturnNullopt, IsAtMostPVC) { std::array listOfCoherentPatIndexes = {0, 1, 2, 3, 4}; for (auto patIndex : listOfCoherentPatIndexes) { diff --git a/shared/test/unit_test/xe_hpg_core/arl/excludes_xe_hpg_core_arl.cpp b/shared/test/unit_test/xe_hpg_core/arl/excludes_xe_hpg_core_arl.cpp index 8d104e69cb..3deb8dfe03 100644 --- a/shared/test/unit_test/xe_hpg_core/arl/excludes_xe_hpg_core_arl.cpp +++ b/shared/test/unit_test/xe_hpg_core/arl/excludes_xe_hpg_core_arl.cpp @@ -23,3 +23,4 @@ HWTEST_EXCLUDE_PRODUCT(ProductHelperTest, givenProductHelperWhenCheckBlitEnqueue HWTEST_EXCLUDE_PRODUCT(ProductHelperTest, whenGettingPreferredAllocationMethodThenNoPreferenceIsReturned, IGFX_ARROWLAKE); HWTEST_EXCLUDE_PRODUCT(ProductHelperTest, givenBooleanUncachedWhenCallOverridePatIndexThenProperPatIndexIsReturned, IGFX_ARROWLAKE); HWTEST_EXCLUDE_PRODUCT(ProductHelperTest, givenProductHelperWhenCheckDummyBlitWaRequiredThenReturnFalse, IGFX_ARROWLAKE); +HWTEST_EXCLUDE_PRODUCT(ProductHelperTest, givenProductHelperWhenIsZeroCopyCpuAccessPreferredCalledThenReturnTrue, IGFX_ARROWLAKE); diff --git a/shared/test/unit_test/xe_hpg_core/mtl/excludes_xe_hpg_core_mtl.cpp b/shared/test/unit_test/xe_hpg_core/mtl/excludes_xe_hpg_core_mtl.cpp index 82062d5799..1c29e635bd 100644 --- a/shared/test/unit_test/xe_hpg_core/mtl/excludes_xe_hpg_core_mtl.cpp +++ b/shared/test/unit_test/xe_hpg_core/mtl/excludes_xe_hpg_core_mtl.cpp @@ -19,3 +19,4 @@ HWTEST_EXCLUDE_PRODUCT(ProductHelperTest, givenProductHelperWhenCheckBlitEnqueue HWTEST_EXCLUDE_PRODUCT(ProductHelperTest, whenGettingPreferredAllocationMethodThenNoPreferenceIsReturned, IGFX_METEORLAKE); HWTEST_EXCLUDE_PRODUCT(ProductHelperTest, givenBooleanUncachedWhenCallOverridePatIndexThenProperPatIndexIsReturned, IGFX_METEORLAKE); HWTEST_EXCLUDE_PRODUCT(ProductHelperTest, givenProductHelperWhenCheckDummyBlitWaRequiredThenReturnFalse, IGFX_METEORLAKE); +HWTEST_EXCLUDE_PRODUCT(ProductHelperTest, givenProductHelperWhenIsZeroCopyCpuAccessPreferredCalledThenReturnTrue, IGFX_METEORLAKE); \ No newline at end of file diff --git a/shared/test/unit_test/xe_hpg_core/os_agnostic_product_helper_xe_lpg_tests.cpp b/shared/test/unit_test/xe_hpg_core/os_agnostic_product_helper_xe_lpg_tests.cpp index cbef2bc69f..6e7d565180 100644 --- a/shared/test/unit_test/xe_hpg_core/os_agnostic_product_helper_xe_lpg_tests.cpp +++ b/shared/test/unit_test/xe_hpg_core/os_agnostic_product_helper_xe_lpg_tests.cpp @@ -354,6 +354,10 @@ HWTEST2_F(XeLpgProductHelperTests, givenProductHelperWhenCallIsNewCoherencyModel EXPECT_TRUE(productHelper->isNewCoherencyModelSupported()); } +HWTEST2_F(XeLpgProductHelperTests, givenProductHelperWhenIsZeroCopyCpuAccessPreferredCalledThenReturnFalse, IsXeLpg) { + EXPECT_FALSE(productHelper->isZeroCopyCpuAccessPreferred()); +} + HWTEST2_F(XeLpgProductHelperTests, givenProductHelperWhenCallDeferMOCSToPatThenFalseIsReturned, IsXeLpg) { const auto &productHelper = getHelper(); EXPECT_FALSE(productHelper.deferMOCSToPatIndex());