feature: support copy function post-sync [4/n]

Added EncodePostSync to BlitPostSyncProperties, and
applyAdditionalBlitProperties to BlitCommandsHelper.

Related-To: NEO-13003
Signed-off-by: Young Jin Yoon <young.jin.yoon@intel.com>
This commit is contained in:
Young Jin Yoon 2025-05-01 16:49:48 +00:00 committed by Compute-Runtime-Automation
parent 55e7b6a209
commit 529b89c16a
11 changed files with 133 additions and 3 deletions

View File

@ -16,6 +16,7 @@ using Family = NEO::Gen12LpFamily;
#include "shared/source/gmm_helper/gmm.h"
#include "shared/source/helpers/address_patch.h"
#include "shared/source/helpers/blit_commands_helper_base.inl"
#include "shared/source/helpers/blit_commands_helper_from_gen12lp_to_xe3.inl"
#include "shared/source/helpers/populate_factory.h"
#include "shared/source/helpers/state_base_address_tgllp_and_later.inl"
@ -332,6 +333,8 @@ bool BlitCommandsHelper<Family>::preBlitCommandWARequired() {
template class CommandStreamReceiverHw<Family>;
template struct BlitCommandsHelper<Family>;
template void BlitCommandsHelper<Family>::applyAdditionalBlitProperties<typename Family::XY_BLOCK_COPY_BLT>(const BlitProperties &blitProperties, typename Family::XY_BLOCK_COPY_BLT &blitCmd, const RootDeviceEnvironment &rootDeviceEnvironment, bool last);
const Family::GPGPU_WALKER Family::cmdInitGpgpuWalker = Family::GPGPU_WALKER::sInit();
const Family::INTERFACE_DESCRIPTOR_DATA Family::cmdInitInterfaceDescriptorData = Family::INTERFACE_DESCRIPTOR_DATA::sInit();
const Family::MEDIA_INTERFACE_DESCRIPTOR_LOAD Family::cmdInitMediaInterfaceDescriptorLoad = Family::MEDIA_INTERFACE_DESCRIPTOR_LOAD::sInit();

View File

@ -234,6 +234,12 @@ if(SUPPORT_XE3_AND_LATER)
)
endif()
if(SUPPORT_XE3_AND_BEFORE)
list(APPEND NEO_CORE_HELPERS
${CMAKE_CURRENT_SOURCE_DIR}/blit_commands_helper_from_gen12lp_to_xe3.inl
)
endif()
set(NEO_CORE_HELPERS_GMM_CALLBACKS_WINDOWS
${CMAKE_CURRENT_SOURCE_DIR}/windows/gmm_callbacks.cpp
${CMAKE_CURRENT_SOURCE_DIR}/windows/gmm_callbacks.h

View File

@ -96,5 +96,8 @@ struct BlitCommandsHelper {
static void encodeWa(LinearStream &cmdStream, const BlitProperties &blitProperties, uint32_t &latestSentBcsWaValue);
static size_t getWaCmdsSize(const BlitPropertiesContainer &blitPropertiesContainer);
template <typename CommandType>
static void applyAdditionalBlitProperties(const BlitProperties &blitProperties, CommandType &cmd, const RootDeviceEnvironment &rootDeviceEnvironment, bool last);
};
} // namespace NEO

View File

