Skip to content

Commit 77ce18a

Browse files
Simplify code for Front End programming
Change-Id: I1f6e1f4f6eef24c8018c54ae1b7f6ec67adb55b3 Signed-off-by: Zbigniew Zdanowicz <[email protected]>
1 parent fa3d4f3 commit 77ce18a

File tree

8 files changed

+36
-29
lines changed

8 files changed

+36
-29
lines changed

runtime/command_stream/command_stream_receiver_hw_base.inl

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,22 @@ inline void CommandStreamReceiverHw<GfxFamily>::alignToCacheLine(LinearStream &c
9393
}
9494
}
9595

96+
template <typename GfxFamily>
97+
inline size_t CommandStreamReceiverHw<GfxFamily>::getRequiredCmdSizeForPreamble(Device &device) const {
98+
size_t size = 0;
99+
100+
if (mediaVfeStateDirty) {
101+
size += PreambleHelper<GfxFamily>::getVFECommandsSize();
102+
}
103+
if (!this->isPreambleSent) {
104+
size += PreambleHelper<GfxFamily>::getAdditionalCommandsSize(device);
105+
}
106+
if (!this->isPreambleSent || this->lastSentThreadArbitrationPolicy != this->requiredThreadArbitrationPolicy) {
107+
size += PreambleHelper<GfxFamily>::getThreadArbitrationCommandsSize();
108+
}
109+
return size;
110+
}
111+
96112
template <typename GfxFamily>
97113
inline typename GfxFamily::PIPE_CONTROL *CommandStreamReceiverHw<GfxFamily>::addPipeControlCmd(LinearStream &commandStream) {
98114
typedef typename GfxFamily::PIPE_CONTROL PIPE_CONTROL;

runtime/command_stream/command_stream_receiver_hw_bdw_plus.inl

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -61,22 +61,6 @@ inline size_t CommandStreamReceiverHw<GfxFamily>::getCmdSizeForPipelineSelect()
6161
return 0;
6262
}
6363

64-
template <typename GfxFamily>
65-
inline size_t CommandStreamReceiverHw<GfxFamily>::getRequiredCmdSizeForPreamble(Device &device) const {
66-
size_t size = 0;
67-
68-
if (mediaVfeStateDirty) {
69-
size += sizeof(typename GfxFamily::PIPE_CONTROL) + sizeof(typename GfxFamily::MEDIA_VFE_STATE);
70-
}
71-
if (!this->isPreambleSent) {
72-
size += PreambleHelper<GfxFamily>::getAdditionalCommandsSize(device);
73-
}
74-
if (!this->isPreambleSent || this->lastSentThreadArbitrationPolicy != this->requiredThreadArbitrationPolicy) {
75-
size += PreambleHelper<GfxFamily>::getThreadArbitrationCommandsSize();
76-
}
77-
return size;
78-
}
79-
8064
template <typename GfxFamily>
8165
void CommandStreamReceiverHw<GfxFamily>::createScratchSpaceController() {
8266
scratchSpaceController = std::make_unique<ScratchSpaceControllerBase>(executionEnvironment, *internalAllocationStorage.get());

runtime/helpers/hw_helper.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,4 +40,9 @@ bool HwHelper::cacheFlushAfterWalkerSupported(const HardwareInfo &hwInfo) {
4040
return hwInfo.capabilityTable.supportCacheFlushAfterWalker;
4141
}
4242

43+
uint32_t HwHelper::getMaxThreadsForVfe(const HardwareInfo &hwInfo) {
44+
uint32_t threadsPerEU = (hwInfo.gtSystemInfo.ThreadCount / hwInfo.gtSystemInfo.EUCount) + hwInfo.capabilityTable.extraQuantityThreadsPerEU;
45+
return hwInfo.gtSystemInfo.EUCount * threadsPerEU;
46+
}
47+
4348
} // namespace NEO

runtime/helpers/hw_helper.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ class HwHelper {
6363
virtual const std::vector<aub_stream::EngineType> getGpgpuEngineInstances() const = 0;
6464
virtual bool getEnableLocalMemory(const HardwareInfo &hwInfo) const = 0;
6565
virtual std::string getExtensions() const = 0;
66+
static uint32_t getMaxThreadsForVfe(const HardwareInfo &hwInfo);
6667

6768
static constexpr uint32_t lowPriorityGpgpuEngineIndex = 1;
6869

runtime/helpers/preamble.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,10 @@ struct PreambleHelper {
3939
static uint32_t getL3Config(const HardwareInfo &hwInfo, bool useSLM);
4040
static size_t getAdditionalCommandsSize(const Device &device);
4141
static size_t getThreadArbitrationCommandsSize();
42+
static size_t getVFECommandsSize();
4243
static size_t getKernelDebuggingCommandsSize(bool debuggingActive);
4344
static void programGenSpecificPreambleWorkArounds(LinearStream *pCommandStream, const HardwareInfo &hwInfo);
4445
static uint32_t getUrbEntryAllocationSize();
45-
static uint32_t getMaxThreadsForVfe(const HardwareInfo &hwInfo);
4646
};
4747

4848
template <PRODUCT_FAMILY ProductFamily>

runtime/helpers/preamble_base.inl

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -82,10 +82,4 @@ size_t PreambleHelper<GfxFamily>::getKernelDebuggingCommandsSize(bool debuggingA
8282
return 0;
8383
}
8484

85-
template <typename GfxFamily>
86-
uint32_t PreambleHelper<GfxFamily>::getMaxThreadsForVfe(const HardwareInfo &hwInfo) {
87-
uint32_t threadsPerEU = (hwInfo.gtSystemInfo.ThreadCount / hwInfo.gtSystemInfo.EUCount) + hwInfo.capabilityTable.extraQuantityThreadsPerEU;
88-
return hwInfo.gtSystemInfo.EUCount * threadsPerEU;
89-
}
90-
9185
} // namespace NEO

