Skip to content

Commit c389db6

Browse files
Add space calculation for SBA instruction
Signed-off-by: Sebastian Luzynski <[email protected]>
1 parent dc6a352 commit c389db6

File tree

11 files changed

+130
-18
lines changed

11 files changed

+130
-18
lines changed

level_zero/core/source/cmdlist/cmdlist_hw.inl

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2006,7 +2006,6 @@ void CommandListCoreFamily<gfxCoreFamily>::programStateBaseAddress(NEO::CommandC
20062006
args.hdcPipelineFlush = true;
20072007
args.textureCacheInvalidationEnable = true;
20082008
NEO::MemorySynchronizationCommands<GfxFamily>::addPipeControl(*commandContainer.getCommandStream(), args);
2009-
auto &hwInfo = device->getHwInfo();
20102009

20112010
STATE_BASE_ADDRESS sba;
20122011
NEO::EncodeStateBaseAddress<GfxFamily>::encode(commandContainer, sba);
@@ -2021,8 +2020,6 @@ void CommandListCoreFamily<gfxCoreFamily>::programStateBaseAddress(NEO::CommandC
20212020

20222021
device->getL0Debugger()->captureStateBaseAddress(commandContainer, sbaAddresses);
20232022
}
2024-
2025-
NEO::EncodeStateBaseAddress<GfxFamily>::addStateBaseAddressIfRequired(commandContainer, sba, hwInfo);
20262023
}
20272024

20282025
template <GFXCORE_FAMILY gfxCoreFamily>

level_zero/core/source/cmdqueue/cmdqueue_xe_hp_core_plus.inl

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#include "shared/source/helpers/api_specific_config.h"
1212
#include "shared/source/helpers/hw_helper.h"
1313
#include "shared/source/helpers/state_base_address.h"
14+
#include "shared/source/os_interface/hw_info_config.h"
1415

1516
#include "level_zero/core/source/cmdqueue/cmdqueue_hw.h"
1617

@@ -48,6 +49,14 @@ void CommandQueueHw<gfxCoreFamily>::programStateBaseAddress(uint64_t gsba, bool
4849
NEO::MemoryCompressionState::NotApplicable,
4950
false,
5051
1u);
52+
*pSbaCmd = sbaCmd;
53+
54+
auto &hwInfo = neoDevice->getHardwareInfo();
55+
auto &hwInfoConfig = *NEO::HwInfoConfig::get(hwInfo.platform.eProductFamily);
56+
if (hwInfoConfig.isAdditionalStateBaseAddressWARequired(hwInfo)) {
57+
auto pSbaCmd = static_cast<STATE_BASE_ADDRESS *>(commandStream.getSpace(sizeof(STATE_BASE_ADDRESS)));
58+
*pSbaCmd = sbaCmd;
59+
}
5160

