2017-12-21 07:45:38 +08:00
|
|
|
/*
|
2018-09-18 15:11:08 +08:00
|
|
|
* Copyright (C) 2018 Intel Corporation
|
2017-12-21 07:45:38 +08:00
|
|
|
*
|
2018-09-18 15:11:08 +08:00
|
|
|
* SPDX-License-Identifier: MIT
|
2017-12-21 07:45:38 +08:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "runtime/helpers/preamble.h"
|
|
|
|
#include "runtime/command_stream/linear_stream.h"
|
2018-01-08 22:58:02 +08:00
|
|
|
#include "runtime/command_stream/preemption.h"
|
2017-12-21 07:45:38 +08:00
|
|
|
#include "hw_cmds.h"
|
2018-04-26 18:55:22 +08:00
|
|
|
#include "reg_configs_common.h"
|
2017-12-21 07:45:38 +08:00
|
|
|
#include "runtime/device/device.h"
|
|
|
|
#include "runtime/kernel/kernel.h"
|
|
|
|
#include "runtime/helpers/aligned_memory.h"
|
|
|
|
#include <cstddef>
|
|
|
|
|
|
|
|
namespace OCLRT {
|
|
|
|
|
|
|
|
template <typename GfxFamily>
|
|
|
|
void PreambleHelper<GfxFamily>::programThreadArbitration(LinearStream *pCommandStream, uint32_t requiredThreadArbitrationPolicy) {
|
2018-02-20 15:11:24 +08:00
|
|
|
}
|
2017-12-21 07:45:38 +08:00
|
|
|
|
2018-04-20 19:55:54 +08:00
|
|
|
template <typename GfxFamily>
|
|
|
|
size_t PreambleHelper<GfxFamily>::getThreadArbitrationCommandsSize() {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2018-02-20 15:11:24 +08:00
|
|
|
template <typename GfxFamily>
|
|
|
|
uint32_t PreambleHelper<GfxFamily>::getDefaultThreadArbitrationPolicy() {
|
|
|
|
return 0;
|
2017-12-21 07:45:38 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
template <typename GfxFamily>
|
|
|
|
void PreambleHelper<GfxFamily>::programGenSpecificPreambleWorkArounds(LinearStream *pCommandStream, const HardwareInfo &hwInfo) {
|
|
|
|
}
|
|
|
|
|
|
|
|
template <typename GfxFamily>
|
2018-02-20 15:11:24 +08:00
|
|
|
size_t PreambleHelper<GfxFamily>::getAdditionalCommandsSize(const Device &device) {
|
2018-04-13 17:50:57 +08:00
|
|
|
size_t totalSize = getKernelDebuggingCommandsSize(device.isSourceLevelDebuggerActive());
|
|
|
|
return totalSize;
|
2017-12-21 07:45:38 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
2018-02-23 21:01:12 +08:00
|
|
|
addPipeControlBeforeVfeCmd(pCommandStream, &hwInfo);
|
2017-12-21 07:45:38 +08:00
|
|
|
|
|
|
|
auto pMediaVfeState = (MEDIA_VFE_STATE *)pCommandStream->getSpace(sizeof(MEDIA_VFE_STATE));
|
|
|
|
*pMediaVfeState = MEDIA_VFE_STATE::sInit();
|
2018-06-22 19:04:02 +08:00
|
|
|
pMediaVfeState->setMaximumNumberOfThreads(PreambleHelper<GfxFamily>::getMaxThreadsForVfe(hwInfo));
|
2017-12-21 07:45:38 +08:00
|
|
|
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));
|
|
|
|
pMediaVfeState->setScratchSpaceBasePointer(lowAddress);
|
|
|
|
pMediaVfeState->setScratchSpaceBasePointerHigh(highAddress);
|
|
|
|
}
|
|
|
|
|
|
|
|
template <typename GfxFamily>
|
|
|
|
void PreambleHelper<GfxFamily>::programL3(LinearStream *pCommandStream, uint32_t l3Config) {
|
|
|
|
auto pCmd = (MI_LOAD_REGISTER_IMM *)pCommandStream->getSpace(sizeof(MI_LOAD_REGISTER_IMM));
|
|
|
|
*pCmd = MI_LOAD_REGISTER_IMM::sInit();
|
|
|
|
|
|
|
|
pCmd->setRegisterOffset(L3CNTLRegisterOffset<GfxFamily>::registerOffset);
|
|
|
|
pCmd->setDataDword(l3Config);
|
|
|
|
}
|
|
|
|
|
|
|
|
template <typename GfxFamily>
|
2018-03-29 15:06:33 +08:00
|
|
|
void PreambleHelper<GfxFamily>::programPreamble(LinearStream *pCommandStream, Device &device, uint32_t l3Config,
|
2018-01-08 22:58:02 +08:00
|
|
|
uint32_t requiredThreadArbitrationPolicy, GraphicsAllocation *preemptionCsr) {
|
2017-12-21 07:45:38 +08:00
|
|
|
programL3(pCommandStream, l3Config);
|
|
|
|
programThreadArbitration(pCommandStream, requiredThreadArbitrationPolicy);
|
2018-01-08 22:58:02 +08:00
|
|
|
programPreemption(pCommandStream, device, preemptionCsr);
|
2018-04-13 17:50:57 +08:00
|
|
|
if (device.isSourceLevelDebuggerActive()) {
|
|
|
|
programKernelDebugging(pCommandStream);
|
|
|
|
}
|
2018-01-08 22:58:02 +08:00
|
|
|
programGenSpecificPreambleWorkArounds(pCommandStream, device.getHardwareInfo());
|
|
|
|
}
|
|
|
|
|
|
|
|
template <typename GfxFamily>
|
2018-03-29 15:06:33 +08:00
|
|
|
void PreambleHelper<GfxFamily>::programPreemption(LinearStream *pCommandStream, Device &device, GraphicsAllocation *preemptionCsr) {
|
2018-01-08 22:58:02 +08:00
|
|
|
PreemptionHelper::programPreamble<GfxFamily>(*pCommandStream, device, preemptionCsr);
|
2017-12-21 07:45:38 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
template <typename GfxFamily>
|
|
|
|
uint32_t PreambleHelper<GfxFamily>::getUrbEntryAllocationSize() {
|
|
|
|
return 0x782;
|
|
|
|
}
|
2018-04-13 17:50:57 +08:00
|
|
|
|
|
|
|
template <typename GfxFamily>
|
|
|
|
void PreambleHelper<GfxFamily>::programKernelDebugging(LinearStream *pCommandStream) {
|
|
|
|
auto pCmd = reinterpret_cast<MI_LOAD_REGISTER_IMM *>(pCommandStream->getSpace(sizeof(MI_LOAD_REGISTER_IMM)));
|
|
|
|
*pCmd = MI_LOAD_REGISTER_IMM::sInit();
|
|
|
|
pCmd->setRegisterOffset(DebugModeRegisterOffset::registerOffset);
|
|
|
|
pCmd->setDataDword(DebugModeRegisterOffset::debugEnabledValue);
|
|
|
|
|
|
|
|
auto pCmd2 = reinterpret_cast<MI_LOAD_REGISTER_IMM *>(pCommandStream->getSpace(sizeof(MI_LOAD_REGISTER_IMM)));
|
|
|
|
*pCmd2 = MI_LOAD_REGISTER_IMM::sInit();
|
|
|
|
pCmd2->setRegisterOffset(TdDebugControlRegisterOffset::registerOffset);
|
|
|
|
pCmd2->setDataDword(TdDebugControlRegisterOffset::debugEnabledValue);
|
|
|
|
}
|
|
|
|
|
|
|
|
template <typename GfxFamily>
|
|
|
|
size_t PreambleHelper<GfxFamily>::getKernelDebuggingCommandsSize(bool debuggingActive) {
|
|
|
|
if (debuggingActive) {
|
|
|
|
return 2 * sizeof(MI_LOAD_REGISTER_IMM);
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2018-06-22 19:04:02 +08:00
|
|
|
template <typename GfxFamily>
|
|
|
|
uint32_t PreambleHelper<GfxFamily>::getMaxThreadsForVfe(const HardwareInfo &hwInfo) {
|
|
|
|
uint32_t threadsPerEU = (hwInfo.pSysInfo->ThreadCount / hwInfo.pSysInfo->EUCount) + hwInfo.capabilityTable.extraQuantityThreadsPerEU;
|
|
|
|
return hwInfo.pSysInfo->EUCount * threadsPerEU;
|
|
|
|
}
|
|
|
|
|
2017-12-21 07:45:38 +08:00
|
|
|
} // namespace OCLRT
|