runtime/helpers/preamble_bdw_plus.inl

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
*
66
*/
77

8+
#include "runtime/helpers/hw_helper.h"
89
#include "runtime/helpers/preamble_base.inl"
910

1011
namespace NEO {
@@ -25,21 +26,27 @@ uint32_t PreambleHelper<GfxFamily>::getUrbEntryAllocationSize() {
2526

2627
template <typename GfxFamily>
2728
void PreambleHelper<GfxFamily>::programVFEState(LinearStream *pCommandStream, const HardwareInfo &hwInfo, int scratchSize, uint64_t scratchAddress) {
28-
typedef typename GfxFamily::MEDIA_VFE_STATE MEDIA_VFE_STATE;
29+
using MEDIA_VFE_STATE = typename GfxFamily::MEDIA_VFE_STATE;
2930

3031
addPipeControlBeforeVfeCmd(pCommandStream, &hwInfo);
3132

32-
auto pMediaVfeState = (MEDIA_VFE_STATE *)pCommandStream->getSpace(sizeof(MEDIA_VFE_STATE));
33+
auto pMediaVfeState = reinterpret_cast<MEDIA_VFE_STATE *>(pCommandStream->getSpace(sizeof(MEDIA_VFE_STATE)));
3334
*pMediaVfeState = GfxFamily::cmdInitMediaVfeState;
34-
pMediaVfeState->setMaximumNumberOfThreads(PreambleHelper<GfxFamily>::getMaxThreadsForVfe(hwInfo));
35+
pMediaVfeState->setMaximumNumberOfThreads(HwHelper::getMaxThreadsForVfe(hwInfo));
3536
pMediaVfeState->setNumberOfUrbEntries(1);
3637
pMediaVfeState->setUrbEntryAllocationSize(PreambleHelper<GfxFamily>::getUrbEntryAllocationSize());
3738
pMediaVfeState->setPerThreadScratchSpace(Kernel::getScratchSizeValueToProgramMediaVfeState(scratchSize));
3839
pMediaVfeState->setStackSize(Kernel::getScratchSizeValueToProgramMediaVfeState(scratchSize));
39-
uint32_t lowAddress = uint32_t(0xFFFFFFFF & scratchAddress);
40-
uint32_t highAddress = uint32_t(0xFFFFFFFF & (scratchAddress >> 32));
40+
uint32_t lowAddress = static_cast<uint32_t>(0xFFFFFFFF & scratchAddress);
41+
uint32_t highAddress = static_cast<uint32_t>(0xFFFFFFFF & (scratchAddress >> 32));
4142
pMediaVfeState->setScratchSpaceBasePointer(lowAddress);
4243
pMediaVfeState->setScratchSpaceBasePointerHigh(highAddress);
4344
}
4445

46+
template <typename GfxFamily>
47+
size_t PreambleHelper<GfxFamily>::getVFECommandsSize() {
48+
using MEDIA_VFE_STATE = typename GfxFamily::MEDIA_VFE_STATE;
49+
return sizeof(MEDIA_VFE_STATE) + sizeof(PIPE_CONTROL);
50+
}
51+
4552
} // namespace NEO

unit_tests/preamble/preamble_tests.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ HWTEST_F(PreambleTest, givenKernelDebuggingActiveAndMidThreadPreemptionWhenGetAd
183183
HWTEST_F(PreambleTest, givenDefaultPreambleWhenGetThreadsMaxNumberIsCalledThenMaximumNumberOfThreadsIsReturned) {
184184
const HardwareInfo &hwInfo = **platformDevices;
185185
uint32_t threadsPerEU = (hwInfo.gtSystemInfo.ThreadCount / hwInfo.gtSystemInfo.EUCount) + hwInfo.capabilityTable.extraQuantityThreadsPerEU;
186-
uint32_t value = PreambleHelper<FamilyType>::getMaxThreadsForVfe(hwInfo);
186+
uint32_t value = HwHelper::getMaxThreadsForVfe(hwInfo);
187187

188188
uint32_t expected = hwInfo.gtSystemInfo.EUCount * threadsPerEU;
189189
EXPECT_EQ(expected, value);

0 commit comments

Comments
 (0)