refactor: reorganize command encode classes 1/n

- remove obsolete file
- move methods from redundant compute mode file into dedicated platform files
- group same implementation into platform specific inl files

Signed-off-by: Zbigniew Zdanowicz <zbigniew.zdanowicz@intel.com>
This commit is contained in:
Zbigniew Zdanowicz
2024-11-07 11:20:06 +00:00
committed by Compute-Runtime-Automation
parent 14f8db73cd
commit 9536510c5b
11 changed files with 119 additions and 156 deletions

View File

@@ -14,8 +14,6 @@ set(NEO_CORE_COMMAND_CONTAINER
${CMAKE_CURRENT_SOURCE_DIR}/command_encoder_enablers.inl
${CMAKE_CURRENT_SOURCE_DIR}/command_encoder_tgllp_and_later.inl
${CMAKE_CURRENT_SOURCE_DIR}/encode_alu_helper.h
${CMAKE_CURRENT_SOURCE_DIR}/encode_compute_mode_bdw_and_later.inl
${CMAKE_CURRENT_SOURCE_DIR}/encode_compute_mode_tgllp_and_later.inl
${CMAKE_CURRENT_SOURCE_DIR}/encode_surface_state.h
${CMAKE_CURRENT_SOURCE_DIR}/implicit_scaling.cpp
${CMAKE_CURRENT_SOURCE_DIR}/implicit_scaling.h
@@ -61,6 +59,12 @@ if(SUPPORT_XE_HPC_AND_BEFORE)
)
endif()
if(SUPPORT_XE_HPC_AND_BEFORE OR SUPPORT_XE2_HPG_CORE)
list(APPEND NEO_CORE_COMMAND_CONTAINER
${CMAKE_CURRENT_SOURCE_DIR}/command_encoder_from_gen12lp_to_xe2_hpg.inl
)
endif()
set_property(GLOBAL PROPERTY NEO_CORE_COMMAND_CONTAINER ${NEO_CORE_COMMAND_CONTAINER})
add_subdirectories()

View File