5261
if (NEO::Debugger::isDebugEnabled(internalUsage) && device->getL0Debugger()) {
5362

@@ -61,7 +70,6 @@ void CommandQueueHw<gfxCoreFamily>::programStateBaseAddress(uint64_t gsba, bool
6170

6271
device->getL0Debugger()->programSbaTrackingCommands(commandStream, sbaAddresses);
6372
}
64-
*pSbaCmd = sbaCmd;
6573

6674
auto heap = neoDevice->getBindlessHeapsHelper()->getHeap(NEO::BindlessHeapsHelper::GLOBAL_SSH);
6775
auto cmd = GfxFamily::cmdInitStateBindingTablePoolAlloc;
@@ -81,12 +89,21 @@ size_t CommandQueueHw<gfxCoreFamily>::estimateStateBaseAddressCmdSize() {
8189
using STATE_BASE_ADDRESS = typename GfxFamily::STATE_BASE_ADDRESS;
8290
using PIPE_CONTROL = typename GfxFamily::PIPE_CONTROL;
8391
using _3DSTATE_BINDING_TABLE_POOL_ALLOC = typename GfxFamily::_3DSTATE_BINDING_TABLE_POOL_ALLOC;
92+
93+
NEO::Device *neoDevice = device->getNEODevice();
94+
auto &hwInfo = neoDevice->getHardwareInfo();
95+
auto &hwInfoConfig = *NEO::HwInfoConfig::get(hwInfo.platform.eProductFamily);
96+
size_t size = 0;
97+
8498
if (NEO::ApiSpecificConfig::getBindlessConfiguration()) {
85-
size_t size = sizeof(STATE_BASE_ADDRESS) + sizeof(PIPE_CONTROL) + sizeof(_3DSTATE_BINDING_TABLE_POOL_ALLOC);
86-
return size;
87-
} else {
88-
return 0;
99+
size += sizeof(STATE_BASE_ADDRESS) + sizeof(PIPE_CONTROL) + sizeof(_3DSTATE_BINDING_TABLE_POOL_ALLOC);
100+
101+
if (hwInfoConfig.isAdditionalStateBaseAddressWARequired(hwInfo)) {
102+
size += sizeof(STATE_BASE_ADDRESS);
103+
}
89104
}
105+
106+
return size;
90107
}
91108

92109
constexpr uint32_t maxPtssIndex = 15u;

shared/source/command_container/command_encoder.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ struct EncodeStateBaseAddress {
219219
using STATE_BASE_ADDRESS = typename GfxFamily::STATE_BASE_ADDRESS;
220220
static void encode(CommandContainer &container, STATE_BASE_ADDRESS &sbaCmd);
221221
static void encode(CommandContainer &container, STATE_BASE_ADDRESS &sbaCmd, uint32_t statelessMocsIndex, bool useGlobalAtomics);
222-
static void addStateBaseAddressIfRequired(CommandContainer &container, STATE_BASE_ADDRESS &sbaCmd, const HardwareInfo &hwInfo);
222+
static size_t getRequiredSizeForStateBaseAddress(Device &device, CommandContainer &container);
223223
};
224224

225225
template <typename GfxFamily>

shared/source/command_container/command_encoder_bdw_plus.inl

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -387,7 +387,9 @@ void EncodeStateBaseAddress<Family>::encode(CommandContainer &container, STATE_B
387387
}
388388

389389
template <typename Family>
390-
void EncodeStateBaseAddress<Family>::addStateBaseAddressIfRequired(CommandContainer &container, STATE_BASE_ADDRESS &sbaCmd, const HardwareInfo &hwInfo) {}
390+
size_t EncodeStateBaseAddress<Family>::getRequiredSizeForStateBaseAddress(Device &device, CommandContainer &container) {
391+
return sizeof(typename Family::STATE_BASE_ADDRESS) + 2 * EncodeWA<Family>::getAdditionalPipelineSelectSize(device);
392+
}
391393

392394
template <typename Family>
393395
void EncodeL3State<Family>::encode(CommandContainer &container, bool enableSLM) {

shared/source/command_container/command_encoder_xehp_plus.inl

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
#include "shared/source/helpers/state_base_address.h"
2626
#include "shared/source/kernel/dispatch_kernel_encoder_interface.h"
2727
#include "shared/source/kernel/kernel_descriptor.h"
28+
#include "shared/source/os_interface/hw_info_config.h"
2829

2930
#include "pipe_control_args.h"
3031

@@ -472,6 +473,13 @@ void EncodeStateBaseAddress<Family>::encode(CommandContainer &container, STATE_B
472473
auto pCmd = reinterpret_cast<STATE_BASE_ADDRESS *>(container.getCommandStream()->getSpace(sizeof(STATE_BASE_ADDRESS)));
473474
*pCmd = sbaCmd;
474475

476+
auto &hwInfo = container.getDevice()->getHardwareInfo();
477+
auto &hwInfoConfig = *HwInfoConfig::get(hwInfo.platform.eProductFamily);
478+
if (hwInfoConfig.isAdditionalStateBaseAddressWARequired(hwInfo)) {
479+
pCmd = reinterpret_cast<STATE_BASE_ADDRESS *>(container.getCommandStream()->getSpace(sizeof(STATE_BASE_ADDRESS)));
480+
*pCmd = sbaCmd;
481+
}
482+
475483
if (container.isHeapDirty(HeapType::SURFACE_STATE)) {
476484
auto heap = container.getIndirectHeap(HeapType::SURFACE_STATE);
477485
auto cmd = Family::cmdInitStateBindingTablePoolAlloc;
@@ -485,7 +493,21 @@ void EncodeStateBaseAddress<Family>::encode(CommandContainer &container, STATE_B
485493
}
486494

487495
template <typename Family>
488-
void EncodeStateBaseAddress<Family>::addStateBaseAddressIfRequired(CommandContainer &container, STATE_BASE_ADDRESS &sbaCmd, const HardwareInfo &hwInfo) {}
496+
size_t EncodeStateBaseAddress<Family>::getRequiredSizeForStateBaseAddress(Device &device, CommandContainer &container) {
497+
auto &hwInfo = device.getHardwareInfo();
498+
auto &hwInfoConfig = *HwInfoConfig::get(hwInfo.platform.eProductFamily);
499+
500+
size_t size = sizeof(typename Family::STATE_BASE_ADDRESS);
501+
if (hwInfoConfig.isAdditionalStateBaseAddressWARequired(hwInfo)) {
502+
size += sizeof(typename Family::STATE_BASE_ADDRESS);
503+
}
504+
505+
if (container.isHeapDirty(HeapType::SURFACE_STATE)) {
506+
size += sizeof(typename Family::_3DSTATE_BINDING_TABLE_POOL_ALLOC);
507+
}
508+
509+
return size;
510+
}
489511

490512
template <typename Family>
491513
void EncodeComputeMode<Family>::adjustComputeMode(LinearStream &csr, void *const stateComputeModePtr, StateComputeModeProperties &properties) {
@@ -650,5 +672,4 @@ template <typename Family>
650672
inline size_t EncodeWA<Family>::getAdditionalPipelineSelectSize(Device &device) {
651673
return 0u;
652674
}
653-
654675
} // namespace NEO

shared/source/command_stream/command_stream_receiver_hw.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ class CommandStreamReceiverHw : public CommandStreamReceiver {
5555
void addBatchBufferStart(MI_BATCH_BUFFER_START *commandBufferMemory, uint64_t startAddress, bool secondary);
5656
static void alignToCacheLine(LinearStream &commandStream);
5757

58-
size_t getRequiredStateBaseAddressSize() const;
58+
size_t getRequiredStateBaseAddressSize(const Device &device) const;
5959
size_t getRequiredCmdStreamSize(const DispatchFlags &dispatchFlags, Device &device);
6060
size_t getRequiredCmdStreamSizeAligned(const DispatchFlags &dispatchFlags, Device &device);
6161
size_t getRequiredCmdSizeForPreamble(Device &device) const;

shared/source/command_stream/command_stream_receiver_hw_base.inl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -774,7 +774,7 @@ size_t CommandStreamReceiverHw<GfxFamily>::getRequiredCmdStreamSizeAligned(const
774774
template <typename GfxFamily>
775775
size_t CommandStreamReceiverHw<GfxFamily>::getRequiredCmdStreamSize(const DispatchFlags &dispatchFlags, Device &device) {
776776
size_t size = getRequiredCmdSizeForPreamble(device);
777-
size += getRequiredStateBaseAddressSize();
777+
size += getRequiredStateBaseAddressSize(device);
778778
if (!this->isStateSipSent || device.isDebuggerActive()) {
779779
size += PreemptionHelper::getRequiredStateSipCmdSize<GfxFamily>(device);
780780
}

shared/source/command_stream/command_stream_receiver_hw_bdw_plus.inl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ inline void CommandStreamReceiverHw<GfxFamily>::programL3(LinearStream &csr, Dis
3535
}
3636

3737
template <typename GfxFamily>
38-
size_t CommandStreamReceiverHw<GfxFamily>::getRequiredStateBaseAddressSize() const {
38+
size_t CommandStreamReceiverHw<GfxFamily>::getRequiredStateBaseAddressSize(const Device &device) const {
3939
using PIPELINE_SELECT = typename GfxFamily::PIPELINE_SELECT;
4040

4141
size_t size = 0;

shared/source/command_stream/command_stream_receiver_hw_xehp_plus.inl

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#include "shared/source/gmm_helper/gmm.h"
1212
#include "shared/source/helpers/preamble.h"
1313
#include "shared/source/kernel/grf_config.h"
14+
#include "shared/source/os_interface/hw_info_config.h"
1415
#include "shared/source/os_interface/os_interface.h"
1516

1617
namespace NEO {
@@ -25,9 +26,18 @@ template <typename GfxFamily>
2526
void CommandStreamReceiverHw<GfxFamily>::programL3(LinearStream &csr, DispatchFlags &dispatchFlags, uint32_t &newL3Config) {}
2627

2728
template <typename GfxFamily>
28-
size_t CommandStreamReceiverHw<GfxFamily>::getRequiredStateBaseAddressSize() const {
29-
return sizeof(typename GfxFamily::STATE_BASE_ADDRESS) + sizeof(typename GfxFamily::_3DSTATE_BINDING_TABLE_POOL_ALLOC) +
30-
sizeof(PIPE_CONTROL);
29+
size_t CommandStreamReceiverHw<GfxFamily>::getRequiredStateBaseAddressSize(const Device &device) const {
30+
size_t size = sizeof(typename GfxFamily::STATE_BASE_ADDRESS);
31+
size += sizeof(typename GfxFamily::_3DSTATE_BINDING_TABLE_POOL_ALLOC);
32+
size += sizeof(PIPE_CONTROL);
33+
34+
auto &hwInfo = *device.getRootDeviceEnvironment().getHardwareInfo();
35+
auto &hwInfoConfig = *HwInfoConfig::get(hwInfo.platform.eProductFamily);
36+
if (hwInfoConfig.isAdditionalStateBaseAddressWARequired(hwInfo)) {
37+
size += sizeof(typename GfxFamily::STATE_BASE_ADDRESS);
38+
}
39+
40+
return size;
3141
}
3242

3343
template <typename GfxFamily>

shared/test/unit_test/encoders/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
target_sources(${TARGET_NAME} PRIVATE
88
${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt
9+
${CMAKE_CURRENT_SOURCE_DIR}/test_command_encoder.cpp
910
${CMAKE_CURRENT_SOURCE_DIR}/test_encode_atomic.cpp
1011
${CMAKE_CURRENT_SOURCE_DIR}/test_encode_command_buffer.cpp
1112
${CMAKE_CURRENT_SOURCE_DIR}/test_encode_dispatch_kernel.cpp

0 commit comments

Comments
 (0)