From 4076d3e294a046b12ec40328b3207977b150d6d0 Mon Sep 17 00:00:00 2001 From: Filip Hazubski Date: Wed, 1 Jul 2020 14:12:53 +0200 Subject: [PATCH] Update BlitCommandsHelper Add getMaxBlitWidthOverride and getMaxBlitHeightOverride functions. Change-Id: Idf23725f5d3336118979c2b5731b023d934374d6 Signed-off-by: Filip Hazubski --- .../command_stream_receiver_hw_tests.cpp | 30 ++++++++----- .../command_stream_receiver_hw_base.inl | 3 +- shared/source/helpers/blit_commands_helper.h | 12 ++++-- .../helpers/blit_commands_helper_base.inl | 43 ++++++++++++------- .../helpers/blit_commands_helper_bdw_plus.inl | 10 +++++ .../helpers/blit_commands_helper_tests.cpp | 8 ++-- 6 files changed, 72 insertions(+), 34 deletions(-) diff --git a/opencl/test/unit_test/command_stream/command_stream_receiver_hw_tests.cpp b/opencl/test/unit_test/command_stream/command_stream_receiver_hw_tests.cpp index 0ede7763e8..b1e1d88515 100644 --- a/opencl/test/unit_test/command_stream/command_stream_receiver_hw_tests.cpp +++ b/opencl/test/unit_test/command_stream/command_stream_receiver_hw_tests.cpp @@ -381,8 +381,10 @@ HWTEST_F(BcsTests, givenBltSizeWhenEstimatingCommandSizeThenAddAllRequiredComman auto expectedAlignedSize = cmdsSizePerBlit * alignedNumberOfBlts; auto expectedNotAlignedSize = cmdsSizePerBlit * notAlignedNumberOfBlts; - auto alignedEstimatedSize = BlitCommandsHelper::estimateBlitCommandsSize({alignedBltSize, 1, 1}, csrDependencies, false, false); - auto notAlignedEstimatedSize = BlitCommandsHelper::estimateBlitCommandsSize({notAlignedBltSize, 1, 1}, csrDependencies, false, false); + auto alignedEstimatedSize = BlitCommandsHelper::estimateBlitCommandsSize( + {alignedBltSize, 1, 1}, csrDependencies, false, false, pClDevice->getRootDeviceEnvironment()); + auto notAlignedEstimatedSize = BlitCommandsHelper::estimateBlitCommandsSize( + {notAlignedBltSize, 1, 1}, csrDependencies, false, false, pClDevice->getRootDeviceEnvironment()); EXPECT_EQ(expectedAlignedSize, alignedEstimatedSize); EXPECT_EQ(expectedNotAlignedSize, notAlignedEstimatedSize); @@ -405,7 +407,8 @@ HWTEST_F(BcsTests, givenDebugCapabilityWhenEstimatingCommandSizeThenAddAllRequir BlitPropertiesContainer blitPropertiesContainer; blitPropertiesContainer.push_back(blitProperties); - auto estimatedSize = BlitCommandsHelper::estimateBlitCommandsSize(blitPropertiesContainer, pDevice->getHardwareInfo(), false, true); + auto estimatedSize = BlitCommandsHelper::estimateBlitCommandsSize( + blitPropertiesContainer, false, true, pClDevice->getRootDeviceEnvironment()); EXPECT_EQ(expectedSize, estimatedSize); } @@ -421,8 +424,10 @@ HWTEST_F(BcsTests, givenBltSizeWhenEstimatingCommandSizeForReadBufferRectThenAdd auto expectedAlignedSize = cmdsSizePerBlit * alignedNumberOfBlts; auto expectedNotAlignedSize = cmdsSizePerBlit * notAlignedNumberOfBlts; - auto alignedEstimatedSize = BlitCommandsHelper::estimateBlitCommandsSize(alignedBltSize, csrDependencies, false, false); - auto notAlignedEstimatedSize = BlitCommandsHelper::estimateBlitCommandsSize(notAlignedBltSize, csrDependencies, false, false); + auto alignedEstimatedSize = BlitCommandsHelper::estimateBlitCommandsSize( + alignedBltSize, csrDependencies, false, false, pClDevice->getRootDeviceEnvironment()); + auto notAlignedEstimatedSize = BlitCommandsHelper::estimateBlitCommandsSize( + notAlignedBltSize, csrDependencies, false, false, pClDevice->getRootDeviceEnvironment()); EXPECT_EQ(expectedAlignedSize, alignedEstimatedSize); EXPECT_EQ(expectedNotAlignedSize, notAlignedEstimatedSize); @@ -462,7 +467,8 @@ HWTEST_F(BcsTests, givenBlitPropertiesContainerWhenExstimatingCommandsSizeThenCa expectedAlignedSize = alignUp(expectedAlignedSize, MemoryConstants::cacheLineSize); - auto alignedEstimatedSize = BlitCommandsHelper::estimateBlitCommandsSize(blitPropertiesContainer, pDevice->getHardwareInfo(), false, false); + auto alignedEstimatedSize = BlitCommandsHelper::estimateBlitCommandsSize( + blitPropertiesContainer, false, false, pClDevice->getRootDeviceEnvironment()); EXPECT_EQ(expectedAlignedSize, alignedEstimatedSize); } @@ -490,7 +496,8 @@ HWTEST_F(BcsTests, givenBlitPropertiesContainerWhenExstimatingCommandsSizeForWri expectedAlignedSize = alignUp(expectedAlignedSize, MemoryConstants::cacheLineSize); - auto alignedEstimatedSize = BlitCommandsHelper::estimateBlitCommandsSize(blitPropertiesContainer, pDevice->getHardwareInfo(), false, false); + auto alignedEstimatedSize = BlitCommandsHelper::estimateBlitCommandsSize( + blitPropertiesContainer, false, false, pClDevice->getRootDeviceEnvironment()); EXPECT_EQ(expectedAlignedSize, alignedEstimatedSize); } @@ -501,8 +508,10 @@ HWTEST_F(BcsTests, givenTimestampPacketWriteRequestWhenEstimatingSizeForCommands auto expectedSizeWithTimestampPacketWrite = expectedBaseSize + EncodeMiFlushDW::getMiFlushDwCmdSizeForDataWrite(); auto expectedSizeWithoutTimestampPacketWrite = expectedBaseSize; - auto estimatedSizeWithTimestampPacketWrite = BlitCommandsHelper::estimateBlitCommandsSize({1, 1, 1}, csrDependencies, true, false); - auto estimatedSizeWithoutTimestampPacketWrite = BlitCommandsHelper::estimateBlitCommandsSize({1, 1, 1}, csrDependencies, false, false); + auto estimatedSizeWithTimestampPacketWrite = BlitCommandsHelper::estimateBlitCommandsSize( + {1, 1, 1}, csrDependencies, true, false, pClDevice->getRootDeviceEnvironment()); + auto estimatedSizeWithoutTimestampPacketWrite = BlitCommandsHelper::estimateBlitCommandsSize( + {1, 1, 1}, csrDependencies, false, false, pClDevice->getRootDeviceEnvironment()); EXPECT_EQ(expectedSizeWithTimestampPacketWrite, estimatedSizeWithTimestampPacketWrite); EXPECT_EQ(expectedSizeWithoutTimestampPacketWrite, estimatedSizeWithoutTimestampPacketWrite); @@ -522,7 +531,8 @@ HWTEST_F(BcsTests, givenBltSizeAndCsrDependenciesWhenEstimatingCommandSizeThenAd size_t expectedSize = (cmdsSizePerBlit * numberOfBlts) + TimestampPacketHelper::getRequiredCmdStreamSize(csrDependencies); - auto estimatedSize = BlitCommandsHelper::estimateBlitCommandsSize({1, 1, 1}, csrDependencies, false, false); + auto estimatedSize = BlitCommandsHelper::estimateBlitCommandsSize( + {1, 1, 1}, csrDependencies, false, false, pClDevice->getRootDeviceEnvironment()); EXPECT_EQ(expectedSize, estimatedSize); } diff --git a/shared/source/command_stream/command_stream_receiver_hw_base.inl b/shared/source/command_stream/command_stream_receiver_hw_base.inl index fce0b0220e..dd1d2a8055 100644 --- a/shared/source/command_stream/command_stream_receiver_hw_base.inl +++ b/shared/source/command_stream/command_stream_receiver_hw_base.inl @@ -874,7 +874,8 @@ uint32_t CommandStreamReceiverHw::blitBuffer(const BlitPropertiesCont bool pauseOnBlitCopyAllowed = (DebugManager.flags.PauseOnBlitCopy.get() == static_cast(taskCount)); - auto &commandStream = getCS(BlitCommandsHelper::estimateBlitCommandsSize(blitPropertiesContainer, peekHwInfo(), profilingEnabled, pauseOnBlitCopyAllowed)); + auto &commandStream = getCS(BlitCommandsHelper::estimateBlitCommandsSize(blitPropertiesContainer, profilingEnabled, pauseOnBlitCopyAllowed, + *this->executionEnvironment.rootDeviceEnvironments[this->rootDeviceIndex])); auto commandStreamStart = commandStream.getUsed(); auto newTaskCount = taskCount + 1; latestSentTaskCount = newTaskCount; diff --git a/shared/source/helpers/blit_commands_helper.h b/shared/source/helpers/blit_commands_helper.h index 454c26e77f..639d00b485 100644 --- a/shared/source/helpers/blit_commands_helper.h +++ b/shared/source/helpers/blit_commands_helper.h @@ -80,12 +80,16 @@ struct BlitProperties { template struct BlitCommandsHelper { using COLOR_DEPTH = typename GfxFamily::XY_COLOR_BLT::COLOR_DEPTH; - static uint64_t getMaxBlitWidth(); - static uint64_t getMaxBlitHeight(); + static uint64_t getMaxBlitWidth(const RootDeviceEnvironment &rootDeviceEnvironment); + static uint64_t getMaxBlitWidthOverride(const RootDeviceEnvironment &rootDeviceEnvironment); + static uint64_t getMaxBlitHeight(const RootDeviceEnvironment &rootDeviceEnvironment); + static uint64_t getMaxBlitHeightOverride(const RootDeviceEnvironment &rootDeviceEnvironment); static void dispatchPostBlitCommand(LinearStream &linearStream); static size_t estimatePostBlitCommandSize(); - static size_t estimateBlitCommandsSize(Vec3 copySize, const CsrDependencies &csrDependencies, bool updateTimestampPacket, bool profilingEnabled); - static size_t estimateBlitCommandsSize(const BlitPropertiesContainer &blitPropertiesContainer, const HardwareInfo &hwInfo, bool profilingEnabled, bool debugPauseEnabled); + static size_t estimateBlitCommandsSize(Vec3 copySize, const CsrDependencies &csrDependencies, bool updateTimestampPacket, + bool profilingEnabled, const RootDeviceEnvironment &rootDeviceEnvironment); + static size_t estimateBlitCommandsSize(const BlitPropertiesContainer &blitPropertiesContainer, bool profilingEnabled, + bool debugPauseEnabled, const RootDeviceEnvironment &rootDeviceEnvironment); static uint64_t calculateBlitCommandDestinationBaseAddress(const BlitProperties &blitProperties, uint64_t offset, uint64_t row, uint64_t slice); static uint64_t calculateBlitCommandSourceBaseAddress(const BlitProperties &blitProperties, uint64_t offset, uint64_t row, uint64_t slice); static void dispatchBlitCommandsForBuffer(const BlitProperties &blitProperties, LinearStream &linearStream, const RootDeviceEnvironment &rootDeviceEnvironment); diff --git a/shared/source/helpers/blit_commands_helper_base.inl b/shared/source/helpers/blit_commands_helper_base.inl index 95650eed9b..6e69b82ec6 100644 --- a/shared/source/helpers/blit_commands_helper_base.inl +++ b/shared/source/helpers/blit_commands_helper_base.inl @@ -16,18 +16,26 @@ namespace NEO { template -uint64_t BlitCommandsHelper::getMaxBlitWidth() { +uint64_t BlitCommandsHelper::getMaxBlitWidth(const RootDeviceEnvironment &rootDeviceEnvironment) { if (DebugManager.flags.LimitBlitterMaxWidth.get() != -1) { return static_cast(DebugManager.flags.LimitBlitterMaxWidth.get()); } + auto maxBlitWidthOverride = getMaxBlitWidthOverride(rootDeviceEnvironment); + if (maxBlitWidthOverride > 0) { + return maxBlitWidthOverride; + } return BlitterConstants::maxBlitWidth; } template -uint64_t BlitCommandsHelper::getMaxBlitHeight() { +uint64_t BlitCommandsHelper::getMaxBlitHeight(const RootDeviceEnvironment &rootDeviceEnvironment) { if (DebugManager.flags.LimitBlitterMaxHeight.get() != -1) { return static_cast(DebugManager.flags.LimitBlitterMaxHeight.get()); } + auto maxBlitHeightOverride = getMaxBlitHeightOverride(rootDeviceEnvironment); + if (maxBlitHeightOverride > 0) { + return maxBlitHeightOverride; + } return BlitterConstants::maxBlitHeight; } @@ -60,7 +68,9 @@ size_t BlitCommandsHelper::estimatePostBlitCommandSize() { } template -size_t BlitCommandsHelper::estimateBlitCommandsSize(Vec3 copySize, const CsrDependencies &csrDependencies, bool updateTimestampPacket, bool profilingEnabled) { +size_t BlitCommandsHelper::estimateBlitCommandsSize(Vec3 copySize, const CsrDependencies &csrDependencies, + bool updateTimestampPacket, bool profilingEnabled, + const RootDeviceEnvironment &rootDeviceEnvironment) { size_t numberOfBlits = 0; uint64_t width = 1; uint64_t height = 1; @@ -69,10 +79,10 @@ size_t BlitCommandsHelper::estimateBlitCommandsSize(Vec3 copy for (uint64_t row = 0; row < copySize.y; row++) { uint64_t sizeToBlit = copySize.x; while (sizeToBlit != 0) { - if (sizeToBlit > getMaxBlitWidth()) { + if (sizeToBlit > getMaxBlitWidth(rootDeviceEnvironment)) { // dispatch 2D blit: maxBlitWidth x (1 .. maxBlitHeight) - width = getMaxBlitWidth(); - height = std::min((sizeToBlit / width), getMaxBlitHeight()); + width = getMaxBlitWidth(rootDeviceEnvironment); + height = std::min((sizeToBlit / width), getMaxBlitHeight(rootDeviceEnvironment)); } else { // dispatch 1D blt: (1 .. maxBlitWidth) x 1 @@ -101,13 +111,16 @@ size_t BlitCommandsHelper::estimateBlitCommandsSize(Vec3 copy } template -size_t BlitCommandsHelper::estimateBlitCommandsSize(const BlitPropertiesContainer &blitPropertiesContainer, const HardwareInfo &hwInfo, bool profilingEnabled, bool debugPauseEnabled) { +size_t BlitCommandsHelper::estimateBlitCommandsSize(const BlitPropertiesContainer &blitPropertiesContainer, + bool profilingEnabled, bool debugPauseEnabled, + const RootDeviceEnvironment &rootDeviceEnvironment) { size_t size = 0; for (auto &blitProperties : blitPropertiesContainer) { size += BlitCommandsHelper::estimateBlitCommandsSize(blitProperties.copySize, blitProperties.csrDependencies, - blitProperties.outputTimestampPacket != nullptr, profilingEnabled); + blitProperties.outputTimestampPacket != nullptr, profilingEnabled, + rootDeviceEnvironment); } - size += MemorySynchronizationCommands::getSizeForAdditonalSynchronization(hwInfo); + size += MemorySynchronizationCommands::getSizeForAdditonalSynchronization(*rootDeviceEnvironment.getHardwareInfo()); size += EncodeMiFlushDW::getMiFlushDwCmdSizeForDataWrite() + sizeof(typename GfxFamily::MI_BATCH_BUFFER_END); if (debugPauseEnabled) { @@ -145,10 +158,10 @@ void BlitCommandsHelper::dispatchBlitCommandsForBuffer(const BlitProp uint64_t offset = 0; uint64_t sizeToBlit = blitProperties.copySize.x; while (sizeToBlit != 0) { - if (sizeToBlit > getMaxBlitWidth()) { + if (sizeToBlit > getMaxBlitWidth(rootDeviceEnvironment)) { // dispatch 2D blit: maxBlitWidth x (1 .. maxBlitHeight) - width = getMaxBlitWidth(); - height = std::min((sizeToBlit / width), getMaxBlitHeight()); + width = getMaxBlitWidth(rootDeviceEnvironment); + height = std::min((sizeToBlit / width), getMaxBlitHeight(rootDeviceEnvironment)); } else { // dispatch 1D blt: (1 .. maxBlitWidth) x 1 width = sizeToBlit; @@ -200,12 +213,12 @@ void BlitCommandsHelper::dispatchBlitMemoryFill(NEO::GraphicsAllocati tmpCmd.setDestinationBaseAddress(ptrOffset(dstAlloc->getGpuAddress(), static_cast(offset))); uint64_t height = 0; uint64_t width = 0; - if (sizeToFill <= getMaxBlitWidth()) { + if (sizeToFill <= getMaxBlitWidth(rootDeviceEnvironment)) { width = sizeToFill; height = 1; } else { - width = getMaxBlitWidth(); - height = std::min((sizeToFill / width), getMaxBlitHeight()); + width = getMaxBlitWidth(rootDeviceEnvironment); + height = std::min((sizeToFill / width), getMaxBlitHeight(rootDeviceEnvironment)); if (height > 1) { appendTilingEnable(tmpCmd); } diff --git a/shared/source/helpers/blit_commands_helper_bdw_plus.inl b/shared/source/helpers/blit_commands_helper_bdw_plus.inl index 79ad6bdfb3..00bc2634a5 100644 --- a/shared/source/helpers/blit_commands_helper_bdw_plus.inl +++ b/shared/source/helpers/blit_commands_helper_bdw_plus.inl @@ -9,6 +9,16 @@ namespace NEO { +template +uint64_t BlitCommandsHelper::getMaxBlitWidthOverride(const RootDeviceEnvironment &rootDeviceEnvironment) { + return 0; +} + +template +uint64_t BlitCommandsHelper::getMaxBlitHeightOverride(const RootDeviceEnvironment &rootDeviceEnvironment) { + return 0; +} + template void BlitCommandsHelper::appendBlitCommandsForBuffer(const BlitProperties &blitProperties, typename GfxFamily::XY_COPY_BLT &blitCmd, const RootDeviceEnvironment &rootDeviceEnvironment) {} diff --git a/shared/test/unit_test/helpers/blit_commands_helper_tests.cpp b/shared/test/unit_test/helpers/blit_commands_helper_tests.cpp index ecfb793250..a1661ab9f6 100644 --- a/shared/test/unit_test/helpers/blit_commands_helper_tests.cpp +++ b/shared/test/unit_test/helpers/blit_commands_helper_tests.cpp @@ -80,14 +80,14 @@ using BlitTests = Test; HWTEST_F(BlitTests, givenDebugVariablesWhenGettingMaxBlitSizeThenHonorUseProvidedValues) { DebugManagerStateRestore restore{}; - ASSERT_EQ(BlitterConstants::maxBlitWidth, BlitCommandsHelper::getMaxBlitWidth()); - ASSERT_EQ(BlitterConstants::maxBlitHeight, BlitCommandsHelper::getMaxBlitHeight()); + ASSERT_EQ(BlitterConstants::maxBlitWidth, BlitCommandsHelper::getMaxBlitWidth(pClDevice->getRootDeviceEnvironment())); + ASSERT_EQ(BlitterConstants::maxBlitHeight, BlitCommandsHelper::getMaxBlitHeight(pClDevice->getRootDeviceEnvironment())); DebugManager.flags.LimitBlitterMaxWidth.set(50); - EXPECT_EQ(50u, BlitCommandsHelper::getMaxBlitWidth()); + EXPECT_EQ(50u, BlitCommandsHelper::getMaxBlitWidth(pClDevice->getRootDeviceEnvironment())); DebugManager.flags.LimitBlitterMaxHeight.set(60); - EXPECT_EQ(60u, BlitCommandsHelper::getMaxBlitHeight()); + EXPECT_EQ(60u, BlitCommandsHelper::getMaxBlitHeight(pClDevice->getRootDeviceEnvironment())); } HWTEST_F(BlitTests, givenDebugVariableWhenEstimatingPostBlitsCommandSizeThenReturnCorrectResult) {