2017-12-21 07:45:38 +08:00
|
|
|
/*
|
2019-01-18 00:10:12 +08:00
|
|
|
* Copyright (C) 2018-2019 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
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2019-08-03 04:25:45 +08:00
|
|
|
#include "core/helpers/aligned_memory.h"
|
2017-12-21 07:45:38 +08:00
|
|
|
#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 "runtime/device/device.h"
|
2019-02-27 18:39:32 +08:00
|
|
|
#include "runtime/helpers/preamble.h"
|
|
|
|
#include "runtime/kernel/kernel.h"
|
|
|
|
|
|
|
|
#include "hw_cmds.h"
|
|
|
|
#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) {
|
|
|
|
}
|
|
|
|
|
|
|
|
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);
|
|
|
|
totalSize += getKernelDebuggingCommandsSize(device.isSourceLevelDebuggerActive());
|
2018-04-13 17:50:57 +08:00
|
|
|
return totalSize;
|
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,
|
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-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;
|
2018-04-13 17:50:57 +08:00
|
|
|
pCmd->setRegisterOffset(DebugModeRegisterOffset::registerOffset);
|
|
|
|
pCmd->setDataDword(DebugModeRegisterOffset::debugEnabledValue);
|
|
|
|
|
|
|
|
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-03-26 18:59:46 +08:00
|
|
|
} // namespace NEO
|