2017-12-21 07:45:38 +08:00
|
|
|
/*
|
2020-01-29 21:15:10 +08:00
|
|
|
* Copyright (C) 2018-2020 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
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2020-02-24 01:46:50 +08:00
|
|
|
#include "command_stream/linear_stream.h"
|
|
|
|
#include "command_stream/preemption.h"
|
|
|
|
#include "device/device.h"
|
|
|
|
#include "helpers/aligned_memory.h"
|
|
|
|
#include "helpers/hw_cmds.h"
|
|
|
|
#include "helpers/preamble.h"
|
2020-02-23 05:50:57 +08:00
|
|
|
#include "opencl/source/helpers/hardware_commands_helper.h"
|
|
|
|
#include "opencl/source/kernel/kernel.h"
|
2019-02-27 18:39:32 +08:00
|
|
|
|
|
|
|
#include "reg_configs_common.h"
|
|
|
|
|
2017-12-21 07:45:38 +08:00
|
|
|
#include <cstddef>
|
|
|
|
|
2019-03-26 18:59:46 +08:00
|
|
|
namespace NEO {
|
2017-12-21 07:45:38 +08:00
|
|
|
|
|
|
|
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) {
|
|
|
|
}
|
|
|
|
|
2019-09-04 22:44:27 +08:00
|
|
|
template <typename GfxFamily>
|
|
|
|
void PreambleHelper<GfxFamily>::programPerDssBackedBuffer(LinearStream *pCommandStream, const HardwareInfo &hwInfo, GraphicsAllocation *perDssBackBufferOffset) {
|
|
|
|
}
|
|
|
|
|
|
|
|
template <typename GfxFamily>
|
|
|
|
size_t PreambleHelper<GfxFamily>::getPerDssBackedBufferCommandsSize(const HardwareInfo &hwInfo) {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2017-12-21 07:45:38 +08:00
|
|
|
template <typename GfxFamily>
|
2018-02-20 15:11:24 +08:00
|
|
|
size_t PreambleHelper<GfxFamily>::getAdditionalCommandsSize(const Device &device) {
|
2018-11-05 18:52:19 +08:00
|
|
|
size_t totalSize = PreemptionHelper::getRequiredPreambleSize<GfxFamily>(device);
|
2020-02-10 22:57:49 +08:00
|
|
|
totalSize += getKernelDebuggingCommandsSize(device.isDebuggerActive());
|
2018-04-13 17:50:57 +08:00
|
|
|
return totalSize;
|
2017-12-21 07:45:38 +08:00
|
|
|
}
|
|
|
|
|
2019-09-10 22:13:11 +08:00
|
|
|
template <typename GfxFamily>
|
|
|
|
size_t PreambleHelper<GfxFamily>::getCmdSizeForPipelineSelect(const HardwareInfo &hwInfo) {
|
|
|
|
size_t size = 0;
|
|
|
|
using PIPELINE_SELECT = typename GfxFamily::PIPELINE_SELECT;
|
|
|
|
size += sizeof(PIPELINE_SELECT);
|
|
|
|
if (HardwareCommandsHelper<GfxFamily>::isPipeControlPriorToPipelineSelectWArequired(hwInfo)) {
|
|
|
|
size += sizeof(PIPE_CONTROL);
|
|
|
|
}
|
|
|
|
return size;
|
|
|
|
}
|
|
|
|
|
2017-12-21 07:45:38 +08:00
|
|
|
template <typename GfxFamily>
|
2018-03-29 15:06:33 +08:00
|
|
|
void PreambleHelper<GfxFamily>::programPreamble(LinearStream *pCommandStream, Device &device, uint32_t l3Config,
|
2019-09-04 22:44:27 +08:00
|
|
|
uint32_t requiredThreadArbitrationPolicy, GraphicsAllocation *preemptionCsr, GraphicsAllocation *perDssBackedBuffer) {
|
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);
|
2020-02-10 22:57:49 +08:00
|
|
|
if (device.isDebuggerActive()) {
|
2018-04-13 17:50:57 +08:00
|
|
|
programKernelDebugging(pCommandStream);
|
|
|
|
}
|
2018-01-08 22:58:02 +08:00
|
|
|
programGenSpecificPreambleWorkArounds(pCommandStream, device.getHardwareInfo());
|
2020-01-29 21:15:10 +08:00
|
|
|
if (perDssBackedBuffer != nullptr) {
|
2019-09-04 22:44:27 +08:00
|
|
|
programPerDssBackedBuffer(pCommandStream, device.getHardwareInfo(), perDssBackedBuffer);
|
|
|
|
}
|
2018-01-08 22:58:02 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
template <typename GfxFamily>
|
2018-03-29 15:06:33 +08:00
|
|
|
void PreambleHelper<GfxFamily>::programPreemption(LinearStream *pCommandStream, Device &device, GraphicsAllocation *preemptionCsr) {
|
2018-11-05 18:52:19 +08:00
|
|
|
PreemptionHelper::programCsrBaseAddress<GfxFamily>(*pCommandStream, device, preemptionCsr);
|
2017-12-21 07:45:38 +08:00
|
|
|
}
|
|
|
|
|
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)));
|
2019-01-18 00:10:12 +08:00
|
|
|
*pCmd = GfxFamily::cmdInitLoadRegisterImm;
|
2019-12-11 22:30:14 +08:00
|
|
|
pCmd->setRegisterOffset(DebugModeRegisterOffset<GfxFamily>::registerOffset);
|
|
|
|
pCmd->setDataDword(DebugModeRegisterOffset<GfxFamily>::debugEnabledValue);
|
2018-04-13 17:50:57 +08:00
|
|
|
|
|
|
|
auto pCmd2 = reinterpret_cast<MI_LOAD_REGISTER_IMM *>(pCommandStream->getSpace(sizeof(MI_LOAD_REGISTER_IMM)));
|
2019-01-18 00:10:12 +08:00
|
|
|
*pCmd2 = GfxFamily::cmdInitLoadRegisterImm;
|
2018-04-13 17:50:57 +08:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2019-08-06 05:57:15 +08:00
|
|
|
template <typename GfxFamily>
|
|
|
|
bool PreambleHelper<GfxFamily>::isL3Configurable(const HardwareInfo &hwInfo) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2019-10-01 17:51:31 +08:00
|
|
|
template <typename GfxFamily>
|
2019-10-07 19:11:12 +08:00
|
|
|
void PreambleHelper<GfxFamily>::programAdditionalFieldsInVfeState(VFE_STATE_TYPE *mediaVfeState, const HardwareInfo &hwInfo) {
|
2019-10-01 17:51:31 +08:00
|
|
|
}
|
|
|
|
|
2019-03-26 18:59:46 +08:00
|
|
|
} // namespace NEO
|