Simplify code for Front End programming

Change-Id: I1f6e1f4f6eef24c8018c54ae1b7f6ec67adb55b3
Signed-off-by: Zbigniew Zdanowicz <zbigniew.zdanowicz@intel.com>
This commit is contained in:
Zbigniew Zdanowicz
2019-05-16 17:17:53 +02:00
committed by sys_ocldev
parent fa3d4f39f4
commit 77ce18ad35
8 changed files with 36 additions and 29 deletions

View File

@ -93,6 +93,22 @@ inline void CommandStreamReceiverHw<GfxFamily>::alignToCacheLine(LinearStream &c
}
}
template <typename GfxFamily>
inline size_t CommandStreamReceiverHw<GfxFamily>::getRequiredCmdSizeForPreamble(Device &device) const {
size_t size = 0;
if (mediaVfeStateDirty) {
size += PreambleHelper<GfxFamily>::getVFECommandsSize();
}
if (!this->isPreambleSent) {
size += PreambleHelper<GfxFamily>::getAdditionalCommandsSize(device);
}
if (!this->isPreambleSent || this->lastSentThreadArbitrationPolicy != this->requiredThreadArbitrationPolicy) {
size += PreambleHelper<GfxFamily>::getThreadArbitrationCommandsSize();
}
return size;
}
template <typename GfxFamily>
inline typename GfxFamily::PIPE_CONTROL *CommandStreamReceiverHw<GfxFamily>::addPipeControlCmd(LinearStream &commandStream) {
typedef typename GfxFamily::PIPE_CONTROL PIPE_CONTROL;

View File

@ -61,22 +61,6 @@ inline size_t CommandStreamReceiverHw<GfxFamily>::getCmdSizeForPipelineSelect()
return 0;
}
template <typename GfxFamily>
inline size_t CommandStreamReceiverHw<GfxFamily>::getRequiredCmdSizeForPreamble(Device &device) const {
size_t size = 0;
if (mediaVfeStateDirty) {
size += sizeof(typename GfxFamily::PIPE_CONTROL) + sizeof(typename GfxFamily::MEDIA_VFE_STATE);
}
if (!this->isPreambleSent) {
size += PreambleHelper<GfxFamily>::getAdditionalCommandsSize(device);
}
if (!this->isPreambleSent || this->lastSentThreadArbitrationPolicy != this->requiredThreadArbitrationPolicy) {
size += PreambleHelper<GfxFamily>::getThreadArbitrationCommandsSize();
}
return size;
}
template <typename GfxFamily>
void CommandStreamReceiverHw<GfxFamily>::createScratchSpaceController() {
scratchSpaceController = std::make_unique<ScratchSpaceControllerBase>(executionEnvironment, *internalAllocationStorage.get());

View File

@ -40,4 +40,9 @@ bool HwHelper::cacheFlushAfterWalkerSupported(const HardwareInfo &hwInfo) {
return hwInfo.capabilityTable.supportCacheFlushAfterWalker;
}
uint32_t HwHelper::getMaxThreadsForVfe(const HardwareInfo &hwInfo) {
uint32_t threadsPerEU = (hwInfo.gtSystemInfo.ThreadCount / hwInfo.gtSystemInfo.EUCount) + hwInfo.capabilityTable.extraQuantityThreadsPerEU;
return hwInfo.gtSystemInfo.EUCount * threadsPerEU;
}
} // namespace NEO

View File

@ -63,6 +63,7 @@ class HwHelper {
virtual const std::vector<aub_stream::EngineType> getGpgpuEngineInstances() const = 0;
virtual bool getEnableLocalMemory(const HardwareInfo &hwInfo) const = 0;
virtual std::string getExtensions() const = 0;
static uint32_t getMaxThreadsForVfe(const HardwareInfo &hwInfo);
static constexpr uint32_t lowPriorityGpgpuEngineIndex = 1;

View File

@ -39,10 +39,10 @@ struct PreambleHelper {
static uint32_t getL3Config(const HardwareInfo &hwInfo, bool useSLM);
static size_t getAdditionalCommandsSize(const Device &device);
static size_t getThreadArbitrationCommandsSize();
static size_t getVFECommandsSize();
static size_t getKernelDebuggingCommandsSize(bool debuggingActive);
static void programGenSpecificPreambleWorkArounds(LinearStream *pCommandStream, const HardwareInfo &hwInfo);
static uint32_t getUrbEntryAllocationSize();
static uint32_t getMaxThreadsForVfe(const HardwareInfo &hwInfo);
};
template <PRODUCT_FAMILY ProductFamily>

View File

@ -82,10 +82,4 @@ size_t PreambleHelper<GfxFamily>::getKernelDebuggingCommandsSize(bool debuggingA
return 0;
}
template <typename GfxFamily>
uint32_t PreambleHelper<GfxFamily>::getMaxThreadsForVfe(const HardwareInfo &hwInfo) {
uint32_t threadsPerEU = (hwInfo.gtSystemInfo.ThreadCount / hwInfo.gtSystemInfo.EUCount) + hwInfo.capabilityTable.extraQuantityThreadsPerEU;
return hwInfo.gtSystemInfo.EUCount * threadsPerEU;
}
} // namespace NEO

