From a96f2ea13a2c91bfb4750ded95f2cbcd1d2ac374 Mon Sep 17 00:00:00 2001 From: Lukasz Jobczyk Date: Wed, 3 Jul 2024 13:28:55 +0000 Subject: [PATCH] performance: disable blit enqueue on LNL Resolves: NEO-11471 Signed-off-by: Lukasz Jobczyk --- opencl/source/command_queue/command_queue.cpp | 3 ++- .../aub_tests/fixtures/image_aub_fixture.h | 4 ++-- .../command_queue/command_queue_tests.cpp | 23 +++++++++++++++++-- .../unit_test/mem_obj/buffer_bcs_tests.cpp | 4 ++-- opencl/test/unit_test/mocks/mock_image.h | 1 + shared/source/os_interface/product_helper.h | 3 ++- shared/source/os_interface/product_helper.inl | 2 +- .../source/os_interface/product_helper_hw.h | 2 +- .../os_agnostic_product_helper_xe_lpg.inl | 2 +- .../os_interface/product_helper_tests.cpp | 2 +- ...s_agnostic_product_helper_xe_lpg_tests.cpp | 2 +- 11 files changed, 35 insertions(+), 13 deletions(-) diff --git a/opencl/source/command_queue/command_queue.cpp b/opencl/source/command_queue/command_queue.cpp index 161c2bf446..8bdd9a2632 100644 --- a/opencl/source/command_queue/command_queue.cpp +++ b/opencl/source/command_queue/command_queue.cpp @@ -1061,7 +1061,8 @@ bool CommandQueue::queueDependenciesClearRequired() const { } bool CommandQueue::blitEnqueueAllowed(const CsrSelectionArgs &args) const { - bool blitEnqueueAllowed = ((device->getRootDeviceEnvironment().isWddmOnLinux() || device->getRootDeviceEnvironment().getProductHelper().blitEnqueueAllowed()) && getGpgpuCommandStreamReceiver().peekTimestampPacketWriteEnabled()) || this->isCopyOnly; + auto isWriteToImageFromBuffer = args.dstResource.image && args.dstResource.image->isImageFromBuffer(); + bool blitEnqueueAllowed = ((device->getRootDeviceEnvironment().isWddmOnLinux() || device->getRootDeviceEnvironment().getProductHelper().blitEnqueueAllowed(isWriteToImageFromBuffer)) && getGpgpuCommandStreamReceiver().peekTimestampPacketWriteEnabled()) || this->isCopyOnly; if (debugManager.flags.EnableBlitterForEnqueueOperations.get() != -1) { blitEnqueueAllowed = debugManager.flags.EnableBlitterForEnqueueOperations.get(); } diff --git a/opencl/test/unit_test/aub_tests/fixtures/image_aub_fixture.h b/opencl/test/unit_test/aub_tests/fixtures/image_aub_fixture.h index 682734dc8d..2a108b29a1 100644 --- a/opencl/test/unit_test/aub_tests/fixtures/image_aub_fixture.h +++ b/opencl/test/unit_test/aub_tests/fixtures/image_aub_fixture.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2022-2023 Intel Corporation + * Copyright (C) 2022-2024 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -33,7 +33,7 @@ struct ImageAubFixture : public AUBCommandStreamFixture { MockExecutionEnvironment mockExecutionEnvironment{}; auto &productHelper = mockExecutionEnvironment.rootDeviceEnvironments[rootDeviceIndex]->getHelper(); - if (!productHelper.isBlitterForImagesSupported() || !productHelper.blitEnqueueAllowed()) { + if (!productHelper.isBlitterForImagesSupported() || !productHelper.blitEnqueueAllowed(false)) { GTEST_SKIP(); } diff --git a/opencl/test/unit_test/command_queue/command_queue_tests.cpp b/opencl/test/unit_test/command_queue/command_queue_tests.cpp index 8235679587..fe8341c273 100644 --- a/opencl/test/unit_test/command_queue/command_queue_tests.cpp +++ b/opencl/test/unit_test/command_queue/command_queue_tests.cpp @@ -1693,7 +1693,7 @@ TEST(CommandQueue, givenCopyOnlyQueueWhenCallingBlitEnqueueAllowedThenReturnTrue CsrSelectionArgs selectionArgs{CL_COMMAND_READ_BUFFER, &multiAlloc, &multiAlloc, 0u, nullptr}; queue.isCopyOnly = false; - EXPECT_EQ(queue.getGpgpuCommandStreamReceiver().peekTimestampPacketWriteEnabled() && context.getDevice(0)->getProductHelper().blitEnqueueAllowed(), + EXPECT_EQ(queue.getGpgpuCommandStreamReceiver().peekTimestampPacketWriteEnabled() && context.getDevice(0)->getProductHelper().blitEnqueueAllowed(false), queue.blitEnqueueAllowed(selectionArgs)); queue.isCopyOnly = true; @@ -1720,7 +1720,7 @@ TEST(CommandQueue, givenSimpleClCommandWhenCallingBlitEnqueueAllowedThenReturnCo CL_COMMAND_SVM_MEMCPY}) { CsrSelectionArgs args{cmdType, &multiAlloc, &multiAlloc, 0u, nullptr}; - bool expectedValue = queue.getGpgpuCommandStreamReceiver().peekTimestampPacketWriteEnabled() && context.getDevice(0)->getProductHelper().blitEnqueueAllowed(); + bool expectedValue = queue.getGpgpuCommandStreamReceiver().peekTimestampPacketWriteEnabled() && context.getDevice(0)->getProductHelper().blitEnqueueAllowed(false); if (cmdType == CL_COMMAND_COPY_IMAGE_TO_BUFFER) { expectedValue = false; } @@ -1785,6 +1785,25 @@ TEST(CommandQueue, givenImageToBufferClCommandWhenCallingBlitEnqueueAllowedThenR EXPECT_FALSE(queue.blitEnqueueAllowed(args)); } +TEST(CommandQueue, givenWriteToImageFromBufferWhenCallingBlitEnqueueAllowedThenReturnCorrectValue) { + MockContext context{}; + MockCommandQueue queue(&context, context.getDevice(0), 0, false); + if (queue.countBcsEngines() == 0) { + queue.bcsEngines[0] = &context.getDevice(0)->getDefaultEngine(); + } + + auto buffer = std::unique_ptr(BufferHelper<>::create(&context)); + size_t origin[3] = {0, 0, 0}; + size_t region[3] = {1, 1, 1}; + MockImageBase dstImage{}; + dstImage.associatedMemObject = buffer.get(); + + CsrSelectionArgs args{CL_COMMAND_WRITE_IMAGE, nullptr, &dstImage, 0u, region, nullptr, origin}; + + bool expectedValue = queue.getGpgpuCommandStreamReceiver().peekTimestampPacketWriteEnabled() && context.getDevice(0)->getProductHelper().blitEnqueueAllowed(true) && context.getDevice(0)->getProductHelper().isBlitterForImagesSupported(); + EXPECT_EQ(queue.blitEnqueueAllowed(args), expectedValue); +} + TEST(CommandQueue, givenBufferWhenMultiStorageIsNotSetThenDontRequireMigrations) { MockDefaultContext context{true}; MockCommandQueue queue(&context, context.getDevice(1), 0, false); diff --git a/opencl/test/unit_test/mem_obj/buffer_bcs_tests.cpp b/opencl/test/unit_test/mem_obj/buffer_bcs_tests.cpp index 94fe211175..d2ce6bc6db 100644 --- a/opencl/test/unit_test/mem_obj/buffer_bcs_tests.cpp +++ b/opencl/test/unit_test/mem_obj/buffer_bcs_tests.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2020-2023 Intel Corporation + * Copyright (C) 2020-2024 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -173,7 +173,7 @@ HWTEST_F(NoBcsBufferTests, givenProductWithNoFullyBlitterSupportWhenCreatingBuff } HWTEST_TEMPLATED_F(BcsBufferTests, givenBcsSupportedWhenEnqueueBufferOperationIsCalledThenUseBcsCsr) { - if (!device->getRootDeviceEnvironment().getProductHelper().blitEnqueueAllowed()) { + if (!device->getRootDeviceEnvironment().getProductHelper().blitEnqueueAllowed(false)) { GTEST_SKIP(); } diff --git a/opencl/test/unit_test/mocks/mock_image.h b/opencl/test/unit_test/mocks/mock_image.h index f095dfd7ca..d21aa199c5 100644 --- a/opencl/test/unit_test/mocks/mock_image.h +++ b/opencl/test/unit_test/mocks/mock_image.h @@ -16,6 +16,7 @@ namespace NEO { struct MockImageBase : public Image { + using Image::associatedMemObject; using Image::imageDesc; using Image::imageFormat; using Image::is3DUAVOrRTV; diff --git a/shared/source/os_interface/product_helper.h b/shared/source/os_interface/product_helper.h index 6b01710d82..906d67f183 100644 --- a/shared/source/os_interface/product_helper.h +++ b/shared/source/os_interface/product_helper.h @@ -37,6 +37,7 @@ struct StateComputeModeProperties; struct StateComputeModePropertiesSupport; class ProductHelper; class ReleaseHelper; +class Image; class GraphicsAllocation; class MemoryManager; struct RootDeviceEnvironment; @@ -166,7 +167,7 @@ class ProductHelper { virtual uint32_t getL1CachePolicy(bool isDebuggerActive) const = 0; virtual bool isEvictionIfNecessaryFlagSupported() const = 0; virtual void adjustNumberOfCcs(HardwareInfo &hwInfo) const = 0; - virtual bool blitEnqueueAllowed() const = 0; + virtual bool blitEnqueueAllowed(bool isWriteToImageFromBuffer) const = 0; virtual bool isPrefetcherDisablingInDirectSubmissionRequired() const = 0; virtual bool isStatefulAddressingModeSupported() const = 0; virtual bool isPlatformQuerySupported() const = 0; diff --git a/shared/source/os_interface/product_helper.inl b/shared/source/os_interface/product_helper.inl index 87b3352ecd..36818cb2b6 100644 --- a/shared/source/os_interface/product_helper.inl +++ b/shared/source/os_interface/product_helper.inl @@ -377,7 +377,7 @@ bool ProductHelperHw::isPageFaultSupported() const { } template -bool ProductHelperHw::blitEnqueueAllowed() const { +bool ProductHelperHw::blitEnqueueAllowed(bool isWriteToImageFromBuffer) const { return true; } diff --git a/shared/source/os_interface/product_helper_hw.h b/shared/source/os_interface/product_helper_hw.h index 0ace577c80..1ae2fbc4df 100644 --- a/shared/source/os_interface/product_helper_hw.h +++ b/shared/source/os_interface/product_helper_hw.h @@ -70,7 +70,7 @@ class ProductHelperHw : public ProductHelper { bool isStorageInfoAdjustmentRequired() const override; bool isBlitterForImagesSupported() const override; bool isPageFaultSupported() const override; - bool blitEnqueueAllowed() const override; + bool blitEnqueueAllowed(bool isWriteToImageFromBuffer) const override; bool isKmdMigrationSupported() const override; bool isDisableScratchPagesSupported() const override; bool isTile64With3DSurfaceOnBCSSupported(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 efb28005bc..b2613e324b 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 @@ -44,7 +44,7 @@ bool ProductHelperHw::isEvictionIfNecessaryFlagSupported() const { } template <> -bool ProductHelperHw::blitEnqueueAllowed() const { +bool ProductHelperHw::blitEnqueueAllowed(bool isWriteToImageFromBuffer) const { return false; } 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 4110de4e91..65ba7d6ace 100644 --- a/shared/test/unit_test/os_interface/product_helper_tests.cpp +++ b/shared/test/unit_test/os_interface/product_helper_tests.cpp @@ -480,7 +480,7 @@ HWTEST2_F(ProductHelperTest, givenProductHelperWhenAskedIfDisableScratchPagesIsS } HWTEST_F(ProductHelperTest, givenProductHelperWhenCheckBlitEnqueueAllowedThenReturnTrue) { - EXPECT_TRUE(productHelper->blitEnqueueAllowed()); + EXPECT_TRUE(productHelper->blitEnqueueAllowed(false)); } HWTEST_F(ProductHelperTest, givenProductHelperWhenAskedIfTile64With3DSurfaceOnBCSIsSupportedThenTrueIsReturned) { 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 5d27d3207b..cbef2bc69f 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 @@ -193,7 +193,7 @@ HWTEST2_F(XeLpgProductHelperTests, givenProductHelperWhenGettingEvictIfNecessary } HWTEST2_F(XeLpgProductHelperTests, givenProductHelperWhenCheckBlitEnqueueAllowedThenReturnFalse, IsXeLpg) { - EXPECT_FALSE(productHelper->blitEnqueueAllowed()); + EXPECT_FALSE(productHelper->blitEnqueueAllowed(false)); } HWTEST2_F(XeLpgProductHelperTests, givenProductHelperWhenCallGetInternalHeapsPreallocatedThenReturnCorrectValue, IsXeLpg) {