@ -209,10 +209,13 @@ void BlitCommandsHelper<GfxFamily>::dispatchBlitCommandsForBufferPerRow(const Bl
appendColorDepth(blitProperties, bltCmd);
const bool useAdditionalBlitProperties = rootDeviceEnvironment.getHelper<ProductHelper>().useAdditionalBlitProperties();
for (uint64_t slice = 0; slice < blitProperties.copySize.z; slice++) {
for (uint64_t row = 0; row < blitProperties.copySize.y; row++) {
uint64_t offset = 0;
uint64_t sizeToBlit = blitProperties.copySize.x;
bool lastIteration = (slice == blitProperties.copySize.z - 1) && (row == blitProperties.copySize.y - 1);
while (sizeToBlit != 0) {
if (sizeToBlit > maxWidth) {
// dispatch 2D blit: maxBlitWidth x (1 .. maxBlitHeight)
@ -223,6 +226,8 @@ void BlitCommandsHelper<GfxFamily>::dispatchBlitCommandsForBufferPerRow(const Bl
width = sizeToBlit;
height = 1;
}
auto blitSize = width * height;
auto lastCommand = lastIteration && (sizeToBlit - blitSize == 0);
bltCmd.setDestinationX2CoordinateRight(static_cast<uint32_t>(width));
bltCmd.setDestinationY2CoordinateBottom(static_cast<uint32_t>(height));
@ -237,6 +242,9 @@ void BlitCommandsHelper<GfxFamily>::dispatchBlitCommandsForBufferPerRow(const Bl
bltCmd.setDestinationBaseAddress(dstAddr);
bltCmd.setSourceBaseAddress(srcAddr);
if (useAdditionalBlitProperties && lastCommand) {
applyAdditionalBlitProperties(blitProperties, bltCmd, rootDeviceEnvironment, lastCommand);
}
appendBlitCommandsForBuffer(blitProperties, bltCmd, rootDeviceEnvironment);
@ -245,7 +253,6 @@ void BlitCommandsHelper<GfxFamily>::dispatchBlitCommandsForBufferPerRow(const Bl
dispatchPostBlitCommand(linearStream, rootDeviceEnvironment);
auto blitSize = width * height;
sizeToBlit -= blitSize;
offset += blitSize;
}

View File

@ -0,0 +1,18 @@
/*
* Copyright (C) 2025 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#include "shared/source/helpers/blit_properties.h"
namespace NEO {
template <typename GfxFamily>
template <typename CommandType>
void BlitCommandsHelper<GfxFamily>::applyAdditionalBlitProperties(const BlitProperties &blitProperties,
CommandType &cmd, const RootDeviceEnvironment &rootDeviceEnvironment, bool last) {
}
} // namespace NEO

View File

@ -6,6 +6,7 @@
*/
#pragma once
#include "shared/source/command_container/command_encoder.h"
#include "shared/source/command_stream/csr_deps.h"
#include "shared/source/gmm_helper/gmm_lib.h"
#include "shared/source/helpers/aux_translation.h"
@ -17,6 +18,7 @@
namespace NEO {
struct TimestampPacketDependencies;
struct BlitSyncPropertiesExt;
class TagNodeBase;
class TimestampPacketContainer;
class GraphicsAllocation;
@ -31,13 +33,13 @@ enum class BlitSyncMode {
};
struct BlitSyncProperties {
EncodePostSyncArgs postSyncArgs{};
TagNodeBase *outputTimestampPacket = nullptr;
BlitSyncMode syncMode = BlitSyncMode::none;
uint64_t deviceGpuWriteAddress = 0;
uint64_t hostGpuWriteAddress = 0;
uint64_t timestampGpuWriteAddress = 0;
uint64_t writeValue = 0;
bool isTimestampMode() const {
return (syncMode == BlitSyncMode::timestamp) || (syncMode == BlitSyncMode::timestampAndImmediate);
}
@ -104,4 +106,4 @@ struct BlitProperties {
bool isSystemMemoryPoolUsed = false;
};
} // namespace NEO
} // namespace NEO

View File

@ -15,6 +15,7 @@ using Family = NEO::Xe2HpgCoreFamily;
#include "shared/source/command_stream/command_stream_receiver_hw_heap_addressing.inl"
#include "shared/source/command_stream/command_stream_receiver_hw_xehp_and_later.inl"
#include "shared/source/gmm_helper/gmm.h"
#include "shared/source/helpers/blit_commands_helper_from_gen12lp_to_xe3.inl"
#include "shared/source/helpers/blit_commands_helper_pvc_and_later.inl"
#include "shared/source/helpers/blit_commands_helper_xe2_and_later.inl"
#include "shared/source/helpers/blit_commands_helper_xehp_and_later.inl"
@ -271,6 +272,9 @@ template void BlitCommandsHelper<Family>::appendColorDepth<typename Family::XY_B
template void BlitCommandsHelper<Family>::appendColorDepth<typename Family::XY_COPY_BLT>(const BlitProperties &blitProperties, typename Family::XY_COPY_BLT &blitCmd);
template void BlitCommandsHelper<Family>::appendBlitCommandsForBuffer<typename Family::XY_COPY_BLT>(const BlitProperties &blitProperties, typename Family::XY_COPY_BLT &blitCmd, const RootDeviceEnvironment &rootDeviceEnvironment);
template void BlitCommandsHelper<Family>::applyAdditionalBlitProperties<typename Family::XY_COPY_BLT>(const BlitProperties &blitProperties, typename Family::XY_COPY_BLT &blitCmd, const RootDeviceEnvironment &rootDeviceEnvironment, bool last);
template void BlitCommandsHelper<Family>::applyAdditionalBlitProperties<typename Family::XY_BLOCK_COPY_BLT>(const BlitProperties &blitProperties, typename Family::XY_BLOCK_COPY_BLT &blitCmd, const RootDeviceEnvironment &rootDeviceEnvironment, bool last);
const Family::COMPUTE_WALKER Family::cmdInitGpgpuWalker = Family::COMPUTE_WALKER::sInit();
const Family::CFE_STATE Family::cmdInitCfeState = Family::CFE_STATE::sInit();
const Family::INTERFACE_DESCRIPTOR_DATA Family::cmdInitInterfaceDescriptorData = Family::INTERFACE_DESCRIPTOR_DATA::sInit();

View File

@ -14,6 +14,7 @@ using Family = NEO::Xe3CoreFamily;
#include "shared/source/command_stream/command_stream_receiver_hw_heap_addressing.inl"
#include "shared/source/command_stream/command_stream_receiver_hw_xehp_and_later.inl"
#include "shared/source/gmm_helper/gmm.h"
#include "shared/source/helpers/blit_commands_helper_from_gen12lp_to_xe3.inl"
#include "shared/source/helpers/blit_commands_helper_pvc_and_later.inl"
#include "shared/source/helpers/blit_commands_helper_xe2_and_later.inl"
#include "shared/source/helpers/blit_commands_helper_xehp_and_later.inl"
@ -225,6 +226,9 @@ template void BlitCommandsHelper<Family>::appendColorDepth<typename Family::XY_B
template void BlitCommandsHelper<Family>::appendColorDepth<typename Family::XY_COPY_BLT>(const BlitProperties &blitProperties, typename Family::XY_COPY_BLT &blitCmd);
template void BlitCommandsHelper<Family>::appendBlitCommandsForBuffer<typename Family::XY_COPY_BLT>(const BlitProperties &blitProperties, typename Family::XY_COPY_BLT &blitCmd, const RootDeviceEnvironment &rootDeviceEnvironment);
template void BlitCommandsHelper<Family>::applyAdditionalBlitProperties<typename Family::XY_COPY_BLT>(const BlitProperties &blitProperties, typename Family::XY_COPY_BLT &blitCmd, const RootDeviceEnvironment &rootDeviceEnvironment, bool last);
template void BlitCommandsHelper<Family>::applyAdditionalBlitProperties<typename Family::XY_BLOCK_COPY_BLT>(const BlitProperties &blitProperties, typename Family::XY_BLOCK_COPY_BLT &blitCmd, const RootDeviceEnvironment &rootDeviceEnvironment, bool last);
const Family::COMPUTE_WALKER Family::cmdInitGpgpuWalker = Family::COMPUTE_WALKER::sInit();
const Family::CFE_STATE Family::cmdInitCfeState = Family::CFE_STATE::sInit();
const Family::INTERFACE_DESCRIPTOR_DATA Family::cmdInitInterfaceDescriptorData = Family::INTERFACE_DESCRIPTOR_DATA::sInit();

View File

@ -16,6 +16,7 @@ using Family = NEO::XeHpcCoreFamily;
#include "shared/source/command_stream/command_stream_receiver_hw_heap_addressing.inl"
#include "shared/source/command_stream/command_stream_receiver_hw_xehp_and_later.inl"
#include "shared/source/gmm_helper/gmm.h"
#include "shared/source/helpers/blit_commands_helper_from_gen12lp_to_xe3.inl"
#include "shared/source/helpers/blit_commands_helper_pvc_and_later.inl"
#include "shared/source/helpers/blit_commands_helper_xehp_and_later.inl"
#include "shared/source/helpers/blit_properties.h"
@ -273,6 +274,8 @@ template class CommandStreamReceiverHw<Family>;
template struct BlitCommandsHelper<Family>;
template void BlitCommandsHelper<Family>::appendBlitCommandsForBuffer<typename Family::XY_COPY_BLT>(const BlitProperties &blitProperties, typename Family::XY_COPY_BLT &blitCmd, const RootDeviceEnvironment &rootDeviceEnvironment);
template void BlitCommandsHelper<Family>::applyAdditionalBlitProperties<typename Family::XY_COPY_BLT>(const BlitProperties &blitProperties, typename Family::XY_COPY_BLT &blitCmd, const RootDeviceEnvironment &rootDeviceEnvironment, bool last);
const Family::COMPUTE_WALKER Family::cmdInitGpgpuWalker = Family::COMPUTE_WALKER::sInit();
const Family::CFE_STATE Family::cmdInitCfeState = Family::CFE_STATE::sInit();
const Family::INTERFACE_DESCRIPTOR_DATA Family::cmdInitInterfaceDescriptorData = Family::INTERFACE_DESCRIPTOR_DATA::sInit();

View File

@ -14,6 +14,7 @@ using Family = NEO::XeHpgCoreFamily;
#include "shared/source/command_stream/command_stream_receiver_hw_dg2_and_later.inl"
#include "shared/source/command_stream/command_stream_receiver_hw_heap_addressing.inl"
#include "shared/source/command_stream/command_stream_receiver_hw_xehp_and_later.inl"
#include "shared/source/helpers/blit_commands_helper_from_gen12lp_to_xe3.inl"
#include "shared/source/helpers/blit_commands_helper_xehp_and_later.inl"
#include "shared/source/helpers/populate_factory.h"
#include "shared/source/helpers/state_base_address_xehp_and_later.inl"
@ -162,6 +163,8 @@ template struct BlitCommandsHelper<Family>;
template void BlitCommandsHelper<Family>::appendColorDepth<typename Family::XY_BLOCK_COPY_BLT>(const BlitProperties &blitProperties, typename Family::XY_BLOCK_COPY_BLT &blitCmd);
template void BlitCommandsHelper<Family>::appendBlitCommandsForBuffer<typename Family::XY_BLOCK_COPY_BLT>(const BlitProperties &blitProperties, typename Family::XY_BLOCK_COPY_BLT &blitCmd, const RootDeviceEnvironment &rootDeviceEnvironment);
template void BlitCommandsHelper<Family>::applyAdditionalBlitProperties<typename Family::XY_BLOCK_COPY_BLT>(const BlitProperties &blitProperties, typename Family::XY_BLOCK_COPY_BLT &blitCmd, const RootDeviceEnvironment &rootDeviceEnvironment, bool last);
const Family::COMPUTE_WALKER Family::cmdInitGpgpuWalker = Family::COMPUTE_WALKER::sInit();
const Family::CFE_STATE Family::cmdInitCfeState = Family::CFE_STATE::sInit();
const Family::INTERFACE_DESCRIPTOR_DATA Family::cmdInitInterfaceDescriptorData = Family::INTERFACE_DESCRIPTOR_DATA::sInit();

View File

@ -15,6 +15,7 @@
#include "shared/test/common/fixtures/device_fixture.h"
#include "shared/test/common/helpers/debug_manager_state_restore.h"
#include "shared/test/common/helpers/default_hw_info.h"
#include "shared/test/common/helpers/mock_product_helper_hw.h"
#include "shared/test/common/mocks/mock_device.h"
#include "shared/test/common/mocks/mock_graphics_allocation.h"
#include "shared/test/common/mocks/mock_timestamp_container.h"
@ -710,3 +711,79 @@ HWTEST_F(BlitTests, givenPlatformWhenCallingDispatchPreBlitCommandThenNoneMiFlus
blitPropertiesContainer2, false, true, false, false, pDevice->getRootDeviceEnvironment());
EXPECT_NE(estimatedSizeWithoutNode, estimatedSizeWithNode);
}
HWTEST2_F(BlitTests, givenPlatformWithBlitSyncPropertiesWithAndWithoutTimestampModeWhenCallingDispatchBlitCommandForBufferThenTheResultsAreTheSame, MatchAny) {
uint32_t src[] = {1, 2, 3, 4};
uint32_t dst[] = {4, 3, 2, 1};
uint32_t clear[] = {5, 6, 7, 8};
uint64_t srcGpuAddr = 0x12345;
uint64_t dstGpuAddr = 0x54321;
uint64_t clearGpuAddr = 0x5678;
std::unique_ptr<MockGraphicsAllocation> srcAlloc(new MockGraphicsAllocation(src, srcGpuAddr, sizeof(src)));
std::unique_ptr<MockGraphicsAllocation> dstAlloc(new MockGraphicsAllocation(dst, dstGpuAddr, sizeof(dst)));
std::unique_ptr<GraphicsAllocation> clearColorAllocation(new MockGraphicsAllocation(clear, clearGpuAddr, sizeof(clear)));
Vec3<size_t> srcOffsets{1, 0, 0};
Vec3<size_t> dstOffsets{1, 0, 0};
Vec3<size_t> copySize{(BlitterConstants::maxBlitWidth * BlitterConstants::maxBlitHeight) + 1, 2, 2};
size_t srcRowPitch = 0;
size_t srcSlicePitch = 0;
size_t dstRowPitch = 0;
size_t dstSlicePitch = 0;
auto blitProperties = NEO::BlitProperties::constructPropertiesForCopy(dstAlloc.get(), srcAlloc.get(),
dstOffsets, srcOffsets, copySize, srcRowPitch, srcSlicePitch,
dstRowPitch, dstSlicePitch, clearColorAllocation.get());
uint32_t streamBuffer[400] = {};
LinearStream stream(streamBuffer, sizeof(streamBuffer));
NEO::BlitCommandsHelper<FamilyType>::dispatchBlitCommandsForBufferPerRow(blitProperties, stream, pDevice->getRootDeviceEnvironmentRef());
// change it into timestamp mode
blitProperties.blitSyncProperties.syncMode = NEO::BlitSyncMode::timestamp;
uint32_t streamBuffer2[400] = {};
LinearStream stream2(streamBuffer2, sizeof(streamBuffer2));
NEO::BlitCommandsHelper<FamilyType>::dispatchBlitCommandsForBufferPerRow(blitProperties, stream2, pDevice->getRootDeviceEnvironmentRef());
EXPECT_EQ(stream.getUsed(), stream2.getUsed());
EXPECT_EQ(0, memcmp(ptrOffset(stream.getCpuBase(), 0), ptrOffset(stream2.getCpuBase(), 0), std::min(stream.getUsed(), stream2.getUsed())));
// change productHelper to return true
pDevice->getRootDeviceEnvironmentRef().productHelper.reset(new MockProductHelperHw<productFamily>);
auto *mockProductHelper = static_cast<MockProductHelperHw<productFamily> *>(pDevice->getRootDeviceEnvironmentRef().productHelper.get());
mockProductHelper->enableAdditionalBlitProperties = true;
uint32_t streamBuffer3[400] = {};
LinearStream stream3(streamBuffer3, sizeof(streamBuffer2));
NEO::BlitCommandsHelper<FamilyType>::dispatchBlitCommandsForBufferPerRow(blitProperties, stream3, pDevice->getRootDeviceEnvironmentRef());
EXPECT_EQ(stream.getUsed(), stream3.getUsed());
EXPECT_EQ(0, memcmp(ptrOffset(stream.getCpuBase(), 0), ptrOffset(stream3.getCpuBase(), 0), std::min(stream.getUsed(), stream3.getUsed())));
}
HWTEST_F(BlitTests, givenBlitPropertieswithImageOperationWhenCallingEstimateBlitCommandSizeThenBlockCopySizeIsReturned) {
Vec3<size_t> copySize{BlitterConstants::maxBlitWidth - 1, 1, 1};
NEO::CsrDependencies csrDependencies{};
size_t totalSize = NEO::BlitCommandsHelper<FamilyType>::estimateBlitCommandSize(copySize, csrDependencies, false, false, true, pDevice->getRootDeviceEnvironmentRef(), false, false);
size_t expectedSize = sizeof(typename FamilyType::XY_BLOCK_COPY_BLT);
expectedSize += NEO::BlitCommandsHelper<FamilyType>::estimatePostBlitCommandSize();
expectedSize += NEO::BlitCommandsHelper<FamilyType>::estimatePreBlitCommandSize();
EXPECT_EQ(expectedSize, totalSize);
}
using IsWithinGen12LPAndXe3Core = IsWithinGfxCore<IGFX_GEN12LP_CORE, IGFX_XE3_CORE>;
HWTEST2_F(BlitTests, givenXyCopyBltCommandWhenApplyBlitPropertiesIsCalledThenNothingChanged, IsWithinGen12LPAndXe3Core) {
using XY_COPY_BLT = typename FamilyType::XY_COPY_BLT;
auto bltCmd = FamilyType::cmdInitXyCopyBlt;
auto bltCmdBefore = bltCmd;
BlitProperties properties = {};
NEO::BlitCommandsHelper<FamilyType>::applyAdditionalBlitProperties(properties, bltCmd, pDevice->getRootDeviceEnvironment(), false);
EXPECT_EQ(memcmp(&bltCmd, &bltCmdBefore, sizeof(XY_COPY_BLT)), 0);
NEO::BlitCommandsHelper<FamilyType>::applyAdditionalBlitProperties(properties, bltCmd, pDevice->getRootDeviceEnvironment(), true);
EXPECT_EQ(memcmp(&bltCmd, &bltCmdBefore, sizeof(XY_COPY_BLT)), 0);
}