View File

@ -5,6 +5,7 @@
*
*/
#include "runtime/helpers/hw_helper.h"
#include "runtime/helpers/preamble_base.inl"
namespace NEO {
@ -25,21 +26,27 @@ uint32_t PreambleHelper<GfxFamily>::getUrbEntryAllocationSize() {
template <typename GfxFamily>
void PreambleHelper<GfxFamily>::programVFEState(LinearStream *pCommandStream, const HardwareInfo &hwInfo, int scratchSize, uint64_t scratchAddress) {
typedef typename GfxFamily::MEDIA_VFE_STATE MEDIA_VFE_STATE;
using MEDIA_VFE_STATE = typename GfxFamily::MEDIA_VFE_STATE;
addPipeControlBeforeVfeCmd(pCommandStream, &hwInfo);
auto pMediaVfeState = (MEDIA_VFE_STATE *)pCommandStream->getSpace(sizeof(MEDIA_VFE_STATE));
auto pMediaVfeState = reinterpret_cast<MEDIA_VFE_STATE *>(pCommandStream->getSpace(sizeof(MEDIA_VFE_STATE)));
*pMediaVfeState = GfxFamily::cmdInitMediaVfeState;
pMediaVfeState->setMaximumNumberOfThreads(PreambleHelper<GfxFamily>::getMaxThreadsForVfe(hwInfo));
pMediaVfeState->setMaximumNumberOfThreads(HwHelper::getMaxThreadsForVfe(hwInfo));
pMediaVfeState->setNumberOfUrbEntries(1);
pMediaVfeState->setUrbEntryAllocationSize(PreambleHelper<GfxFamily>::getUrbEntryAllocationSize());
pMediaVfeState->setPerThreadScratchSpace(Kernel::getScratchSizeValueToProgramMediaVfeState(scratchSize));
pMediaVfeState->setStackSize(Kernel::getScratchSizeValueToProgramMediaVfeState(scratchSize));
uint32_t lowAddress = uint32_t(0xFFFFFFFF & scratchAddress);
uint32_t highAddress = uint32_t(0xFFFFFFFF & (scratchAddress >> 32));
uint32_t lowAddress = static_cast<uint32_t>(0xFFFFFFFF & scratchAddress);
uint32_t highAddress = static_cast<uint32_t>(0xFFFFFFFF & (scratchAddress >> 32));
pMediaVfeState->setScratchSpaceBasePointer(lowAddress);
pMediaVfeState->setScratchSpaceBasePointerHigh(highAddress);
}
template <typename GfxFamily>
size_t PreambleHelper<GfxFamily>::getVFECommandsSize() {
using MEDIA_VFE_STATE = typename GfxFamily::MEDIA_VFE_STATE;
return sizeof(MEDIA_VFE_STATE) + sizeof(PIPE_CONTROL);
}
} // namespace NEO

View File

@ -183,7 +183,7 @@ HWTEST_F(PreambleTest, givenKernelDebuggingActiveAndMidThreadPreemptionWhenGetAd
HWTEST_F(PreambleTest, givenDefaultPreambleWhenGetThreadsMaxNumberIsCalledThenMaximumNumberOfThreadsIsReturned) {
const HardwareInfo &hwInfo = **platformDevices;
uint32_t threadsPerEU = (hwInfo.gtSystemInfo.ThreadCount / hwInfo.gtSystemInfo.EUCount) + hwInfo.capabilityTable.extraQuantityThreadsPerEU;
uint32_t value = PreambleHelper<FamilyType>::getMaxThreadsForVfe(hwInfo);
uint32_t value = HwHelper::getMaxThreadsForVfe(hwInfo);
uint32_t expected = hwInfo.gtSystemInfo.EUCount * threadsPerEU;
EXPECT_EQ(expected, value);