2017-12-21 07:45:38 +08:00
|
|
|
/*
|
2021-05-17 02:51:16 +08:00
|
|
|
* Copyright (C) 2019-2021 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 05:44:01 +08:00
|
|
|
#include "shared/source/command_stream/linear_stream.h"
|
|
|
|
#include "shared/source/command_stream/preemption.h"
|
|
|
|
#include "shared/source/device/device.h"
|
|
|
|
#include "shared/source/helpers/aligned_memory.h"
|
2020-10-06 00:32:55 +08:00
|
|
|
#include "shared/source/helpers/hw_helper.h"
|
2020-02-24 05:44:01 +08:00
|
|
|
#include "shared/source/helpers/preamble.h"
|
2020-06-24 20:53:51 +08:00
|
|
|
#include "shared/source/helpers/register_offsets.h"
|
2020-02-24 17:22:30 +08:00
|
|
|
|
2020-07-30 21:02:11 +08:00
|
|
|
#include "hw_cmds.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;
|
|
|
|
}
|
|
|
|
|
2017-12-21 07:45:38 +08:00
|
|
|
template <typename GfxFamily>
|
|
|
|
void PreambleHelper<GfxFamily>::programGenSpecificPreambleWorkArounds(LinearStream *pCommandStream, const HardwareInfo &hwInfo) {
|
|
|
|
}
|
|
|
|
|
2020-06-24 20:53:51 +08:00
|
|
|
template <typename GfxFamily>
|
|
|
|
void PreambleHelper<GfxFamily>::programSemaphoreDelay(LinearStream *pCommandStream) {
|
|
|
|
if (DebugManager.flags.ForceSemaphoreDelayBetweenWaits.get() > -1) {
|
|
|
|
uint32_t valueOfNewSemaphoreDelay = DebugManager.flags.ForceSemaphoreDelayBetweenWaits.get();
|
|
|
|
LriHelper<GfxFamily>::program(pCommandStream,
|
|
|
|
SEMA_WAIT_POLL,
|
|
|
|
valueOfNewSemaphoreDelay,
|
|
|
|
true);
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
template <typename GfxFamily>
|
|
|
|
size_t PreambleHelper<GfxFamily>::getSemaphoreDelayCommandSize() {
|
|
|
|
return sizeof(MI_LOAD_REGISTER_IMM);
|
|
|
|
}
|
|
|
|
|
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-10-27 23:00:56 +08:00
|
|
|
bool debuggingEnabled = device.getDebugger() != nullptr || device.isDebuggerActive();
|
|
|
|
totalSize += getKernelDebuggingCommandsSize(debuggingEnabled);
|
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);
|
2020-10-06 00:32:55 +08:00
|
|
|
if (MemorySynchronizationCommands<GfxFamily>::isPipeControlPriorToPipelineSelectWArequired(hwInfo)) {
|
2019-09-10 22:13:11 +08:00
|
|
|
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,
|
2020-11-27 03:02:18 +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);
|
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-06-24 20:53:51 +08:00
|
|
|
programSemaphoreDelay(pCommandStream);
|
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) {
|
2020-04-28 22:48:23 +08:00
|
|
|
LriHelper<GfxFamily>::program(pCommandStream,
|
|
|
|
DebugModeRegisterOffset<GfxFamily>::registerOffset,
|
|
|
|
DebugModeRegisterOffset<GfxFamily>::debugEnabledValue,
|
2020-10-19 22:04:58 +08:00
|
|
|
true);
|
2020-04-28 22:48:23 +08:00
|
|
|
|
|
|
|
LriHelper<GfxFamily>::program(pCommandStream,
|
2020-10-19 22:04:58 +08:00
|
|
|
TdDebugControlRegisterOffset<GfxFamily>::registerOffset,
|
|
|
|
TdDebugControlRegisterOffset<GfxFamily>::debugEnabledValue,
|
2020-04-28 22:48:23 +08:00
|
|
|
false);
|
2018-04-13 17:50:57 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
2020-11-27 17:13:06 +08:00
|
|
|
template <typename GfxFamily>
|
2021-08-13 22:48:13 +08:00
|
|
|
void PreambleHelper<GfxFamily>::appendProgramVFEState(const HardwareInfo &hwInfo, const StreamProperties &streamProperties, void *cmd) {}
|
2020-11-27 17:13:06 +08:00
|
|
|
|
2020-10-06 17:54:04 +08:00
|
|
|
template <typename GfxFamily>
|
|
|
|
uint32_t PreambleHelper<GfxFamily>::getScratchSizeValueToProgramMediaVfeState(uint32_t scratchSize) {
|
|
|
|
scratchSize >>= static_cast<uint32_t>(MemoryConstants::kiloByteShiftSize);
|
|
|
|
uint32_t valueToProgram = 0;
|
|
|
|
while (scratchSize >>= 1) {
|
|
|
|
valueToProgram++;
|
|
|
|
}
|
|
|
|
return valueToProgram;
|
|
|
|
}
|
|
|
|
|
2019-03-26 18:59:46 +08:00
|
|
|
} // namespace NEO
|