@@ -0,0 +1,41 @@
/*
* Copyright (C) 2020-2024 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#include "shared/source/command_container/command_encoder.h"
#include "shared/source/command_stream/linear_stream.h"
#include "shared/source/helpers/pipe_control_args.h"
namespace NEO {
template <typename Family>
inline void EncodeComputeMode<Family>::programComputeModeCommandWithSynchronization(
LinearStream &csr, StateComputeModeProperties &properties, const PipelineSelectArgs &args,
bool hasSharedHandles, const RootDeviceEnvironment &rootDeviceEnvironment, bool isRcs, bool dcFlush) {
auto &hwInfo = *rootDeviceEnvironment.getHardwareInfo();
NEO::EncodeWA<Family>::encodeAdditionalPipelineSelect(csr, args, true, rootDeviceEnvironment, isRcs);
auto *releaseHelper = rootDeviceEnvironment.getReleaseHelper();
auto &productHelper = rootDeviceEnvironment.getHelper<ProductHelper>();
const auto &[isBasicWARequired, isExtendedWARequired] = productHelper.isPipeControlPriorToNonPipelinedStateCommandsWARequired(hwInfo, isRcs, releaseHelper);
std::ignore = isExtendedWARequired;
if (isBasicWARequired) {
PipeControlArgs args;
NEO::EncodeWA<Family>::addPipeControlPriorToNonPipelinedStateCommand(csr, args, rootDeviceEnvironment, isRcs);
}
EncodeComputeMode<Family>::programComputeModeCommand(csr, properties, rootDeviceEnvironment);
if (hasSharedHandles) {
PipeControlArgs args;
args.csStallOnly = true;
MemorySynchronizationCommands<Family>::addSingleBarrier(csr, args);
}
NEO::EncodeWA<Family>::encodeAdditionalPipelineSelect(csr, args, false, rootDeviceEnvironment, isRcs);
}
} // namespace NEO

View File

@@ -21,4 +21,10 @@ uint32_t EncodeDispatchKernel<Family>::alignPreferredSlmSize(uint32_t slmSize) {
return EncodeDispatchKernel<Family>::alignSlmSize(slmSize);
}
template <typename Family>
void EncodeSurfaceState<Family>::disableCompressionFlags(R_SURFACE_STATE *surfaceState) {
surfaceState->setAuxiliarySurfaceMode(Family::RENDER_SURFACE_STATE::AUXILIARY_SURFACE_MODE::AUXILIARY_SURFACE_MODE_AUX_NONE);
surfaceState->setMemoryCompressionEnable(false);
}
} // namespace NEO

View File

@@ -13,7 +13,58 @@
namespace NEO {
template <>
template <typename Family>
size_t EncodeComputeMode<Family>::getCmdSizeForComputeMode(const RootDeviceEnvironment &rootDeviceEnvironment, bool hasSharedHandles, bool isRcs) {
size_t size = 0;
auto &productHelper = rootDeviceEnvironment.getHelper<ProductHelper>();
auto *releaseHelper = rootDeviceEnvironment.getReleaseHelper();
auto &hwInfo = *rootDeviceEnvironment.getHardwareInfo();
const auto &[isBasicWARequired, isExtendedWARequired] = productHelper.isPipeControlPriorToNonPipelinedStateCommandsWARequired(hwInfo, isRcs, releaseHelper);
std::ignore = isExtendedWARequired;
if (isBasicWARequired) {
size += MemorySynchronizationCommands<Family>::getSizeForSingleBarrier(false);
}
size += sizeof(typename Family::STATE_COMPUTE_MODE);
if (hasSharedHandles) {
size += MemorySynchronizationCommands<Family>::getSizeForSingleBarrier(false);
}
if (productHelper.is3DPipelineSelectWARequired() && isRcs) {
size += (2 * PreambleHelper<Family>::getCmdSizeForPipelineSelect(rootDeviceEnvironment));
}
return size;
}
template <typename GfxFamily>
inline size_t EncodeComputeMode<GfxFamily>::getSizeForComputeMode() {
return sizeof(typename GfxFamily::STATE_COMPUTE_MODE);
}
template <typename Family>
void EncodeSetMMIO<Family>::remapOffset(MI_LOAD_REGISTER_MEM *pMiLoadReg) {
if (isRemapApplicable(pMiLoadReg->getRegisterAddress())) {
pMiLoadReg->setMmioRemapEnable(true);
}
}
template <typename Family>
void EncodeSetMMIO<Family>::remapOffset(MI_LOAD_REGISTER_REG *pMiLoadReg) {
if (isRemapApplicable(pMiLoadReg->getSourceRegisterAddress())) {
pMiLoadReg->setMmioRemapEnableSource(true);
}
if (isRemapApplicable(pMiLoadReg->getDestinationRegisterAddress())) {
pMiLoadReg->setMmioRemapEnableDestination(true);
}
}
template <typename Family>
inline bool EncodeSetMMIO<Family>::isRemapApplicable(uint32_t offset) {
return (0x2000 <= offset && offset <= 0x27ff) ||
(0x4200 <= offset && offset <= 0x420f) ||
(0x4400 <= offset && offset <= 0x441f);
}
template <typename Family>
void EncodeWA<Family>::addPipeControlBeforeStateBaseAddress(LinearStream &commandStream,
const RootDeviceEnvironment &rootDeviceEnvironment, bool isRcs, bool dcFlushRequired) {
PipeControlArgs args;
@@ -24,7 +75,7 @@ void EncodeWA<Family>::addPipeControlBeforeStateBaseAddress(LinearStream &comman
NEO::EncodeWA<Family>::addPipeControlPriorToNonPipelinedStateCommand(commandStream, args, rootDeviceEnvironment, isRcs);
}
template <>
template <typename Family>
inline void EncodeMiArbCheck<Family>::adjust(MI_ARB_CHECK &miArbCheck, std::optional<bool> preParserDisable) {
if (debugManager.flags.ForcePreParserEnabledForMiArbCheck.get() != -1) {
preParserDisable = !debugManager.flags.ForcePreParserEnabledForMiArbCheck.get();
@@ -34,7 +85,7 @@ inline void EncodeMiArbCheck<Family>::adjust(MI_ARB_CHECK &miArbCheck, std::opti
}
}
template <>
template <typename Family>
inline void EncodeStoreMemory<Family>::encodeForceCompletionCheck(MI_STORE_DATA_IMM &storeDataImmCmd) {
storeDataImmCmd.setForceWriteCompletionCheck(true);
}

View File

@@ -36,4 +36,8 @@ void EncodeDispatchKernel<Family>::encodeComputeDispatchAllWalker(WalkerType &wa
walkerCmd.setComputeDispatchAllWalkerEnable(computeDispatchAllWalkerEnable);
}
template <typename Family>
void EncodeSurfaceState<Family>::disableCompressionFlags(R_SURFACE_STATE *surfaceState) {
}
} // namespace NEO

View File

@@ -1,42 +0,0 @@
/*
* Copyright (C) 2020-2023 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#pragma once
#include "shared/source/command_container/command_encoder.h"
#include "shared/source/command_stream/linear_stream.h"
namespace NEO {
template <typename Family>
inline void EncodeComputeMode<Family>::programComputeModeCommandWithSynchronization(
LinearStream &csr, StateComputeModeProperties &properties, const PipelineSelectArgs &args,
bool hasSharedHandles, const RootDeviceEnvironment &rootDeviceEnvironment, bool isRcs, bool dcFlush) {
EncodeComputeMode<Family>::programComputeModeCommand(csr, properties, rootDeviceEnvironment);
}
template <typename Family>
inline void EncodeStoreMMIO<Family>::appendFlags(MI_STORE_REGISTER_MEM *storeRegMem, bool workloadPartition) {
}
template <typename Family>
inline void EncodeSetMMIO<Family>::remapOffset(MI_LOAD_REGISTER_MEM *pMiLoadReg) {
}
template <typename Family>
inline void EncodeSetMMIO<Family>::remapOffset(MI_LOAD_REGISTER_REG *pMiLoadReg) {
}
template <typename Family>
inline bool EncodeSetMMIO<Family>::isRemapApplicable(uint32_t offset) {
return false;
}
template <typename Family>
void EncodeSurfaceState<Family>::disableCompressionFlags(R_SURFACE_STATE *surfaceState) {
}
} // namespace NEO

View File

@@ -1,97 +0,0 @@
/*
* Copyright (C) 2020-2024 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#pragma once
#include "shared/source/command_container/command_encoder.h"
#include "shared/source/command_stream/linear_stream.h"
namespace NEO {
template <typename Family>
size_t EncodeComputeMode<Family>::getCmdSizeForComputeMode(const RootDeviceEnvironment &rootDeviceEnvironment, bool hasSharedHandles, bool isRcs) {
size_t size = 0;
auto &productHelper = rootDeviceEnvironment.getHelper<ProductHelper>();
auto *releaseHelper = rootDeviceEnvironment.getReleaseHelper();
auto &hwInfo = *rootDeviceEnvironment.getHardwareInfo();
const auto &[isBasicWARequired, isExtendedWARequired] = productHelper.isPipeControlPriorToNonPipelinedStateCommandsWARequired(hwInfo, isRcs, releaseHelper);
std::ignore = isExtendedWARequired;
if (isBasicWARequired) {
size += MemorySynchronizationCommands<Family>::getSizeForSingleBarrier(false);
}
size += sizeof(typename Family::STATE_COMPUTE_MODE);
if (hasSharedHandles) {
size += MemorySynchronizationCommands<Family>::getSizeForSingleBarrier(false);
}
if (productHelper.is3DPipelineSelectWARequired() && isRcs) {
size += (2 * PreambleHelper<Family>::getCmdSizeForPipelineSelect(rootDeviceEnvironment));
}
return size;
}
template <typename GfxFamily>
inline size_t EncodeComputeMode<GfxFamily>::getSizeForComputeMode() {
return sizeof(typename GfxFamily::STATE_COMPUTE_MODE);
}
template <typename Family>
inline void EncodeComputeMode<Family>::programComputeModeCommandWithSynchronization(
LinearStream &csr, StateComputeModeProperties &properties, const PipelineSelectArgs &args,
bool hasSharedHandles, const RootDeviceEnvironment &rootDeviceEnvironment, bool isRcs, bool dcFlush) {
auto &hwInfo = *rootDeviceEnvironment.getHardwareInfo();
NEO::EncodeWA<Family>::encodeAdditionalPipelineSelect(csr, args, true, rootDeviceEnvironment, isRcs);
auto *releaseHelper = rootDeviceEnvironment.getReleaseHelper();
auto &productHelper = rootDeviceEnvironment.getHelper<ProductHelper>();
const auto &[isBasicWARequired, isExtendedWARequired] = productHelper.isPipeControlPriorToNonPipelinedStateCommandsWARequired(hwInfo, isRcs, releaseHelper);
std::ignore = isExtendedWARequired;
if (isBasicWARequired) {
PipeControlArgs args;
NEO::EncodeWA<Family>::addPipeControlPriorToNonPipelinedStateCommand(csr, args, rootDeviceEnvironment, isRcs);
}
EncodeComputeMode<Family>::programComputeModeCommand(csr, properties, rootDeviceEnvironment);
if (hasSharedHandles) {
PipeControlArgs args;
args.csStallOnly = true;
MemorySynchronizationCommands<Family>::addSingleBarrier(csr, args);
}
NEO::EncodeWA<Family>::encodeAdditionalPipelineSelect(csr, args, false, rootDeviceEnvironment, isRcs);
}
template <typename Family>
void EncodeSetMMIO<Family>::remapOffset(MI_LOAD_REGISTER_MEM *pMiLoadReg) {
if (isRemapApplicable(pMiLoadReg->getRegisterAddress())) {
pMiLoadReg->setMmioRemapEnable(true);
}
}
template <typename Family>
void EncodeSetMMIO<Family>::remapOffset(MI_LOAD_REGISTER_REG *pMiLoadReg) {
if (isRemapApplicable(pMiLoadReg->getSourceRegisterAddress())) {
pMiLoadReg->setMmioRemapEnableSource(true);
}
if (isRemapApplicable(pMiLoadReg->getDestinationRegisterAddress())) {
pMiLoadReg->setMmioRemapEnableDestination(true);
}
}
template <typename Family>
inline bool EncodeSetMMIO<Family>::isRemapApplicable(uint32_t offset) {
return (0x2000 <= offset && offset <= 0x27ff) ||
(0x4200 <= offset && offset <= 0x420f) ||
(0x4400 <= offset && offset <= 0x441f);
}
template <typename Family>
void EncodeSurfaceState<Family>::disableCompressionFlags(R_SURFACE_STATE *surfaceState) {
surfaceState->setAuxiliarySurfaceMode(Family::RENDER_SURFACE_STATE::AUXILIARY_SURFACE_MODE::AUXILIARY_SURFACE_MODE_AUX_NONE);
surfaceState->setMemoryCompressionEnable(false);
}
} // namespace NEO

View File

@@ -8,7 +8,9 @@
#include "shared/source/command_container/command_encoder.h"
#include "shared/source/command_container/command_encoder.inl"
#include "shared/source/command_container/command_encoder_bdw_and_later.inl"
#include "shared/source/command_container/command_encoder_from_gen12lp_to_xe2_hpg.inl"
#include "shared/source/command_container/command_encoder_pre_xe2_hpg_core.inl"
#include "shared/source/command_container/command_encoder_tgllp_and_later.inl"
#include "shared/source/command_stream/stream_properties.h"
#include "shared/source/gen12lp/hw_cmds_base.h"
#include "shared/source/gen12lp/reg_configs.h"
@@ -21,8 +23,6 @@
using Family = NEO::Gen12LpFamily;
#include "shared/source/command_container/command_encoder_heap_addressing.inl"
#include "shared/source/command_container/command_encoder_tgllp_and_later.inl"
#include "shared/source/command_container/encode_compute_mode_tgllp_and_later.inl"
#include "shared/source/command_container/image_surface_state/compression_params_bdw_and_later.inl"
#include "shared/source/command_container/image_surface_state/compression_params_tgllp_and_later.inl"
#include "shared/source/command_stream/command_stream_receiver.h"

View File

@@ -7,10 +7,11 @@
#include "shared/source/command_container/command_encoder.h"
#include "shared/source/command_container/command_encoder.inl"
#include "shared/source/command_container/command_encoder_from_gen12lp_to_xe2_hpg.inl"
#include "shared/source/command_container/command_encoder_heap_addressing.inl"
#include "shared/source/command_container/command_encoder_tgllp_and_later.inl"
#include "shared/source/command_container/command_encoder_xe2_hpg_core_and_later.inl"
#include "shared/source/command_container/command_encoder_xehp_and_later.inl"
#include "shared/source/command_container/encode_compute_mode_tgllp_and_later.inl"
#include "shared/source/command_stream/stream_properties.h"
#include "shared/source/helpers/constants.h"
#include "shared/source/kernel/grf_config.h"
@@ -20,7 +21,6 @@
using Family = NEO::Xe2HpgCoreFamily;
#include "shared/source/command_container/command_encoder_tgllp_and_later.inl"
#include "shared/source/command_container/command_encoder_xe_hpc_core_and_later.inl"
#include "shared/source/command_container/command_encoder_xe_hpg_core_and_later.inl"
#include "shared/source/command_container/image_surface_state/compression_params_xehp_and_later.inl"
@@ -225,10 +225,6 @@ template <>
inline void EncodeSurfaceState<Family>::setFlagsForMediaCompression(R_SURFACE_STATE *surfaceState, Gmm *gmm) {
}
template <>
void EncodeSurfaceState<Family>::disableCompressionFlags(R_SURFACE_STATE *surfaceState) {
}
template <>
template <typename InterfaceDescriptorType>
void EncodeDispatchKernel<Family>::setGrfInfo(InterfaceDescriptorType *pInterfaceDescriptor, uint32_t grfCount,

View File

@@ -7,9 +7,10 @@
#include "shared/source/command_container/command_encoder.h"
#include "shared/source/command_container/command_encoder.inl"
#include "shared/source/command_container/command_encoder_from_gen12lp_to_xe2_hpg.inl"
#include "shared/source/command_container/command_encoder_pre_xe2_hpg_core.inl"
#include "shared/source/command_container/command_encoder_tgllp_and_later.inl"
#include "shared/source/command_container/command_encoder_xehp_and_later.inl"
#include "shared/source/command_container/encode_compute_mode_tgllp_and_later.inl"
#include "shared/source/command_stream/stream_properties.h"
#include "shared/source/helpers/constants.h"
#include "shared/source/kernel/grf_config.h"
@@ -20,7 +21,6 @@
using Family = NEO::XeHpcCoreFamily;
#include "shared/source/command_container/command_encoder_heap_addressing.inl"
#include "shared/source/command_container/command_encoder_tgllp_and_later.inl"
#include "shared/source/command_container/command_encoder_xe_hpc_core_and_later.inl"
#include "shared/source/command_container/command_encoder_xe_hpg_core_and_later.inl"
#include "shared/source/command_container/image_surface_state/compression_params_tgllp_and_later.inl"

View File

@@ -7,9 +7,10 @@
#include "shared/source/command_container/command_encoder.h"
#include "shared/source/command_container/command_encoder.inl"
#include "shared/source/command_container/command_encoder_from_gen12lp_to_xe2_hpg.inl"
#include "shared/source/command_container/command_encoder_pre_xe2_hpg_core.inl"
#include "shared/source/command_container/command_encoder_tgllp_and_later.inl"
#include "shared/source/command_container/command_encoder_xehp_and_later.inl"
#include "shared/source/command_container/encode_compute_mode_tgllp_and_later.inl"
#include "shared/source/command_stream/stream_properties.h"
#include "shared/source/helpers/cache_flush_xehp_and_later.inl"
#include "shared/source/os_interface/product_helper.h"
@@ -20,7 +21,6 @@
using Family = NEO::XeHpgCoreFamily;
#include "shared/source/command_container/command_encoder_heap_addressing.inl"
#include "shared/source/command_container/command_encoder_tgllp_and_later.inl"
#include "shared/source/command_container/command_encoder_xe_hpg_core_and_later.inl"
#include "shared/source/command_container/image_surface_state/compression_params_tgllp_and_later.inl"
#include "shared/source/command_container/image_surface_state/compression_params_xehp_and_later.inl"